|
|
@ -1,9 +1,22 @@
|
|
|
|
package com.op.mes.service.impl;
|
|
|
|
package com.op.mes.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
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.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.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.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.op.mes.mapper.MesPrepareMapper;
|
|
|
|
import com.op.mes.mapper.MesPrepareMapper;
|
|
|
@ -18,9 +31,15 @@ import com.op.mes.service.IMesPrepareService;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class MesPrepareServiceImpl implements IMesPrepareService {
|
|
|
|
public class MesPrepareServiceImpl implements IMesPrepareService {
|
|
|
|
|
|
|
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesPrepareMapper mesPrepareMapper;
|
|
|
|
private MesPrepareMapper mesPrepareMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private RemoteSapService remoteSapService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private RemoteUserService remoteUserService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesPrepareDetailMapper mesPrepareDetailMapper;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询备料单
|
|
|
|
* 查询备料单
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -94,4 +113,47 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
|
|
|
|
public int deleteMesPrepareByPrepareId(String prepareId) {
|
|
|
|
public int deleteMesPrepareByPrepareId(String prepareId) {
|
|
|
|
return mesPrepareMapper.deleteMesPrepareByPrepareId(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()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|