diff --git a/.gitignore b/.gitignore index 65e334d1..2b4a2e55 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /**/logs/* /**/.settings/* /**/.node_modules/* -/**/*.idea \ No newline at end of file +/**/*.idea +/**/*.iml \ No newline at end of file diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteSapService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteSapService.java index 3e22efaf..b029df80 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteSapService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteSapService.java @@ -7,6 +7,8 @@ import com.op.system.api.factory.RemoteSapFallbackFactory; import com.op.system.api.model.SapProOrder; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; /** @@ -18,12 +20,12 @@ import java.util.List; public interface RemoteSapService { @PostMapping("/sap/shopOrderSync") - public R> shopOrderSync(SapProOrder sapProOrder); + public R> shopOrderSync(@RequestBody SapProOrder sapProOrder); @PostMapping("/bomSync") public R bomSync(); @PostMapping("/sap/sapProRouteProcess") public R sapProRouteProcess(); @PostMapping("/sap/materialPreparation") - public R>materialPreparation(SapMaterialPreparation sapMaterialPreparation); + public R>materialPreparation(@RequestParam("shopOrder") String shopOrder); } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteSapFallbackFactory.java b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteSapFallbackFactory.java index b3fc47eb..59e4890d 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteSapFallbackFactory.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteSapFallbackFactory.java @@ -7,6 +7,7 @@ import com.op.system.api.model.SapProOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -32,7 +33,7 @@ public class RemoteSapFallbackFactory implements FallbackFactory> materialPreparation(SapMaterialPreparation sapMaterialPreparation) { + public R> materialPreparation(String shopOrder) { return R.fail("SAP服务获取SAP领料单失败:" + throwable.getMessage()); } }; diff --git a/op-modules/op-job/src/main/java/com/op/job/task/RyTask.java b/op-modules/op-job/src/main/java/com/op/job/task/RyTask.java index d3804837..e97e5458 100644 --- a/op-modules/op-job/src/main/java/com/op/job/task/RyTask.java +++ b/op-modules/op-job/src/main/java/com/op/job/task/RyTask.java @@ -1,6 +1,11 @@ package com.op.job.task; +import com.op.common.core.domain.R; +import com.op.common.core.utils.DateUtils; +import com.op.common.core.web.domain.AjaxResult; import com.op.system.api.RemoteMesService; +import com.op.system.api.RemoteSapService; +import com.op.system.api.model.SapProOrder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.op.common.core.utils.StringUtils; @@ -16,6 +21,9 @@ public class RyTask { @Autowired private RemoteMesService remoteMesService; + @Autowired + private RemoteSapService remoteSapService; + public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); } @@ -28,6 +36,16 @@ public class RyTask { System.out.println("执行无参方法"); } + public void shopOrderSync(){ + SapProOrder sapProOrder=new SapProOrder(); + sapProOrder.setCreateTime(DateUtils.getNowDate()); + remoteSapService.shopOrderSync(sapProOrder); + } + + /**每天23点执行 + * 今天凌晨16点出明天的领料单 + * 0 0 23 * * ? + */ public void getMesPrepareTask(){ System.out.println("++同步领料单+开始++getMesPrepareTask+++++"); remoteMesService.getMesPrepare(); diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesPrepare.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesPrepare.java index 742d746b..e000f3c4 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesPrepare.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesPrepare.java @@ -9,7 +9,7 @@ import com.op.common.core.web.domain.BaseEntity; /** * 备料单对象 mes_prepare - * + * * @author Open Platform * @date 2023-08-03 */ @@ -119,6 +119,17 @@ public class MesPrepare extends BaseEntity { /** 工厂编码 */ @Excel(name = "工厂编码") private String factoryCode; + + private String dayStr; + + public String getDayStr() { + return dayStr; + } + + public void setDayStr(String dayStr) { + this.dayStr = dayStr; + } + public String getMaterialCode() { return materialCode; } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java index 4e10490b..57aba9a8 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java @@ -6,14 +6,14 @@ import com.op.mes.domain.MesPrepare; /** * 备料单Mapper接口 - * + * * @author Open Platform * @date 2023-08-03 */ public interface MesPrepareMapper { /** * 查询备料单 - * + * * @param prepareId 备料单主键 * @return 备料单 */ @@ -21,7 +21,7 @@ public interface MesPrepareMapper { /** * 查询备料单列表 - * + * * @param mesPrepare 备料单 * @return 备料单集合 */ @@ -29,7 +29,7 @@ public interface MesPrepareMapper { /** * 新增备料单 - * + * * @param mesPrepare 备料单 * @return 结果 */ @@ -37,7 +37,7 @@ public interface MesPrepareMapper { /** * 修改备料单 - * + * * @param mesPrepare 备料单 * @return 结果 */ @@ -45,7 +45,7 @@ public interface MesPrepareMapper { /** * 删除备料单 - * + * * @param prepareId 备料单主键 * @return 结果 */ @@ -53,9 +53,11 @@ public interface MesPrepareMapper { /** * 批量删除备料单 - * + * * @param prepareIds 需要删除的数据主键集合 * @return 结果 */ public int deleteMesPrepareByPrepareIds(String[] prepareIds); + + public List getParentWorkOrderT1(MesPrepare qo); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java index 9dbed40f..99a4a442 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java @@ -1,5 +1,6 @@ package com.op.mes.service.impl; +import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.*; import java.util.stream.Collectors; @@ -25,6 +26,8 @@ import org.springframework.stereotype.Service; import com.op.mes.mapper.MesPrepareMapper; import com.op.mes.domain.MesPrepare; import com.op.mes.service.IMesPrepareService; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.RequestParam; /** * 备料单Service业务层处理 @@ -34,183 +37,201 @@ import com.op.mes.service.IMesPrepareService; */ @Service public class MesPrepareServiceImpl implements IMesPrepareService { - protected Logger logger = LoggerFactory.getLogger(getClass()); - @Autowired - private MesPrepareMapper mesPrepareMapper; - @Autowired - private RemoteSapService remoteSapService; - @Autowired - private RemoteUserService remoteUserService; - @Autowired - private MesPrepareDetailMapper mesPrepareDetailMapper; - /** - * 查询备料单 - * - * @param prepareId 备料单主键 - * @return 备料单 - */ - @Override - @DS("#header.poolName") - public MesPrepare selectMesPrepareByPrepareId(String prepareId) { - return mesPrepareMapper.selectMesPrepareByPrepareId(prepareId); - } - - /** - * 查询备料单列表 - * - * @param mesPrepare 备料单 - * @return 备料单 - */ - @Override - @DS("#header.poolName") - public List selectMesPrepareList(MesPrepare mesPrepare) { - return mesPrepareMapper.selectMesPrepareList(mesPrepare); - } - - /** - * 新增备料单 - * - * @param mesPrepare 备料单 - * @return 结果 - */ - @Override - @DS("#header.poolName") - public int insertMesPrepare(MesPrepare mesPrepare) { - mesPrepare.setCreateTime(DateUtils.getNowDate()); - return mesPrepareMapper.insertMesPrepare(mesPrepare); - } - - /** - * 修改备料单 - * - * @param mesPrepare 备料单 - * @return 结果 - */ - @Override - @DS("#header.poolName") - public int updateMesPrepare(MesPrepare mesPrepare) { - mesPrepare.setUpdateTime(DateUtils.getNowDate()); - return mesPrepareMapper.updateMesPrepare(mesPrepare); - } - - /** - * 批量删除备料单 - * - * @param prepareIds 需要删除的备料单主键 - * @return 结果 - */ - @Override - @DS("#header.poolName") - public int deleteMesPrepareByPrepareIds(String[] prepareIds) { - return mesPrepareMapper.deleteMesPrepareByPrepareIds(prepareIds); - } - - /** - * 删除备料单信息 - * - * @param prepareId 备料单主键 - * @return 结果 - */ - @Override - @DS("#header.poolName") - public int deleteMesPrepareByPrepareId(String prepareId) { - return mesPrepareMapper.deleteMesPrepareByPrepareId(prepareId); - } - - @Override - public R getMesPrepare() { - SapMaterialPreparation qo = new SapMaterialPreparation(); - - List sapMaterialPreparationList = remoteSapService.materialPreparation(qo).getData(); - // 加载sf-cloud库的sys_datasource - SysUser sysUser = new SysUser(); - sysUser.setUserId(1L); - R>> dateSources0 = remoteUserService.getPoolNameList(sysUser); - List> dateSources = dateSources0.getData(); - ExecutorService executorService = new ThreadPoolExecutor( - dateSources.size(), - dateSources.size(), - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue()); - try{ - dateSources.forEach(dateSource ->{ - logger.info("++++++++++++"+dateSource.get("poolName")+"++++开始++++++++++"); - Runnable run = () -> getMesPrepareByFactory(dateSource.get("poolName"),sapMaterialPreparationList); - executorService.execute(run); - }); - }catch (Exception e){ - logger.error("service == deviceOfflineTimingTask == exception", e); - return R.fail("service == deviceOfflineTimingTask == exception"); - }finally { - executorService.shutdown(); - } - return R.ok(true); - } - public void getMesPrepareByFactory(String poolName, List sapMaterialPreparationList) { - DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key - List list = sapMaterialPreparationList.stream() - .filter(a->a.getWERKS().equals(poolName)) - .collect(Collectors.toList()); - - //取出各单位集合中所有单位名称 - Set orderCodes = list.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet()); - for(String orderCode : orderCodes){ - /**mes_prepare**/ - String mesPrepareId = IdUtils.fastSimpleUUID(); - MesPrepare mesPrepare = new MesPrepare(); - mesPrepare.setPrepareId(mesPrepareId); - mesPrepare.setWorkorderCode(orderCode);//工单(子) - mesPrepare.setCreateTime(DateUtils.getNowDate()); - mesPrepare.setCreateBy(SecurityUtils.getUsername()); - mesPrepare.setStatus("L0");//默认待确认 - mesPrepareMapper.insertMesPrepare(mesPrepare); - /**mes_prepare_detail**/ - List details = new ArrayList<>(); - List listdetails = list.stream() - .filter(a->a.getAUFNR().equals(orderCode)) - .collect(Collectors.toList()); - MesPrepareDetail detail = null; - Date createDate = DateUtils.getNowDate(); - for(SapMaterialPreparation sap:listdetails){ - detail = new MesPrepareDetail(); - detail.setPrepareId(mesPrepareId); - detail.setRecordId(IdUtils.fastSimpleUUID()); - detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号 - detail.setMaterialCode(sap.getMATNR());//物料号 - detail.setMaterailName(sap.getMAKTX());//物料描述(短文本) - detail.setFactoryCode(sap.getWERKS());//工厂 - detail.setLocator(sap.getLGORT());//库存地点 - detail.setNeedDate(sap.getBDTER());//组件的需求日期 - detail.setQuantity(sap.getBDMNG());////需求量 - detail.setFundQuanlity(sap.getZQLSL());//欠料数量 - detail.setUnit(sap.getMEINS());//基本计量单位 - detail.setRecoil(sap.getRGEKZ());//反冲标识 - detail.setBuyFlag(sap.getDBSKZ());//直接采购标识 - detail.setCreateBy(SecurityUtils.getUsername()); - detail.setCreateTime(createDate); - details.add(detail); - } - mesPrepareDetailMapper.insertMesPrepareDetails(details); - } - - } - - public static void main(String args[]){ - List list = new ArrayList<>(); - SapMaterialPreparation p1 = new SapMaterialPreparation(); - p1.setAUFNR("1001"); - p1.setWERKS("1001a"); - list.add(p1); - SapMaterialPreparation p2 = new SapMaterialPreparation(); - p2.setAUFNR("1001"); - p2.setWERKS("1001b"); - list.add(p2); - SapMaterialPreparation p3 = new SapMaterialPreparation(); - p3.setAUFNR("1002"); - p3.setWERKS("1002a"); - list.add(p3); - //取出各单位集合中所有单位名称 - Set orderCodes = list.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet()); - System.out.println(JSON.toJSONString(orderCodes)); - } + protected Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired + private MesPrepareMapper mesPrepareMapper; + @Autowired + private RemoteSapService remoteSapService; + @Autowired + private RemoteUserService remoteUserService; + @Autowired + private MesPrepareDetailMapper mesPrepareDetailMapper; + + /** + * 查询备料单 + * + * @param prepareId 备料单主键 + * @return 备料单 + */ + @Override + @DS("#header.poolName") + public MesPrepare selectMesPrepareByPrepareId(String prepareId) { + return mesPrepareMapper.selectMesPrepareByPrepareId(prepareId); + } + + /** + * 查询备料单列表 + * + * @param mesPrepare 备料单 + * @return 备料单 + */ + @Override + @DS("#header.poolName") + public List selectMesPrepareList(MesPrepare mesPrepare) { + return mesPrepareMapper.selectMesPrepareList(mesPrepare); + } + + /** + * 新增备料单 + * + * @param mesPrepare 备料单 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int insertMesPrepare(MesPrepare mesPrepare) { + mesPrepare.setCreateTime(DateUtils.getNowDate()); + return mesPrepareMapper.insertMesPrepare(mesPrepare); + } + + /** + * 修改备料单 + * + * @param mesPrepare 备料单 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int updateMesPrepare(MesPrepare mesPrepare) { + mesPrepare.setUpdateTime(DateUtils.getNowDate()); + return mesPrepareMapper.updateMesPrepare(mesPrepare); + } + + /** + * 批量删除备料单 + * + * @param prepareIds 需要删除的备料单主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteMesPrepareByPrepareIds(String[] prepareIds) { + return mesPrepareMapper.deleteMesPrepareByPrepareIds(prepareIds); + } + + /** + * 删除备料单信息 + * + * @param prepareId 备料单主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteMesPrepareByPrepareId(String prepareId) { + return mesPrepareMapper.deleteMesPrepareByPrepareId(prepareId); + } + + @Override + public R getMesPrepare() { + // 加载sf-cloud库的sys_datasource + SysUser sysUser = new SysUser(); + sysUser.setUserId(1L); + R>> dateSources0 = remoteUserService.getPoolNameList(sysUser); + List> dateSources = dateSources0.getData(); + ExecutorService executorService = new ThreadPoolExecutor( + dateSources.size(), + dateSources.size(), + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue()); + try { + dateSources.forEach(dateSource -> { + logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++"); + Runnable run = () -> getMesPrepareByFactory(dateSource.get("poolName")); + executorService.execute(run); + }); + } catch (Exception e) { + logger.error("service == deviceOfflineTimingTask == exception", e); + return R.fail("service == deviceOfflineTimingTask == exception"); + } finally { + executorService.shutdown(); + } + + + return R.ok(true); + } + + public void getMesPrepareByFactory(String poolName) { + DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key +// List list = sapMaterialPreparationList.stream() +// .filter(a->a.getWERKS().equals(poolName)) +// .collect(Collectors.toList()); + + //获取T+1天的所有母工单 + MesPrepare qo = new MesPrepare(); + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.DATE, 1);//这里改为1 + Date time = cal.getTime(); + qo.setDayStr(new SimpleDateFormat("yyyy-MM-dd").format(time)); + List parents = mesPrepareMapper.getParentWorkOrderT1(qo); + if (CollectionUtils.isEmpty(parents)) { + System.out.println("T+1无母工单数据"); + } + for (MesPrepare mesPrepare : parents) { + List sapMaterialPreparationList = remoteSapService.materialPreparation(mesPrepare.getWorkorderCode()).getData(); + if (CollectionUtils.isEmpty(sapMaterialPreparationList)) { + System.out.println("sap无领料单数据"); + } + //取出各领料单 + Set orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet()); + for (String orderCode : orderCodes) { + /**mes_prepare**/ + String mesPrepareId = IdUtils.fastSimpleUUID(); + MesPrepare mesPrepare0 = new MesPrepare(); + mesPrepare0.setPrepareId(mesPrepareId); + mesPrepare0.setWorkorderCode(orderCode);//工单(子) + mesPrepare0.setCreateTime(DateUtils.getNowDate()); + mesPrepare0.setCreateBy(SecurityUtils.getUsername()); + mesPrepare0.setStatus("L0");//默认待确认 + mesPrepareMapper.insertMesPrepare(mesPrepare0); + /**mes_prepare_detail**/ + List details = new ArrayList<>(); +// List listdetails = list.stream() +// .filter(a->a.getAUFNR().equals(orderCode)) +// .collect(Collectors.toList()); + MesPrepareDetail detail = null; + Date createDate = DateUtils.getNowDate(); + for (SapMaterialPreparation sap : sapMaterialPreparationList) { + detail = new MesPrepareDetail(); + detail.setPrepareId(mesPrepareId); + detail.setRecordId(IdUtils.fastSimpleUUID()); + detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号 + detail.setMaterialCode(sap.getMATNR());//物料号 + detail.setMaterailName(sap.getMAKTX());//物料描述(短文本) + detail.setFactoryCode(sap.getWERKS());//工厂 + detail.setLocator(sap.getLGORT());//库存地点 + detail.setNeedDate(sap.getBDTER());//组件的需求日期 + detail.setQuantity(sap.getBDMNG());////需求量 + detail.setFundQuanlity(sap.getZQLSL());//欠料数量 + detail.setUnit(sap.getMEINS());//基本计量单位 + detail.setRecoil(sap.getRGEKZ());//反冲标识 + detail.setBuyFlag(sap.getDBSKZ());//直接采购标识 + detail.setCreateBy(SecurityUtils.getUsername()); + detail.setCreateTime(createDate); + details.add(detail); + } + mesPrepareDetailMapper.insertMesPrepareDetails(details); + } + } + + + } + + public static void main(String args[]) { + List list = new ArrayList<>(); + SapMaterialPreparation p1 = new SapMaterialPreparation(); + p1.setAUFNR("1001"); + p1.setWERKS("1001a"); + list.add(p1); + SapMaterialPreparation p2 = new SapMaterialPreparation(); + p2.setAUFNR("1001"); + p2.setWERKS("1001b"); + list.add(p2); + SapMaterialPreparation p3 = new SapMaterialPreparation(); + p3.setAUFNR("1002"); + p3.setWERKS("1002a"); + list.add(p3); + //取出各单位集合中所有单位名称 + Set orderCodes = list.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet()); + System.out.println(JSON.toJSONString(orderCodes)); + } } diff --git a/op-modules/op-mes/src/main/resources/mapper/MesPrepareDetailMapper.xml b/op-modules/op-mes/src/main/resources/mapper/MesPrepareDetailMapper.xml index 53c269c2..4aa93c7a 100644 --- a/op-modules/op-mes/src/main/resources/mapper/MesPrepareDetailMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/MesPrepareDetailMapper.xml @@ -118,9 +118,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" )VALUES ( - #{list.recordId},#{list.prepareId},#{list.materialCode},#{list.materialName},#{list.unit}, - #{list.quantity},#{list.createBy},#{list.createTime},#{list.factoryCode},#{list.status}, - #{list.locator},#{list.needDate},#{list.recoil},#{list.fundQuanlity},#{list.buyFlag}, + #{d.recordId},#{d.prepareId},#{d.materialCode},#{d.materailName},#{d.unit}, + #{d.quantity},#{d.createBy},#{d.createTime},#{d.factoryCode},#{d.status}, + #{d.locator},#{d.needDate},#{d.recoil},#{d.fundQuanlity},#{d.buyFlag} ) diff --git a/op-modules/op-mes/src/main/resources/mapper/MesPrepareMapper.xml b/op-modules/op-mes/src/main/resources/mapper/MesPrepareMapper.xml index 1de2a32d..022986d1 100644 --- a/op-modules/op-mes/src/main/resources/mapper/MesPrepareMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/MesPrepareMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" msd.unit, msd.quantity from mes_prepare ms,mes_prepare_detail msd - + and workorder_code = #{workorderCode} and workorder_name like concat('%', #{workorderName}, '%') and parent_order = #{parentOrder} @@ -96,122 +96,129 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and factory_code = #{factoryCode} - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + insert into mes_prepare + + prepare_id, + workorder_code, + workorder_name, + parent_order, + order_id, + order_code, + product_id, + product_code, + prod_type, + product_name, + product_spc, + wet_detail_plan_id, + product_date, + shift_id, + ancestors, + status, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + factory_code, + material_code, + material_name, + material_spc, + unit, + quantity, + + + #{prepareId}, + #{workorderCode}, + #{workorderName}, + #{parentOrder}, + #{orderId}, + #{orderCode}, + #{productId}, + #{productCode}, + #{prodType}, + #{productName}, + #{productSpc}, + #{wetDetailPlanId}, + #{productDate}, + #{shiftId}, + #{ancestors}, + #{status}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{factoryCode}, + #{materialCode}, + #{materialName}, + #{materialSpc}, + #{unit}, + #{quantity}, + + + + + update mes_prepare + + workorder_code = #{workorderCode}, + workorder_name = #{workorderName}, + parent_order = #{parentOrder}, + order_id = #{orderId}, + order_code = #{orderCode}, + product_id = #{productId}, + product_code = #{productCode}, + prod_type = #{prodType}, + product_name = #{productName}, + product_spc = #{productSpc}, + wet_detail_plan_id = #{wetDetailPlanId}, + product_date = #{productDate}, + shift_id = #{shiftId}, + ancestors = #{ancestors}, + status = #{status}, + remark = #{remark}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + attr4 = #{attr4}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + factory_code = #{factoryCode}, + + where prepare_id = #{prepareId} + - - - + + delete from mes_prepare where prepare_id = #{prepareId} + - - - - - - - \ No newline at end of file + + delete from mes_prepare where prepare_id in + + #{prepareId} + + + diff --git a/op-modules/op-sap/src/main/java/com/op/sap/controller/SapController.java b/op-modules/op-sap/src/main/java/com/op/sap/controller/SapController.java index d671527b..95f4f6c4 100644 --- a/op-modules/op-sap/src/main/java/com/op/sap/controller/SapController.java +++ b/op-modules/op-sap/src/main/java/com/op/sap/controller/SapController.java @@ -1,5 +1,6 @@ package com.op.sap.controller; +import com.op.common.core.domain.R; import com.op.common.core.utils.DateUtils; import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.domain.AjaxResult; @@ -10,6 +11,7 @@ import com.op.sap.service.SapBomService; import com.op.sap.domain.SapBom; import com.op.sap.service.SapMaterialPreparationService; import com.op.sap.service.SapOrderService; +import com.op.system.api.domain.sap.SapMaterialPreparation; import com.op.system.api.model.SapProOrder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -35,7 +37,7 @@ public class SapController extends BaseController { */ @PostMapping("/shopOrderSync") @Log(title = "同步SAP订单", businessType = BusinessType.SAP) - public AjaxResult shopOrderSync(@RequestBody SapProOrder sapProOrder){ + public R> shopOrderSync(@RequestBody SapProOrder sapProOrder){ return sapOrderService.shopOrderSync(sapProOrder); } @@ -66,7 +68,7 @@ public class SapController extends BaseController { @PostMapping("/materialPreparation") @Log(title = "生产订单备料单接口", businessType = BusinessType.SAP) - public AjaxResult materialPreparation(@RequestParam("shopOrder") String shopOrder){ + public R> materialPreparation(@RequestParam("shopOrder") String shopOrder){ return sapMaterialPreparationService.MaterialPreparation(shopOrder); } diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/SapMaterialPreparationService.java b/op-modules/op-sap/src/main/java/com/op/sap/service/SapMaterialPreparationService.java index 0392f5d5..5c6f3dfc 100644 --- a/op-modules/op-sap/src/main/java/com/op/sap/service/SapMaterialPreparationService.java +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/SapMaterialPreparationService.java @@ -1,8 +1,12 @@ package com.op.sap.service; +import com.op.common.core.domain.R; import com.op.common.core.web.domain.AjaxResult; +import com.op.system.api.domain.sap.SapMaterialPreparation; + +import java.util.List; public interface SapMaterialPreparationService { - AjaxResult MaterialPreparation(String shopOrder); + R> MaterialPreparation(String shopOrder); } diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/SapOrderService.java b/op-modules/op-sap/src/main/java/com/op/sap/service/SapOrderService.java index aabae1f5..5aaf78a3 100644 --- a/op-modules/op-sap/src/main/java/com/op/sap/service/SapOrderService.java +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/SapOrderService.java @@ -1,5 +1,6 @@ package com.op.sap.service; +import com.op.common.core.domain.R; import com.op.common.core.web.domain.AjaxResult; import com.op.sap.domain.SapBom; import com.op.system.api.model.SapProOrder; @@ -8,5 +9,5 @@ import java.util.List; public interface SapOrderService { - AjaxResult shopOrderSync(SapProOrder sapProOrder); + R> shopOrderSync(SapProOrder sapProOrder); } diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapMaterialPreparationServiceImpl.java b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapMaterialPreparationServiceImpl.java index 136aec04..b0b1d752 100644 --- a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapMaterialPreparationServiceImpl.java +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapMaterialPreparationServiceImpl.java @@ -1,10 +1,12 @@ package com.op.sap.service.impl; +import com.op.common.core.domain.R; import com.op.common.core.web.domain.AjaxResult; -import com.op.sap.domain.SapMaterialPreparation; + import com.op.sap.mapper.SapMaterialPreparationMapper; import com.op.sap.service.SapMaterialPreparationService; import com.op.sap.util.SAPConnUtils; +import com.op.system.api.domain.sap.SapMaterialPreparation; import com.sap.conn.jco.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,7 +21,7 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation SapMaterialPreparationMapper sapMaterialPreparationMapper; @Override - public AjaxResult MaterialPreparation(String shopOrder) { + public R> MaterialPreparation(String shopOrder) { // 连接 try { @@ -86,9 +88,9 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation sapMaterialPreparation.setZQLSL(ZQLSL); sapMaterialPreparationList.add(sapMaterialPreparation); } - return AjaxResult.success(sapMaterialPreparationList); + return R.ok(sapMaterialPreparationList); } catch (Exception e) { - return AjaxResult.error(e.getMessage()); + return R.fail(e.getMessage()); } } } diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapOrderServiceImpl.java b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapOrderServiceImpl.java index 6af578de..7dee4260 100644 --- a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapOrderServiceImpl.java +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapOrderServiceImpl.java @@ -1,5 +1,6 @@ package com.op.sap.service.impl; +import com.op.common.core.domain.R; import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.web.domain.AjaxResult; @@ -27,12 +28,8 @@ import java.util.List; @Service public class SapOrderServiceImpl implements SapOrderService { - - @Autowired - private RemotePlanService remotePlanService; - @Override - public AjaxResult shopOrderSync(SapProOrder sapProOrder) { + public R> shopOrderSync(SapProOrder sapProOrder) { try { // 获取调用 RFC 函数对象 @@ -98,7 +95,7 @@ public class SapOrderServiceImpl implements SapOrderService { // remoteMesService.sapAddOrder(proOrder); } - return AjaxResult.success(proOrderList); + return R.ok(proOrderList); } catch (Exception e) { return null; }