skjcmanager/skjcmanager-service-api/skjcmanager-sm-api/src/main/java/cn/gistack/sm/sg/DO/SgProjectInfoDO.java
@@ -1,6 +1,7 @@ package cn.gistack.sm.sg.DO; import cn.gistack.sm.sg.VO.PreAcceVO; import cn.gistack.sm.sg.VO.PtypeVO; import cn.gistack.sm.sg.VO.SgTypeVO; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -172,7 +173,7 @@ @TableField(exist = false) private List<SgTypeVO> sgGxDOS; private List<PtypeVO> ptypeVOS; @TableField(exist = false) private List<PreAcceVO> preAcce; skjcmanager/skjcmanager-service-api/skjcmanager-sm-api/src/main/java/cn/gistack/sm/sg/VO/PtypeVO.java
New file @@ -0,0 +1,22 @@ package cn.gistack.sm.sg.VO; import cn.gistack.sm.sg.DO.SgDeviceDO; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.util.List; /** * 工序父类型 进度实体类 */ @Data @AllArgsConstructor @NoArgsConstructor @Builder public class PtypeVO { private String pTypeName; private String pTypeProgress; private List<SgTypeVO> sgTypeVOS; } skjcmanager/skjcmanager-service-api/skjcmanager-sm-api/src/main/java/cn/gistack/sm/sg/VO/SgProjectInfoVO.java
@@ -29,4 +29,6 @@ private Integer deviceStatus; private Integer projectStatus; private String progressName; private String Ptype; private String PtypeName; } skjcmanager/skjcmanager-service-api/skjcmanager-sm-api/src/main/java/cn/gistack/sm/sg/VO/SgTypeVO.java
@@ -16,5 +16,6 @@ public class SgTypeVO { private String typeName; private String typeProgress; private String progress; private List<SgDeviceDO> deviceDOS; } skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProgressReportMapper.java
@@ -1,6 +1,7 @@ package cn.gistack.sm.sg.mapper; import cn.gistack.sm.sg.DO.SgProgressReportDO; import cn.gistack.sm.sg.DO.SgReportUserDO; import cn.gistack.sm.sg.DTO.ProjectSearchDTO; import cn.gistack.sm.sg.VO.SgProgressReportVO; import cn.gistack.sm.sg.VO.SgStepReportVO; @@ -39,4 +40,6 @@ List<SgProgressReportVO> queryPageListAll(@Param("page") IPage<SgProgressReportVO> page, @Param("dto") ProjectSearchDTO searchDTO); Long selectProframId(Long deviceId); List<SgReportUserDO> selectProcessUserByProjectId(@Param("programId") Long programId); } skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProgressReportMapper.xml
@@ -105,7 +105,7 @@ and userR.approval_status = 1 </if> <if test="dto.approvalStatus != null and dto.approvalStatus ==2"> AND userR.approval_order = 2 AND userR.approval_status = 2 </if> <if test="dto.startTime != null and dto.startTime !='' "> and report.report_time >= #{dto.startTime} @@ -190,4 +190,8 @@ <select id="selectProframId" resultType="java.lang.Long"> select program_id from ywxt.sg_device where id = #{deviceId} </select> <select id="selectProcessUserByProjectId" resultType="cn.gistack.sm.sg.DO.SgReportUserDO"> select u.* from ywxt.sg_report_user u left join ywxt.sg_progresss_report r on u.report_id = r.id where 1=1 and r.profram_id = #{programId} </select> </mapper> skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProjectInfoMapper.xml
@@ -60,6 +60,8 @@ gx.id AS gxId, gx.gx_name, d.device_name, Pdict.dict_key as Ptype, Pdict.dict_value as PtypeName, d.device_type, dict."DICT_VALUE" AS typeName, d.id AS dId, @@ -74,8 +76,8 @@ FROM ywxt.sg_project_info pro LEFT JOIN ywxt.sg_device d ON pro.id = d.program_id LEFT JOIN YWXT."BLADE_DICT_BIZ" AS dict ON d.device_type = dict.DICT_KEY AND dict.CODE = 'SG_DEVICE_TYPE' LEFT JOIN YWXT."BLADE_DICT_BIZ" AS dict ON d.device_type = dict.DICT_KEY AND dict.CODE = 'SG_DEVICE_TYPE' LEFT JOIN YWXT."BLADE_DICT_BIZ" Pdict on dict.parent_id = Pdict.id LEFT JOIN ywxt.sg_gx gx ON d.device_type = gx.gx_type LEFT JOIN ywxt.sg_gx_step step ON gx.id = step.gx_info_id LEFT JOIN ywxt.sg_progress_report re ON re.gx_step_id = step.id skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxServiceImpl.java
@@ -106,6 +106,6 @@ if (CollectionUtils.isNotEmpty(list)){ throw new ServiceException("此工序存在工序步骤,不允许删除"); } this.delete(id); sgGxMapper.deleteById(id); } } skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java
@@ -103,9 +103,18 @@ } SgProjectInfoVO sgProjectInfoVO = value.get(0); SgProjectInfoDO sgProjectInfoDO = SgProjectInfoDO.builder().id(porId).lonLat(sgProjectInfoVO.getLonLat()).status(sgProjectInfoVO.getProjectStatus()).projectName(sgProjectInfoVO.getProjectName()).build(); //父类型分组 List<PtypeVO> pTypes = new ArrayList(); Map<String, List<SgProjectInfoVO>> pTypeMap = value.stream().filter(s->s.getPtype()!=null).collect(Collectors.groupingBy(SgProjectInfoVO::getPtype)); for (Map.Entry<String, List<SgProjectInfoVO>> pty : pTypeMap.entrySet()) { List<SgProjectInfoVO> ptyValue = pty.getValue(); if (CollectionUtils.isEmpty(ptyValue)){ continue; } PtypeVO ptypeVO = PtypeVO.builder().pTypeName(ptyValue.get(0).getPtypeName()).build(); List<SgTypeVO> sgGxDOS = new ArrayList<>(); //类型分组 Map<String, List<SgProjectInfoVO>> GxMap = value.stream().filter(s->s.getDeviceType()!=null).collect(Collectors.groupingBy(SgProjectInfoVO::getDeviceType)); Map<String, List<SgProjectInfoVO>> GxMap = ptyValue.stream().filter(s->s.getDeviceType()!=null).collect(Collectors.groupingBy(SgProjectInfoVO::getDeviceType)); for (Map.Entry<String, List<SgProjectInfoVO>> ty : GxMap.entrySet()) { String type = ty.getKey(); List<SgProjectInfoVO> gxList = ty.getValue(); @@ -143,14 +152,23 @@ BigDecimal divideDevice = deviceOver.divide(deviceSize, 2, RoundingMode.HALF_UP); typeVO.setDeviceDOS(deviceDOS); typeVO.setTypeProgress(getBigDecimalPercent(divideDevice)); typeVO.setProgress(divideDevice.toString()); sgGxDOS.add(typeVO); } BigDecimal sgGxSize = BigDecimal.valueOf(sgGxDOS.size()); double sum = sgGxDOS.stream().mapToDouble(s -> Double.parseDouble(s.getProgress())).sum(); BigDecimal sgGxOver = BigDecimal.valueOf(sum); BigDecimal divideSgGx = sgGxOver.divide(sgGxSize, 2, RoundingMode.HALF_UP); ptypeVO.setPTypeProgress(getBigDecimalPercent(divideSgGx)); ptypeVO.setSgTypeVOS(sgGxDOS); pTypes.add(ptypeVO); } BigDecimal allDeviceSize = BigDecimal.valueOf(allDevice.size()); if (!allDeviceSize.equals(BigDecimal.ZERO)){ double sum = allDevice.stream().mapToDouble(s -> Double.parseDouble(s.getProgress())).sum(); BigDecimal allDeviceOver = BigDecimal.valueOf(sum); BigDecimal allDivideDevice = allDeviceOver.divide(allDeviceSize, 2, RoundingMode.HALF_UP); sgProjectInfoDO.setSgGxDOS(sgGxDOS); sgProjectInfoDO.setPtypeVOS(pTypes); sgProjectInfoDO.setProjectProgress( getBigDecimalPercent(allDivideDevice)); sgProjectInfoDO.setProjectProgressNum(allDivideDevice); } @@ -314,11 +332,11 @@ List<SgProjectInfoDO> projectProgress = getProjectProgress(list); projectProgress.forEach(p -> { List<SgTypeVO> sgGxDOS = p.getSgGxDOS(); sgGxDOS.forEach(sgTypeVO -> { String typeProgress = sgTypeVO.getTypeProgress().replace("%", ""); List<PtypeVO> ptypeVOS = p.getPtypeVOS(); ptypeVOS.forEach(sgTypeVO -> { String typeProgress = sgTypeVO.getPTypeProgress().replace("%", ""); BigDecimal percentageBigDecimal = new BigDecimal(typeProgress).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP); bigDecimals.merge(sgTypeVO.getTypeName(), percentageBigDecimal, BigDecimal::add); bigDecimals.merge(sgTypeVO.getPTypeName(), percentageBigDecimal, BigDecimal::add); }); }); skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectPersonConfigServiceImpl.java
@@ -3,11 +3,14 @@ import cn.gistack.sm.sg.DO.SgProgressReportDO; import cn.gistack.sm.sg.DO.SgProjectPersonConfigDO; import cn.gistack.sm.sg.DO.SgProjectRolePersonV0; import cn.gistack.sm.sg.DO.SgReportUserDO; import cn.gistack.sm.sg.DTO.AddSgProjectPersonConfigDTO; import cn.gistack.sm.sg.DTO.ProjectSearchDTO; import cn.gistack.sm.sg.mapper.SgProgressReportMapper; import cn.gistack.sm.sg.mapper.SgProjectPersonConfigMapper; import cn.gistack.sm.sg.mapper.SgReportUserMapper; import cn.gistack.sm.sg.service.SgProjectPersonConfigService; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -33,6 +36,9 @@ private SgProjectPersonConfigMapper projectPersonConfigMapper; @Autowired private SgProgressReportMapper sgProgressReportMapper; @Autowired private SgReportUserMapper sgReportUserMapper; @Override public List<String> getRoleList(ProjectSearchDTO searchDTO) { List<String> list = projectPersonConfigMapper.getRoleList(searchDTO); @@ -48,17 +54,26 @@ projectPersonConfigMapper.insert(sgProjectPersonConfigDO); }else { SgProjectPersonConfigDO old = projectPersonConfigMapper.selectById(id); boolean isReport = !new LambdaQueryChainWrapper<>(sgProgressReportMapper).eq(SgProgressReportDO::getProframId, old.getProgramId()).list().isEmpty(); List<SgReportUserDO> reportUserDOS = sgProgressReportMapper.selectProcessUserByProjectId(old.getProgramId()); if (Objects.isNull(userId)){ /*if (isReport){ throw new ServiceException("此项目配置存在审批,不允许修改"); }*/ projectPersonConfigMapper.deleteById(id); if (!CollectionUtils.isEmpty(reportUserDOS)){ reportUserDOS.forEach(s->{ if (Objects.equals(old.getUserId(), s.getUserId())){ // sgReportUserMapper.deleteById(s.getId()); } }); } }else if (!old.getUserId().equals(sgProjectPersonConfigDO.getUserId())){ /*if (isReport){ throw new ServiceException("此项目配置存在审批,不允许修改"); }*/ projectPersonConfigMapper.updateById(sgProjectPersonConfigDO); if (!CollectionUtils.isEmpty(reportUserDOS)){ reportUserDOS.forEach(s->{ if (Objects.equals(old.getUserId(), s.getUserId())){ s.setUserId(sgProjectPersonConfigDO.getUserId()); sgReportUserMapper.updateById(s); } }); } } } }