|
@@ -2,6 +2,7 @@ package com.huimv.produce.produce.controller;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.huimv.common.utils.Result;
|
|
|
import com.huimv.common.utils.ResultCode;
|
|
@@ -17,7 +18,7 @@ import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 前端控制器
|
|
|
+ * 前端控制器
|
|
|
* </p>
|
|
|
*
|
|
|
* @author astupidcoder
|
|
@@ -29,21 +30,43 @@ public class ProdProduceController {
|
|
|
|
|
|
@Autowired
|
|
|
private IProdProduceService prodProduceService;
|
|
|
+ private String[] fullDataType = new String[]{"avg_farrow_1", "avg_farrow_2", "avg_farrow_3", "avg_weight", "break_grice", "break_rate", "breed_rate",
|
|
|
+ "fatpig_rate", "grice_rate", "nest_times", "piglet_rate", "psy"};
|
|
|
|
|
|
@GetMapping("/listProducee")
|
|
|
- public Result listProducee(@RequestParam(name = "farmId") Integer farmId){
|
|
|
+ public Result listProducee(@RequestParam(name = "farmId") Integer farmId) {
|
|
|
Date now = new Date();
|
|
|
- List<ProdProduce> list = prodProduceService.list(new QueryWrapper<ProdProduce>().eq("farm_id", farmId).eq("year", DateUtil.year(now)).eq("month", DateUtil.month(now)+1));
|
|
|
+ List<ProdProduce> list = prodProduceService.list(new QueryWrapper<ProdProduce>().eq("farm_id", farmId).eq("year", DateUtil.year(now)).eq("month", DateUtil.month(now) + 1));
|
|
|
Map map = new HashMap();
|
|
|
+ JSONArray stockTypeJa = new JSONArray();
|
|
|
for (ProdProduce prodProduce : list) {
|
|
|
String stockType = prodProduce.getStockType();
|
|
|
- map.put(stockType,prodProduce);
|
|
|
+ stockTypeJa.add(stockType);
|
|
|
+ map.put(stockType, prodProduce);
|
|
|
+ }
|
|
|
+ //结果完整性检查
|
|
|
+ checkFullResult(map, stockTypeJa);
|
|
|
+ return new Result(ResultCode.SUCCESS, map);
|
|
|
+ }
|
|
|
+ //结果完整性检查
|
|
|
+ public void checkFullResult(Map map, JSONArray stockTypeJa) {
|
|
|
+ for(int a=0;a<fullDataType.length;a++){
|
|
|
+ System.out.println("a>>"+fullDataType[a]);
|
|
|
+ boolean isExist = false;
|
|
|
+ for (int b = 0; b < stockTypeJa.size(); b++) {
|
|
|
+ if (stockTypeJa.getString(b).trim().equalsIgnoreCase(fullDataType[a])) {
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isExist) {
|
|
|
+ map.put(fullDataType[a],"{stockType:'"+fullDataType[a]+"',stockQuantity:'0'}");
|
|
|
+ }
|
|
|
}
|
|
|
- return new Result(ResultCode.SUCCESS,map);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/listImportance")
|
|
|
- public Result listImportance(@RequestBody Map<String, String> map){
|
|
|
+ public Result listImportance(@RequestBody Map<String, String> map) {
|
|
|
|
|
|
return prodProduceService.listImportance(map);
|
|
|
}
|