From 1801ac712294f0ca6ddd8ad132ab1231bb774085 Mon Sep 17 00:00:00 2001 From: zhaoxiaolin Date: Wed, 13 Mar 2024 21:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E5=9D=AF=E6=9C=BA=E7=9C=8B=E6=9D=BF?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E6=95=B0=E6=8D=AE+=E6=88=90=E5=93=81?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IWCInterfaceServiceImpl.java | 19 ++++- .../plan/controller/ProOrderController.java | 18 +++- .../com/op/plan/mapper/ProOrderMapper.java | 3 +- .../plan/mapper/ProOrderWorkorderMapper.java | 6 ++ .../com/op/plan/service/IProOrderService.java | 2 + .../service/impl/ProOrderServiceImpl.java | 82 +++++++++++++++++++ .../resources/mapper/plan/ProOrderMapper.xml | 8 +- .../mapper/plan/ProOrderWorkorderMapper.xml | 34 ++++++++ 8 files changed, 168 insertions(+), 4 deletions(-) diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java index 349343ef..83c28596 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java @@ -191,9 +191,26 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { totals = mesMapper.getTotalNum(boardDTO); everys = mesMapper.getEveryNum(boardDTO); } - + /**质量看板测试开始**/ + if("equ_type_spj".equals(boardDTO.getEquTypeCode())){ + boardDTO.setEquTypeCode("equ_type_hf"); + totals = mesMapper.getTotalNum(boardDTO); + for(BoardDTO total:totals){ + total.setTotalNum(total.getTotalNum()-2); + total.setEquTypeCode(total.getEquTypeCode().replace("H","X")); + total.setEquTypeName(total.getEquTypeName().replace("烘房","收坯机")); + } + everys = mesMapper.getEveryNum(boardDTO); + for(BoardDTO every:everys){ + every.setTotalNum(every.getTotalNum()-2); + every.setEquCode(every.getEquCode().replace("H","X")); + every.setEquName(every.getEquName().replace("烘房","收坯机")); + } + } + /**质量看板测试结束**/ boardMap.put("totalNum", totals); boardMap.put("everyNum", everys); + return boardMap; } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java index adbc3918..d8bbab66 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java @@ -284,5 +284,21 @@ public class ProOrderController extends BaseController { public R syncSAPOrders() { return proOrderService.syncSAPOrders(); } - + /** + * 下发生产工单。workorderIds:母工单号 + */ + @RequiresPermissions("mes:pro:order:edit") + @Log(title = "关闭订单", businessType = BusinessType.OTHER) + @PostMapping("/deleteOrder/{orderIds}") + public AjaxResult deleteOrder(@PathVariable String[] orderIds) { + int m = proOrderService.deleteOrder(orderIds); + if(m==2){ + //有活动中的单 + return AjaxResult.error("订单拆分成的工单,已经进行生产,不允许关闭,请联系系统管理员!"); + }else if(m==1){ + return AjaxResult.success("订单关闭成功"); + }else{ + return AjaxResult.error(); + } + } } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java index 67b7ba88..0b0807e6 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java @@ -142,7 +142,8 @@ public interface ProOrderMapper { */ public List selectPackageLine(); - public void updateOrderBatch(@Param("workers") List workers); + public int updateOrderBatch(@Param("workers") List workers); + public int updateCloseOrderBatch(@Param("workers") List workers); /** * 通过id查询班次名称 diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java index 6749019c..a42f2eff 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java @@ -184,5 +184,11 @@ public interface ProOrderWorkorderMapper { ProOrderWorkorder getSonWorkOrder(ProOrderWorkorder whiteOrder); ProOrderWorkorder selectSonWorkOrder(String workorderCode); + + List getWorkOrderByOrders(@Param("orderIds")String[] orderIds); + + int deletePrepareBatch(@Param("workorders")List workorders); + + int deletePrepareDetailBatch(@Param("workorders")List workorders); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java b/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java index fa89f96d..2b098a57 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java @@ -141,4 +141,6 @@ public interface IProOrderService { AjaxResult getCascadeProOrder(String orderCode); int getProSortNo(ProOrder proOrder); + + int deleteOrder(String[] orderCodes); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java index 8e160ee4..04f47982 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java @@ -32,6 +32,7 @@ import com.op.system.api.RemoteSapService; import com.op.system.api.RemoteUserService; import com.op.system.api.domain.SysSapLog; import com.op.system.api.domain.SysUser; +import com.op.system.api.domain.sap.SapCloseOrderQuery; import com.op.system.api.domain.sap.SapShopOrderQuery; import com.op.system.api.model.SapProOrder; import org.apache.commons.lang3.time.DateFormatUtils; @@ -1084,6 +1085,87 @@ public class ProOrderServiceImpl implements IProOrderService { } return success(); } + + @Override + @DS("#header.poolName") + @Transactional(rollbackFor = Exception.class) + public int deleteOrder(String[] orderIds) { + //可以进行订单关闭的数据 + List checkWorkOrders = proOrderWorkorderMapper.getWorkOrderByOrders(orderIds); + if(checkWorkOrders.size() != orderIds.length){ + return 2; + } + for(ProOrderWorkorder workorder:checkWorkOrders){ + //要删除的工单id们 + List delteIds = new ArrayList<>(); + delteIds.add(workorder.getWorkorderId()); + //关闭订单用 + List ordercodes = new ArrayList<>(); + ordercodes.add(workorder.getWorkorderCodeSap()); + //删领料单用 + List workorderCodes = new ArrayList<>(); + workorderCodes.add(workorder.getWorkorderCode()); + //删除订单 + List workers = new ArrayList<>(); + workers.add(workorder); + ProOrderWorkorder topWork = workorder; + Boolean run = true; + while (run) { + //下级 + ProOrderWorkorder sonWorkers = proOrderWorkorderMapper.selectSonWorkOrder(topWork.getWorkorderCode()); + //有上级code + if (sonWorkers != null) { + workers.add(sonWorkers); + delteIds.add(sonWorkers.getWorkorderId()); + ordercodes.add(sonWorkers.getWorkorderCodeSap()); + workorderCodes.add(sonWorkers.getWorkorderCode()); + topWork.setWorkorderCode(sonWorkers.getWorkorderCode()); + } else { + run = false; + } + } + + //调用sap订单关闭接口 + //关闭母子订单//订单的订单编码(关闭订单暂时隐藏) + SapCloseOrderQuery sapCloseOrderQuery = new SapCloseOrderQuery(); + sapCloseOrderQuery.setOrderCodes(ordercodes); + R closeR= remoteSapService.sapCloseOrder(sapCloseOrderQuery); + logger.info(workorderCodes.get(0)+"删除订单后关闭订单"+ + JSONObject.toJSONString(sapCloseOrderQuery)+ + closeR.getCode()+","+ + closeR.getMsg()+","+ + closeR.getData()); + //if(closeR.getCode()==200){ + String[] workorderIds = (String[]) delteIds.toArray(new String[delteIds.size()]); + if (workorderIds.length > 0) { + //删除工单(字母)pro_order_workorder + int m1 = proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(workorderIds); + logger.info(workorderCodes.get(0)+"删除订单m1:"+m1); + //删除批次pro_order_workorder_batch + int m2 = proOrderWorkorderBatchMapper.deleteBatch(workorderIds); + logger.info(workorderCodes.get(0)+"删除订单m2:"+m2); + //删除领料单mes_prepare + int m3 = proOrderWorkorderMapper.deletePrepareBatch(workorderCodes); + logger.info(workorderCodes.get(0)+"删除订单m3:"+m3); + //删除领料单明细mes_prepare_detail + int m4 = proOrderWorkorderMapper.deletePrepareDetailBatch(workorderCodes); + logger.info(workorderCodes.get(0)+"删除订单m4:"+m4); + } + + if (!CollectionUtils.isEmpty(workers)) { + //删除订单pro_order + int m5 = proOrderMapper.updateCloseOrderBatch(workers); + logger.info(workorderCodes.get(0)+"删除订单m5:"+m5); + } +// }else{ +// logger.info(workorder.getWorkorderCode()+"删除订单后关闭订单sap返回结果:"+ +// JSONObject.toJSONString(closeR)); +// return 0; +// } + } + return 1; + } + public static void main(String args[]){ String arrayStr = "[[\"GX01\",\"LG1\"],[\"GX01\",\"LG2\"],[\"GX02\",\"S1\"],[\"GX02\",\"S2\"],[\"GX03\",\"HF01\"],[\"GX04\",\"SPJ01\"]]"; JSONArray jsonArray = JSONArray.parseArray(arrayStr); diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml index 4e810034..9542f4f8 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml @@ -321,7 +321,13 @@ where id = #{worker.orderId} - + + + update pro_order set del_flag = '1', + update_time = GETDATE() + where id = #{worker.orderId} + + update pro_order diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml index 2528e57a..37eb1ed2 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml @@ -507,6 +507,22 @@ from pro_wet_material_plan_detail where workorder_id = #{workorderId} and del_flag = '0' + insert into mes_prepare_detail @@ -705,4 +721,22 @@ #{orderId} + + update mes_prepare + set del_flag = '1', + update_time = GETDATE() + where workorder_code in + + #{workorder} + + + + update mes_prepare_detail + set del_flag = '1', + update_time = GETDATE() + where parent_work_order in + + #{workorder} + +