|
@@ -1,8 +1,11 @@
|
|
|
package com.huimv.production.datasource.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.huimv.common.result.Result;
|
|
|
+import com.huimv.common.result.ResultCode;
|
|
|
import com.huimv.production.datasource.service.IErpDataService;
|
|
|
import com.huimv.production.datasource.utils.TokenUtil;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.repository.query.Param;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -37,12 +40,16 @@ public class ErpDataController {
|
|
|
* @Time : 20:57
|
|
|
*/
|
|
|
@RequestMapping("/getPsy")
|
|
|
- public String getPsy(@RequestParam(value = "accessToken") String accessToken){
|
|
|
- JSONObject tokenJo = tokenUtil.verifyToken(accessToken);
|
|
|
- if(!tokenJo.getBoolean("success")){
|
|
|
- return tokenJo.toJSONString();
|
|
|
+ public Result getPsy(@RequestParam(value = "accessToken") String accessToken){
|
|
|
+ if(StringUtils.isBlank(accessToken)){
|
|
|
+ return new Result(10001,"token不能为空.",false);
|
|
|
}
|
|
|
- return erpDataService.getPsy();
|
|
|
+ // 验证token
|
|
|
+ Result result = tokenUtil.verifyToken(accessToken);
|
|
|
+ if(!result.isSuccess()){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,erpDataService.getPsy());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -56,8 +63,16 @@ public class ErpDataController {
|
|
|
* @Time : 21:14
|
|
|
*/
|
|
|
@RequestMapping("/getReEstrusRate")
|
|
|
- public String getReEstrusRate(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate){
|
|
|
- return erpDataService.getReEstrusRate(startDate,endDate);
|
|
|
+ public Result getReEstrusRate(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate,@RequestParam(value = "accessToken") String accessToken){
|
|
|
+ if(StringUtils.isBlank(accessToken)){
|
|
|
+ return new Result(10001,"token不能为空.",false);
|
|
|
+ }
|
|
|
+ // 验证token
|
|
|
+ Result result = tokenUtil.verifyToken(accessToken);
|
|
|
+ if(!result.isSuccess()){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,erpDataService.getReEstrusRate(startDate,endDate));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -71,8 +86,16 @@ public class ErpDataController {
|
|
|
* @Time : 11:02
|
|
|
*/
|
|
|
@RequestMapping("/getParturitionRate")
|
|
|
- public String getParturitionRate(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate){
|
|
|
- return erpDataService.getParturitionRate(startDate,endDate);
|
|
|
+ public Result getParturitionRate(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate,@RequestParam(value = "accessToken",required = true) String accessToken){
|
|
|
+ if(StringUtils.isBlank(accessToken)){
|
|
|
+ return new Result(10001,"token不能为空.",false);
|
|
|
+ }
|
|
|
+ // 验证token
|
|
|
+ Result result = tokenUtil.verifyToken(accessToken);
|
|
|
+ if(!result.isSuccess()){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,erpDataService.getParturitionRate(startDate,endDate));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -86,8 +109,16 @@ public class ErpDataController {
|
|
|
* @Time : 11:16
|
|
|
*/
|
|
|
@RequestMapping("/getStorage")
|
|
|
- public String getStorage(){
|
|
|
- return erpDataService.getStorage();
|
|
|
+ public Result getStorage(@RequestParam(value = "accessToken") String accessToken){
|
|
|
+ if(StringUtils.isBlank(accessToken)){
|
|
|
+ return new Result(10001,"token不能为空.",false);
|
|
|
+ }
|
|
|
+ // 验证token
|
|
|
+ Result result = tokenUtil.verifyToken(accessToken);
|
|
|
+ if(!result.isSuccess()){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,erpDataService.getStorage());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -101,8 +132,16 @@ public class ErpDataController {
|
|
|
* @Time : 11:18
|
|
|
*/
|
|
|
@RequestMapping("/getPigletInfo")
|
|
|
- public String getPigletInfo(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate){
|
|
|
- return erpDataService.getPigletInfo(startDate,endDate);
|
|
|
+ public Result getPigletInfo(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate,@RequestParam(value = "accessToken") String accessToken){
|
|
|
+ if(StringUtils.isBlank(accessToken)){
|
|
|
+ return new Result(10001,"token不能为空.",false);
|
|
|
+ }
|
|
|
+ // 验证token
|
|
|
+ Result result = tokenUtil.verifyToken(accessToken);
|
|
|
+ if(!result.isSuccess()){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,erpDataService.getPigletInfo(startDate,endDate));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -116,8 +155,17 @@ public class ErpDataController {
|
|
|
* @Time : 11:35
|
|
|
*/
|
|
|
@RequestMapping("/getMateQuantity")
|
|
|
- public String getMateQuantity(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate){
|
|
|
- return erpDataService.getMateQuantity(startDate,endDate);
|
|
|
+ public Result getMateQuantity(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate,@RequestParam(value = "accessToken") String accessToken){
|
|
|
+ if(StringUtils.isBlank(accessToken)){
|
|
|
+ return new Result(10001,"token不能为空.",false);
|
|
|
+ }
|
|
|
+ // 验证token
|
|
|
+ Result result = tokenUtil.verifyToken(accessToken);
|
|
|
+ if(!result.isSuccess()){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,erpDataService.getMateQuantity(startDate,endDate));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -131,8 +179,16 @@ public class ErpDataController {
|
|
|
* @Time : 11:38
|
|
|
*/
|
|
|
@RequestMapping("/getConceptionRate")
|
|
|
- public String getConceptionRate(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate){
|
|
|
- return erpDataService.getConceptionRate(startDate,endDate);
|
|
|
+ public Result getConceptionRate(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate,@RequestParam(value = "accessToken") String accessToken){
|
|
|
+ if(StringUtils.isBlank(accessToken)){
|
|
|
+ return new Result(10001,"token不能为空.",false);
|
|
|
+ }
|
|
|
+ // 验证token
|
|
|
+ Result result = tokenUtil.verifyToken(accessToken);
|
|
|
+ if(!result.isSuccess()){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,erpDataService.getConceptionRate(startDate,endDate));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -146,7 +202,15 @@ public class ErpDataController {
|
|
|
* @Time : 11:39
|
|
|
*/
|
|
|
@RequestMapping("/getAllStorage")
|
|
|
- public String getAllStorage(){
|
|
|
- return erpDataService.getAllStorage();
|
|
|
+ public Result getAllStorage(@RequestParam(value = "accessToken",required = false) String accessToken){
|
|
|
+ if(StringUtils.isBlank(accessToken)){
|
|
|
+ return new Result(10001,"token不能为空.",false);
|
|
|
+ }
|
|
|
+ // 验证token
|
|
|
+ Result result = tokenUtil.verifyToken(accessToken);
|
|
|
+ if(!result.isSuccess()){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,erpDataService.getAllStorage());
|
|
|
}
|
|
|
}
|