|
|
@ -34,8 +34,6 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ProOrderWorkorderMapper proOrderWorkorderMapper;
|
|
|
|
private ProOrderWorkorderMapper proOrderWorkorderMapper;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ProOrderMapper proOrderMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
|
|
|
|
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -189,133 +187,99 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
|
|
|
|
@DS("#header.poolName")
|
|
|
|
@DS("#header.poolName")
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public AjaxResult addWetPlan(List<ProOrderWorkorder> proOrderWorkorderList) {
|
|
|
|
public AjaxResult addWetPlan(List<ProOrderWorkorder> proOrderWorkorderList) {
|
|
|
|
// 获取料罐信息list
|
|
|
|
// 判断在该计划日期下是否存在计划-存在计划则获取主计划id-不存在新建计划
|
|
|
|
List<Bucket> bucketList = proWetMaterialPlanMapper.selectBucketList();
|
|
|
|
String planId = proWetMaterialPlanMapper.selectWetMaterialPlanByPlanTime(proOrderWorkorderList.get(0).getPlanTime());
|
|
|
|
// 获取班次信息list
|
|
|
|
if (planId == null) {
|
|
|
|
List<ProShift> shiftList = proOrderMapper.selectProShift();
|
|
|
|
// 创建主计划
|
|
|
|
|
|
|
|
ProWetMaterialPlan proWetMaterialPlan = createProWetMaterialPlan(proOrderWorkorderList.get(0));
|
|
|
|
// 湿料计划分类
|
|
|
|
// 将主计划更新至数据库
|
|
|
|
// 在该班次下
|
|
|
|
proWetMaterialPlanMapper.insertProWetMaterialPlan(proWetMaterialPlan);
|
|
|
|
for (int shift = 0; shift < shiftList.size(); shift++){
|
|
|
|
// 循环创建湿料计划详情
|
|
|
|
// 在该料罐下
|
|
|
|
for (int i = 0; i < proOrderWorkorderList.size(); i++) {
|
|
|
|
for (int bucket = 0; bucket < bucketList.size(); bucket++){
|
|
|
|
// 将湿料计划详情更新至数据库
|
|
|
|
int onlyOne = 0;
|
|
|
|
proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorderList.get(i), proWetMaterialPlan.getId()));
|
|
|
|
// 循环传入的工单信息
|
|
|
|
}
|
|
|
|
for (int order = 0; order < proOrderWorkorderList.size(); order++){
|
|
|
|
}else {
|
|
|
|
// 如果该工单在该班次并且在该料罐下
|
|
|
|
// 循环创建湿料计划详情
|
|
|
|
if (proOrderWorkorderList.get(order).getShiftId().equals(shiftList.get(shift).getShiftId().toString()) && (proOrderWorkorderList.get(order).getBucketId() == bucketList.get(bucket).getBucketId())){
|
|
|
|
for (int i = 0; i < proOrderWorkorderList.size(); i++) {
|
|
|
|
// 同班次同料罐下所有工单进行相同操作
|
|
|
|
// 将湿料计划详情更新至数据库
|
|
|
|
// 如果首次创建主计划
|
|
|
|
proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorderList.get(i), planId));
|
|
|
|
if (onlyOne==0){
|
|
|
|
|
|
|
|
// 创建主湿料计划
|
|
|
|
|
|
|
|
ProWetMaterialPlan proWetMaterialPlan = new ProWetMaterialPlan();
|
|
|
|
|
|
|
|
// 设置主键id
|
|
|
|
|
|
|
|
proWetMaterialPlan.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
// TODO 计划工厂编码
|
|
|
|
|
|
|
|
// 订单类型
|
|
|
|
|
|
|
|
proWetMaterialPlan.setProdType(proOrderWorkorderList.get(order).getProdType());
|
|
|
|
|
|
|
|
// 物料号
|
|
|
|
|
|
|
|
proWetMaterialPlan.setProdCode(proOrderWorkorderList.get(order).getProductCode());
|
|
|
|
|
|
|
|
// 物料名称
|
|
|
|
|
|
|
|
proWetMaterialPlan.setProdDesc(proOrderWorkorderList.get(order).getProductName());
|
|
|
|
|
|
|
|
// 存放大罐Code
|
|
|
|
|
|
|
|
proWetMaterialPlan.setProdSource(proOrderWorkorderList.get(order).getBucketCode());
|
|
|
|
|
|
|
|
// 计划状态(1正常0停用)
|
|
|
|
|
|
|
|
proWetMaterialPlan.setStatus("1");
|
|
|
|
|
|
|
|
// 创建者
|
|
|
|
|
|
|
|
proWetMaterialPlan.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
// 创建时间
|
|
|
|
|
|
|
|
proWetMaterialPlan.setCreateTime(new Date());
|
|
|
|
|
|
|
|
// 更新者
|
|
|
|
|
|
|
|
proWetMaterialPlan.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
// 更新时间
|
|
|
|
|
|
|
|
proWetMaterialPlan.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
// 同步状态(1已同步0未同步)
|
|
|
|
|
|
|
|
proWetMaterialPlan.setSyncFlag("0");
|
|
|
|
|
|
|
|
// 计划编码
|
|
|
|
|
|
|
|
proWetMaterialPlan.setProdCode("SL"+ DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, new Date()));
|
|
|
|
|
|
|
|
// 计划日期
|
|
|
|
|
|
|
|
proWetMaterialPlan.setPlanTime(proOrderWorkorderList.get(order).getPlanTime());
|
|
|
|
|
|
|
|
// 班次id
|
|
|
|
|
|
|
|
proWetMaterialPlan.setShiftId(Integer.valueOf(proOrderWorkorderList.get(order).getShiftId()));
|
|
|
|
|
|
|
|
// 班次名称
|
|
|
|
|
|
|
|
proWetMaterialPlan.setShiftDesc(proOrderWorkorderList.get(order).getShiftDesc());
|
|
|
|
|
|
|
|
// 将主湿料计划加入到数据库
|
|
|
|
|
|
|
|
proWetMaterialPlanMapper.insertProWetMaterialPlan(proWetMaterialPlan);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建湿料计划详情
|
|
|
|
|
|
|
|
ProWetMaterialPlanDetail proWetMaterialPlanDetail = new ProWetMaterialPlanDetail();
|
|
|
|
|
|
|
|
// 主键id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
// TODO 计划工厂编码
|
|
|
|
|
|
|
|
// 配料计划id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setWetMaterialPlanId(proWetMaterialPlan.getId());
|
|
|
|
|
|
|
|
// 工单id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setWorkorderId(proOrderWorkorderList.get(order).getWorkorderId());
|
|
|
|
|
|
|
|
// 接料状态(1接料完成0未接料)
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setStatus("0");
|
|
|
|
|
|
|
|
// 料罐id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setBucketId(String.valueOf(proOrderWorkorderList.get(order).getBucketId()));
|
|
|
|
|
|
|
|
// 料罐编码
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setBucketCode(proOrderWorkorderList.get(order).getBucketCode());
|
|
|
|
|
|
|
|
// 物料编码
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setMaterialCode(proOrderWorkorderList.get(order).getMaterialCode());
|
|
|
|
|
|
|
|
// 物料id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setMaterialId(String.valueOf(proOrderWorkorderList.get(order).getMaterialId()));
|
|
|
|
|
|
|
|
// 物料名称
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setMaterialName(proOrderWorkorderList.get(order).getMaterialName());
|
|
|
|
|
|
|
|
// 产品名称
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setProductName(proOrderWorkorderList.get(order).getProductName());
|
|
|
|
|
|
|
|
// 班次id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setShiftId(Long.valueOf(proOrderWorkorderList.get(order).getShiftId()));
|
|
|
|
|
|
|
|
// TODO 班次编码
|
|
|
|
|
|
|
|
// 班次简称
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setShiftDesc(proOrderWorkorderList.get(order).getShiftDesc());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(proWetMaterialPlanDetail);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
// 查询当天下-该班次-该料罐下的主湿料计划的id
|
|
|
|
|
|
|
|
String id = proWetMaterialPlanMapper.selectProWetMaterialPlanByPlanTime(proOrderWorkorderList.get(order).getPlanTime(),proOrderWorkorderList.get(order).getBucketCode(),proOrderWorkorderList.get(order).getShiftId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建湿料计划详情
|
|
|
|
|
|
|
|
ProWetMaterialPlanDetail proWetMaterialPlanDetail = new ProWetMaterialPlanDetail();
|
|
|
|
|
|
|
|
// 主键id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
// TODO 计划工厂编码
|
|
|
|
|
|
|
|
// 配料计划id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setWetMaterialPlanId(id);
|
|
|
|
|
|
|
|
// 工单id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setWorkorderId(proOrderWorkorderList.get(order).getWorkorderId());
|
|
|
|
|
|
|
|
// 接料状态(1接料完成0未接料)
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setStatus("0");
|
|
|
|
|
|
|
|
// 料罐id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setBucketId(String.valueOf(proOrderWorkorderList.get(order).getBucketId()));
|
|
|
|
|
|
|
|
// 料罐编码
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setBucketCode(proOrderWorkorderList.get(order).getBucketCode());
|
|
|
|
|
|
|
|
// 物料编码
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setMaterialCode(proOrderWorkorderList.get(order).getMaterialCode());
|
|
|
|
|
|
|
|
// 物料id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setMaterialId(String.valueOf(proOrderWorkorderList.get(order).getMaterialId()));
|
|
|
|
|
|
|
|
// 物料名称
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setMaterialName(proOrderWorkorderList.get(order).getMaterialName());
|
|
|
|
|
|
|
|
// 产品名称
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setProductName(proOrderWorkorderList.get(order).getProductName());
|
|
|
|
|
|
|
|
// 班次id
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setShiftId(Long.valueOf(proOrderWorkorderList.get(order).getShiftId()));
|
|
|
|
|
|
|
|
// TODO 班次编码
|
|
|
|
|
|
|
|
// 班次简称
|
|
|
|
|
|
|
|
proWetMaterialPlanDetail.setShiftDesc(proOrderWorkorderList.get(order).getShiftDesc());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(proWetMaterialPlanDetail);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onlyOne+=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return success();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 创建湿料(主)计划
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param proOrderWorkorder
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private ProWetMaterialPlan createProWetMaterialPlan(ProOrderWorkorder proOrderWorkorder) {
|
|
|
|
|
|
|
|
ProWetMaterialPlan proWetMaterialPlan = new ProWetMaterialPlan();
|
|
|
|
|
|
|
|
// 创建者
|
|
|
|
|
|
|
|
proWetMaterialPlan.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
// 创建时间
|
|
|
|
|
|
|
|
proWetMaterialPlan.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
// 更新者
|
|
|
|
|
|
|
|
proWetMaterialPlan.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
// 更新时间
|
|
|
|
|
|
|
|
proWetMaterialPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
// 计划状态(1正常0停用)
|
|
|
|
|
|
|
|
proWetMaterialPlan.setStatus("1");
|
|
|
|
|
|
|
|
// TODO 订单类型
|
|
|
|
|
|
|
|
//proWetMaterialPlan.setOrderType();
|
|
|
|
|
|
|
|
// TODO 计划工厂编码
|
|
|
|
|
|
|
|
//proWetMaterialPlan.setFactoryCode();
|
|
|
|
|
|
|
|
// 计划日期
|
|
|
|
|
|
|
|
proWetMaterialPlan.setPlanTime(proOrderWorkorder.getPlanTime());
|
|
|
|
|
|
|
|
// 同步状态(1已同步0未同步)
|
|
|
|
|
|
|
|
proWetMaterialPlan.setSyncFlag("0");
|
|
|
|
|
|
|
|
// 计划编码
|
|
|
|
|
|
|
|
proWetMaterialPlan.setProdCode("PC" + DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, DateUtils.getNowDate()));
|
|
|
|
|
|
|
|
// 创建主键id
|
|
|
|
|
|
|
|
proWetMaterialPlan.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
return proWetMaterialPlan;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 创建湿料计划详情
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param workorder
|
|
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private ProWetMaterialPlanDetail createProWetMaterialPlanDetail(ProOrderWorkorder workorder, String id) {
|
|
|
|
|
|
|
|
ProWetMaterialPlanDetail detail = new ProWetMaterialPlanDetail();
|
|
|
|
|
|
|
|
// 设置主键id
|
|
|
|
|
|
|
|
detail.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
// TODO 计划工厂编码
|
|
|
|
|
|
|
|
//detail.setFactoryCode();
|
|
|
|
|
|
|
|
// 主计划id
|
|
|
|
|
|
|
|
detail.setWetMaterialPlanId(id);
|
|
|
|
|
|
|
|
// 工单id
|
|
|
|
|
|
|
|
detail.setWorkorderId(workorder.getWorkorderId());
|
|
|
|
|
|
|
|
// 接料状态(1已接料0未接料)
|
|
|
|
|
|
|
|
detail.setStatus("0");
|
|
|
|
|
|
|
|
// 料罐id
|
|
|
|
|
|
|
|
detail.setBucketId(String.valueOf(workorder.getBucketId()));
|
|
|
|
|
|
|
|
// 料罐编码
|
|
|
|
|
|
|
|
detail.setBucketCode(workorder.getBucketCode());
|
|
|
|
|
|
|
|
// 物料编码
|
|
|
|
|
|
|
|
detail.setMaterialCode(workorder.getMaterialCode());
|
|
|
|
|
|
|
|
// 物料id
|
|
|
|
|
|
|
|
detail.setMaterialId(String.valueOf(workorder.getMaterialId()));
|
|
|
|
|
|
|
|
// 物料名称
|
|
|
|
|
|
|
|
detail.setMaterialName(workorder.getMaterialName());
|
|
|
|
|
|
|
|
// 班次id
|
|
|
|
|
|
|
|
detail.setShiftId(Long.valueOf(workorder.getShiftId()));
|
|
|
|
|
|
|
|
// TODO 班次编码
|
|
|
|
|
|
|
|
//detail.setShiftCode();
|
|
|
|
|
|
|
|
// 班次简称
|
|
|
|
|
|
|
|
detail.setShiftDesc(workorder.getShiftDesc());
|
|
|
|
|
|
|
|
// 湿料计划时间
|
|
|
|
|
|
|
|
detail.setPlanTime(workorder.getPlanTime());
|
|
|
|
|
|
|
|
return detail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|