|
@@ -1,16 +1,22 @@
|
|
|
package org.jeecg.modules.ProdPlan.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.temporal.WeekFields;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.system.vo.DictModel;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.ProdPlan.entity.DelayProduct;
|
|
|
import org.jeecg.modules.ProdPlan.entity.ProdPlan;
|
|
@@ -21,6 +27,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import org.jeecg.modules.system.service.ISysDictItemService;
|
|
|
+import org.jeecg.modules.system.service.ISysDictService;
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
@@ -50,7 +58,9 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
public class DelayProductController extends JeecgController<DelayProduct, IDelayProductService> {
|
|
|
@Autowired
|
|
|
private IDelayProductService delayProductService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ISysDictService sysDictService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
@@ -72,7 +82,7 @@ public class DelayProductController extends JeecgController<DelayProduct, IDelay
|
|
|
IPage<DelayProduct> pageList = delayProductService.page(page, queryWrapper);
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|
|
@@ -86,7 +96,7 @@ public class DelayProductController extends JeecgController<DelayProduct, IDelay
|
|
|
delayProductService.save(delayProduct);
|
|
|
return Result.OK("添加成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 编辑
|
|
|
*
|
|
@@ -100,7 +110,7 @@ public class DelayProductController extends JeecgController<DelayProduct, IDelay
|
|
|
delayProductService.updateById(delayProduct);
|
|
|
return Result.OK("编辑成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 通过id删除
|
|
|
*
|
|
@@ -114,7 +124,7 @@ public class DelayProductController extends JeecgController<DelayProduct, IDelay
|
|
|
delayProductService.removeById(id);
|
|
|
return Result.OK("删除成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 批量删除
|
|
|
*
|
|
@@ -128,7 +138,7 @@ public class DelayProductController extends JeecgController<DelayProduct, IDelay
|
|
|
this.delayProductService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
return Result.OK("批量删除成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 通过id查询
|
|
|
*
|
|
@@ -169,4 +179,87 @@ public class DelayProductController extends JeecgController<DelayProduct, IDelay
|
|
|
return super.importExcel(request, response, DelayProduct.class);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/getDelayProductByWeek")
|
|
|
+ public Result<Map> getDelayProductByWeek() {
|
|
|
+ Integer week = LocalDate.now().get(WeekFields.ISO.weekOfYear());
|
|
|
+ week = 20;
|
|
|
+ //获取饼图数据,前一周,当前周及后两周
|
|
|
+ //String pieQueryWeeks = "W" + (week - 1) + ", W" + week + "', 'W" + (week + 1) + "', 'W" + (week + 2) + "'";
|
|
|
+ QueryWrapper<DelayProduct> pieQueryWrapper = new QueryWrapper<>();
|
|
|
+ List<String> pieWeeks = new ArrayList<>();
|
|
|
+ pieWeeks.add("W" + (week - 1));
|
|
|
+ pieWeeks.add("W" + week);
|
|
|
+ pieWeeks.add("W" + (week + 1));
|
|
|
+ pieWeeks.add("W" + (week + 2));
|
|
|
+ pieQueryWrapper.lambda().in(DelayProduct::getWeek, pieWeeks);
|
|
|
+ List<DelayProduct> pieProducts = delayProductService.list(pieQueryWrapper);
|
|
|
+
|
|
|
+ Map<String, String> ruleColor = sysDictService.queryDictItemsByCode("rule_color").stream().collect(Collectors.toMap(DictModel::getText, DictModel::getValue));
|
|
|
+ Map<String, Long> pieInside = pieProducts.stream().collect(Collectors.groupingBy(DelayProduct::getComment1, Collectors.counting()));
|
|
|
+ Map<String, Long> pieOutside = pieProducts.stream().collect(Collectors.groupingBy(DelayProduct::getRemark, Collectors.counting()));
|
|
|
+ JSONArray pieInsideJSON = new JSONArray();
|
|
|
+ for(String key : pieInside.keySet()) {
|
|
|
+ JSONObject item = new JSONObject();
|
|
|
+ item.put("name", key);
|
|
|
+ item.put("value", pieInside.get(key));
|
|
|
+ Map<String, String> color = new HashMap<>();
|
|
|
+ color.put("color", "#" + ruleColor.get(key));
|
|
|
+ item.put("itemStyle", color);
|
|
|
+ pieInsideJSON.add(item);
|
|
|
+ }
|
|
|
+ JSONArray pieOutsideJSON = new JSONArray();
|
|
|
+ for(String key : pieOutside.keySet()) {
|
|
|
+ JSONObject item = new JSONObject();
|
|
|
+ item.put("name", key);
|
|
|
+ item.put("value", pieOutside.get(key));
|
|
|
+ Map<String, String> color = new HashMap<>();
|
|
|
+ color.put("color", "#" + ruleColor.get(key));
|
|
|
+ item.put("itemStyle", color);
|
|
|
+ pieOutsideJSON.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取柱状图数据,前两周,当前周及后两周
|
|
|
+ //String columnarQueryWeeks = "'W" + (week - 3) + "', 'W" + (week - 2) + "', 'W" + (week - 1) + "', 'W" + week + "', 'W" + week + 1 + "', 'W" + week + 2 + "'";
|
|
|
+ List<String> columnarWeeks = new ArrayList<>();
|
|
|
+ columnarWeeks.add("W" + (week - 3));
|
|
|
+ columnarWeeks.add("W" + (week - 2));
|
|
|
+ columnarWeeks.add("W" + (week - 1));
|
|
|
+ columnarWeeks.add("W" + week);
|
|
|
+ columnarWeeks.add("W" + (week + 1));
|
|
|
+ columnarWeeks.add("W" + (week + 2));
|
|
|
+ QueryWrapper<DelayProduct> columnarQueryWrapper = new QueryWrapper<>();
|
|
|
+ columnarQueryWrapper.lambda().in(DelayProduct::getWeek, columnarWeeks);
|
|
|
+ List<DelayProduct> columnarProducts = delayProductService.list(columnarQueryWrapper);
|
|
|
+ Map<String, Long> columnarInside = columnarProducts.stream().collect(Collectors.groupingBy(DelayProduct::getComment1, Collectors.counting()));
|
|
|
+ Map<String, Long> columnarOutside = columnarProducts.stream().collect(Collectors.groupingBy(DelayProduct::getRemark, Collectors.counting()));
|
|
|
+ JSONArray columnarInsideJSON = new JSONArray();
|
|
|
+ for(String key : columnarInside.keySet()) {
|
|
|
+ JSONObject item = new JSONObject();
|
|
|
+ item.put("name", key);
|
|
|
+ item.put("value", columnarInside.get(key));
|
|
|
+ Map<String, String> color = new HashMap<>();
|
|
|
+ color.put("color", "#" + ruleColor.get(key));
|
|
|
+ item.put("itemStyle", new JSONObject().put("color", color));
|
|
|
+ columnarInsideJSON.add(item);
|
|
|
+ }
|
|
|
+ JSONArray columnarOutsideJSON = new JSONArray();
|
|
|
+ for(String key : columnarOutside.keySet()) {
|
|
|
+ JSONObject item = new JSONObject();
|
|
|
+ item.put("name", key);
|
|
|
+ item.put("value", columnarOutside.get(key));
|
|
|
+ Map<String, String> color = new HashMap<>();
|
|
|
+ color.put("color", "#" + ruleColor.get(key));
|
|
|
+ item.put("itemStyle", new JSONObject().put("color", color));
|
|
|
+ columnarOutsideJSON.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, JSONArray> result = new HashMap<>();
|
|
|
+ result.put("pieInside", pieInsideJSON);
|
|
|
+ result.put("pieOutside", pieOutsideJSON);
|
|
|
+ result.put("columnarInside", columnarInsideJSON);
|
|
|
+ result.put("columnarOutside", columnarOutsideJSON);
|
|
|
+ return Result.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
}
|