|
|
|
@ -248,16 +248,16 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
ProOrderWorkorder work = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId);
|
|
|
|
|
if (work != null) {
|
|
|
|
|
workers.add(work);
|
|
|
|
|
ProOrderWorkorder bottomWork = work;
|
|
|
|
|
ProOrderWorkorder topWork = work;
|
|
|
|
|
Boolean run = true;
|
|
|
|
|
while (run) {
|
|
|
|
|
//上级
|
|
|
|
|
ProOrderWorkorder topworkers = proOrderWorkorderMapper.selectWorkOrderByCode(bottomWork.getParentOrder());
|
|
|
|
|
//下级
|
|
|
|
|
ProOrderWorkorder sonWorkers = proOrderWorkorderMapper.selectSonWorkOrder(topWork.getWorkorderCode());
|
|
|
|
|
//有上级code
|
|
|
|
|
if (topworkers != null) {
|
|
|
|
|
workers.add(topworkers);
|
|
|
|
|
delteIds.add(topworkers.getWorkorderId());
|
|
|
|
|
bottomWork.setParentOrder(topworkers.getParentOrder());
|
|
|
|
|
if (sonWorkers != null) {
|
|
|
|
|
workers.add(sonWorkers);
|
|
|
|
|
delteIds.add(sonWorkers.getWorkorderId());
|
|
|
|
|
topWork.setWorkorderCode(sonWorkers.getWorkorderCode());
|
|
|
|
|
} else {
|
|
|
|
|
run = false;
|
|
|
|
|
}
|
|
|
|
@ -268,7 +268,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
//删除工单(字母)pro_order_workorder
|
|
|
|
|
proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(workorderIds0);
|
|
|
|
|
//删除批次pro_order_workorder_batch
|
|
|
|
|
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds0);
|
|
|
|
|
proOrderWorkorderBatchMapper.deleteBatch(workorderIds0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(workers)) {
|
|
|
|
@ -831,7 +831,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
"订单数量变更结果:" + rSapChange.getCode() + "," + rSapChange.getMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获得对应工单
|
|
|
|
|
// 获得对应工单----------------------------------------------------------------------------?
|
|
|
|
|
ProOrderWorkorder proOrderWorkorder = workOrderList.get(--index);
|
|
|
|
|
// 更新订单
|
|
|
|
|
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
@ -882,9 +882,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
// 更新至数据库
|
|
|
|
|
proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch);
|
|
|
|
|
|
|
|
|
|
// 测试
|
|
|
|
|
// System.out.println("这里是workorderId----------->"+workBatch.getWorkorderId());
|
|
|
|
|
// System.out.println("这里是拆分数量----------->"+workBatch.getBatchQuantity());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果存在子节点
|
|
|
|
@ -900,7 +897,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success("变更成功");
|
|
|
|
|
// throw new RuntimeException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -910,6 +906,192 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
return error(500, "批次号不能重复");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交修改工单接口
|
|
|
|
|
*
|
|
|
|
|
* @param splitOrderDTO
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
@Transactional
|
|
|
|
|
public AjaxResult subChangeWorkOrderPro(SplitOrderDTO splitOrderDTO) {
|
|
|
|
|
|
|
|
|
|
// 获得子工单对象——(这里没有用BeanUtils是因为若依与这个冲突造成死循环得到错误的结果)
|
|
|
|
|
ProOrderWorkorder proWorkOrder = splitOrderDTO.getProOrderWorkorder();
|
|
|
|
|
// 通过子工单获得所有工单信息,并将所有工单信息放入list中
|
|
|
|
|
List<ProOrderWorkorder> workOrderList = new ArrayList<>();
|
|
|
|
|
// 将获得的工单的id存放
|
|
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
|
|
boolean getworkOrder = true;
|
|
|
|
|
// 将工单放入list
|
|
|
|
|
workOrderList.add(proWorkOrder);
|
|
|
|
|
// 将id放入
|
|
|
|
|
ids.add(proWorkOrder.getWorkorderId());
|
|
|
|
|
|
|
|
|
|
// 用于循环
|
|
|
|
|
ProOrderWorkorder childWorkOrder = new ProOrderWorkorder();
|
|
|
|
|
BeanUtils.copyProperties(proWorkOrder, childWorkOrder);
|
|
|
|
|
|
|
|
|
|
while (getworkOrder) {
|
|
|
|
|
// 通过parentOrder查询子工单信息
|
|
|
|
|
ProOrderWorkorder sonWorkOrder = proOrderWorkorderMapper.selectSonWorkOrder(childWorkOrder.getWorkorderCode());
|
|
|
|
|
if (sonWorkOrder != null) {
|
|
|
|
|
// 将重置对象
|
|
|
|
|
BeanUtils.copyProperties(sonWorkOrder, childWorkOrder);
|
|
|
|
|
// 将工单放入list
|
|
|
|
|
workOrderList.add(sonWorkOrder);
|
|
|
|
|
// 将id放入
|
|
|
|
|
ids.add(sonWorkOrder.getWorkorderId());
|
|
|
|
|
} else {
|
|
|
|
|
// 终止循环
|
|
|
|
|
getworkOrder = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean checkout = true;
|
|
|
|
|
|
|
|
|
|
// 校验批次编号是否存在(重复问题)
|
|
|
|
|
String[] workorderIds = (String[]) ids.toArray(new String[ids.size()]);
|
|
|
|
|
List<String> batchCodes = proOrderWorkorderBatchMapper.selectCodeByWorkOrderIds(workorderIds);
|
|
|
|
|
for (int i = 0; i < batchCodes.size(); i++) {
|
|
|
|
|
for (int j = 0; j < splitOrderDTO.getFormFields().size(); j++) {
|
|
|
|
|
if (batchCodes.get(i).equals(splitOrderDTO.getFormFields().get(j).getBatchCode())) {
|
|
|
|
|
checkout = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//校验各工序设备是否已选择
|
|
|
|
|
List<CascaderDTO> processes = proOrderMapper.getRouteProcess(splitOrderDTO.getRouteCode());
|
|
|
|
|
if (splitOrderDTO.getProdLineCodeArray().length == 0) {
|
|
|
|
|
checkout = false;
|
|
|
|
|
return error(500, "必须选择工单生产设备!");
|
|
|
|
|
} else {
|
|
|
|
|
String codeArray = JSONArray.toJSONString(splitOrderDTO.getProdLineCodeArray());
|
|
|
|
|
for (int i = 0; i < processes.size(); i++) {
|
|
|
|
|
if (codeArray.indexOf(processes.get(i).getValue()) < 0) {
|
|
|
|
|
checkout = false;
|
|
|
|
|
return error(500, "所有有工序节点都必须选择生产设备!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[][] array = splitOrderDTO.getProdLineCodeArray();
|
|
|
|
|
for (int m = 0; m < array.length; m++) {
|
|
|
|
|
if (array[m].length < 2) {
|
|
|
|
|
checkout = false;
|
|
|
|
|
return error(500, "工序没有生产设备可选择,请维护工艺!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
splitOrderDTO.setProdLineCode(codeArray);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (checkout) {
|
|
|
|
|
// 删除所有工单s下的批次信息
|
|
|
|
|
int i = proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds);
|
|
|
|
|
// 删除湿料计划
|
|
|
|
|
proWetMaterialPlanDetailMapper.deleteProWetMaterialPlanDetailByWorkId(proWorkOrder.getWorkorderId());
|
|
|
|
|
// 创建订单信息,并将信息copy进去
|
|
|
|
|
ProOrder proOrder = new ProOrder();
|
|
|
|
|
BeanUtils.copyProperties(splitOrderDTO.getProduct(), proOrder);
|
|
|
|
|
// 设置换算基数,用于获得换算值
|
|
|
|
|
Long quantity = proOrder.getQuantity();
|
|
|
|
|
// 创建批次表通用对象
|
|
|
|
|
ProOrderWorkorderBatch workBatch = setCommonBatchAttribute();
|
|
|
|
|
boolean run = true;
|
|
|
|
|
// 获取单位换算值
|
|
|
|
|
Long conver = 1L;
|
|
|
|
|
int index = 0;
|
|
|
|
|
while (run) {
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(proOrder.getParentOrder())) {
|
|
|
|
|
//推送sap订单更新信息
|
|
|
|
|
SapShopOrderQuery sapChange = new SapShopOrderQuery();
|
|
|
|
|
sapChange.setAufnr(proOrder.getOrderCode());//母订单号
|
|
|
|
|
BigDecimal newSapQuantityNum = new BigDecimal(proOrder.getQuantity())
|
|
|
|
|
.subtract(new BigDecimal(proOrder.getAtrr1()));
|
|
|
|
|
sapChange.setQuantity(newSapQuantityNum.toString());//母订单新数量
|
|
|
|
|
logger.info("母订单" + proOrder.getOrderCode() +
|
|
|
|
|
"订单数量变更:修改前" + proOrder.getQuantity() + "," +
|
|
|
|
|
"已拆数量" + proOrder.getAtrr1() + "," +
|
|
|
|
|
"给sap汇报数量" + newSapQuantityNum.toString());
|
|
|
|
|
R rSapChange = remoteSapService.shopUpdateSync(sapChange);//sap只能同步指定日期的数据
|
|
|
|
|
logger.info("母订单" + proOrder.getOrderCode() +
|
|
|
|
|
"订单数量变更结果:" + rSapChange.getCode() + "," + rSapChange.getMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获得对应工单----------------------------------------------------------------------------?
|
|
|
|
|
ProOrderWorkorder proOrderWorkorder = workOrderList.get(index++);
|
|
|
|
|
// 更新订单
|
|
|
|
|
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
proOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
proOrder.setQuantitySplit(proOrder.getQuantitySplit() + Long.valueOf(proOrder.getAtrr1()));
|
|
|
|
|
if (proOrder.getQuantity().longValue() == proOrder.getQuantitySplit().longValue()) {
|
|
|
|
|
// 已拆分
|
|
|
|
|
proOrder.setStatus("o2");
|
|
|
|
|
} else {
|
|
|
|
|
// 拆分中
|
|
|
|
|
proOrder.setStatus("o1");
|
|
|
|
|
}
|
|
|
|
|
proOrderMapper.updateProOrder(proOrder);
|
|
|
|
|
// 设置工单信息
|
|
|
|
|
proOrderWorkorder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
proOrderWorkorder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
// 拆分数量
|
|
|
|
|
proOrderWorkorder.setQuantitySplit(Long.valueOf(proOrder.getAtrr1()));
|
|
|
|
|
// 2.将工单信息更新至数据库
|
|
|
|
|
if (splitOrderDTO.getProdLineCode() != null) {
|
|
|
|
|
proOrderWorkorder.setProdLineCode(splitOrderDTO.getProdLineCode());
|
|
|
|
|
}
|
|
|
|
|
if (splitOrderDTO.getProductDate() != null) {
|
|
|
|
|
proOrderWorkorder.setProductDate(splitOrderDTO.getProductDate());
|
|
|
|
|
}
|
|
|
|
|
if (splitOrderDTO.getShiftId() != null) {
|
|
|
|
|
proOrderWorkorder.setShiftId(splitOrderDTO.getShiftId());
|
|
|
|
|
}
|
|
|
|
|
if (splitOrderDTO.getRouteCode() != null) {
|
|
|
|
|
proOrderWorkorder.setRouteCode(splitOrderDTO.getRouteCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(proOrderWorkorder);
|
|
|
|
|
// 删除工单下对应批次信息
|
|
|
|
|
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderId(proOrderWorkorder.getWorkorderId());
|
|
|
|
|
|
|
|
|
|
// 生成对应批次表
|
|
|
|
|
workBatch.setWorkorderId(proOrderWorkorder.getWorkorderId());
|
|
|
|
|
|
|
|
|
|
// 生成批次表信息并更新至数据库
|
|
|
|
|
for (Batch batch : splitOrderDTO.getFormFields()) {
|
|
|
|
|
// 生成批次id
|
|
|
|
|
workBatch.setBatchId(IdUtils.fastSimpleUUID());
|
|
|
|
|
// 生成批次号
|
|
|
|
|
workBatch.setBatchCode(batch.getBatchCode());
|
|
|
|
|
// 生成批次数量
|
|
|
|
|
workBatch.setBatchQuantity(batch.getBatchQuantity() * conver);
|
|
|
|
|
// 更新至数据库
|
|
|
|
|
proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果存在子节点
|
|
|
|
|
if (proOrder.getChildren().size() > 0) {
|
|
|
|
|
ProOrderDTO newProOrder = (ProOrderDTO) proOrder.getChildren().get(0);
|
|
|
|
|
// 更新换算值
|
|
|
|
|
conver = (newProOrder.getQuantity() / quantity);
|
|
|
|
|
// 将child信息重新赋值给proOrder
|
|
|
|
|
BeanUtils.copyProperties(newProOrder, proOrder);
|
|
|
|
|
} else {
|
|
|
|
|
// 结束循环
|
|
|
|
|
run = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success("变更成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return error(500, "批次号不能重复");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验工单是否可以修改
|
|
|
|
|
* 如果工单已生成湿料计划则不允许修改
|
|
|
|
|