|
@@ -4881,74 +4881,130 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public HttpRespMsg getPlanDataWithStation(Integer isFilterDept,Integer stationId, String startDate, String endDate, Integer pageIndex, Integer pageSize) {
|
|
|
- HttpRespMsg msg=new HttpRespMsg();
|
|
|
- User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- NumberFormat format = NumberFormat.getPercentInstance();
|
|
|
- format.setMinimumFractionDigits(2);
|
|
|
- Integer companyId = user.getCompanyId();
|
|
|
- DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- DateTimeFormatter dtf1=DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
- List<LocalDate> dates = getDays(LocalDate.parse(startDate, dtf), LocalDate.parse(endDate, dtf));
|
|
|
- List<String> dataStringList=new ArrayList<>();
|
|
|
- for (LocalDate localDate : dates) {
|
|
|
- dataStringList.add(localDate.format(dtf1));
|
|
|
- }
|
|
|
- Integer pageStart = null;
|
|
|
- if (pageIndex!=null){
|
|
|
- pageStart = (pageIndex -1) * pageSize;
|
|
|
- pageSize=pageStart+pageSize;
|
|
|
- }
|
|
|
- List<Integer> deptIds=null;
|
|
|
- if(isFilterDept!=0){
|
|
|
- List<Department> departmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().select(Department::getDepartmentId).eq(Department::getSuperiorId, stationId));
|
|
|
- deptIds=departmentList.stream().map(Department::getDepartmentId).distinct().collect(Collectors.toList());
|
|
|
- }
|
|
|
- boolean viewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部车间工位计划表");
|
|
|
- List<Map<String, Object>> mapList;
|
|
|
- Integer total;
|
|
|
- if(!viewAll){
|
|
|
- mapList = reportMapper.getPlanDataWithStation(companyId, startDate, endDate, user.getId(), deptIds, pageStart, pageSize);
|
|
|
-// total = reportMapper.getPlanDataWithStationCount(companyId, startDate, endDate, user.getId(), deptIds, null, null);
|
|
|
- }else {
|
|
|
- mapList = reportMapper.getPlanDataWithStation(companyId,startDate,endDate,null,deptIds,pageStart,pageSize);
|
|
|
-// total =reportMapper.getPlanDataWithStationCount(companyId,startDate,endDate,null,deptIds,null,null);
|
|
|
- }
|
|
|
- List<String> dateList = mapList.stream().map(m -> String.valueOf(m.get("startDate"))).distinct().collect(Collectors.toList());
|
|
|
- Map<Object, List<Map<String, Object>>> listMapGroupByDate = mapList.stream().collect(Collectors.groupingBy(m -> String.valueOf(m.get("startDate"))));
|
|
|
- Map<String,Object> resultMap=new HashMap<>();
|
|
|
- //处理数据 先按照日期 再按照分组重新组装数据
|
|
|
- List<Map<String,Object>> resultList=new ArrayList<>();
|
|
|
- for (String date : dateList) {
|
|
|
- List<Map<String, Object>> maps = listMapGroupByDate.get(date);
|
|
|
- if(maps==null||maps.size()<=0){
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<Integer> deptIdList = maps.stream().map(m -> Integer.valueOf(String.valueOf(m.get("deptId")))).distinct().collect(Collectors.toList());
|
|
|
- Map<Object, List<Map<String, Object>>> listMapGroupByDept = maps.stream().collect(Collectors.groupingBy(m -> Integer.valueOf(String.valueOf(m.get("deptId")))));
|
|
|
- Map<String,Object> item=new HashMap<>();
|
|
|
- item.put("startDate",date);
|
|
|
- BigDecimal planNum=new BigDecimal(0);
|
|
|
- BigDecimal nowNum=new BigDecimal(0);
|
|
|
- for (Integer dept : deptIdList) {
|
|
|
- List<Map<String, Object>> list = listMapGroupByDept.get(dept);
|
|
|
- item.put("deptId",dept);
|
|
|
- for (Map<String, Object> map : list) {
|
|
|
- planNum=planNum.add(new BigDecimal((String.valueOf(map.get("planNum")))));
|
|
|
- nowNum=nowNum.add(new BigDecimal((String.valueOf(map.get("nowNum")))));
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object fixSteelNumData() {
|
|
|
+ List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>());
|
|
|
+ int dealCount = 0;
|
|
|
+ for (int t=0;t<reportList.size(); t++) {
|
|
|
+ Report report = reportList.get(t);
|
|
|
+ String creatorId = report.getCreatorId();
|
|
|
+ LocalDate date = report.getCreateDate();
|
|
|
+ Integer userProcedureTeamId = report.getUserProcedureTeamId();
|
|
|
+ String steelNum = report.getSteelNumArray();
|
|
|
+ List<String> reportSteelNumArray1 = JSONArray.parseArray(steelNum, String.class);
|
|
|
+ if (!StringUtils.isEmpty(steelNum)) {
|
|
|
+ //检查该钢印号在其他的日报中当前员工是否也有填报的
|
|
|
+ for (int i=t+1;i<reportList.size(); i++) {
|
|
|
+ Report iReport = reportList.get(i);
|
|
|
+ if (iReport.getCreatorId().equals(creatorId) && iReport.getUserProcedureTeamId().equals(userProcedureTeamId) && !iReport.getCreateDate().isEqual(date)) {
|
|
|
+ String steelNumArray = iReport.getSteelNumArray();
|
|
|
+ if (!StringUtils.isEmpty(steelNumArray)) {
|
|
|
+ List<String> reportSteelNumArray2 = JSONArray.parseArray(steelNumArray, String.class);
|
|
|
+ JSONArray updateSteelNum = new JSONArray();
|
|
|
+ boolean hasChange = false;
|
|
|
+ for (int m=0;m<reportSteelNumArray2.size(); m++) {
|
|
|
+ String s = reportSteelNumArray2.get(m);
|
|
|
+ //之前已经报过了该钢印号
|
|
|
+ if (reportSteelNumArray1.contains(s)) {
|
|
|
+ hasChange = true;
|
|
|
+ } else {
|
|
|
+ updateSteelNum.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hasChange) {
|
|
|
+ //日报中的钢印号需要修正
|
|
|
+ Report updateR = new Report();
|
|
|
+ updateR.setId(iReport.getId());
|
|
|
+ updateR.setSteelNumArray(updateSteelNum.toString());
|
|
|
+ dealCount++;
|
|
|
+ System.out.println("检测:"+steelNum+", 更新日报: id="+iReport.getId()+", 原始 steelArrayNum==" + steelNumArray + " ,更新为: "+updateSteelNum.toString());
|
|
|
+ reportMapper.updateById(updateR);
|
|
|
+ reportSteelNumMapper.delete(new QueryWrapper<ReportSteelNum>().eq("report_id", iReport.getId()));
|
|
|
+ for (int q=0;q<updateSteelNum.size(); q++) {
|
|
|
+ ReportSteelNum num = new ReportSteelNum();
|
|
|
+ num.setReportId(updateR.getId());
|
|
|
+ num.setSteelNum(updateSteelNum.getString(q));
|
|
|
+ reportSteelNumMapper.insert(num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- item.put("planNum",planNum.doubleValue());
|
|
|
- item.put("nowNum",nowNum.doubleValue());
|
|
|
- BigDecimal progress = nowNum.divide(planNum, RoundingMode.HALF_UP);
|
|
|
- item.put("progress",format.format(progress.doubleValue()));
|
|
|
- resultList.add(item);
|
|
|
}
|
|
|
}
|
|
|
- resultMap.put("records",resultList.subList(pageStart,pageSize));
|
|
|
- resultMap.put("header",dataStringList);
|
|
|
- resultMap.put("total",resultList.size());
|
|
|
- msg.setData(resultMap);
|
|
|
- return msg;
|
|
|
+ System.out.println("共更新:"+dealCount);
|
|
|
+ return dealCount;
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getPlanDataWithStation(Integer isFilterDept,Integer stationId, String startDate, String endDate, Integer pageIndex, Integer pageSize) {
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ NumberFormat format = NumberFormat.getPercentInstance();
|
|
|
+ format.setMinimumFractionDigits(2);
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+ DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter dtf1=DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
+ List<LocalDate> dates = getDays(LocalDate.parse(startDate, dtf), LocalDate.parse(endDate, dtf));
|
|
|
+ List<String> dataStringList=new ArrayList<>();
|
|
|
+ for (LocalDate localDate : dates) {
|
|
|
+ dataStringList.add(localDate.format(dtf1));
|
|
|
+ }
|
|
|
+ Integer pageStart = null;
|
|
|
+ if (pageIndex!=null){
|
|
|
+ pageStart = (pageIndex -1) * pageSize;
|
|
|
+ pageSize=pageStart+pageSize;
|
|
|
+ }
|
|
|
+ List<Integer> deptIds=null;
|
|
|
+ if(isFilterDept!=0){
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().select(Department::getDepartmentId).eq(Department::getSuperiorId, stationId));
|
|
|
+ deptIds=departmentList.stream().map(Department::getDepartmentId).distinct().collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ boolean viewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部车间工位计划表");
|
|
|
+ List<Map<String, Object>> mapList;
|
|
|
+ Integer total;
|
|
|
+ if(!viewAll){
|
|
|
+ mapList = reportMapper.getPlanDataWithStation(companyId, startDate, endDate, user.getId(), deptIds, pageStart, pageSize);
|
|
|
+ // total = reportMapper.getPlanDataWithStationCount(companyId, startDate, endDate, user.getId(), deptIds, null, null);
|
|
|
+ }else {
|
|
|
+ mapList = reportMapper.getPlanDataWithStation(companyId,startDate,endDate,null,deptIds,pageStart,pageSize);
|
|
|
+ // total =reportMapper.getPlanDataWithStationCount(companyId,startDate,endDate,null,deptIds,null,null);
|
|
|
+ }
|
|
|
+ List<String> dateList = mapList.stream().map(m -> String.valueOf(m.get("startDate"))).distinct().collect(Collectors.toList());
|
|
|
+ Map<Object, List<Map<String, Object>>> listMapGroupByDate = mapList.stream().collect(Collectors.groupingBy(m -> String.valueOf(m.get("startDate"))));
|
|
|
+ Map<String,Object> resultMap=new HashMap<>();
|
|
|
+ //处理数据 先按照日期 再按照分组重新组装数据
|
|
|
+ List<Map<String,Object>> resultList=new ArrayList<>();
|
|
|
+ for (String date : dateList) {
|
|
|
+ List<Map<String, Object>> maps = listMapGroupByDate.get(date);
|
|
|
+ if(maps==null||maps.size()<=0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<Integer> deptIdList = maps.stream().map(m -> Integer.valueOf(String.valueOf(m.get("deptId")))).distinct().collect(Collectors.toList());
|
|
|
+ Map<Object, List<Map<String, Object>>> listMapGroupByDept = maps.stream().collect(Collectors.groupingBy(m -> Integer.valueOf(String.valueOf(m.get("deptId")))));
|
|
|
+ Map<String,Object> item=new HashMap<>();
|
|
|
+ item.put("startDate",date);
|
|
|
+ BigDecimal planNum=new BigDecimal(0);
|
|
|
+ BigDecimal nowNum=new BigDecimal(0);
|
|
|
+ for (Integer dept : deptIdList) {
|
|
|
+ List<Map<String, Object>> list = listMapGroupByDept.get(dept);
|
|
|
+ item.put("deptId",dept);
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ planNum=planNum.add(new BigDecimal((String.valueOf(map.get("planNum")))));
|
|
|
+ nowNum=nowNum.add(new BigDecimal((String.valueOf(map.get("nowNum")))));
|
|
|
+ }
|
|
|
+ item.put("planNum",planNum.doubleValue());
|
|
|
+ item.put("nowNum",nowNum.doubleValue());
|
|
|
+ BigDecimal progress = nowNum.divide(planNum, RoundingMode.HALF_UP);
|
|
|
+ item.put("progress",format.format(progress.doubleValue()));
|
|
|
+ resultList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultMap.put("records",resultList.subList(pageStart,pageSize));
|
|
|
+ resultMap.put("header",dataStringList);
|
|
|
+ resultMap.put("total",resultList.size());
|
|
|
+ msg.setData(resultMap);
|
|
|
+ return msg;
|
|
|
+ }}
|