工序计划

This commit is contained in:
cwchen 2024-03-30 13:37:44 +08:00
parent 8e06d16c37
commit a6c466c73d
12 changed files with 196 additions and 58 deletions

View File

@ -36,6 +36,8 @@ public class Constant {
public final static double MAX_VALUE = 100.0; public final static double MAX_VALUE = 100.0;
public final static String XL = "线路"; 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 = "2";
public final static String SG_SCREEN_NAME = "施工大屏"; public final static String SG_SCREEN_NAME = "施工大屏";

View File

@ -38,7 +38,7 @@ public class DeviceBdChildVo {
@ApiModelProperty(value = "设备网络") @ApiModelProperty(value = "设备网络")
@NotBlank(message = "设备网络不能为空", groups = {Query.class}) @NotBlank(message = "设备网络不能为空", groups = {Query.class})
@Length(max = 20, message = "设备网络字符长度不能超过20", 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; private String ip;
@ApiModelProperty(value = "设备名称") @ApiModelProperty(value = "设备名称")

View File

@ -33,12 +33,10 @@ public class DeviceBdVo {
@ApiModelProperty(value = "边带ip") @ApiModelProperty(value = "边带ip")
@NotBlank(message = "边带ip不能为空", groups = {Query.class}) @NotBlank(message = "边带ip不能为空", groups = {Query.class})
@Length(max = 50, message = "边带ip字符长度不能超过50", 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; private String bdIp;
@ApiModelProperty(value = "边带型号") @ApiModelProperty(value = "边带型号")
@NotBlank(message = "边带型号不能为空", groups = {Query.class})
@Length(max = 80, message = "边带型号字符长度不能超过80", groups = {Query.class})
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
private String bdType; private String bdType;
@ -46,8 +44,6 @@ public class DeviceBdVo {
private String bdTypeName; private String bdTypeName;
@ApiModelProperty(value = "设备类型编码") @ApiModelProperty(value = "设备类型编码")
@NotBlank(message = "设备类型编码不能为空", groups = {Query.class})
@Length(max = 11, message = "设备类型编码字符长度不能超过11", groups = {Query.class})
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
private String typeCode; private String typeCode;

View File

@ -27,6 +27,7 @@ public class GxPlanProgressVo {
private String gxId; private String gxId;
@ApiModelProperty(value = "杆塔当前工序ID") @ApiModelProperty(value = "杆塔当前工序ID")
@NotBlank(message = "当前工序不能为空", groups = {Query.class})
private String nowGxId; private String nowGxId;
@ApiModelProperty(value = "计划名称") @ApiModelProperty(value = "计划名称")
@ -63,6 +64,12 @@ public class GxPlanProgressVo {
@ApiModelProperty(value = "1.更新工序计划开始时间 2.更新工序计划结束时间或者延期原因") @ApiModelProperty(value = "1.更新工序计划开始时间 2.更新工序计划结束时间或者延期原因")
private Integer type; private Integer type;
@ApiModelProperty(value = "工序计划当前进度")
private double planProgress;
@ApiModelProperty(value = "工序名称")
private String gxName;
/** /**
* 查询条件限制 * 查询条件限制
*/ */

View File

@ -64,6 +64,9 @@ public class GxPlanVo {
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
private Integer type; private Integer type;
@ApiModelProperty(value = "工序计划进度")
private String planProgress;
/** /**
* 查询条件限制 * 查询条件限制
*/ */

View File

@ -119,7 +119,7 @@
</insert> </insert>
<!--删除边带设备--> <!--删除边带设备-->
<delete id="delDeviceBdById"> <delete id="delDeviceBdById">
UPDATE tb_pro_bd SET del_flag = 0 WHERE id = #{id} UPDATE tb_pro_bd SET del_flag = 1 WHERE id = #{id}
</delete> </delete>
<!--删除边带设备--> <!--删除边带设备-->
<delete id="delDeviceBdChildById"> <delete id="delDeviceBdChildById">

View File

@ -213,6 +213,7 @@ public interface IProMapper {
/** /**
* 获取工程状态 * 获取工程状态
*
* @return Map<String, Map < String, String>> * @return Map<String, Map < String, String>>
* @description * @description
* @author cwchen * @author cwchen
@ -220,4 +221,14 @@ public interface IProMapper {
*/ */
@MapKey("name") @MapKey("name")
Map<String, Map<String, String>> getProStatus(); Map<String, Map<String, String>> getProStatus();
/**
* 添加工序计划时杆塔是否被重复添加
* @param vo
* @return int
* @description
* @author cwchen
* @date 2024/3/29 17:51
*/
int getTowerIsExist(GxPlanVo vo);
} }

View File

@ -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.GxPlanProgressVo;
import com.securitycontrol.entity.system.base.vo.GxPlanVo; import com.securitycontrol.entity.system.base.vo.GxPlanVo;
import com.securitycontrol.entity.system.base.vo.ProScheduleVo; import com.securitycontrol.entity.system.base.vo.ProScheduleVo;
import org.apache.ibatis.annotations.MapKey;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @authorcwchen * @authorcwchen
@ -104,6 +106,7 @@ public interface IProScheduleMapper {
/** /**
* 获取当前工序计划的填报进度 * 获取当前工序计划的填报进度
*
* @param vo * @param vo
* @return String * @return String
* @description * @description
@ -111,4 +114,25 @@ public interface IProScheduleMapper {
* @date 2024/3/28 14:10 * @date 2024/3/28 14:10
*/ */
String getGxPlanProgress(GxPlanProgressVo vo); String getGxPlanProgress(GxPlanProgressVo vo);
/**
* 查询该工序计划所有填报信息
*
* @param vo
* @return List<Map < Object>>
* @description
* @author cwchen
* @date 2024/3/30 12:39
*/
@MapKey("planId")
List<Map<String, Object>> getProgressData(GxPlanProgressVo vo);
/**
* 更新工序计划进度
* @param vo
* @description
* @author cwchen
* @date 2024/3/30 13:05
*/
void updateGxPlan(GxPlanProgressVo vo);
} }

View File

@ -14,15 +14,17 @@ import com.securitycontrol.entity.system.base.vo.ProScheduleVo;
import com.securitycontrol.system.base.mapper.IProScheduleMapper; import com.securitycontrol.system.base.mapper.IProScheduleMapper;
import com.securitycontrol.system.base.service.IProScheduleService; import com.securitycontrol.system.base.service.IProScheduleService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.UUID;
/** /**
* @authorcwchen * @authorcwchen
@ -92,48 +94,21 @@ public class ProScheduleServiceImpl implements IProScheduleService {
if (StringUtils.isNotBlank(validResult)) { if (StringUtils.isNotBlank(validResult)) {
return AjaxResult.error(validResult); return AjaxResult.error(validResult);
} }
int result = mapper.isFirstFillingGxProgress(vo); // 验证工序计划进度数据
if (result == 0) { AjaxResult ajaxResult = validateData(vo);
// 更新 工序计划开始时间 if (ajaxResult != null) {
vo.setStartTime(DateTimeHelper.getNowDate()); return ajaxResult;
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);
} }
// 工序计划进度赋值
vo = setGxPlanProgressData(vo);
// 填报工序计划 // 填报工序计划
vo.setCreateTime(DateTimeHelper.getNowTime()); vo.setCreateTime(DateTimeHelper.getNowTime());
String progressId = IdUtils.getUUId(); String progressId = IdUtils.getUUId();
vo.setProgressId(progressId); vo.setProgressId(progressId);
mapper.addGxPlanProgress(vo); mapper.addGxPlanProgress(vo);
// 工程为线路时 更新杆塔当前工序 // 查询该工序计划所有填报信息
if (Objects.equals(Constant.XL, vo.getProType())) { List<Map<String, Object>> progressList = mapper.getProgressData(vo);
mapper.updateGtData(vo); statisticsProgress(progressList,vo);
}
} catch (Exception e) { } catch (Exception e) {
log.error("填报工序计划进度列表", e); log.error("填报工序计划进度列表", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@ -141,4 +116,99 @@ public class ProScheduleServiceImpl implements IProScheduleService {
} }
return AjaxResult.success(); 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<Map<String, Object>> progressList, GxPlanProgressVo vo) {
if (CollectionUtils.isNotEmpty(progressList)) {
BigDecimal value = new BigDecimal("0");
BigDecimal gxNum = new BigDecimal("3");
for (Map<String, Object> 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);
}
}
} }

View File

@ -548,6 +548,10 @@ public class ProServiceImpl implements IProService {
if (StringUtils.isNotBlank(validResult)) { if (StringUtils.isNotBlank(validResult)) {
return AjaxResult.error(validResult); return AjaxResult.error(validResult);
} }
int result = mapper.getTowerIsExist(vo);
if(result > 0){
return AjaxResult.error("杆塔或工序不能重复选择");
}
List<Map<String, String>> weightList = mapper.getGxWeight(vo.getBidCode()); List<Map<String, String>> weightList = mapper.getGxWeight(vo.getBidCode());
if (CollectionUtils.isNotEmpty(weightList)) { if (CollectionUtils.isNotEmpty(weightList)) {
Boolean isFlag = isExceedData(weightList, vo.getPlanId(), vo.getGxWeight()); Boolean isFlag = isExceedData(weightList, vo.getPlanId(), vo.getGxWeight());

View File

@ -261,7 +261,8 @@
<if test="proType == '线路'"> <if test="proType == '线路'">
tpg.gt_name AS gxName, tpg.gt_name AS gxName,
</if> </if>
tgp.gx_id AS gxId tgp.gx_id AS gxId,
tgp.plan_progress AS planProgress
FROM tb_gx_plan tgp FROM tb_gx_plan tgp
<if test="proType == '变电'"> <if test="proType == '变电'">
LEFT JOIN sys_dict sd ON sd.dict_code = tgp.gx_id 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 WHERE sd.dict_code = 1200 AND sd.del_flag = 0
ORDER BY sd2.dict_sort ORDER BY sd2.dict_sort
</select> </select>
<!--添加工序计划时杆塔是否被重复添加-->
<select id="getTowerIsExist" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tb_gx_plan WHERE gx_id = #{gxId} AND del_flag = 0
</select>
</mapper> </mapper>

View File

@ -8,7 +8,7 @@
<if test="progressId != null and progressId != ''">id,</if> <if test="progressId != null and progressId != ''">id,</if>
<if test="planId != null and planId!=''">plan_id,</if> <if test="planId != null and planId!=''">plan_id,</if>
<if test="gxProgress != null and gxProgress!=''">gx_progress,</if> <if test="gxProgress != null and gxProgress!=''">gx_progress,</if>
<if test="gxId != null and gxId!=''">gx_id,</if> <if test="nowGxId != null and nowGxId!=''">gx_id,</if>
<if test="createTime != null and createTime!=''">create_time,</if> <if test="createTime != null and createTime!=''">create_time,</if>
<if test="delaReason != null and delaReason!=''">dela_reason,</if> <if test="delaReason != null and delaReason!=''">dela_reason,</if>
</trim> </trim>
@ -16,7 +16,7 @@
<if test="progressId != null and progressId != ''">#{progressId},</if> <if test="progressId != null and progressId != ''">#{progressId},</if>
<if test="planId != null and planId!=''">#{planId},</if> <if test="planId != null and planId!=''">#{planId},</if>
<if test="gxProgress != null and gxProgress!=''">#{gxProgress},</if> <if test="gxProgress != null and gxProgress!=''">#{gxProgress},</if>
<if test="gxId != null and gxId!=''">#{gxId},</if> <if test="nowGxId != null and nowGxId!=''">#{nowGxId},</if>
<if test="createTime != null and createTime!=''">#{createTime},</if> <if test="createTime != null and createTime!=''">#{createTime},</if>
<if test="delaReason != null and delaReason!=''">#{delaReason},</if> <if test="delaReason != null and delaReason!=''">#{delaReason},</if>
</trim> </trim>
@ -40,6 +40,10 @@
<update id="updateGtData"> <update id="updateGtData">
UPDATE t_pro_gt SET now_gx = #{nowGxId} WHERE gt_id = #{gxId} UPDATE t_pro_gt SET now_gx = #{nowGxId} WHERE gt_id = #{gxId}
</update> </update>
<!--更新工序计划进度-->
<update id="updateGxPlan">
UPDATE tb_gx_plan SET plan_progress = #{planProgress} WHERE plan_id = #{planId}
</update>
<!--获取工程进度列表--> <!--获取工程进度列表-->
<select id="getProScheduleLists" resultType="com.securitycontrol.entity.system.base.vo.ProScheduleVo"> <select id="getProScheduleLists" resultType="com.securitycontrol.entity.system.base.vo.ProScheduleVo">
@ -92,7 +96,8 @@
<if test="proType == '线路'"> <if test="proType == '线路'">
tpg.gt_name AS gxName, tpg.gt_name AS gxName,
</if> </if>
tgp.gx_id AS gxId tgp.gx_id AS gxId,
tgp.plan_progress AS planProgress
FROM tb_gx_plan tgp FROM tb_gx_plan tgp
<if test="proType == '变电'"> <if test="proType == '变电'">
LEFT JOIN sys_dict sd ON sd.dict_code = tgp.gx_id LEFT JOIN sys_dict sd ON sd.dict_code = tgp.gx_id
@ -100,7 +105,7 @@
<if test="proType == '线路'"> <if test="proType == '线路'">
LEFT JOIN t_pro_gt tpg ON tgp.gx_id = tpg.gt_id LEFT JOIN t_pro_gt tpg ON tgp.gx_id = tpg.gt_id
</if> </if>
WHERE tgp.bid_code = #{bidCode} WHERE tgp.bid_code = #{bidCode} AND tgp.del_flag = 0
<if test="proType == '变电' and keyWord!='' and keyWord!=null"> <if test="proType == '变电' and keyWord!='' and keyWord!=null">
AND INSTR(sd.dict_name,#{keyWord}) > 0 AND INSTR(sd.dict_name,#{keyWord}) > 0
</if> </if>
@ -116,10 +121,13 @@
<select id="getGxPlanProgressLists" <select id="getGxPlanProgressLists"
resultType="com.securitycontrol.entity.system.base.vo.GxPlanProgressVo"> resultType="com.securitycontrol.entity.system.base.vo.GxPlanProgressVo">
SELECT tpp.gx_progress AS gxProgress, SELECT tpp.gx_progress AS gxProgress,
tpp.create_time AS createTime tpp.create_time AS createTime,
sd.dict_name AS gxName
FROM tb_project_progress tpp FROM tb_project_progress tpp
LEFT JOIN tb_gx_plan tgp ON tpp.plan_id = tgp.plan_id 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} WHERE tpp.plan_id = #{planId}
ORDER BY tpp.create_time
</select> </select>
<!--工序计划是否第一次填报--> <!--工序计划是否第一次填报-->
<select id="isFirstFillingGxProgress" resultType="java.lang.Integer"> <select id="isFirstFillingGxProgress" resultType="java.lang.Integer">
@ -129,8 +137,16 @@
<select id="getGxPlanProgress" resultType="java.lang.String"> <select id="getGxPlanProgress" resultType="java.lang.String">
SELECT tpp.gx_progress AS gxProgress SELECT tpp.gx_progress AS gxProgress
FROM tb_project_progress tpp FROM tb_project_progress tpp
WHERE plan_id = #{planId} WHERE plan_id = #{planId} AND gx_id = #{nowGxId}
ORDER BY create_time DESC ORDER BY create_time DESC
LIMIT 1 LIMIT 1
</select> </select>
<!--查询该工序计划所有填报信息-->
<select id="getProgressData" resultType="java.util.Map">
SELECT tpp.plan_id AS planId,
tpp.gx_progress AS gxProgress
FROM tb_project_progress tpp
INNER JOIN (SELECT MAX( create_time ) AS create_time FROM tb_project_progress WHERE plan_id = #{planId} GROUP BY gx_id) tpp2 ON tpp.create_time = tpp2.create_time
WHERE plan_id = #{planId}
</select>
</mapper> </mapper>