pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrAssemblyPlan.java
@@ -78,6 +78,8 @@ public String proName; @TableField(exist = false) public String batchNo; @TableField(exist = false) public String processName; /** * 创建时间 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrDevOpsPlan.java
@@ -2,6 +2,7 @@ import com.alibaba.fastjson2.annotation.JSONField; import com.alibaba.fastjson2.writer.ObjectWriterImplToString; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.dy.common.po.BaseEntity; @@ -32,10 +33,10 @@ */ public String name; /** * 点位数量 */ public Integer num; // /** // * 点位数量 // */ // public Integer num; /** * 状态:正常(1)、暂停(0)、结束(-1) @@ -46,7 +47,11 @@ * 创建人 */ @JSONField(serializeUsing= ObjectWriterImplToString.class) public String creator; public Long creator; @TableField(exist = false) public String creatorName; // @TableField(exist = false) // public String proName; /** * 创建时间 pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
@@ -24,6 +24,8 @@ select="com.dy.pmsGlobal.daoBa.BaUserMapper.selectNameByUserId" fetchType="eager" /> <association property="batchNo" column="batch_id" javaType="java.lang.Long" select="com.dy.pmsGlobal.daoPr.PrBatchNumberMapper.selectBatchNoById" fetchType="eager" /> <association property="processName" column="process_id" javaType="java.lang.Long" select="com.dy.pmsGlobal.daoPr.PrProductionProcessMapper.selectProcessNameById" fetchType="eager" /> </resultMap> <sql id="Base_Column_List"> pms-parent/pms-global/src/main/resources/mapper/PrDevOpsPlanMapper.xml
@@ -5,20 +5,22 @@ <mapper namespace="com.dy.pmsGlobal.daoPr.PrDevOpsPlanMapper"> <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPr.PrDevOpsPlan"> <id property="id" column="id" jdbcType="BIGINT"/> <result property="name" column="name" jdbcType="VARCHAR"/> <result property="num" column="num" jdbcType="INTEGER"/> <result property="status" column="status" jdbcType="TINYINT"/> <result property="creator" column="creator" jdbcType="VARCHAR"/> <result property="dt" column="dt" jdbcType="TIMESTAMP"/> <result property="startDate" column="start_date" jdbcType="VARCHAR"/> <result property="endDate" column="end_date" jdbcType="VARCHAR"/> <result property="deleted" column="deleted" jdbcType="TINYINT"/> <result property="content" column="content" jdbcType="VARCHAR"/> <id property="id" column="id" jdbcType="BIGINT"/> <result property="name" column="name" jdbcType="VARCHAR"/> <!-- <result property="num" column="num" jdbcType="INTEGER"/>--> <result property="status" column="status" jdbcType="TINYINT"/> <result property="creator" column="creator" jdbcType="VARCHAR"/> <result property="dt" column="dt" jdbcType="TIMESTAMP"/> <result property="startDate" column="start_date" jdbcType="VARCHAR"/> <result property="endDate" column="end_date" jdbcType="VARCHAR"/> <result property="deleted" column="deleted" jdbcType="TINYINT"/> <result property="content" column="content" jdbcType="VARCHAR"/> <association property="creatorName" column="creator" javaType="java.lang.Long" select="com.dy.pmsGlobal.daoBa.BaUserMapper.selectNameByUserId" fetchType="eager" /> </resultMap> <sql id="Base_Column_List"> id,name,num, id,name, status,creator,dt, start_date,end_date,deleted, content @@ -37,11 +39,10 @@ </delete> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPr.PrDevOpsPlan" useGeneratedKeys="true"> insert into pr_dev_ops_plan ( id,name,num ,status,creator,dt ( id,name,status,creator,dt ,start_date,end_date,deleted ,content) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{num,jdbcType=INTEGER} values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR} ,#{status,jdbcType=TINYINT},#{creator,jdbcType=VARCHAR},#{dt,jdbcType=TIMESTAMP} ,#{startDate,jdbcType=VARCHAR},#{endDate,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT} ,#{content,jdbcType=VARCHAR}) @@ -51,7 +52,6 @@ <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">id,</if> <if test="name != null">name,</if> <if test="num != null">num,</if> <if test="status != null">status,</if> <if test="creator != null">creator,</if> <if test="dt != null">dt,</if> @@ -63,7 +63,6 @@ <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id,jdbcType=BIGINT},</if> <if test="name != null">#{name,jdbcType=VARCHAR},</if> <if test="num != null">#{num,jdbcType=INTEGER},</if> <if test="status != null">#{status,jdbcType=TINYINT},</if> <if test="creator != null">#{creator,jdbcType=VARCHAR},</if> <if test="dt != null">#{dt,jdbcType=TIMESTAMP},</if> @@ -78,9 +77,6 @@ <set> <if test="name != null"> name = #{name,jdbcType=VARCHAR}, </if> <if test="num != null"> num = #{num,jdbcType=INTEGER}, </if> <if test="status != null"> status = #{status,jdbcType=TINYINT}, @@ -110,7 +106,6 @@ update pr_dev_ops_plan set name = #{name,jdbcType=VARCHAR}, num = #{num,jdbcType=INTEGER}, status = #{status,jdbcType=TINYINT}, creator = #{creator,jdbcType=VARCHAR}, dt = #{dt,jdbcType=TIMESTAMP}, @@ -126,36 +121,18 @@ <include refid="Base_Column_List" /> from pr_dev_ops_plan <trim prefix="where" suffixOverrides="and"> <if test="id != null"> id = #{id,jdbcType=BIGINT} and </if> <if test="name != null"> name = #{name,jdbcType=VARCHAR} and </if> <if test="num != null"> num = #{num,jdbcType=INTEGER} and </if> <if test="status != null"> status = #{status,jdbcType=TINYINT} and </if> <if test="creator != null"> creator = #{creator,jdbcType=VARCHAR} and </if> <if test="dt != null"> dt = #{dt,jdbcType=TIMESTAMP} and </if> <if test="startDate != null"> start_date = #{startDate,jdbcType=VARCHAR} and </if> <if test="endDate != null"> end_date = #{endDate,jdbcType=VARCHAR} and </if> <if test="deleted != null"> deleted = #{deleted,jdbcType=TINYINT} and </if> <if test="content != null"> content = #{content,jdbcType=VARCHAR} and </if> <if test="name != null"> name = #{name,jdbcType=VARCHAR} and </if> <if test="status != null"> status = #{status,jdbcType=TINYINT} and </if> <if test="startDate != null and startDate != '' "> start_date = #{startDate,jdbcType=VARCHAR} and </if> <if test="endDate != null and endDate != '' "> end_date = #{endDate,jdbcType=VARCHAR} and </if> </trim> order by id desc <trim prefix="limit " > @@ -169,36 +146,18 @@ select count(1) from pr_dev_ops_plan <trim prefix="where" suffixOverrides="and"> <if test="id != null"> id = #{id,jdbcType=BIGINT} and </if> <if test="name != null"> name = #{name,jdbcType=VARCHAR} and </if> <if test="num != null"> num = #{num,jdbcType=INTEGER} and </if> <if test="status != null"> status = #{status,jdbcType=TINYINT} and </if> <if test="creator != null"> creator = #{creator,jdbcType=VARCHAR} and </if> <if test="dt != null"> dt = #{dt,jdbcType=TIMESTAMP} and </if> <if test="startDate != null"> start_date = #{startDate,jdbcType=VARCHAR} and </if> <if test="endDate != null"> end_date = #{endDate,jdbcType=VARCHAR} and </if> <if test="deleted != null"> deleted = #{deleted,jdbcType=TINYINT} and </if> <if test="content != null"> content = #{content,jdbcType=VARCHAR} and </if> <if test="name != null"> name = #{name,jdbcType=VARCHAR} and </if> <if test="status != null"> status = #{status,jdbcType=TINYINT} and </if> <if test="startDate != null and startDate != '' "> start_date = #{startDate,jdbcType=VARCHAR} and </if> <if test="endDate != null and endDate != '' "> end_date = #{endDate,jdbcType=VARCHAR} and </if> </trim> </select> pms-parent/pms-global/src/main/resources/mapper/PrProductionProcessMapper.xml
@@ -28,7 +28,11 @@ </sql> <select id="selectProcessNameById" resultType="java.lang.String"> select name from pr_production_process where id = #{id,jdbcType=BIGINT} </select> <select id="selectByProcess" resultMap="com.dy.pmsGlobal.daoPr.PrProductionNodeMapper.BaseResultMap"> select * from pr_production_node pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanCtrl.java
@@ -86,6 +86,23 @@ } } @PostMapping(path="updateStatus") @SsoPowerAop(power = "-1") @Log("更新任务计划状态") public BaseResponse<Boolean> updateStatus(@RequestBody PrAssemblyPlan plan){ int count; try { count = sv.updateStatus(plan); }catch (Exception e){ log.error("更新组装任务计划异常", e); return BaseResponseUtils.buildException(e.getMessage()); } if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 根据ID查询 * @return pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java
@@ -85,6 +85,7 @@ return assemblyDao.insertSelective(plan); } @Transactional public int update(PrAssemblyPlan plan){ PrAssemblyPlan origPlan = assemblyDao.selectByPrimaryKey(plan.id); PrBatchNumber batch = batchDao.selectByPrimaryKey(origPlan.batchId); @@ -100,7 +101,7 @@ } @Transactional public int addEquip(Long planId,int num){ PrAssemblyPlan plan = assemblyDao.selectByPrimaryKey(planId); PrBatchNumber batch = batchDao.selectByPrimaryKey(plan.batchId); @@ -134,7 +135,7 @@ return insertBatchEquip(list); } public int insertBatchEquip(List<PrEquip> list) { private int insertBatchEquip(List<PrEquip> list) { int count = 0; for (int i = 0; i < list.size(); i += BATCH_SIZE) { List<PrEquip> subList = list.subList(i, Math.min(i + BATCH_SIZE, list.size())); @@ -224,4 +225,17 @@ public List<PrEquip> selectEquipByBatchId(Long batchId) { return equipDao.selectByBatchId(batchId); } /** * 只更新状态,不更新其他字段 * @param plan * @return */ @Transactional public int updateStatus(PrAssemblyPlan plan) { PrAssemblyPlan param = new PrAssemblyPlan(); param.id =plan.id; param.status = plan.status; return assemblyDao.updateByPrimaryKeySelective(plan); } } pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/DevOpsPlanCtrl.java
@@ -1,8 +1,19 @@ package com.dy.pmsProduct.taskPlan; import com.dy.common.aop.SsoPowerAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.aop.Log; import com.dy.pmsGlobal.pojoPr.PrDevOpsPlan; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Objects; /** * 安装运维任务计划 @@ -11,4 +22,94 @@ @RestController @RequestMapping(path="devOps") public class DevOpsPlanCtrl { private DevOpsSv sv; @Autowired public void setSv(DevOpsSv sv) { this.sv = sv; } @PostMapping(path="save") @SsoPowerAop(power = "-1") @Log("保存组装任务计划") public BaseResponse<Boolean> save(@RequestBody @Valid PrDevOpsPlan plan, BindingResult bindingResult){ if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } int count; try { count = sv.save(plan); }catch (Exception e){ log.error("保存组装任务计划异常", e); return BaseResponseUtils.buildException(e.getMessage()); } if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 更新 * @param plan * @param bindingResult * @return */ @PostMapping(path="update") @SsoPowerAop(power = "-1") @Log("更新组装任务计划") public BaseResponse<Boolean> update(@RequestBody @Valid PrDevOpsPlan plan, BindingResult bindingResult){ int count; try { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } count = sv.update(plan); }catch (Exception e){ log.error("更新组装任务计划异常", e); return BaseResponseUtils.buildException(e.getMessage()); } if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 根据ID查询 * @return */ @GetMapping(path="one") @SsoPowerAop(power = "-1") @Log("根据ID查询组装任务计划") public BaseResponse<PrDevOpsPlan> one(Long id){ try{ PrDevOpsPlan plan=sv.selectById(id); return BaseResponseUtils.buildSuccess(plan); }catch (Exception e){ log.error("根据ID查询组装任务计划异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } /** * 分页查询 * @param vo * @return */ @PostMapping(path="some") @SsoPowerAop(power = "-1") @Log("分页查询组装任务计划") public BaseResponse<QueryResultVo<List<PrDevOpsPlan>>> some(@RequestBody QueryVo vo){ try { QueryResultVo<List<PrDevOpsPlan>> list = sv.selectSome(vo) ; return BaseResponseUtils.buildSuccess(list); }catch (Exception e){ log.error("分页查询组装任务计划异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } } pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/DevOpsSv.java
New file @@ -0,0 +1,60 @@ package com.dy.pmsProduct.taskPlan; import com.dy.common.webFilter.UserTokenContext; import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.daoPr.PrDevOpsPlanMapper; import com.dy.pmsGlobal.pojoBa.BaUser; import com.dy.pmsGlobal.pojoPr.PrDevOpsPlan; import com.dy.pmsGlobal.util.UserUtil; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Map; @Slf4j @Service public class DevOpsSv { private PrDevOpsPlanMapper devOpsDao; private UserUtil userUtil; @Autowired public void setDevOpsDao(PrDevOpsPlanMapper devOpsDao) { this.devOpsDao = devOpsDao; } @Autowired public void setUserUtil(UserUtil userUtil) { this.userUtil = userUtil; } public PrDevOpsPlan selectById(Long id) { return devOpsDao.selectByPrimaryKey(id); } @Transactional public int save(PrDevOpsPlan plan) { BaUser loginUser = userUtil.getUser(UserTokenContext.get()); if(loginUser!=null){ plan.creator = loginUser.id; } plan.deleted = false; return devOpsDao.insertSelective(plan); } @Transactional public int update(PrDevOpsPlan plan) { return devOpsDao.updateByPrimaryKeySelective(plan); } public QueryResultVo<List<PrDevOpsPlan>> selectSome(QueryVo queryVo) { Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); //查询符合条件的记录总数 Long itemTotal = devOpsDao.selectSomeCount(params); QueryResultVo<List<PrDevOpsPlan>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ; //计算分页等信息 rsVo.calculateAndSet(itemTotal, params); //查询符合条件的记录 rsVo.obj = devOpsDao.selectSome(params); return rsVo ; } }