领料单提交

highway
zhaoxiaolin 1 year ago
parent 6708ff8f48
commit 432a1c761c

@ -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<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(qo).getData();
// 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser();
sysUser.setUserId(1L);
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
List<Map<String, String>> dateSources = dateSources0.getData();
ExecutorService executorService = new ThreadPoolExecutor(
dateSources.size(),
dateSources.size(),
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
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<SapMaterialPreparation> sapMaterialPreparationList) {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
List<SapMaterialPreparation> 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()
}
}

Loading…
Cancel
Save