From 432a1c761cf563bc41b9b4bbcf956a5e6dbf42e9 Mon Sep 17 00:00:00 2001 From: zhaoxiaolin Date: Mon, 21 Aug 2023 11:08:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E6=96=99=E5=8D=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/MesPrepareServiceImpl.java | 78 +++++++++++++++++-- 1 file changed, 70 insertions(+), 8 deletions(-) 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 4f448c9f..355a16ba 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,9 +1,22 @@ package com.op.mes.service.impl; import java.util.List; +import java.util.Map; +import java.util.concurrent.*; +import java.util.stream.Collectors; import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +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.mes.mapper.MesPrepareDetailMapper; +import com.op.system.api.RemoteSapService; +import com.op.system.api.RemoteUserService; +import com.op.system.api.domain.SysUser; +import com.op.system.api.domain.sap.SapMaterialPreparation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.mes.mapper.MesPrepareMapper; @@ -12,18 +25,24 @@ import com.op.mes.service.IMesPrepareService; /** * 备料单Service业务层处理 - * + * * @author Open Platform * @date 2023-08-03 */ @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 备料单 */ @@ -35,7 +54,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService { /** * 查询备料单列表 - * + * * @param mesPrepare 备料单 * @return 备料单 */ @@ -47,7 +66,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService { /** * 新增备料单 - * + * * @param mesPrepare 备料单 * @return 结果 */ @@ -60,7 +79,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService { /** * 修改备料单 - * + * * @param mesPrepare 备料单 * @return 结果 */ @@ -73,7 +92,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService { /** * 批量删除备料单 - * + * * @param prepareIds 需要删除的备料单主键 * @return 结果 */ @@ -85,7 +104,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService { /** * 删除备料单信息 - * + * * @param prepareId 备料单主键 * @return 结果 */ @@ -94,4 +113,47 @@ public class MesPrepareServiceImpl implements IMesPrepareService { 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()); + for(SapMaterialPreparation sap:list){ + + } + /**mes_prepare**/ + //mesPrepareMapper.insertMesPrepare(); + /**mes_prepare_detail**/ + //mesPrepareDetailMapper.insertMesPrepareDetail() + } }