计划问题修改

highway
zhaoxiaolin 1 year ago
parent 00a06d2898
commit f92e75d11f

@ -35,7 +35,7 @@ public interface RemoteSapService {
public R<List<SapMaterialPreparation>>materialPreparation(@RequestParam("shopOrder") String shopOrder); public R<List<SapMaterialPreparation>>materialPreparation(@RequestParam("shopOrder") String shopOrder);
/**回传sap母工单**/ /**回传sap母工单**/
@PostMapping("/sap/SapCreateOrder") @PostMapping("/sap/sapCreateOrder")
public R<List<String>> SapCreateOrder(@RequestBody List<SapCreateOrder> sapCreateOrderList); public R<List<String>> SapCreateOrder(@RequestBody List<SapCreateOrder> sapCreateOrderList);
/**关闭订单**/ /**关闭订单**/

@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse;
import com.op.common.core.domain.R; import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.DateUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.plan.domain.dto.SplitOrderDTO; import com.op.plan.domain.dto.SplitOrderDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -83,15 +84,19 @@ public class ProOrderController extends BaseController {
List<ProOrder> orderList = new ArrayList<>(); List<ProOrder> orderList = new ArrayList<>();
ProOrder example = new ProOrder(); ProOrder example = new ProOrder();
example.setPlanFactoryCode("000000"); example.setPlanFactoryCode("000000");
example.setOrderType("LJ01");
example.setOrderCode("000000"); example.setOrderCode("000000");
example.setProdCode("000000"); example.setProdCode("000000");
example.setProdDesc("物料名称样例"); example.setProdDesc("物料名称样例");
example.setQuantity(100L); example.setQuantity(100L);
example.setUnit("BP"); example.setUnit("KAR");
example.setProdType("white"); example.setWorkerOrder("510000");
example.setProdType("prod");
example.setStatus("o0"); example.setStatus("o0");
example.setParentOrder("1000000");
example.setPlanComplete(DateUtils.getNowDate()); example.setPlanComplete(DateUtils.getNowDate());
example.setPlanProDate(DateUtils.getNowDate()); example.setPlanProDate(DateUtils.getNowDate());
example.setCreateBy(SecurityUtils.getUsername());
example.setCreateTime(DateUtils.getNowDate()); example.setCreateTime(DateUtils.getNowDate());
example.setUpdateTime(DateUtils.getNowDate()); example.setUpdateTime(DateUtils.getNowDate());
orderList.add(example); orderList.add(example);
@ -218,18 +223,6 @@ public class ProOrderController extends BaseController {
return toAjax(proOrderService.insertProOrder(proOrder)); return toAjax(proOrderService.insertProOrder(proOrder));
} }
/**
* SAP
*
* @param proOrderList
* @return
*/
@Log(title = "同步SAP订单", businessType = BusinessType.INSERT)
@PostMapping("/shopOrderSync")
public void shopOrderSync(List<ProOrder> proOrderList) {
proOrderService.shopOrderSync(proOrderList);
}
/** /**
* *

@ -28,6 +28,7 @@ public class ProOrder extends TreeEntity {
private String factoryCode; private String factoryCode;
/** 订单类型 */ /** 订单类型 */
@Excel(name = "订单类型")
private String orderType; private String orderType;
/** 订单号 */ /** 订单号 */
@ -55,6 +56,7 @@ public class ProOrder extends TreeEntity {
private String unit; private String unit;
/** 任务清单 */ /** 任务清单 */
@Excel(name = "任务清单")
private String workerOrder; private String workerOrder;
private String bomBo; private String bomBo;
@ -99,6 +101,7 @@ public class ProOrder extends TreeEntity {
private String status; private String status;
/** 上级工单 */ /** 上级工单 */
@Excel(name = "父级订单")
private String parentOrder; private String parentOrder;
public String getPlanFactoryCode() { public String getPlanFactoryCode() {

@ -116,6 +116,8 @@ public interface ProOrderMapper {
*/ */
List<ProOrder> selectChildProOrderByCode(String orderCode); List<ProOrder> selectChildProOrderByCode(String orderCode);
List<ProOrder> selectParentProOrderByCode(String parentOrder);
/** /**
* code线 * code线
* *

@ -97,13 +97,6 @@ public interface IProOrderService {
public AjaxResult getOrderList(String id); public AjaxResult getOrderList(String id);
/**
* SAP
* @param proOrderList
*/
void shopOrderSync(List<ProOrder> proOrderList);
public AjaxResult syncSAP(); public AjaxResult syncSAP();
/** /**

@ -381,21 +381,6 @@ public class ProOrderServiceImpl implements IProOrderService {
return success(proOrder); 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 * sap
*/ */
@ -424,12 +409,28 @@ public class ProOrderServiceImpl implements IProOrderService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void syncSAPFunc(List<SapProOrder> newOrders){ public String syncSAPFunc(List<SapProOrder> newOrders){
String failOrder = "";
ProOrder proOrder = null; ProOrder proOrder = null;
for (SapProOrder sapProOrder:newOrders) { for (SapProOrder sapProOrder:newOrders) {
//工单下达后整个订单就被锁定//订单存在就更新,不存在就插入 //工单生产后整个订单就被锁定//订单存在就更新,不存在就插入
proOrder = new ProOrder(); proOrder = new ProOrder();
BeanUtils.copyProperties(sapProOrder, 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 //pro_order_workorder
Date nowDate = DateUtils.getNowDate(); Date nowDate = DateUtils.getNowDate();
ProOrder orderExit = proOrderMapper.selectProOrderByOrderCode(proOrder.getOrderCode()); ProOrder orderExit = proOrderMapper.selectProOrderByOrderCode(proOrder.getOrderCode());
@ -459,12 +460,14 @@ public class ProOrderServiceImpl implements IProOrderService {
//删除工单pro_order_workorder //删除工单pro_order_workorder
proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(ids); proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(ids);
} }
}else{
failOrder = proOrder.getOrderCode();
} }
// else {//关闭订单 // else {//关闭订单
// remoteSapService.sapCloseOrder(proOrder.getOrderCode()); // remoteSapService.sapCloseOrder(proOrder.getOrderCode());
// } // }
} }
} return failOrder;
} }
//父查子递归 //父查子递归
@ -478,6 +481,7 @@ public class ProOrderServiceImpl implements IProOrderService {
return codeList; return codeList;
} }
/** /**
* *
* *
@ -492,81 +496,8 @@ public class ProOrderServiceImpl implements IProOrderService {
AjaxResult checkResult = checkImportOrder(orderList); AjaxResult checkResult = checkImportOrder(orderList);
// 如果数据校验成功 // 如果数据校验成功
if (checkResult.isSuccess()) { if (checkResult.isSuccess()) {
// 校验数据是否可编辑 String info = syncImportFunc(orderList);
boolean checkEdit = false; return success("信息导入完成。其中导入失败订单:"+info);
// 反馈数据
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("信息导入成功");
} }
// 校验失败 // 校验失败
return checkResult; return checkResult;

@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static com.op.common.core.web.domain.AjaxResult.error; import static com.op.common.core.web.domain.AjaxResult.error;
import static com.op.common.core.web.domain.AjaxResult.success; import static com.op.common.core.web.domain.AjaxResult.success;
@ -204,7 +205,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int downProOrderWorkorderByWorkorderIds(String[] workorderIds) { public int downProOrderWorkorderByWorkorderIds(String[] workorderIds) {
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
List<ProOrder> psorders = new ArrayList<>();//父级工单
List<SapCreateOrder> sapList = null;//回传给sap的工单 List<SapCreateOrder> sapList = null;//回传给sap的工单
//如果是白坯生成备料单 //如果是白坯生成备料单
for (String workorderId : workorderIds) { for (String workorderId : workorderIds) {
@ -244,7 +245,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
}else{ }else{
//无湿料计划,下发不了 //无湿料计划,下发不了
} }
} else if (whiteOrder != null) {//成品的母工单回传sap } else if (whiteOrder != null && !"white".equals(whiteOrder.getProdType())) {//成品的母工单回传sap
sapList = new ArrayList<>(); sapList = new ArrayList<>();
SapCreateOrder sap = new SapCreateOrder(); SapCreateOrder sap = new SapCreateOrder();
sap.setWerks(whiteOrder.getFactoryCode());//工厂编码 sap.setWerks(whiteOrder.getFactoryCode());//工厂编码
@ -280,10 +281,18 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
logger.info("sap工单回传sap虚拟工单号" + sapCode); logger.info("sap工单回传sap虚拟工单号" + sapCode);
} }
//子查父工单,都要工单状态改下发
ProOrder pOrder = new ProOrder();
pOrder.setParentOrder(workorderId);
List<ProOrder> pordes = getListBySonCode(pOrder);
if(!CollectionUtils.isEmpty(pordes)){
psorders.addAll(pordes);
} }
ids.add(workorderId); ids.add(workorderId);
} }
} }
}
if(!CollectionUtils.isEmpty(ids)){ if(!CollectionUtils.isEmpty(ids)){
String[] idsArray = (String[])ids.toArray(new String[ids.size()]); String[] idsArray = (String[])ids.toArray(new String[ids.size()]);
List<ProOrderWorkorder> workorders = proOrderWorkorderMapper.getWorkOrderByIds(idsArray); List<ProOrderWorkorder> workorders = proOrderWorkorderMapper.getWorkOrderByIds(idsArray);
@ -304,13 +313,29 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
} }
} }
} }
//下达工单 //下达工单
return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(idsArray); if(!CollectionUtils.isEmpty(psorders)){
List<String> pcodes = psorders.stream().map(e -> e.getOrderCode()).collect(Collectors.toList());
ids.addAll(pcodes);
}
String[] idsArrayAll = (String[])ids.toArray(new String[ids.size()]);
//下达工单
return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(idsArrayAll);
} }
return 0; return 0;
} }
//子查父递归
public List<ProOrder> getListBySonCode(ProOrder pOrder) {
List<ProOrder> codeList = new ArrayList<>();
codeList.add(pOrder);
List<ProOrder> parentOrder = proOrderMapper.selectParentProOrderByCode(pOrder.getParentOrder());
if (!CollectionUtils.isEmpty(parentOrder)) {
getListBySonCode(parentOrder.get(0));
}
return codeList;
}
// //获取最低级材料 // //获取最低级材料
// private void getLastChildren(List<BaseBomComponentDTO> all, List<BaseBomComponentDTO> allChildren , BaseBomComponentDTO bc) { // private void getLastChildren(List<BaseBomComponentDTO> all, List<BaseBomComponentDTO> allChildren , BaseBomComponentDTO bc) {
// List<BaseBomComponentDTO> cList = all.stream().filter(item -> item.getCumc().equals(bc.getComponent())) // List<BaseBomComponentDTO> cList = all.stream().filter(item -> item.getCumc().equals(bc.getComponent()))

@ -85,8 +85,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where parent_order = #{orderCode} and del_flag = '0' where parent_order = #{orderCode} and del_flag = '0'
</select> </select>
<select id="selectParentProOrderByCode" parameterType="String" resultMap="ProOrderResult">
<include refid="selectProOrderVo"/>
where order_code = #{parentOrder} and del_flag = '0'
</select>
<select id="selectProShift" resultType="com.op.plan.domain.ProShift"> <select id="selectProShift" resultType="com.op.plan.domain.ProShift">
SELECT bst.Shift_Id shiftId,bst.Shift_Desc_Global shiftDesc SELECT bst.Shift_Id shiftId,bst.Shift_Desc shiftDesc
FROM base_shifts_t bst FROM base_shifts_t bst
</select> </select>

@ -40,7 +40,7 @@ public class QuaController extends BaseController {
remoteMesService.requestDestinationStations(wcsdto); remoteMesService.requestDestinationStations(wcsdto);
return R.ok(); return R.ok();
} }
return R.fail(); return R.ok();
} }
/** /**

Loading…
Cancel
Save