| | |
| | | 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; |
| | |
| | | private PrBatchNumberMapper batchDao; |
| | | private PrEquipMapper equipDao; |
| | | private PltProductMapper productDao; |
| | | private SqlSessionFactory sqlSessionFactory; |
| | | private PrProductionProcessMapper processDao; |
| | | @Autowired |
| | | public void setAssemblyDao(PrAssemblyPlanMapper assemblyDao) { |
| | | this.assemblyDao = assemblyDao; |
| | |
| | | } |
| | | |
| | | @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.equals(plan.proId)){ |
| | | throw new RuntimeException("产品与生产流程不匹配"); |
| | | } |
| | | PrBatchNumber batch = new PrBatchNumber(); |
| | | batch.batchNumber = getNextCode(); |
| | | batch.proId = plan.proId; |
| | |
| | | return assemblyDao.insertSelective(plan); |
| | | } |
| | | |
| | | @Transactional |
| | | public int update(PrAssemblyPlan plan){ |
| | | //计划名称不能重复 |
| | | if(assemblyDao.exists(plan.name,plan.id)){ |
| | | throw new RuntimeException("计划名称不能重复"); |
| | | } |
| | | PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId); |
| | | if(process == null || !process.proId.equals(plan.proId)){ |
| | | 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){ |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Transactional |
| | | public int addEquip(Long planId,int num){ |
| | | PrAssemblyPlan plan = assemblyDao.selectByPrimaryKey(planId); |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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())); |
| | |
| | | public QueryResultVo<List<PrEquip>> selectSomeEquip(QueryVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | //查询符合条件的记录总数 |
| | | Long itemTotal = assemblyDao.selectSomeCount(params); |
| | | Long itemTotal = equipDao.selectSomeCount(params); |
| | | QueryResultVo<List<PrEquip>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ; |
| | | //计算分页等信息 |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | |
| | | 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(param); |
| | | } |
| | | } |