|
|
|
@ -381,21 +381,6 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
return success(proOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void shopOrderSync(List<ProOrder> proOrderList) {
|
|
|
|
|
|
|
|
|
|
for (ProOrder proOrder : proOrderList) {
|
|
|
|
|
String shopOrder = proOrder.getOrderCode();
|
|
|
|
|
if (StringUtil.isBlank(shopOrder)) {
|
|
|
|
|
throw new CheckedException("订单号不能为空!");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isBlank(proOrder.getStatus())) {
|
|
|
|
|
throw new CheckedException("订单号不能为空!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手动同步sap订单
|
|
|
|
|
*/
|
|
|
|
@ -424,12 +409,28 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void syncSAPFunc(List<SapProOrder> newOrders){
|
|
|
|
|
public String syncSAPFunc(List<SapProOrder> newOrders){
|
|
|
|
|
String failOrder = "";
|
|
|
|
|
ProOrder proOrder = null;
|
|
|
|
|
for (SapProOrder sapProOrder:newOrders) {
|
|
|
|
|
//工单下达后整个订单就被锁定//订单存在就更新,不存在就插入
|
|
|
|
|
//工单生产后整个订单就被锁定//订单存在就更新,不存在就插入
|
|
|
|
|
proOrder = new ProOrder();
|
|
|
|
|
BeanUtils.copyProperties(sapProOrder, proOrder);
|
|
|
|
|
failOrder += syncFunc(proOrder);
|
|
|
|
|
}
|
|
|
|
|
return failOrder;
|
|
|
|
|
}
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public String syncImportFunc(List<ProOrder> newOrders){
|
|
|
|
|
String failOrder = "";
|
|
|
|
|
for (ProOrder proOrder:newOrders) {
|
|
|
|
|
failOrder += syncFunc(proOrder);
|
|
|
|
|
}
|
|
|
|
|
return failOrder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String syncFunc(ProOrder proOrder){
|
|
|
|
|
String failOrder = "";
|
|
|
|
|
//pro_order_workorder
|
|
|
|
|
Date nowDate = DateUtils.getNowDate();
|
|
|
|
|
ProOrder orderExit = proOrderMapper.selectProOrderByOrderCode(proOrder.getOrderCode());
|
|
|
|
@ -459,12 +460,14 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
//删除工单pro_order_workorder
|
|
|
|
|
proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(ids);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
failOrder = proOrder.getOrderCode();
|
|
|
|
|
}
|
|
|
|
|
// else {//关闭订单
|
|
|
|
|
// remoteSapService.sapCloseOrder(proOrder.getOrderCode());
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return failOrder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//父查子递归
|
|
|
|
@ -478,6 +481,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
return codeList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理表格信息
|
|
|
|
|
*
|
|
|
|
@ -492,81 +496,8 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
AjaxResult checkResult = checkImportOrder(orderList);
|
|
|
|
|
// 如果数据校验成功
|
|
|
|
|
if (checkResult.isSuccess()) {
|
|
|
|
|
// 校验数据是否可编辑
|
|
|
|
|
boolean checkEdit = false;
|
|
|
|
|
// 反馈数据
|
|
|
|
|
StringBuilder errMsg = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < orderList.size(); i++) {
|
|
|
|
|
// 当前行操作
|
|
|
|
|
boolean checkOnly = false;
|
|
|
|
|
|
|
|
|
|
List<ProOrderWorkorder> workOrderList = proOrderWorkorderMapper.selectWorkOrderByOrderCode(orderList.get(i).getOrderCode());
|
|
|
|
|
|
|
|
|
|
// 遍历查询工单是否已下达-下达则不允许编辑更新
|
|
|
|
|
for (ProOrderWorkorder workOrder : workOrderList) {
|
|
|
|
|
// 如果工单已生产
|
|
|
|
|
if (!(workOrder.getStatus().equals("w0") || workOrder.getStatus().equals("w1"))) {
|
|
|
|
|
checkEdit = true;
|
|
|
|
|
checkOnly = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 组装工单已下达反馈信息
|
|
|
|
|
if (checkOnly) {
|
|
|
|
|
errMsg.append("第" + (i + 1) + "行:" + "订单号为:" + orderList.get(i).getOrderCode() + ",该订单下工单已生产,不允许更新;" + "<br/>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果存在不可编辑信息
|
|
|
|
|
if (checkEdit) {
|
|
|
|
|
return error(500, errMsg.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 正常插入与更新操作
|
|
|
|
|
for (ProOrder order : orderList) {
|
|
|
|
|
// 查询订单是否存在
|
|
|
|
|
ProOrder proOrder = proOrderMapper.selectProOrderByOrderCode(order.getOrderCode());
|
|
|
|
|
// 如果存在
|
|
|
|
|
if (proOrder != null) {
|
|
|
|
|
// 通过订单Code查询该订单下的所有工单id-用于删除批次表
|
|
|
|
|
List<ProOrderWorkorder> childWorkOrderList = proOrderWorkorderMapper.selectWorkOrderByOrderCode(proOrder.getOrderCode());
|
|
|
|
|
// 存在工单
|
|
|
|
|
if (childWorkOrderList.size() > 0){
|
|
|
|
|
// 将获得的工单id封装
|
|
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
|
|
for (ProOrderWorkorder workOrder : childWorkOrderList) {
|
|
|
|
|
ids.add(workOrder.getWorkorderId());
|
|
|
|
|
}
|
|
|
|
|
String[] workorderIds = (String[])ids.toArray(new String[ids.size()]);
|
|
|
|
|
|
|
|
|
|
// 删除所有该订单下的工单
|
|
|
|
|
proOrderWorkorderMapper.deleteProOrderWorkorderByOrderId(proOrder.getId());
|
|
|
|
|
// 删除工单下的所有批次表信息
|
|
|
|
|
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新字段
|
|
|
|
|
order.setStatus("o0");
|
|
|
|
|
order.setQuantitySplit(0L);
|
|
|
|
|
order.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
order.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
// 通过订单号code更新订单信息
|
|
|
|
|
proOrderMapper.updateProOrderByOrderCode(order);
|
|
|
|
|
} else {
|
|
|
|
|
// 创建字段
|
|
|
|
|
order.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
// 更新字段
|
|
|
|
|
order.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
order.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
// 不存在则创建
|
|
|
|
|
order.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
order.setOrderType(order.getProdType());
|
|
|
|
|
order.setParentOrder("0");
|
|
|
|
|
proOrderMapper.insertProOrder(order);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success("信息导入成功");
|
|
|
|
|
String info = syncImportFunc(orderList);
|
|
|
|
|
return success("信息导入完成。其中导入失败订单:"+info);
|
|
|
|
|
}
|
|
|
|
|
// 校验失败
|
|
|
|
|
return checkResult;
|
|
|
|
|