计划问题修改

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);
/**回传sap母工单**/
@PostMapping("/sap/SapCreateOrder")
@PostMapping("/sap/sapCreateOrder")
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.utils.DateUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.plan.domain.dto.SplitOrderDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -83,15 +84,19 @@ public class ProOrderController extends BaseController {
List<ProOrder> orderList = new ArrayList<>();
ProOrder example = new ProOrder();
example.setPlanFactoryCode("000000");
example.setOrderType("LJ01");
example.setOrderCode("000000");
example.setProdCode("000000");
example.setProdDesc("物料名称样例");
example.setQuantity(100L);
example.setUnit("BP");
example.setProdType("white");
example.setUnit("KAR");
example.setWorkerOrder("510000");
example.setProdType("prod");
example.setStatus("o0");
example.setParentOrder("1000000");
example.setPlanComplete(DateUtils.getNowDate());
example.setPlanProDate(DateUtils.getNowDate());
example.setCreateBy(SecurityUtils.getUsername());
example.setCreateTime(DateUtils.getNowDate());
example.setUpdateTime(DateUtils.getNowDate());
orderList.add(example);
@ -218,18 +223,6 @@ public class ProOrderController extends BaseController {
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;
/** 订单类型 */
@Excel(name = "订单类型")
private String orderType;
/** 订单号 */
@ -55,6 +56,7 @@ public class ProOrder extends TreeEntity {
private String unit;
/** 任务清单 */
@Excel(name = "任务清单")
private String workerOrder;
private String bomBo;
@ -99,6 +101,7 @@ public class ProOrder extends TreeEntity {
private String status;
/** 上级工单 */
@Excel(name = "父级订单")
private String parentOrder;
public String getPlanFactoryCode() {

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

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

@ -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,47 +409,65 @@ 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);
//pro_order_workorder
Date nowDate = DateUtils.getNowDate();
ProOrder orderExit = proOrderMapper.selectProOrderByOrderCode(proOrder.getOrderCode());
if (orderExit==null) {//不存在就插入
proOrder.setId(IdUtils.fastSimpleUUID());
//proOrder.setCreateTime(nowDate);
proOrder.setCreateBy(SecurityUtils.getUsername());
proOrderMapper.insertProOrder(proOrder);
} else {//存在,如果没活动更新,否则不允许更新,关闭订单
proOrder.setId(orderExit.getId());
proOrder.setQuantitySplit(0L);
ProOrderWorkorder owork = new ProOrderWorkorder();
owork.setOrderCode(proOrder.getOrderCode());
owork.setStatusArray("'w2','w3','w4'");//已派发w1未派w0活动w2报工w3暂停w4
List<ProOrderWorkorder> workOrders = proOrderWorkorderMapper.selectProOrderWorkorderList(owork);
if (CollectionUtils.isEmpty(workOrders)) {//更新
proOrder.setUpdateTime(nowDate);
proOrder.setUpdateBy(SecurityUtils.getUsername());
//如果工单没下达则更新pro_order
proOrderMapper.updateProOrder(proOrder);
List<ProOrder> orderCodes = this.getListByPCode(proOrder);
if (!CollectionUtils.isEmpty(orderCodes)) {
List<String> idstr = orderCodes.stream().map(order -> order.getId()).collect(Collectors.toList());
String[] ids = idstr.stream().toArray(String[]::new);
//删除批次pro_order_workorder_batch
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(ids);
//删除工单pro_order_workorder
proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(ids);
}
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());
if (orderExit==null) {//不存在就插入
proOrder.setId(IdUtils.fastSimpleUUID());
//proOrder.setCreateTime(nowDate);
proOrder.setCreateBy(SecurityUtils.getUsername());
proOrderMapper.insertProOrder(proOrder);
} else {//存在,如果没活动更新,否则不允许更新,关闭订单
proOrder.setId(orderExit.getId());
proOrder.setQuantitySplit(0L);
ProOrderWorkorder owork = new ProOrderWorkorder();
owork.setOrderCode(proOrder.getOrderCode());
owork.setStatusArray("'w2','w3','w4'");//已派发w1未派w0活动w2报工w3暂停w4
List<ProOrderWorkorder> workOrders = proOrderWorkorderMapper.selectProOrderWorkorderList(owork);
if (CollectionUtils.isEmpty(workOrders)) {//更新
proOrder.setUpdateTime(nowDate);
proOrder.setUpdateBy(SecurityUtils.getUsername());
//如果工单没下达则更新pro_order
proOrderMapper.updateProOrder(proOrder);
List<ProOrder> orderCodes = this.getListByPCode(proOrder);
if (!CollectionUtils.isEmpty(orderCodes)) {
List<String> idstr = orderCodes.stream().map(order -> order.getId()).collect(Collectors.toList());
String[] ids = idstr.stream().toArray(String[]::new);
//删除批次pro_order_workorder_batch
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(ids);
//删除工单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;

@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
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.success;
@ -204,7 +205,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
@Transactional(rollbackFor = Exception.class)
public int downProOrderWorkorderByWorkorderIds(String[] workorderIds) {
List<String> ids = new ArrayList<>();
List<ProOrder> psorders = new ArrayList<>();//父级工单
List<SapCreateOrder> sapList = null;//回传给sap的工单
//如果是白坯生成备料单
for (String workorderId : workorderIds) {
@ -244,7 +245,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
}else{
//无湿料计划,下发不了
}
} else if (whiteOrder != null) {//成品的母工单回传sap
} else if (whiteOrder != null && !"white".equals(whiteOrder.getProdType())) {//成品的母工单回传sap
sapList = new ArrayList<>();
SapCreateOrder sap = new SapCreateOrder();
sap.setWerks(whiteOrder.getFactoryCode());//工厂编码
@ -280,8 +281,16 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
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)){
@ -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;
}
//子查父递归
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) {
// 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'
</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 bst.Shift_Id shiftId,bst.Shift_Desc_Global shiftDesc
SELECT bst.Shift_Id shiftId,bst.Shift_Desc shiftDesc
FROM base_shifts_t bst
</select>

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

Loading…
Cancel
Save