|
@@ -2052,6 +2052,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
String projectId = manageDo.getId();
|
|
|
List<String> machinenoList = projectDeviceNumberService.list(Wrappers.<ZhcxProjectDeviceNumberDo>lambdaQuery()
|
|
|
.eq(ZhcxProjectDeviceNumberDo::getDeleted, "0")
|
|
|
+ .ne(ZhcxProjectDeviceNumberDo::getStatus, "发运")
|
|
|
.eq(ZhcxProjectDeviceNumberDo::getPid, projectId))
|
|
|
.stream().map(ZhcxProjectDeviceNumberDo::getDeviceNumber)
|
|
|
.collect(Collectors.toList());
|
|
@@ -2103,7 +2104,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
BeanUtils.copyProperties(record, vo); // 使用 Spring 的工具类复制属性
|
|
|
return vo;
|
|
|
})
|
|
|
- .collect(Collectors.toList());;
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
RectifySnapDto rectifySnapDto = new RectifySnapDto();
|
|
|
Set<String> dateList = new HashSet<>();
|
|
@@ -2209,8 +2210,15 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
.sorted(Collections.reverseOrder())
|
|
|
.map(dateFormat::format)
|
|
|
.collect(Collectors.toList());
|
|
|
+ LambdaQueryWrapper<ZhcxProjectDeviceNumberDo> deviceWapper = Wrappers.<ZhcxProjectDeviceNumberDo>lambdaQuery()
|
|
|
+ .eq(ZhcxProjectDeviceNumberDo::getPid, projectId)
|
|
|
+ .eq(ZhcxProjectDeviceNumberDo::getDeleted, "0");
|
|
|
+ Map<String, List<ZhcxProjectDeviceNumberDo>> deviceMap = projectDeviceNumberService.list(deviceWapper).stream()
|
|
|
+ .collect(Collectors.groupingBy(ZhcxProjectDeviceNumberDo::getDeviceNumber));
|
|
|
+
|
|
|
for (int i = 0; i < machineNoData.size(); i++) {
|
|
|
List<RectifySnapVo> snapList = machineNoData.get(i).getSnapList();
|
|
|
+ List<ZhcxProjectDeviceNumberDo> deviceNumberDos = deviceMap.get(machineNoData.get(i).getMachineNo());
|
|
|
snapList.forEach(snapVo -> {
|
|
|
List<ZhcxProjectRectifySnapVo> dataList = snapVo.getData();
|
|
|
if (dataList != null) {
|
|
@@ -2221,12 +2229,13 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
String formattedDate = sdf.format(data.getDate());
|
|
|
return formattedDate.equals(date);
|
|
|
});
|
|
|
- if (b) {
|
|
|
+
|
|
|
+ if (b && !"发运".equals(deviceNumberDos.get(0).getStatus())) {
|
|
|
ZhcxProjectRectifySnapVo zhcxProjectRectifySnapVo = new ZhcxProjectRectifySnapVo();
|
|
|
// 将字符串 date 转换为 Date 对象
|
|
|
ZhcxProjectRectifySnapVo zhcxProjectRectifySnapVo1 = dataList.get(0);
|
|
|
BeanUtil.copyProperties(zhcxProjectRectifySnapVo1, zhcxProjectRectifySnapVo);
|
|
|
- zhcxProjectRectifySnapVo.setDate(new Date());
|
|
|
+ zhcxProjectRectifySnapVo.setDate(new Date(date));
|
|
|
zhcxProjectRectifySnapVo.setRectifytotal(null);
|
|
|
zhcxProjectRectifySnapVo.setTbcnum(null);
|
|
|
zhcxProjectRectifySnapVo.setUnFinishNum(null);
|
|
@@ -2282,27 +2291,23 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
public R searchRectifyTabData(Map<String, Object> map) {
|
|
|
Object projectIdObj = map.get("projectId");
|
|
|
Object machineNoObj = map.get("machineNo");
|
|
|
-
|
|
|
+ Object tabDetailTypeObj = map.get("tabDetailType");
|
|
|
if (ObjectUtil.isEmpty(projectIdObj) || ObjectUtil.isEmpty(machineNoObj)) {
|
|
|
return R.error();
|
|
|
}
|
|
|
String projectId = (String) projectIdObj;
|
|
|
- List<String> machineNos = (List<String>) machineNoObj;
|
|
|
|
|
|
- LambdaQueryWrapper<ZhcxProjectRectifySnapDo> eq = Wrappers.<ZhcxProjectRectifySnapDo>lambdaQuery()
|
|
|
- .eq(ZhcxProjectRectifySnapDo::getProjectid, projectId)
|
|
|
- .in(ZhcxProjectRectifySnapDo::getMachineno, machineNos)
|
|
|
- .eq(ZhcxProjectRectifySnapDo::getDeleted, "0");
|
|
|
-
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
- List<ZhcxProjectRectifySnapVo> list = zhcxProjectRectifySnapService.list(eq).stream()
|
|
|
- .map(record -> {
|
|
|
- ZhcxProjectRectifySnapVo vo = new ZhcxProjectRectifySnapVo();
|
|
|
- BeanUtils.copyProperties(record, vo); // 使用 Spring 的工具类复制属性
|
|
|
- return vo;
|
|
|
- })
|
|
|
- .collect(Collectors.toList());;
|
|
|
|
|
|
+ List<ZhcxProjectRectifySnapVo> list = null;
|
|
|
+ if ("day".equals(tabDetailTypeObj)) {
|
|
|
+ list = zhcxProjectRectifySnapService.listCloseTotalDataByDay(map);
|
|
|
+ }else if("week".equals(tabDetailTypeObj)){
|
|
|
+ list = zhcxProjectRectifySnapService.listCloseTotalDataByWeek(map);
|
|
|
+ }else if("halfMonth".equals(tabDetailTypeObj)){
|
|
|
+ list = zhcxProjectRectifySnapService.listCloseTotalDataByHalfMonth(map);
|
|
|
+ }else if("month".equals(tabDetailTypeObj)){
|
|
|
+ list = zhcxProjectRectifySnapService.listCloseTotalDataByMonth(map);
|
|
|
+ }
|
|
|
RectifySnapDto rectifySnapDto = new RectifySnapDto();
|
|
|
Set<String> dateList = new HashSet<>();
|
|
|
//根据机号分组
|
|
@@ -2324,8 +2329,8 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
rectifySnapVo.setIfoutsidebase(v2.get(0).getIfoutsidebase());
|
|
|
//根据日期分组
|
|
|
Map<String, List<ZhcxProjectRectifySnapVo>> collect3 = v2.stream()
|
|
|
- .filter(e -> Objects.nonNull(e.getDate()))
|
|
|
- .collect(Collectors.groupingBy(e -> dateFormat.format(e.getDate())));
|
|
|
+ .filter(e -> Objects.nonNull(e.getDatestr()))
|
|
|
+ .collect(Collectors.groupingBy(e -> e.getDatestr()));
|
|
|
collect3.forEach((k3, v3) -> {
|
|
|
dateList.add(k3);
|
|
|
data.addAll(v3);
|
|
@@ -2357,77 +2362,102 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
return base1.compareTo(base2); // 其他情况默认字典排序
|
|
|
});
|
|
|
Map<String, List<ZhcxProjectRectifySnapVo>> collect4 = v.stream()
|
|
|
- .filter(e -> Objects.nonNull(e.getDate()))
|
|
|
- .collect(Collectors.groupingBy(e -> dateFormat.format(e.getDate())));
|
|
|
+ .filter(e -> Objects.nonNull(e.getDatestr()))
|
|
|
+ .collect(Collectors.groupingBy(e -> e.getDatestr()));
|
|
|
List<ZhcxProjectRectifySnapVo> data = new ArrayList<>();
|
|
|
RectifySnapVo rectifySnapVo = new RectifySnapVo();
|
|
|
+ List<ZhcxProjectRectifySnapVo> data2 = new ArrayList<>();
|
|
|
+ RectifySnapVo rectifySnapVo2 = new RectifySnapVo();
|
|
|
rectifySnapVo.setFirstdeptname("总合计");
|
|
|
+ rectifySnapVo2.setFirstdeptname("待确认");
|
|
|
collect4.forEach((k4, v4) -> {
|
|
|
// 汇总两个字段
|
|
|
int sumField1 = v4.stream().mapToInt(vo -> Optional.ofNullable(vo.getFinishnum()).orElse(0)).sum();
|
|
|
int sumField2 = v4.stream().mapToInt(vo -> Optional.ofNullable(vo.getRectifytotal()).orElse(0)).sum();
|
|
|
+ int sumField3 = v4.stream().mapToInt(vo -> Optional.ofNullable(vo.getTbcnum()).orElse(0)).sum();
|
|
|
// 创建汇总对象
|
|
|
ZhcxProjectRectifySnapVo summaryVo = new ZhcxProjectRectifySnapVo();
|
|
|
- summaryVo.setDate(v4.get(0).getDate()); // 设置分组的日期
|
|
|
+ summaryVo.setDatestr(v4.get(0).getDatestr()); // 设置分组的日期
|
|
|
summaryVo.setFinishnum(sumField1); // 设置字段1的总和
|
|
|
summaryVo.setRectifytotal(sumField2); // 设置字段2的总和
|
|
|
summaryVo.setFirstorgname("总合计");
|
|
|
+ ZhcxProjectRectifySnapVo summaryVo2 = new ZhcxProjectRectifySnapVo();
|
|
|
+ summaryVo2.setDatestr(v4.get(0).getDatestr()); // 设置分组的日期
|
|
|
+ summaryVo2.setFinishnum(sumField1); // 设置字段1的总和
|
|
|
+ summaryVo2.setRectifytotal(sumField2); // 设置字段2的总和
|
|
|
+ summaryVo2.setTbcnum(sumField3);
|
|
|
+ summaryVo2.setFirstorgname("待确认");
|
|
|
+
|
|
|
data.add(summaryVo);
|
|
|
+ data2.add(summaryVo2);
|
|
|
});
|
|
|
rectifySnapVo.setData(data);
|
|
|
+ rectifySnapVo2.setData(data2);
|
|
|
rectifySnapVos.add(rectifySnapVo);
|
|
|
+ rectifySnapVos.add(rectifySnapVo2);
|
|
|
RectifySnapMachineDto rectifySnapMachineDto = new RectifySnapMachineDto();
|
|
|
rectifySnapMachineDto.setMachineNo(k);
|
|
|
rectifySnapMachineDto.setSnapList(rectifySnapVos);
|
|
|
machineNoData.add(rectifySnapMachineDto);
|
|
|
});
|
|
|
|
|
|
- List<String> sortedDateList = dateList.stream()
|
|
|
- .map(date -> {
|
|
|
- try {
|
|
|
- return dateFormat.parse(date);
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- })
|
|
|
- .sorted(Collections.reverseOrder())
|
|
|
- .map(dateFormat::format)
|
|
|
- .collect(Collectors.toList());
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ZhcxProjectDeviceNumberDo> deviceWapper = Wrappers.<ZhcxProjectDeviceNumberDo>lambdaQuery()
|
|
|
+ .eq(ZhcxProjectDeviceNumberDo::getPid, projectId)
|
|
|
+ .eq(ZhcxProjectDeviceNumberDo::getDeleted, "0");
|
|
|
+ Map<String, List<ZhcxProjectDeviceNumberDo>> deviceMap = projectDeviceNumberService.list(deviceWapper).stream()
|
|
|
+ .collect(Collectors.groupingBy(ZhcxProjectDeviceNumberDo::getDeviceNumber));
|
|
|
+
|
|
|
for (int i = 0; i < machineNoData.size(); i++) {
|
|
|
List<RectifySnapVo> snapList = machineNoData.get(i).getSnapList();
|
|
|
+ List<ZhcxProjectDeviceNumberDo> deviceNumberDos = deviceMap.get(machineNoData.get(i).getMachineNo());
|
|
|
snapList.forEach(snapVo -> {
|
|
|
List<ZhcxProjectRectifySnapVo> dataList = snapVo.getData();
|
|
|
if (dataList != null) {
|
|
|
+
|
|
|
+// dateList.forEach(date -> {
|
|
|
+// boolean b = dataList.stream().noneMatch(data -> {
|
|
|
+//// SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
+//// String formattedDate = sdf.format(data.getDate());
|
|
|
+// return data.getDatestr().equals(date);
|
|
|
+// });
|
|
|
+//
|
|
|
+// if (b && !"发运".equals(deviceNumberDos.get(0).getStatus())) {
|
|
|
+// ZhcxProjectRectifySnapVo zhcxProjectRectifySnapVo = new ZhcxProjectRectifySnapVo();
|
|
|
+// // 将字符串 date 转换为 Date 对象
|
|
|
+// ZhcxProjectRectifySnapVo zhcxProjectRectifySnapVo1 = dataList.get(0);
|
|
|
+// BeanUtil.copyProperties(zhcxProjectRectifySnapVo1, zhcxProjectRectifySnapVo);
|
|
|
+// zhcxProjectRectifySnapVo.setDate(new Date(date));
|
|
|
+// zhcxProjectRectifySnapVo.setRectifytotal(null);
|
|
|
+// zhcxProjectRectifySnapVo.setTbcnum(null);
|
|
|
+// zhcxProjectRectifySnapVo.setUnFinishNum(null);
|
|
|
+// zhcxProjectRectifySnapVo.setNowFinishNum(null);
|
|
|
+// zhcxProjectRectifySnapVo.setFinishnum(null);
|
|
|
+// zhcxProjectRectifySnapVo.setInitstatus(false);
|
|
|
+// dataList.add(zhcxProjectRectifySnapVo);
|
|
|
+// }
|
|
|
+// });
|
|
|
// 按 date 字段倒序排序
|
|
|
- dataList.sort(Comparator.comparing(ZhcxProjectRectifySnapVo::getDate, Comparator.nullsLast(Comparator.reverseOrder())));
|
|
|
- sortedDateList.forEach(date -> {
|
|
|
- if (dataList.stream().noneMatch(data -> {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
- String formattedDate = sdf.format(data.getDate());
|
|
|
- return formattedDate.equals(date); // 假设 date 是一个字符串,格式为 "yyyy-MM-dd"
|
|
|
- })) {
|
|
|
- ZhcxProjectRectifySnapVo zhcxProjectRectifySnapVo = new ZhcxProjectRectifySnapVo();
|
|
|
- zhcxProjectRectifySnapVo.setDate(new Date(date)); // 将字符串 date 转换为 Date 对象
|
|
|
- dataList.add(zhcxProjectRectifySnapVo);
|
|
|
- }
|
|
|
- });
|
|
|
+ dataList.sort(Comparator.comparing(ZhcxProjectRectifySnapVo::getDatestr, Comparator.nullsLast(Comparator.reverseOrder())));
|
|
|
for (int j = dataList.size() -1; j >= 0; j--) {
|
|
|
ZhcxProjectRectifySnapVo current = dataList.get(j);
|
|
|
- Integer rectifytotal = current.getRectifytotal() != null ? current.getRectifytotal() : 0;
|
|
|
- Integer finishnum = current.getFinishnum() != null ? current.getFinishnum() : 0;
|
|
|
- // 设置未完成数
|
|
|
- current.setUnFinishNum(rectifytotal - finishnum);
|
|
|
-
|
|
|
- // 设置当前完成数
|
|
|
- if (j < dataList.size() - 1) {
|
|
|
- // 前一个元素
|
|
|
- ZhcxProjectRectifySnapVo previous = dataList.get(j + 1);
|
|
|
- int i1 = previous.getUnFinishNum() == null ? 0 : previous.getUnFinishNum();
|
|
|
- int i2 = current.getUnFinishNum() == null ? 0 : current.getUnFinishNum();
|
|
|
- current.setNowFinishNum(i1 - i2);
|
|
|
- } else {
|
|
|
- // 第一条记录没有 "前一条" 数据
|
|
|
- current.setNowFinishNum(0);
|
|
|
+ if (current.getInitstatus()) {
|
|
|
+ Integer rectifytotal = current.getRectifytotal() != null ? current.getRectifytotal() : 0;
|
|
|
+ Integer finishnum = current.getFinishnum() != null ? current.getFinishnum() : 0;
|
|
|
+ // 设置未完成数
|
|
|
+ current.setUnFinishNum(rectifytotal - finishnum);
|
|
|
+
|
|
|
+ // 设置当前完成数
|
|
|
+ if (j < dataList.size() - 1) {
|
|
|
+ // 前一个元素
|
|
|
+ ZhcxProjectRectifySnapVo previous = dataList.get(j + 1);
|
|
|
+ int i1 = previous.getUnFinishNum() == null ? 0 : previous.getUnFinishNum();
|
|
|
+ int i2 = current.getUnFinishNum() == null ? 0 : current.getUnFinishNum();
|
|
|
+ current.setNowFinishNum(i1 - i2);
|
|
|
+ } else {
|
|
|
+ // 第一条记录没有 "前一条" 数据
|
|
|
+ current.setNowFinishNum(0);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2444,7 +2474,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
// 比较数字部分
|
|
|
return Integer.compare(num1, num2);
|
|
|
});
|
|
|
- rectifySnapDto.setDateList(sortedDateList);
|
|
|
+ rectifySnapDto.setDateList(new ArrayList<>(dateList));
|
|
|
rectifySnapDto.setList(machineNoData);
|
|
|
return R.ok(rectifySnapDto);
|
|
|
}
|