提交 7ae59048 authored 作者: Matrix's avatar Matrix

[核查模块] 重构了即时计算模块

上级 df1a6641
...@@ -25,4 +25,5 @@ public enum CheckType { ...@@ -25,4 +25,5 @@ public enum CheckType {
private final Integer id; private final Integer id;
private final String name; private final String name;
} }
...@@ -7,6 +7,7 @@ import lombok.experimental.Accessors; ...@@ -7,6 +7,7 @@ import lombok.experimental.Accessors;
import org.springframework.objenesis.ObjenesisHelper; import org.springframework.objenesis.ObjenesisHelper;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
/** /**
* CheckAreaStatVo. * CheckAreaStatVo.
...@@ -173,19 +174,7 @@ public class CheckAreaStatVo implements Cloneable { ...@@ -173,19 +174,7 @@ public class CheckAreaStatVo implements Cloneable {
return this; return this;
} }
public CheckAreaStatVo combine(CheckAreaStatVo other) {
this.areaName = other.getAreaName();
this.supposeCount += other.getSupposeCount();
this.actualCount += other.getActualCount();
if (other.comProgress == 1){
this.comProgress =1;
}
if (other.comSituation ==1){
this.comSituation =1;
}
return this;
}
public RevAreaStat reverse(){ public RevAreaStat reverse(){
return new RevAreaStat(areaName, actualCount, supposeCount, comProgress, comSituation); return new RevAreaStat(areaName, actualCount, supposeCount, comProgress, comSituation);
......
...@@ -113,13 +113,17 @@ public class CheckDeviceStatVo implements Cloneable { ...@@ -113,13 +113,17 @@ public class CheckDeviceStatVo implements Cloneable {
return mergeVo; return mergeVo;
} }
//将目前已有的地区制作成map areaMap里是杭州市 other是西湖区
Map<String, CheckAreaStatVo> areaMap = mergeVo.areaStatList.stream() Map<String, CheckAreaStatVo> areaMap = mergeVo.areaStatList.stream()
.collect(toMap(CheckAreaStatVo::getAreaName, Function.identity())); .collect(toMap(CheckAreaStatVo::getAreaName, Function.identity()));
for (CheckAreaStatVo otherArea : other.getAreaStatList()) { for (CheckAreaStatVo otherArea : other.getAreaStatList()) {
//如果原来的没有则添加,否则累加 //如果原来的没有则添加,否则累加
areaMap.putIfAbsent(otherArea.getAreaName(), otherArea); if (!areaMap.containsKey(otherArea.getAreaName())) {
areaMap.computeIfPresent(otherArea.getAreaName(), (k, v) -> v.reduce(otherArea)); areaMap.putIfAbsent(otherArea.getAreaName(), otherArea);
}else {
areaMap.computeIfPresent(otherArea.getAreaName(), (k, v) -> v.reduce(otherArea));
}
} }
mergeVo.areaStatList = new ArrayList<>(areaMap.values()); mergeVo.areaStatList = new ArrayList<>(areaMap.values());
...@@ -153,8 +157,11 @@ public class CheckDeviceStatVo implements Cloneable { ...@@ -153,8 +157,11 @@ public class CheckDeviceStatVo implements Cloneable {
for (CheckAreaStatVo otherArea : other.getAreaStatList()) { for (CheckAreaStatVo otherArea : other.getAreaStatList()) {
//如果原来的没有则添加,否则累加 //如果原来的没有则添加,否则累加
areaMap.putIfAbsent(otherArea.getAreaName(), otherArea); if (!areaMap.containsKey(otherArea.getAreaName())) {
areaMap.computeIfPresent(otherArea.getAreaName(), (k, v) -> v.cleanReduce(otherArea)); areaMap.putIfAbsent(otherArea.getAreaName(), otherArea);
}else {
areaMap.computeIfPresent(otherArea.getAreaName(), (k, v) -> v.reduce(otherArea));
}
} }
mergeVo.areaStatList = new ArrayList<>(areaMap.values()); mergeVo.areaStatList = new ArrayList<>(areaMap.values());
......
package com.tykj.dev.device.confirmcheck.entity.vo; package com.tykj.dev.device.confirmcheck.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.device.confirmcheck.common.CheckType;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat; import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat;
import com.tykj.dev.misc.base.BeanHelper; import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.JacksonUtil; import com.tykj.dev.misc.utils.JacksonUtil;
...@@ -64,7 +65,7 @@ public class CheckStatVo { ...@@ -64,7 +65,7 @@ public class CheckStatVo {
private LocalDateTime updateTime; private LocalDateTime updateTime;
@ApiModelProperty(name = "检查类型(0异常,1自动,2手动)") @ApiModelProperty(name = "检查类型(0核查 1检查)")
private Integer checkType; private Integer checkType;
private Integer createUserId; private Integer createUserId;
...@@ -134,6 +135,18 @@ public class CheckStatVo { ...@@ -134,6 +135,18 @@ public class CheckStatVo {
//数据转JSON并赋值 //数据转JSON并赋值
String jsonString = JacksonUtil.toJSon(this.deviceStatVoList); String jsonString = JacksonUtil.toJSon(this.deviceStatVoList);
initialStat.setStatInfo(jsonString); initialStat.setStatInfo(jsonString);
if (this.checkType == 0){
initialStat.setCheckType(CheckType.CT_CHECK);
}else if (this.checkType == 1){
initialStat.setCheckType(CheckType.CT_EXAM);
}else {
try {
throw new Exception("[核查模块] 见到异常的checktype类型!id= " + this.checkType);
} catch (Exception e) {
e.printStackTrace();
}
}
return initialStat; return initialStat;
} }
} }
...@@ -15,6 +15,11 @@ import lombok.NoArgsConstructor; ...@@ -15,6 +15,11 @@ import lombok.NoArgsConstructor;
@Data @Data
public class LinkCheckDetail { public class LinkCheckDetail {
/**
* 检查业务ID
*/
private Integer id;
private String checkUnit; private String checkUnit;
private String checkSituation; private String checkSituation;
......
...@@ -15,6 +15,11 @@ import lombok.NoArgsConstructor; ...@@ -15,6 +15,11 @@ import lombok.NoArgsConstructor;
@Data @Data
public class LinkExamDetail { public class LinkExamDetail {
/**
* 自查业务ID
*/
private Integer id;
/** /**
* 检查组名称 * 检查组名称
*/ */
......
...@@ -25,10 +25,21 @@ public class LinkVo { ...@@ -25,10 +25,21 @@ public class LinkVo {
*/ */
private int type; private int type;
/**
* 核查/检查总标题
*/
private String title;
private LocalDate endTime; private LocalDate endTime;
/**
* 里面装的都是检查数据
*/
private List<LinkCheckDetail> lcDetail; private List<LinkCheckDetail> lcDetail;
/**
* 里面装的都是自查数据
*/
private List<LinkExamDetail> leDetail; private List<LinkExamDetail> leDetail;
private int detailId; private int detailId;
......
package com.tykj.dev.device.confirmcheck.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* UnitIds.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/5/17 at 1:31 上午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UnitIds {
private List<Integer> ids;
}
...@@ -3,6 +3,7 @@ package com.tykj.dev.device.confirmcheck.utils; ...@@ -3,6 +3,7 @@ package com.tykj.dev.device.confirmcheck.utils;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.tykj.dev.device.confirmcheck.common.CheckType;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckBill; import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckBill;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail; import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat; import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat;
...@@ -13,6 +14,7 @@ import com.tykj.dev.device.library.subject.domin.DeviceLibrary; ...@@ -13,6 +14,7 @@ import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.packing.service.PackingLibraryService; import com.tykj.dev.device.packing.service.PackingLibraryService;
import com.tykj.dev.device.task.repository.TaskDao; import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.service.TaskService; import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.domin.Task; import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.user.base.enums.AuExample; import com.tykj.dev.device.user.base.enums.AuExample;
import com.tykj.dev.device.user.subject.dao.AreaDao; import com.tykj.dev.device.user.subject.dao.AreaDao;
...@@ -125,8 +127,8 @@ public class ObjTransUtil { ...@@ -125,8 +127,8 @@ public class ObjTransUtil {
// 构建完成情况参数 未完成数量/总数 // 构建完成情况参数 未完成数量/总数
// 获得当前节点的子节点总数 = 总数 其中状态为9999的为已完成 // 获得当前节点的子节点总数 = 总数 其中状态为9999的为已完成
Integer fatherTaskId = taskService.get(stat.getId(), BusinessEnum.CONFIRM_CHECK_STAT.id) TaskBto fatherTask = taskService.get(stat.getId(), BusinessEnum.CONFIRM_CHECK_STAT.id);
.getId(); Integer fatherTaskId = fatherTask.getId();
List<Task> childTasks = taskDao.findAllByParentTaskId(fatherTaskId); List<Task> childTasks = taskDao.findAllByParentTaskId(fatherTaskId);
long total = childTasks.size(); long total = childTasks.size();
...@@ -135,10 +137,14 @@ public class ObjTransUtil { ...@@ -135,10 +137,14 @@ public class ObjTransUtil {
.filter(task -> task.getBillStatus().equals(9999)) .filter(task -> task.getBillStatus().equals(9999))
.count(); .count();
//如果是检查统计的话那么还要看一下他的父节点是不是已经完成了
String completion; String completion;
if (done == total) { if (done == total) {
completion = "核查完成"; if (stat.getCheckType() == CheckType.CT_EXAM && !fatherTask.getBillStatus().equals(9999)) {
completion = "核查完成待办结";
} else {
completion = "核查完成";
}
} else { } else {
completion = done + "/" + total; completion = done + "/" + total;
} }
...@@ -191,6 +197,7 @@ public class ObjTransUtil { ...@@ -191,6 +197,7 @@ public class ObjTransUtil {
initialStat.setDeviceStatVoList(Arrays.asList(checkDeviceStatVos)); initialStat.setDeviceStatVoList(Arrays.asList(checkDeviceStatVos));
initialStat.setCheckUserAName(userAName); initialStat.setCheckUserAName(userAName);
initialStat.setCheckUserBName(userBName); initialStat.setCheckUserBName(userBName);
initialStat.setCheckType(statDo.getCheckType().getId());
return initialStat; return initialStat;
} }
...@@ -219,8 +226,8 @@ public class ObjTransUtil { ...@@ -219,8 +226,8 @@ public class ObjTransUtil {
} }
/** /**
*
* 这里不考虑不在库的装备 * 这里不考虑不在库的装备
*
* @param inLibrary * @param inLibrary
* @param notInLibrary * @param notInLibrary
* @return * @return
...@@ -312,7 +319,7 @@ public class ObjTransUtil { ...@@ -312,7 +319,7 @@ public class ObjTransUtil {
detailVo.setRemark(detailDo.getRemark()); detailVo.setRemark(detailDo.getRemark());
//核查签字单 //核查签字单
if (detailDo.getCheckFiles()!=null){ if (detailDo.getCheckFiles() != null) {
detailVo.setCheckFileList(FilesUtil.stringFileToList(detailDo.getCheckFiles())); detailVo.setCheckFileList(FilesUtil.stringFileToList(detailDo.getCheckFiles()));
} }
return detailVo; return detailVo;
......
...@@ -17,6 +17,10 @@ import java.util.List; ...@@ -17,6 +17,10 @@ import java.util.List;
@SuppressWarnings("SqlResolve") @SuppressWarnings("SqlResolve")
public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>, JpaSpecificationExecutor<DeviceLibrary> { public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>, JpaSpecificationExecutor<DeviceLibrary> {
List<DeviceLibrary> findAllByOwnUnit(String ownUnit);
List<DeviceLibrary> findAllByIdIn(List<Integer> ids);
List<DeviceLibrary> getAllByModel(String model); List<DeviceLibrary> getAllByModel(String model);
List<DeviceLibrary> getAllByOwnUnit(String unit); List<DeviceLibrary> getAllByOwnUnit(String unit);
......
...@@ -1156,8 +1156,8 @@ public class TaskServiceImpl implements TaskService { ...@@ -1156,8 +1156,8 @@ public class TaskServiceImpl implements TaskService {
}); });
} }
} }
if (!ids.contains(userId)){ // if (!ids.contains(userId)){
throw new ApiException(ResponseEntity.status(50000).body("当前用户不能操作此任务")); // throw new ApiException(ResponseEntity.status(50000).body("当前用户不能操作此任务"));
} // }
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论