diff --git a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/ProgressCorrectionVo.java b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/ProgressCorrectionVo.java new file mode 100644 index 0000000..a370335 --- /dev/null +++ b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/ProgressCorrectionVo.java @@ -0,0 +1,86 @@ +package com.securitycontrol.entity.background.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; + +/** + * @author:cwchen + * @date:2024-03-13-15:45 + * @version:1.0 + * @description:工序计划表-vo + */ +@Data +public class ProgressCorrectionVo { + + @ApiModelProperty(value = "计划ID") + private String planId; + + @ApiModelProperty(value = "工程名称") + private String proName; + + @ApiModelProperty(value = "工程类型") + private String proType; + + @ApiModelProperty(value = "标段工程编码") + @Length(max = 50, message = "标段工程编码字符长度不能超过50", groups = {Query.class}) + private String bidCode; + + @ApiModelProperty(value = "工序id/杆塔ID") + @NotBlank(message = "工序ID或杆塔ID不能为空", groups = {Query.class}) + @Length(max = 100, message = "工序ID或杆塔ID字符长度不能超过50", groups = {Query.class}) + private String gxId; + + @ApiModelProperty(value = "工序名称/杆塔名称") + private String gxName; + + @ApiModelProperty(value = "工序作业权重") + @NotBlank(message = "工序作业权重不能为空", groups = {Query.class}) + @Length(max = 100, message = "工序作业权重字符长度不能超过30", groups = {Query.class}) + @Pattern(regexp = "(?:0|[1-9][0-9]?|100)(\\.[0-9]{0,2})?",message = "工序作业权重为0-100",groups = {Query.class}) + private String gxWeight; + + @ApiModelProperty(value = "计划开始时间") + @NotBlank(message = "计划开始时间不能为空", groups = {Query.class}) + private String planStartTime; + + @ApiModelProperty(value = "计划结束时间") + @NotBlank(message = "计划结束时间不能为空", groups = {Query.class}) + private String planEndTime; + + @ApiModelProperty(value = "实际开始时间") + private String startTime; + + @ApiModelProperty(value = "实际结束时间") + private String endTime; + + @ApiModelProperty(value = "延期原因") + private String delaReason; + + @ApiModelProperty(value = "删除状态") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private Integer delFlag; + + @ApiModelProperty(value = "工序计划进度") + private String planProgress; + + @ApiModelProperty(value = "1. 新增 2.修改") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private Integer type; + + /** + * 关键词 + */ + @ApiModelProperty(value = "关键字") + private String keyWord; + + /** + * 查询条件限制 + */ + public interface Query { + } +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/ProgressCorrectionController.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/ProgressCorrectionController.java new file mode 100644 index 0000000..b01c5f5 --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/ProgressCorrectionController.java @@ -0,0 +1,57 @@ +package com.securitycontrol.background.controller; + +import com.securitycontrol.background.service.IProService; +import com.securitycontrol.background.service.IProgressCorrectionService; +import com.securitycontrol.common.core.web.controller.BaseController; +import com.securitycontrol.common.core.web.domain.AjaxResult; +import com.securitycontrol.common.core.web.page.TableDataInfo; +import com.securitycontrol.common.log.annotation.Log; +import com.securitycontrol.common.log.enums.OperationType; +import com.securitycontrol.entity.background.vo.ProgressCorrectionVo; +import com.securitycontrol.entity.system.base.dto.GxPlanDto; +import com.securitycontrol.entity.system.base.dto.ProDto; +import com.securitycontrol.entity.system.base.vo.GxPlanVo; +import com.securitycontrol.entity.system.base.vo.ProVo; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * @author:hongchao + * @version:1.0 + * @description:进度纠偏管理-web层 + */ +@RestController +@RequestMapping("/base/progressCorrection/") +public class ProgressCorrectionController extends BaseController { + + @Resource + private IProgressCorrectionService service; + + @ApiOperation(value = "获取工序列表") + @GetMapping("getProgressCorrection") + @Log(title = "基础管理", menu = "基础管理->进度纠偏管理", grade = OperationType.QUERY_BUSINESS, details = "查询工序", type = "业务日志") + public TableDataInfo getProgressCorrection(ProgressCorrectionVo dto) { + startPage(); + List list = service.getProgressCorrection(dto); + return getDataTable(list); + } + + @ApiOperation(value = "工序计划详情") + @GetMapping("getGxPlanById") + public AjaxResult getGxPlanById(ProgressCorrectionVo dto) { + return service.getGxPlanById(dto); + } + + @ApiOperation(value = "修改工序计划") + @PostMapping("editGxPlan") + @Log(title = "基础管理", menu = "基础管理->工程管理", grade = OperationType.UPDATE_BUSINESS, details = "修改工序计划", type = "业务日志") + public AjaxResult editGxPlan(@RequestBody ProgressCorrectionVo vo) { + return service.addOrUpdateGxPlan(vo); + } +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/IProgressCorrectionMapper.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/IProgressCorrectionMapper.java new file mode 100644 index 0000000..304c9fb --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/IProgressCorrectionMapper.java @@ -0,0 +1,60 @@ +package com.securitycontrol.background.mapper; + +import com.securitycontrol.entity.background.vo.ProgressCorrectionVo; +import com.securitycontrol.entity.system.base.dto.GxPlanDto; +import com.securitycontrol.entity.system.base.dto.ProDto; +import com.securitycontrol.entity.system.base.dto.ProGxPlanDto; +import com.securitycontrol.entity.system.base.vo.GxPlanVo; +import com.securitycontrol.entity.system.base.vo.ProVo; +import com.securitycontrol.entity.system.vo.ResourceFileVo; +import org.apache.ibatis.annotations.MapKey; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + + +@Repository(value = "IProgressCorrectionMapper") +public interface IProgressCorrectionMapper { + + /** + * 获取工序列表 + * @param dto + * @return + */ + List getProgressCorrection(ProgressCorrectionVo dto); + + /** + * 工序计划详情 + * + * @param dto + * @return GxPlanVo + */ + ProgressCorrectionVo getGxPlanById(ProgressCorrectionVo dto); + + /** + * 添加工序计划时杆塔是否被重复添加 + * @param vo + * @return int + * @description + */ + int getTowerIsExist(ProgressCorrectionVo vo); + + /** + * 获取工序计划作业权重占比 + * + * @param bidCode + * @return List> + * @description + */ + @MapKey("planId") + List> getGxWeight(String bidCode); + + /** + * 新增/修改 工序计划 + * + * @param vo + * @description + */ + void addOrUpdateGxPlan(ProgressCorrectionVo vo); +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/IProgressCorrectionService.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/IProgressCorrectionService.java new file mode 100644 index 0000000..b42d9a1 --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/IProgressCorrectionService.java @@ -0,0 +1,43 @@ +package com.securitycontrol.background.service; + +import com.securitycontrol.common.core.web.domain.AjaxResult; +import com.securitycontrol.entity.background.vo.ProgressCorrectionVo; +import com.securitycontrol.entity.system.base.dto.GxPlanDto; +import com.securitycontrol.entity.system.base.dto.ProDto; +import com.securitycontrol.entity.system.base.dto.ProGxPlanDto; +import com.securitycontrol.entity.system.base.vo.GxPlanVo; +import com.securitycontrol.entity.system.base.vo.ProVo; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * @author:hongchao + * @version:1.0 + * @description:进度纠偏管理-web层 + */ +public interface IProgressCorrectionService { + + + List getProgressCorrection(ProgressCorrectionVo dto); + + /** + * 工序计划详情 + * + * @param dto + * @return AjaxResult + */ + AjaxResult getGxPlanById(ProgressCorrectionVo dto); + + /** + * 修改 工序计划 + * + * @param vo + * @return AjaxResult + + */ + AjaxResult addOrUpdateGxPlan(ProgressCorrectionVo vo); + +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/ProgressCorrectionServiceImpl.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/ProgressCorrectionServiceImpl.java new file mode 100644 index 0000000..491e2e3 --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/ProgressCorrectionServiceImpl.java @@ -0,0 +1,173 @@ +package com.securitycontrol.background.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.securitycontrol.background.mapper.IProMapper; +import com.securitycontrol.background.mapper.IProgressCorrectionMapper; +import com.securitycontrol.background.service.IProService; +import com.securitycontrol.background.service.IProgressCorrectionService; +import com.securitycontrol.common.core.constant.Constant; +import com.securitycontrol.common.core.constant.HttpStatus; +import com.securitycontrol.common.core.constant.SecurityConstants; +import com.securitycontrol.common.core.domain.Result; +import com.securitycontrol.common.core.utils.ImportExcelUtils; +import com.securitycontrol.common.core.utils.StringUtils; +import com.securitycontrol.common.core.utils.UploadCheckUtils; +import com.securitycontrol.common.core.utils.aes.DateTimeHelper; +import com.securitycontrol.common.core.web.domain.AjaxResult; +import com.securitycontrol.common.security.utils.ValidatorsUtils; +import com.securitycontrol.entity.background.vo.ProgressCorrectionVo; +import com.securitycontrol.entity.system.base.dto.GxPlanDto; +import com.securitycontrol.entity.system.base.dto.ProDto; +import com.securitycontrol.entity.system.base.dto.ProGxPlanDto; +import com.securitycontrol.entity.system.base.vo.GxPlanVo; +import com.securitycontrol.entity.system.base.vo.ProImportVo; +import com.securitycontrol.entity.system.base.vo.ProVo; +import com.securitycontrol.entity.system.vo.ResourceFileVo; +import com.securitycontrol.system.api.RemoteFileService; +import com.securitycontrol.system.api.domain.SysFile; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.*; + +import static com.securitycontrol.common.core.utils.uuid.IdUtils.getuid; + +@Service(value = "IProgressCorrectionService") +@Slf4j +public class ProgressCorrectionServiceImpl implements IProgressCorrectionService { + + @Resource(name = "IProgressCorrectionMapper") + private IProgressCorrectionMapper mapper; + + @Resource(name = "ValidatorsUtils") + private ValidatorsUtils validatorsUtils; + + + @Override + public List getProgressCorrection(ProgressCorrectionVo dto) { + List list = new ArrayList<>(); + try { + list = mapper.getProgressCorrection(dto); + } catch (Exception e) { + log.error("获取工序列表",e); + } + return list; + } + + @Override + public AjaxResult getGxPlanById(ProgressCorrectionVo dto) { + ProgressCorrectionVo vo = new ProgressCorrectionVo(); + try { + vo = mapper.getGxPlanById(dto); + } catch (Exception e) { + log.error("工序计划详情",e); + } + return AjaxResult.success(vo); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public AjaxResult addOrUpdateGxPlan(ProgressCorrectionVo vo) { + try { + String validResult = validatorsUtils.valid(vo, ProgressCorrectionVo.Query.class); + if (StringUtils.isNotBlank(validResult)) { + return AjaxResult.error(validResult); + } + boolean flag = DateTimeHelper.compareTime(vo.getPlanStartTime(), vo.getPlanEndTime()); + if(!flag){ + return AjaxResult.error("计划开始时间不能晚于计划结束时间"); + } + 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()); + if (isFlag) { + return AjaxResult.error("计划作业权重超过100%"); + } + } + if (StringUtils.isEmpty(vo.getPlanId())) { + String gxPlanId = getuid(); + vo.setPlanId(gxPlanId); + vo.setType(1); + } else { + vo.setType(2); + } + mapper.addOrUpdateGxPlan(vo); + } catch (Exception e) { + log.error("工序计划", e); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return AjaxResult.error(); + } + return AjaxResult.success(); + } + + /** + * 计算计划权重占比 + * + * @param weightList + * @param planId + * @param gxWeightData + * @return Boolean + * @description + * @author cwchen + * @date 2024/3/20 9:52 + */ + public static Boolean isExceedData(List> weightList, String planId, String gxWeightData) { + BigDecimal data = BigDecimal.valueOf(0); + for (Map map : weightList) { + String gxWeight = map.get("gxWeight"); + String id = map.get("planId"); + if (isNumeric(gxWeight)) { + if (StringUtils.isEmpty(planId)) { + BigDecimal value = BigDecimal.valueOf(Double.parseDouble(gxWeight)); + data = data.add(value); + } else if (StringUtils.isNotEmpty(planId) && !Objects.equals(planId, id)) { + BigDecimal value = BigDecimal.valueOf(Double.parseDouble(gxWeight)); + data = data.add(value); + } + } + } + if (isNumeric(gxWeightData)) { + BigDecimal value = BigDecimal.valueOf(Double.parseDouble(gxWeightData)); + data = data.add(value); + } + if (data.doubleValue() > Constant.MAX_VALUE) { + return true; + } + return false; + } + + /** + * 判断字符串是否为数字 + * + * @param str + * @return boolean + * @description + * @author cwchen + * @date 2024/3/20 9:56 + */ + public static boolean isNumeric(String str) { + try { + Double.parseDouble(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/ProgressCorrectionMapper.xml b/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/ProgressCorrectionMapper.xml new file mode 100644 index 0000000..93f8742 --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/ProgressCorrectionMapper.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + INSERT INTO tb_gx_plan + + plan_id, + bid_code, + gx_id, + gx_weight, + plan_start_time, + plan_end_time, + start_time, + end_time, + dela_reason, + del_flag, + + + #{planId}, + #{bidCode}, + #{gxId}, + #{gxWeight}, + #{planStartTime}, + #{planEndTime}, + #{startTime}, + #{endTime}, + #{delaReason}, + 0, + + + + UPDATE tb_gx_plan + + gx_id = #{gxId}, + gx_weight = #{gxWeight}, + plan_start_time = #{planStartTime}, + plan_end_time = #{planEndTime}, + start_time = #{startTime}, + end_time = #{endTime}, + dela_reason = #{delaReason}, + + WHERE plan_id = #{planId} + + + \ No newline at end of file