pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java
@@ -23,4 +23,6 @@ List<PltProduct> selectAll(Map<String, Object> params); String selectMaxCode(); boolean exists(String name, Long id); } pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java
@@ -33,4 +33,5 @@ int deleteLogicById(Long id); boolean exists(String name, Long id); } pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrDevOpsPlanMapper.java
@@ -33,4 +33,5 @@ int deleteLogicById(Long id); boolean exists(String name, Long id); } pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionProcessMapper.java
@@ -31,5 +31,7 @@ int deleteLogicById(Long id); @MapKey("id") List<Map<String,String>> queryAll(); List<Map<String,String>> queryAll(Long proId); boolean exists(String name, Long id); } pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml
@@ -195,5 +195,11 @@ <select id="selectMaxCode" resultType="java.lang.String"> select max(code) from plt_product </select> <select id="exists" resultType="java.lang.Boolean"> select count(1) from plt_product where name = #{name} <if test="id != null"> and id != #{id} </if> </select> </mapper> pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
@@ -191,6 +191,14 @@ </if> </trim> </select> <select id="exists" resultType="java.lang.Boolean"> select count(1) > 0 from pr_assembly_plan where name = #{name,jdbcType=VARCHAR} <if test="id != null"> and id != #{id,jdbcType=BIGINT} </if> </select> <update id="deleteLogicById" parameterType="java.lang.Long"> update pr_assembly_plan set deleted = 1 pms-parent/pms-global/src/main/resources/mapper/PrDevOpsPlanMapper.xml
@@ -160,6 +160,14 @@ </if> </trim> </select> <select id="exists" resultType="java.lang.Boolean"> select count(1) > 0 from pr_dev_ops_plan where name = #{name,jdbcType=VARCHAR} <if test="id != null"> and id != #{id,jdbcType=BIGINT} </if> </select> <update id="deleteLogicById" parameterType="java.lang.Long"> update pr_dev_ops_plan set deleted = 1 pms-parent/pms-global/src/main/resources/mapper/PrProductionProcessMapper.xml
@@ -175,6 +175,17 @@ CAST(id AS CHAR) AS id,name from pr_production_process where deleted = 0 <trim prefix="and" suffixOverrides=","> pro_id = #{proId,jdbcType=BIGINT} </trim> </select> <select id="exists" resultType="java.lang.Boolean"> select count(1) from pr_production_process where name = #{name} and deleted = 0 <if test="id != null"> and id != #{id} </if> </select> pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java
@@ -76,6 +76,10 @@ @Transactional public int save(PltProduct p) { //判断产品不能重名 if (dao.exists(p.name, p.id)) { throw new RuntimeException("产品名称重复"); } int flag=0; do { p.code = getNextCode(); @@ -110,6 +114,9 @@ @Transactional public int update(PltProduct p) { if (dao.exists(p.name, p.id)) { throw new RuntimeException("产品名称重复"); } int count = dao.updateByPrimaryKeySelective(p); //删除旧数据,重新插入 pfDao.deleteByProId(p.id); pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessCtrl.java
@@ -125,9 +125,9 @@ @GetMapping(path="queryAll") @SsoPowerAop(power = "-1") @Log("查询所有生产流程") public BaseResponse<List<Map<String,String>>> queryAll(){ public BaseResponse<List<Map<String,String>>> queryAll(Long proId){ try { return BaseResponseUtils.buildSuccess(sv.queryAll()); return BaseResponseUtils.buildSuccess(sv.queryAll(proId)); }catch (Exception e){ log.error("查询所有生产流程异常", e); return BaseResponseUtils.buildException(e.getMessage()); pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java
@@ -63,6 +63,10 @@ } @Transactional public int save(PrProductionProcess process){ //流程名称不能重复 if (processDao.exists(process.name, process.id)) { throw new RuntimeException("流程名称不能重复"); } prepareProcess(process); int count = processDao.insertSelective(process); saveNodesAndInstructions(process); @@ -71,6 +75,10 @@ @Transactional public int update(PrProductionProcess process){ //流程名称不能重复 if (processDao.exists(process.name, process.id)) { throw new RuntimeException("流程名称不能重复"); } prepareProcess(process); int count = processDao.updateByPrimaryKeySelective(process); // 优化:只有当节点有变更时才删除并重新插入 @@ -159,8 +167,8 @@ return rsVo ; } public List<Map<String,String>> queryAll(){ return processDao.queryAll(); public List<Map<String,String>> queryAll(Long proId){ return processDao.queryAll(proId); } private void addUrl(PrWorkingInstruction ins){ pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java
@@ -8,11 +8,13 @@ import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper; import com.dy.pmsGlobal.daoPr.PrBatchNumberMapper; import com.dy.pmsGlobal.daoPr.PrEquipMapper; import com.dy.pmsGlobal.daoPr.PrProductionProcessMapper; import com.dy.pmsGlobal.pojoBa.BaUser; import com.dy.pmsGlobal.pojoPlt.PltProduct; import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan; import com.dy.pmsGlobal.pojoPr.PrBatchNumber; import com.dy.pmsGlobal.pojoPr.PrEquip; import com.dy.pmsGlobal.pojoPr.PrProductionProcess; import com.dy.pmsGlobal.util.QrCodeUtil; import com.dy.pmsGlobal.util.UserUtil; import lombok.extern.slf4j.Slf4j; @@ -38,7 +40,7 @@ private PrBatchNumberMapper batchDao; private PrEquipMapper equipDao; private PltProductMapper productDao; private SqlSessionFactory sqlSessionFactory; private PrProductionProcessMapper processDao; @Autowired public void setAssemblyDao(PrAssemblyPlanMapper assemblyDao) { this.assemblyDao = assemblyDao; @@ -61,12 +63,20 @@ } @Autowired public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) { this.sqlSessionFactory = sqlSessionFactory; public void setProcessDao(PrProductionProcessMapper processDao) { this.processDao = processDao; } @Transactional public int save(PrAssemblyPlan plan){ //计划名称不能重复 if(assemblyDao.exists(plan.name,plan.id)){ throw new RuntimeException("计划名称不能重复"); } PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId); if(process == null || process.proId != plan.proId){ throw new RuntimeException("产品与生产流程不匹配"); } PrBatchNumber batch = new PrBatchNumber(); batch.batchNumber = getNextCode(); batch.proId = plan.proId; @@ -87,10 +97,17 @@ @Transactional public int update(PrAssemblyPlan plan){ //计划名称不能重复 if(assemblyDao.exists(plan.name,plan.id)){ throw new RuntimeException("计划名称不能重复"); } PrAssemblyPlan origPlan = assemblyDao.selectByPrimaryKey(plan.id); PrBatchNumber batch = batchDao.selectByPrimaryKey(origPlan.batchId); //产品改变则更新全部已生成设备号 if(origPlan.proId != plan.proId){ batch.proId = plan.proId; batchDao.updateByPrimaryKeySelective(batch); equipDao.deleteByBatchId(origPlan.batchId); insertEquip(plan.proId,origPlan.batchId,batch.batchNumber,plan.number,1); }else if(origPlan.number < plan.number){ @@ -107,7 +124,7 @@ PrBatchNumber batch = batchDao.selectByPrimaryKey(plan.batchId); int count =insertEquip(plan.proId,plan.batchId,batch.batchNumber,num + plan.number,plan.number+1); plan.number = plan.number + num; assemblyDao.updateByPrimaryKeySelective(plan); assemblyDao.updateByPrimaryKeySelective (plan); return count; } pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/DevOpsSv.java
@@ -35,6 +35,9 @@ @Transactional public int save(PrDevOpsPlan plan) { if(devOpsDao.exists(plan.name,plan.id)){ throw new RuntimeException("计划名不能重复"); } BaUser loginUser = userUtil.getUser(UserTokenContext.get()); if(loginUser!=null){ plan.creator = loginUser.id; @@ -44,6 +47,9 @@ } @Transactional public int update(PrDevOpsPlan plan) { if(devOpsDao.exists(plan.name,plan.id)){ throw new RuntimeException("计划名不能重复"); } return devOpsDao.updateByPrimaryKeySelective(plan); } public QueryResultVo<List<PrDevOpsPlan>> selectSome(QueryVo queryVo) {