skjcmanager/skjcmanager-service-api/skjcmanager-sm-api/src/main/java/cn/gistack/sm/sg/DTO/ProjectSearchDTO.java
@@ -66,6 +66,8 @@ private Integer projectSort; private String auditPerson; private List<String> sgCodeS; } skjcmanager/skjcmanager-service-api/skjcmanager-sm-api/src/main/java/cn/gistack/sm/sg/VO/SgStatisDeviceVO.java
New file @@ -0,0 +1,10 @@ package cn.gistack.sm.sg.VO; import lombok.Data; @Data public class SgStatisDeviceVO { private Integer deviceCount; private Integer deviceStart; private String pType; } skjcmanager/skjcmanager-service-api/skjcmanager-sm-api/src/main/java/cn/gistack/sm/sg/VO/SgStatisProVO.java
@@ -20,6 +20,32 @@ private int commenceNum; private String projectProgress; /** * 表面变形 */ private int surfaceNum; private String surfaceProgress; /** * 视频 */ private int videoNum; private String videoProgress; /** * 渗流压力 */ private int transNum; private String transProgress; /** * 渗流量 */ private int seepageNum; private String seepageProgress; private String proIds; } skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProjectInfoMapper.java
@@ -3,10 +3,7 @@ import cn.gistack.sm.sg.DO.SgGxStepDO; import cn.gistack.sm.sg.DO.SgProjectInfoDO; import cn.gistack.sm.sg.DTO.ProjectSearchDTO; import cn.gistack.sm.sg.VO.SgProjectInfoVO; import cn.gistack.sm.sg.VO.SgStatisProVO; import cn.gistack.sm.sg.VO.SgStatistccVO; import cn.gistack.sm.sg.VO.SgStatisticsVO; import cn.gistack.sm.sg.VO.*; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Param; @@ -51,5 +48,9 @@ SgProjectInfoVO selectVOById(@Param("proframId") Long proframId); String getSgCodeByUser(String id); List<SgStatisDeviceVO> getDeviceTypes(@Param("s") String s); //List<String> getProjectIds(String code,@Param("grad") String grad ); } skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProjectInfoMapper.xml
@@ -15,6 +15,7 @@ LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id WHERE 1 =1 <include refid="sgCodeCondition" /> <if test="dto.projectName != null and dto.projectName != ''"> and info.project_name like concat( concat ('%',#{dto.projectName}),'%') </if> @@ -42,6 +43,25 @@ #{id} </foreach> </if> <!--<if test="dto.sgCodeS != null and dto.sgCodeS.size > 0"> and (dria.province_cd in <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")"> #{id} </foreach> or dria.city_cd in <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")"> #{id} </foreach> or dria.county_cd in <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")"> #{id} </foreach> or dria.town_cd in <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")"> #{id} </foreach> ) </if>--> <if test="dto.projectSort == null or dto.projectSort ==0"> ORDER BY info.status desc ,info.project_progress desc </if> @@ -52,6 +72,20 @@ ORDER BY info.sk_id asc </if> </select> <sql id="sgCodeCondition"> <if test="dto.sgCodeS != null and dto.sgCodeS.size() > 0"> AND ( <foreach collection="dto.sgCodeS" item="id" separator="OR" open="(" close=")"> dria.province_cd = #{id} OR dria.city_cd = #{id} OR dria.county_cd = #{id} or dria.town_cd = #{id} </foreach> ) </if> </sql> <select id="queryStepByProject" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO"> SELECT @@ -147,14 +181,16 @@ a."ad_code" CODE, a."ad_name" NAME, SUM( CASE WHEN b.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum, count( b.STATUS ) projectSum count( b.STATUS ) projectSum, LISTAGG(b.id, ',') as proIds FROM ( SELECT dria."county_cd" AS countyCode, att."guid" AS cityCode, ad."ad_code" AS provinceCode, info.STATUS info.STATUS, info.id FROM YWXT.SG_PROJECT_INFO info LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id @@ -177,7 +213,8 @@ SELECT dria."city_cd" code, dria."city_nm" name , sum( CASE WHEN info.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum, count( info.STATUS ) projectSum count( info.STATUS ) projectSum, LISTAGG(info.id, ',') as proIds FROM YWXT.SG_PROJECT_INFO info LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id @@ -199,7 +236,8 @@ info.lot as code, info.lot as name, sum( CASE WHEN info.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum, count( info.STATUS ) AS projectSum count( info.STATUS ) AS projectSum, LISTAGG(info.id, ',') as proIds FROM YWXT.SG_PROJECT_INFO info LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id @@ -369,7 +407,27 @@ <select id="selectVOById" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO"> select * from ywxt.sg_project_info pro where pro.id = #{proframId} </select> <!-- <select id="getProjectIds" resultType="java.lang.String">--> <!-- </select>--> <select id="getDeviceTypes" resultType="cn.gistack.sm.sg.VO.SgStatisDeviceVO"> SELECT count( d.id) AS deviceCount, sum( CASE WHEN d.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END) deviceStart, Pdict.DICT_KEY as pType FROM ywxt.sg_device d LEFT JOIN ywxt.blade_dict_biz dict ON d.device_type = dict.DICT_KEY LEFT JOIN YWXT."BLADE_DICT_BIZ" Pdict ON dict.parent_id = Pdict.id WHERE program_id IN ${s} GROUP BY Pdict.DICT_KEY </select> <select id="getSgCodeByUser" resultType="java.lang.String"> SELECT dp."SG_CODE" FROM ywxt.BLADE_USER u LEFT JOIN ywxt.blade_dept dp ON u.dept_id = cast( dp.id AS VARCHAR ) WHERE u.id = #{userId} </select> </mapper> skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java
@@ -18,11 +18,13 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jetbrains.annotations.NotNull; import org.springblade.core.secure.utils.AuthUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StopWatch; import javax.security.auth.login.LoginContext; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; @@ -53,6 +55,8 @@ @Override public IPage<SgProjectInfoDO> queryPageList(IPage<SgProjectInfoDO> page, ProjectSearchDTO searchDTO) { List<String> sgCodeS = getSgCodeByUser(); searchDTO.setSgCodeS(sgCodeS); List<SgProjectInfoDO> sgProjectInfoDOS = baseMapper.queryPageList(page,searchDTO); List<SgProjectInfoDO> projectProgress = getProjectProgress(sgProjectInfoMapper.queryStepByProject(searchDTO)); if (CollectionUtils.isNotEmpty(projectProgress)){ @@ -64,6 +68,18 @@ return page.setRecords(sgProjectInfoDOS); } /** * 获取当前用户的工程编码 */ public List<String> getSgCodeByUser(){ Long userId = AuthUtil.getUserId(); String sgCode = sgProjectInfoMapper.getSgCodeByUser(userId.toString()); if (StringUtils.isNotBlank(sgCode)){ List<String> list = List.of(sgCode.split(",")); return list; } return null; } /** * 获取项目及项目下设备及设备下工序进度 * @param searchDTO @@ -269,17 +285,90 @@ //片区 if (ywxtAdDetail == null) { sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsZero(code); getDeviceTypes(sgStatisProVOS); // String getname = sgProjectInfoMapper.getname(code); String getname = code; updateProjectProgress(sgStatisProVOS, code, getname, "2"); } else if (ywxtAdDetail.getAdGrad().equals("1")) {//默认 sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsOne(code); getDeviceTypes(sgStatisProVOS); updateProjectProgress(sgStatisProVOS, ywxtAdDetail.getPAdCode(), ywxtAdDetail.getPAdName(), "0"); } else {//区县 sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsList(code); getDeviceTypes(sgStatisProVOS); updateProjectProgress(sgStatisProVOS, ywxtAdDetail.getAdCode(), ywxtAdDetail.getAdName(), "3"); } return sgStatisProVOS; } /** * 统计设备类型开工率 * @param sgStatisProVOS */ private void getDeviceTypes(List<SgStatisProVO> sgStatisProVOS) { if (CollectionUtils.isNotEmpty(sgStatisProVOS)){ for (SgStatisProVO vo : sgStatisProVOS) { String proIds = vo.getProIds(); if (StringUtils.isNotBlank(proIds)){ List<SgStatisDeviceVO> deviceVOS = sgProjectInfoMapper.getDeviceTypes("("+proIds+")"); if(CollectionUtils.isNotEmpty(deviceVOS)){ Map<String, SgStatisDeviceVO> map = deviceVOS.stream().collect(Collectors.toMap(SgStatisDeviceVO::getPType, Function.identity())); //表面变形 SgStatisDeviceVO sg108 = map.get("sg108"); if (Objects.nonNull(sg108)){ Integer deviceCount = sg108.getDeviceCount(); Integer deviceStart = sg108.getDeviceStart(); vo.setSurfaceNum(deviceCount); if (deviceCount != 0){ BigDecimal divide = BigDecimal.valueOf(deviceStart).divide(BigDecimal.valueOf(deviceCount), 2, BigDecimal.ROUND_UP); vo.setSeepageProgress(getBigDecimalPercent(divide)); }else { vo.setSeepageProgress("0%"); } } //视频 SgStatisDeviceVO sg104 = map.get("sg104"); if (Objects.nonNull(sg104)){ Integer deviceCount = sg104.getDeviceCount(); Integer deviceStart = sg104.getDeviceStart(); vo.setVideoNum(deviceCount); if (deviceCount != 0){ BigDecimal divide = BigDecimal.valueOf(deviceStart).divide(BigDecimal.valueOf(deviceCount), 2, BigDecimal.ROUND_UP); vo.setVideoProgress(getBigDecimalPercent(divide)); }else { vo.setVideoProgress("0%"); } } //渗压 SgStatisDeviceVO sg101 = map.get("sg101"); if (Objects.nonNull(sg101)){ Integer deviceCount = sg101.getDeviceCount(); Integer deviceStart = sg101.getDeviceStart(); vo.setTransNum(deviceCount); if (deviceCount != 0){ BigDecimal divide = BigDecimal.valueOf(deviceStart).divide(BigDecimal.valueOf(deviceCount), 2, BigDecimal.ROUND_UP); vo.setTransProgress(getBigDecimalPercent(divide)); }else { vo.setTransProgress("0%"); } } //渗流 SgStatisDeviceVO sg102 = map.get("sg102"); if (Objects.nonNull(sg102)){ Integer deviceCount = sg102.getDeviceCount(); Integer deviceStart = sg102.getDeviceStart(); vo.setSeepageNum(deviceCount); if (deviceCount != 0){ BigDecimal divide = BigDecimal.valueOf(deviceStart).divide(BigDecimal.valueOf(deviceCount), 2, BigDecimal.ROUND_UP); vo.setSeepageProgress(getBigDecimalPercent(divide)); }else { vo.setSeepageProgress("0%"); } } } } } } } private void updateProjectProgress(List<SgStatisProVO> sgStatisProVOS, String pcode, String pname, String adGrad) { @@ -401,6 +490,7 @@ private PreAcceVO handleQuery( int stepIdForNull, Long programId) { QueryWrapper<SgProgressReportDO> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("gx_step_id", stepIdForNull) .ne("status",3) .eq("profram_id", programId); SgProgressReportDO sgProgressReportDO = sgProgressReportMapper.selectOne(queryWrapper);