|
|
|
@ -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()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|