Merge remote-tracking branch 'origin/master'

This commit is contained in:
haozq 2024-09-12 14:36:51 +08:00
commit e950fa859d
6 changed files with 551 additions and 0 deletions

View File

@ -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;
/**
* @authorcwchen
* @date2024-03-13-15:45
* @version1.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 {
}
}

View File

@ -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;
/**
* @authorhongchao
* @version1.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<ProgressCorrectionVo> 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);
}
}

View File

@ -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<ProgressCorrectionVo> getProgressCorrection(ProgressCorrectionVo dto);
/**
* 工序计划详情
*
* @param dto
* @return GxPlanVo
*/
ProgressCorrectionVo getGxPlanById(ProgressCorrectionVo dto);
/**
* 添加工序计划时杆塔是否被重复添加
* @param vo
* @return int
* @description
*/
int getTowerIsExist(ProgressCorrectionVo vo);
/**
* 获取工序计划作业权重占比
*
* @param bidCode
* @return List<Map < String, String>>
* @description
*/
@MapKey("planId")
List<Map<String, String>> getGxWeight(String bidCode);
/**
* 新增/修改 工序计划
*
* @param vo
* @description
*/
void addOrUpdateGxPlan(ProgressCorrectionVo vo);
}

View File

@ -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;
/**
* @authorhongchao
* @version1.0
* @description进度纠偏管理-web层
*/
public interface IProgressCorrectionService {
List<ProgressCorrectionVo> getProgressCorrection(ProgressCorrectionVo dto);
/**
* 工序计划详情
*
* @param dto
* @return AjaxResult
*/
AjaxResult getGxPlanById(ProgressCorrectionVo dto);
/**
* 修改 工序计划
*
* @param vo
* @return AjaxResult
*/
AjaxResult addOrUpdateGxPlan(ProgressCorrectionVo vo);
}

View File

@ -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<ProgressCorrectionVo> getProgressCorrection(ProgressCorrectionVo dto) {
List<ProgressCorrectionVo> 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<Map<String, String>> 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<Map<String, String>> weightList, String planId, String gxWeightData) {
BigDecimal data = BigDecimal.valueOf(0);
for (Map<String, String> 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;
}
}
}

View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.securitycontrol.background.mapper.IProgressCorrectionMapper">
<!--获取工程列表-->
<select id="getProgressCorrection" resultType="com.securitycontrol.entity.background.vo.ProgressCorrectionVo">
select
tgp.plan_id AS planId,
tgp.gx_weight AS gxWeight,
tgp.plan_start_time AS planStartTime,
tgp.plan_end_time AS planEndTime,
tgp.start_time AS startTime,
tgp.end_time AS endTime,
tgp.dela_reason AS delaReason,
tgp.bid_code AS bidCode,
tgp.gx_id AS gxId,
tgp.plan_progress AS planProgress,
tp.pro_name as proName,
tp.pro_type as proType,
sd.dict_name AS gxName
from tb_gx_plan tgp
left join tb_project tp on tp.bid_code = tgp.bid_code and tp.del_flag = 0
left join sys_dict sd on sd.dict_code = tgp.gx_id
where tgp.del_flag = 0 and tp.pro_type='变电'
<if test="keyWord !=null and keyWord!=''">
AND (INSTR(sd.dict_name,#{keyWord}) > 0 OR
INSTR(tp.pro_name,#{keyWord}) > 0)
</if>
UNION ALL
select
tgp.plan_id AS planId,
tgp.gx_weight AS gxWeight,
tgp.plan_start_time AS planStartTime,
tgp.plan_end_time AS planEndTime,
tgp.start_time AS startTime,
tgp.end_time AS endTime,
tgp.dela_reason AS delaReason,
tgp.bid_code AS bidCode,
tgp.gx_id AS gxId,
tgp.plan_progress AS planProgress,
tp.pro_name as proName,
tp.pro_type as proType,
tpg.gt_name AS gxName
from tb_gx_plan tgp
left join tb_project tp on tp.bid_code = tgp.bid_code and tp.del_flag = 0
left join t_pro_gt tpg on tgp.gx_id = tpg.gt_id
where tgp.del_flag = 0 and tp.pro_type='线路' and tpg.del_flag = 0
<if test="keyWord !=null and keyWord!=''">
AND (INSTR(tpg.gt_name,#{keyWord}) > 0 OR
INSTR(tp.pro_name,#{keyWord}) > 0)
</if>
</select>
<!--工序计划详情-->
<select id="getGxPlanById" resultType="com.securitycontrol.entity.background.vo.ProgressCorrectionVo">
SELECT tgp.plan_id AS planId,
gx_weight AS gxWeight,
tgp.plan_start_time AS planStartTime,
tgp.plan_end_time AS planEndTime,
tgp.start_time AS startTime,
tgp.end_time AS endTime,
tgp.dela_reason AS delaReason,
tgp.bid_code AS bidCode,
tgp.gx_id AS gxId,
tp.pro_type as proType
FROM tb_gx_plan tgp
left join tb_project tp on tp.bid_code = tgp.bid_code and tp.del_flag = 0
WHERE tgp.bid_code = #{bidCode} AND tgp.plan_id =#{planId}
</select>
<!--添加工序计划时杆塔是否被重复添加-->
<select id="getTowerIsExist" resultType="java.lang.Integer">
<if test="planId == null or planId == ''">
SELECT COUNT(*) FROM tb_gx_plan WHERE gx_id = #{gxId} AND bid_code = #{bidCode} AND del_flag = 0
</if>
<if test="planId != null and planId != ''">
SELECT COUNT(*) FROM tb_gx_plan WHERE gx_id = #{gxId} AND bid_code = #{bidCode} AND plan_id != #{planId} AND del_flag = 0
</if>
</select>
<!--获取工序计划作业权重占比-->
<select id="getGxWeight" resultType="java.util.Map">
SELECT plan_id AS planId,
gx_weight AS gxWeight
FROM tb_gx_plan
WHERE bid_code = #{bidCode}
</select>
<!--新增/修改 工序计划-->
<insert id="addOrUpdateGxPlan">
<if test="type == 1">
INSERT INTO tb_gx_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="planId != null and planId != ''">plan_id,</if>
<if test="bidCode != null and bidCode!=''">bid_code,</if>
<if test="gxId != null and gxId!=''">gx_id,</if>
<if test="gxWeight != null and gxWeight!=''">gx_weight,</if>
<if test="planStartTime != null and planStartTime!=''">plan_start_time,</if>
<if test="planEndTime != null and planEndTime!=''">plan_end_time,</if>
<if test="startTime != null and startTime!=''">start_time,</if>
<if test="endTime != null and endTime!=''">end_time,</if>
<if test="delaReason != null and delaReason!=''">dela_reason,</if>
del_flag,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="planId != null and planId != ''">#{planId},</if>
<if test="bidCode != null and bidCode!=''">#{bidCode},</if>
<if test="gxId != null and gxId!=''">#{gxId},</if>
<if test="gxWeight != null and gxWeight!=''">#{gxWeight},</if>
<if test="planStartTime != null and planStartTime != ''">#{planStartTime},</if>
<if test="planEndTime != null and planEndTime!=''">#{planEndTime},</if>
<if test="startTime != null and startTime!=''">#{startTime},</if>
<if test="endTime != null and endTime!=''">#{endTime},</if>
<if test="delaReason != null and delaReason!=''">#{delaReason},</if>
0,
</trim>
</if>
<if test="type == 2">
UPDATE tb_gx_plan
<set>
<if test="gxId != null and gxId != ''">gx_id = #{gxId},</if>
<if test="gxWeight != null and gxWeight != ''">gx_weight = #{gxWeight},</if>
<if test="planStartTime != null and planStartTime != ''">plan_start_time = #{planStartTime},</if>
<if test="planEndTime != null and planEndTime != ''">plan_end_time = #{planEndTime},</if>
<if test="startTime != null and startTime != ''">start_time = #{startTime},</if>
<if test="endTime != null and endTime != ''">end_time = #{endTime},</if>
<if test="delaReason != null and delaReason != ''">dela_reason = #{delaReason},</if>
</set>
WHERE plan_id = #{planId}
</if>
</insert>
</mapper>