diff --git a/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/constant/Constant.java b/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/constant/Constant.java index 79e04f2..0c6ad3f 100644 --- a/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/constant/Constant.java +++ b/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/constant/Constant.java @@ -36,6 +36,8 @@ public class Constant { public final static double MAX_VALUE = 100.0; public final static String XL = "线路"; + public final static String BD = "变电"; + public final static String JX = "架线"; public final static String SG_SCREEN = "2"; public final static String SG_SCREEN_NAME = "施工大屏"; diff --git a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DeviceBdChildVo.java b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DeviceBdChildVo.java index c846862..a3d185a 100644 --- a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DeviceBdChildVo.java +++ b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DeviceBdChildVo.java @@ -38,7 +38,7 @@ public class DeviceBdChildVo { @ApiModelProperty(value = "设备网络") @NotBlank(message = "设备网络不能为空", groups = {Query.class}) @Length(max = 20, message = "设备网络字符长度不能超过20", groups = {Query.class}) - @Pattern(regexp = "((0|1\\d{0,2}|2[0-4]\\d|25[0-5])\\.){3}(0|1\\d{0,2}|2[0-4]\\d|25[0-5])",message = "设备网络格式不正确",groups = {Query.class}) + @Pattern(regexp = "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",message = "设备网络格式不正确",groups = {Query.class}) private String ip; @ApiModelProperty(value = "设备名称") diff --git a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DeviceBdVo.java b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DeviceBdVo.java index f807257..059c918 100644 --- a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DeviceBdVo.java +++ b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DeviceBdVo.java @@ -33,12 +33,10 @@ public class DeviceBdVo { @ApiModelProperty(value = "边带ip") @NotBlank(message = "边带ip不能为空", groups = {Query.class}) @Length(max = 50, message = "边带ip字符长度不能超过50", groups = {Query.class}) - @Pattern(regexp = "((0|1\\d{0,2}|2[0-4]\\d|25[0-5])\\.){3}(0|1\\d{0,2}|2[0-4]\\d|25[0-5])",message = "ip格式不正确",groups = {Query.class}) + @Pattern(regexp = "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",message = "ip格式不正确",groups = {Query.class}) private String bdIp; @ApiModelProperty(value = "边带型号") - @NotBlank(message = "边带型号不能为空", groups = {Query.class}) - @Length(max = 80, message = "边带型号字符长度不能超过80", groups = {Query.class}) @JsonInclude(JsonInclude.Include.NON_EMPTY) private String bdType; @@ -46,8 +44,6 @@ public class DeviceBdVo { private String bdTypeName; @ApiModelProperty(value = "设备类型编码") - @NotBlank(message = "设备类型编码不能为空", groups = {Query.class}) - @Length(max = 11, message = "设备类型编码字符长度不能超过11", groups = {Query.class}) @JsonInclude(JsonInclude.Include.NON_EMPTY) private String typeCode; diff --git a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/system/base/vo/GxPlanProgressVo.java b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/system/base/vo/GxPlanProgressVo.java index dd2684e..c142294 100644 --- a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/system/base/vo/GxPlanProgressVo.java +++ b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/system/base/vo/GxPlanProgressVo.java @@ -27,6 +27,7 @@ public class GxPlanProgressVo { private String gxId; @ApiModelProperty(value = "杆塔当前工序ID") + @NotBlank(message = "当前工序不能为空", groups = {Query.class}) private String nowGxId; @ApiModelProperty(value = "计划名称") @@ -63,6 +64,12 @@ public class GxPlanProgressVo { @ApiModelProperty(value = "1.更新工序计划开始时间 2.更新工序计划结束时间或者延期原因") private Integer type; + @ApiModelProperty(value = "工序计划当前进度") + private double planProgress; + + @ApiModelProperty(value = "工序名称") + private String gxName; + /** * 查询条件限制 */ diff --git a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/system/base/vo/GxPlanVo.java b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/system/base/vo/GxPlanVo.java index d3f63c6..c110d61 100644 --- a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/system/base/vo/GxPlanVo.java +++ b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/system/base/vo/GxPlanVo.java @@ -64,6 +64,9 @@ public class GxPlanVo { @JsonInclude(JsonInclude.Include.NON_EMPTY) private Integer type; + @ApiModelProperty(value = "工序计划进度") + private String planProgress; + /** * 查询条件限制 */ diff --git a/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/DeviceBdMapper.xml b/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/DeviceBdMapper.xml index 49d8178..1e3f67c 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/DeviceBdMapper.xml +++ b/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/DeviceBdMapper.xml @@ -119,7 +119,7 @@ - UPDATE tb_pro_bd SET del_flag = 0 WHERE id = #{id} + UPDATE tb_pro_bd SET del_flag = 1 WHERE id = #{id} diff --git a/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/mapper/IProMapper.java b/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/mapper/IProMapper.java index 381c7c4..9124c34 100644 --- a/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/mapper/IProMapper.java +++ b/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/mapper/IProMapper.java @@ -213,11 +213,22 @@ public interface IProMapper { /** * 获取工程状态 - * @return Map> + * + * @return Map> * @description * @author cwchen * @date 2024/3/27 11:05 */ @MapKey("name") Map> getProStatus(); + + /** + * 添加工序计划时杆塔是否被重复添加 + * @param vo + * @return int + * @description + * @author cwchen + * @date 2024/3/29 17:51 + */ + int getTowerIsExist(GxPlanVo vo); } diff --git a/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/mapper/IProScheduleMapper.java b/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/mapper/IProScheduleMapper.java index 7e3b5e1..8646d47 100644 --- a/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/mapper/IProScheduleMapper.java +++ b/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/mapper/IProScheduleMapper.java @@ -5,9 +5,11 @@ import com.securitycontrol.entity.system.base.dto.ProScheduleDto; import com.securitycontrol.entity.system.base.vo.GxPlanProgressVo; import com.securitycontrol.entity.system.base.vo.GxPlanVo; import com.securitycontrol.entity.system.base.vo.ProScheduleVo; +import org.apache.ibatis.annotations.MapKey; import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Map; /** * @author:cwchen @@ -104,6 +106,7 @@ public interface IProScheduleMapper { /** * 获取当前工序计划的填报进度 + * * @param vo * @return String * @description @@ -111,4 +114,25 @@ public interface IProScheduleMapper { * @date 2024/3/28 14:10 */ String getGxPlanProgress(GxPlanProgressVo vo); + + /** + * 查询该工序计划所有填报信息 + * + * @param vo + * @return List> + * @description + * @author cwchen + * @date 2024/3/30 12:39 + */ + @MapKey("planId") + List> getProgressData(GxPlanProgressVo vo); + + /** + * 更新工序计划进度 + * @param vo + * @description + * @author cwchen + * @date 2024/3/30 13:05 + */ + void updateGxPlan(GxPlanProgressVo vo); } diff --git a/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/service/impl/ProScheduleServiceImpl.java b/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/service/impl/ProScheduleServiceImpl.java index 92ef3ad..c3eded3 100644 --- a/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/service/impl/ProScheduleServiceImpl.java +++ b/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/service/impl/ProScheduleServiceImpl.java @@ -14,15 +14,17 @@ import com.securitycontrol.entity.system.base.vo.ProScheduleVo; import com.securitycontrol.system.base.mapper.IProScheduleMapper; import com.securitycontrol.system.base.service.IProScheduleService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; -import java.util.UUID; /** * @author:cwchen @@ -46,7 +48,7 @@ public class ProScheduleServiceImpl implements IProScheduleService { try { list = mapper.getProScheduleLists(dto); } catch (Exception e) { - log.error("获取工程进度列表",e); + log.error("获取工程进度列表", e); } return list; } @@ -57,7 +59,7 @@ public class ProScheduleServiceImpl implements IProScheduleService { try { list = mapper.getGxPlanLists(dto); } catch (Exception e) { - log.error("获取工序计划列表",e); + log.error("获取工序计划列表", e); } return list; } @@ -68,7 +70,7 @@ public class ProScheduleServiceImpl implements IProScheduleService { try { list = mapper.getGxPlansIsDela(dto); } catch (Exception e) { - log.error("工序计划延期提醒",e); + log.error("工序计划延期提醒", e); } return AjaxResult.success(list); } @@ -79,7 +81,7 @@ public class ProScheduleServiceImpl implements IProScheduleService { try { list = mapper.getGxPlanProgressLists(dto); } catch (Exception e) { - log.error("获取工序计划进度列表",e); + log.error("获取工序计划进度列表", e); } return list; } @@ -92,48 +94,21 @@ public class ProScheduleServiceImpl implements IProScheduleService { if (StringUtils.isNotBlank(validResult)) { return AjaxResult.error(validResult); } - int result = mapper.isFirstFillingGxProgress(vo); - if (result == 0) { - // 更新 工序计划开始时间 - vo.setStartTime(DateTimeHelper.getNowDate()); - vo.setType(1); - mapper.updateGxPlanData(vo); - } - // 获取当前工序计划的填报进度 - String nowGxPlanProgress = mapper.getGxPlanProgress(vo); - if(StringUtils.isNotEmpty(nowGxPlanProgress)){ - double aDouble = Double.parseDouble(nowGxPlanProgress); - double bDouble = Double.parseDouble(vo.getGxProgress()); - if(bDouble < aDouble){ - return AjaxResult.error("当前进度填报需大于上一次填报进度"); - } - } - Long timestamp = DateTimeHelper.convertDateStringToTimestamp(vo.getPlanEndTime(), "yyyy-MM-dd"); - if (timestamp == null) { - return AjaxResult.error("计划结束时间格式不正确"); - } - Long timestamp2 = DateTimeHelper.convertDateStringToTimestamp(DateTimeHelper.getNowDate(), "yyyy-MM-dd"); - if (timestamp2 > timestamp && StringUtils.isEmpty(vo.getDelaReason())) { - return AjaxResult.error("计划延期原因不能为空"); - } - // 计划填报进度为100 更新工序计划 - if (vo.getGxProgress().contains(Constant.GX_PLAN_PROGRESS)) { - vo.setEndTime(DateTimeHelper.getNowDate()); - } - // 计划有延期更新到工序计划 - if (StringUtils.isNotEmpty(vo.getDelaReason()) || vo.getGxProgress().contains(Constant.GX_PLAN_PROGRESS)) { - vo.setType(2); - mapper.updateGxPlanData(vo); + // 验证工序计划进度数据 + AjaxResult ajaxResult = validateData(vo); + if (ajaxResult != null) { + return ajaxResult; } + // 工序计划进度赋值 + vo = setGxPlanProgressData(vo); // 填报工序计划 vo.setCreateTime(DateTimeHelper.getNowTime()); String progressId = IdUtils.getUUId(); vo.setProgressId(progressId); mapper.addGxPlanProgress(vo); - // 工程为线路时 更新杆塔当前工序 - if (Objects.equals(Constant.XL, vo.getProType())) { - mapper.updateGtData(vo); - } + // 查询该工序计划所有填报信息 + List> progressList = mapper.getProgressData(vo); + statisticsProgress(progressList,vo); } catch (Exception e) { log.error("填报工序计划进度列表", e); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); @@ -141,4 +116,99 @@ public class ProScheduleServiceImpl implements IProScheduleService { } return AjaxResult.success(); } + + /** + * 验证进度填报 + * + * @return AjaxResult + * @description + * @author cwchen + * @date 2024/3/29 18:06 + */ + public AjaxResult validateData(GxPlanProgressVo vo) { + // 计划结束时间不能为空 + Long timestamp = DateTimeHelper.convertDateStringToTimestamp(vo.getPlanEndTime(), "yyyy-MM-dd"); + if (timestamp == null) { + return AjaxResult.error("计划结束时间格式不正确"); + } + // 如果当前时间超过计划结束时间 需要填写计划延期原因 + Long timestamp2 = DateTimeHelper.convertDateStringToTimestamp(DateTimeHelper.getNowDate(), "yyyy-MM-dd"); + if (timestamp2 > timestamp && StringUtils.isEmpty(vo.getDelaReason())) { + return AjaxResult.error("计划延期原因不能为空"); + } + // 获取当前工序的填报进度 线路->杆塔分为 基础、组塔、架线 变电直接到工序 + String nowGxPlanProgress = mapper.getGxPlanProgress(vo); + if (StringUtils.isNotEmpty(nowGxPlanProgress)) { + double aDouble = Double.parseDouble(nowGxPlanProgress); + double bDouble = Double.parseDouble(vo.getGxProgress()); + if (bDouble < aDouble) { + return AjaxResult.error("当前工序进度填报需大于上一次工序填报进度"); + } + } + return null; + } + + /** + * 进度填报赋值 + * + * @param vo + * @return GxPlanProgressVo + * @description + * @author cwchen + * @date 2024/3/30 12:44 + */ + public GxPlanProgressVo setGxPlanProgressData(GxPlanProgressVo vo) { + // 判断计划是否是第一次填报 并更新工序计划开始时间 + int result = mapper.isFirstFillingGxProgress(vo); + if (result == 0) { + vo.setStartTime(DateTimeHelper.getNowDate()); + vo.setType(1); + mapper.updateGxPlanData(vo); + } + // 变电 - 工序进度达到 100 更新计划结束日期 + if (Objects.equals(vo.getProType(), Constant.BD) && + Objects.equals(Double.parseDouble(Constant.GX_PLAN_PROGRESS), vo.getGxProgress())) { + vo.setEndTime(DateTimeHelper.getNowDate()); + } + // 线路 - 工序进度为架线 并且进度到100 更新计划结束日期 + if (Objects.equals(vo.getProType(), Constant.XL) && + Objects.equals(Double.parseDouble(Constant.GX_PLAN_PROGRESS), vo.getGxProgress()) && + Objects.equals(vo.getNowGxId(), Constant.JX)) { + vo.setEndTime(DateTimeHelper.getNowDate()); + } + // 计划有延期或者进度填报达到100时更新到工序计划 + if (StringUtils.isNotEmpty(vo.getDelaReason()) || StringUtils.isNotEmpty(vo.getEndTime())) { + vo.setType(2); + mapper.updateGxPlanData(vo); + } + // 工程为线路时 更新杆塔当前工序 + if (Objects.equals(Constant.XL, vo.getProType())) { + mapper.updateGtData(vo); + } + return vo; + } + + /** + * 统计并更新工序计划进度 + * @param progressList + * @param vo + * @description + * @author cwchen + * @date 2024/3/30 12:46 + */ + public void statisticsProgress(List> progressList, GxPlanProgressVo vo) { + if (CollectionUtils.isNotEmpty(progressList)) { + BigDecimal value = new BigDecimal("0"); + BigDecimal gxNum = new BigDecimal("3"); + for (Map map : progressList) { + BigDecimal dataValue = new BigDecimal(String.valueOf(map.get("gxProgress"))); + value = value.add(dataValue); + } + if(Objects.equals(vo.getProType(),Constant.XL)){ + value = value.divide(gxNum, 3, BigDecimal.ROUND_HALF_UP); + } + vo.setPlanProgress(value.doubleValue()); + mapper.updateGxPlan(vo); + } + } } diff --git a/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/service/impl/ProServiceImpl.java b/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/service/impl/ProServiceImpl.java index 3fadabc..858fe0d 100644 --- a/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/service/impl/ProServiceImpl.java +++ b/securitycontrol-model/securitycontrol-system/src/main/java/com/securitycontrol/system/base/service/impl/ProServiceImpl.java @@ -548,6 +548,10 @@ public class ProServiceImpl implements IProService { if (StringUtils.isNotBlank(validResult)) { return AjaxResult.error(validResult); } + int result = mapper.getTowerIsExist(vo); + if(result > 0){ + return AjaxResult.error("杆塔或工序不能重复选择"); + } List> weightList = mapper.getGxWeight(vo.getBidCode()); if (CollectionUtils.isNotEmpty(weightList)) { Boolean isFlag = isExceedData(weightList, vo.getPlanId(), vo.getGxWeight()); diff --git a/securitycontrol-model/securitycontrol-system/src/main/resources/mapper/base/ProMapper.xml b/securitycontrol-model/securitycontrol-system/src/main/resources/mapper/base/ProMapper.xml index ae1d128..d602dee 100644 --- a/securitycontrol-model/securitycontrol-system/src/main/resources/mapper/base/ProMapper.xml +++ b/securitycontrol-model/securitycontrol-system/src/main/resources/mapper/base/ProMapper.xml @@ -261,7 +261,8 @@ tpg.gt_name AS gxName, - tgp.gx_id AS gxId + tgp.gx_id AS gxId, + tgp.plan_progress AS planProgress FROM tb_gx_plan tgp LEFT JOIN sys_dict sd ON sd.dict_code = tgp.gx_id @@ -323,4 +324,8 @@ WHERE sd.dict_code = 1200 AND sd.del_flag = 0 ORDER BY sd2.dict_sort + + \ No newline at end of file diff --git a/securitycontrol-model/securitycontrol-system/src/main/resources/mapper/base/ProScheduleMapper.xml b/securitycontrol-model/securitycontrol-system/src/main/resources/mapper/base/ProScheduleMapper.xml index 787e871..c9390e3 100644 --- a/securitycontrol-model/securitycontrol-system/src/main/resources/mapper/base/ProScheduleMapper.xml +++ b/securitycontrol-model/securitycontrol-system/src/main/resources/mapper/base/ProScheduleMapper.xml @@ -8,7 +8,7 @@ id, plan_id, gx_progress, - gx_id, + gx_id, create_time, dela_reason, @@ -16,7 +16,7 @@ #{progressId}, #{planId}, #{gxProgress}, - #{gxId}, + #{nowGxId}, #{createTime}, #{delaReason}, @@ -40,6 +40,10 @@ UPDATE t_pro_gt SET now_gx = #{nowGxId} WHERE gt_id = #{gxId} + + + UPDATE tb_gx_plan SET plan_progress = #{planProgress} WHERE plan_id = #{planId} + SELECT tpp.gx_progress AS gxProgress, - tpp.create_time AS createTime - FROM tb_project_progress tpp - LEFT JOIN tb_gx_plan tgp ON tpp.plan_id = tgp.plan_id + tpp.create_time AS createTime, + sd.dict_name AS gxName + FROM tb_project_progress tpp + LEFT JOIN tb_gx_plan tgp ON tpp.plan_id = tgp.plan_id AND tgp.del_flag = 0 + LEFT JOIN sys_dict sd on tpp.gx_id = sd.dict_code AND sd.del_flag = 0 WHERE tpp.plan_id = #{planId} + ORDER BY tpp.create_time SELECT tpp.gx_progress AS gxProgress FROM tb_project_progress tpp - WHERE plan_id = #{planId} + WHERE plan_id = #{planId} AND gx_id = #{nowGxId} ORDER BY create_time DESC LIMIT 1 + + \ No newline at end of file