|
|
|
@ -21,10 +21,13 @@ import com.op.common.core.utils.bean.BeanUtils;
|
|
|
|
|
import com.op.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.op.quality.domain.*;
|
|
|
|
|
import com.op.system.api.RemoteOpenService;
|
|
|
|
|
import com.op.system.api.RemoteSapService;
|
|
|
|
|
import com.op.system.api.RemoteUserService;
|
|
|
|
|
import com.op.system.api.domain.SysRole;
|
|
|
|
|
import com.op.system.api.domain.SysUser;
|
|
|
|
|
import com.op.system.api.domain.quality.HRInfo;
|
|
|
|
|
import com.op.system.api.domain.quality.QcCheckTaskIncomeDTO;
|
|
|
|
|
import com.op.system.api.domain.sap.SapSupplier;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
@ -62,6 +65,9 @@ public class QcCheckTaskIncomeController extends BaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private RemoteUserService remoteUserService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RemoteSapService remoteSapService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询来料检验列表
|
|
|
|
|
*/
|
|
|
|
@ -156,10 +162,15 @@ public class QcCheckTaskIncomeController extends BaseController {
|
|
|
|
|
0L, TimeUnit.MILLISECONDS,
|
|
|
|
|
new LinkedBlockingQueue<Runnable>());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
dateSources.forEach(dateSource -> {
|
|
|
|
|
Runnable run = () -> createIncomeBatchTaskFunc(dateSource.get("poolName"));
|
|
|
|
|
executorService.execute(run);
|
|
|
|
|
if(!"ds_999".equals(dateSource.get("poolName"))){
|
|
|
|
|
Runnable run = () -> createIncomeBatchTaskFunc(dateSource.get("poolName"));
|
|
|
|
|
executorService.execute(run);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("controller == createIncomeBatchTask == exception", e);
|
|
|
|
|
return error("controller == createIncomeBatchTask == exception");
|
|
|
|
@ -174,32 +185,39 @@ public class QcCheckTaskIncomeController extends BaseController {
|
|
|
|
|
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
|
|
|
|
|
Date taskTime = DateUtils.getNowDate();
|
|
|
|
|
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务开始+++时间:"+ taskTime +"++++++++++");
|
|
|
|
|
List<QcCheckTaskIncome> incomeBatchLists = qcCheckTaskIncomeService.getIncomeBatchList(poolName);
|
|
|
|
|
List<String> batchRecordIds = new ArrayList<>();
|
|
|
|
|
Map<String, Object> mapBom = new HashMap<String, Object>();
|
|
|
|
|
mapBom.put("P_WERKS",poolName.replace("ds_",""));//物料工厂 例如:1000
|
|
|
|
|
logger.info("来料信息查询请求:" + JSONObject.toJSONString(mapBom));
|
|
|
|
|
R incomeR = remoteSapService.inComingCheck(mapBom);
|
|
|
|
|
if(incomeR.getCode()==500){
|
|
|
|
|
logger.info("来料信息查询请求:" + JSONObject.toJSONString(incomeR));
|
|
|
|
|
return AjaxResult.error(JSONObject.toJSONString(incomeR));
|
|
|
|
|
}
|
|
|
|
|
logger.info("来料信息查询结果:" + JSONObject.toJSONString(incomeR));
|
|
|
|
|
List<QcCheckTaskIncomeDTO> incomeAll = (List<QcCheckTaskIncomeDTO>)incomeR.getData();
|
|
|
|
|
//已经生成过检验任务的采购订单
|
|
|
|
|
List<String> todayIncomeLists = qcCheckTaskIncomeService.getTodayIncomeLists();
|
|
|
|
|
List<QcCheckTaskIncomeDTO> newIncomes = incomeAll.stream()
|
|
|
|
|
.filter(item -> !todayIncomeLists.contains(item.getOrderNo()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
int successNum = 0;//成功任务数
|
|
|
|
|
int failNum = 0;//失败任务数
|
|
|
|
|
if(incomeBatchLists != null){
|
|
|
|
|
for( int i = 0 ; i < incomeBatchLists.size();){
|
|
|
|
|
QcCheckTaskIncomeDTO qcCheckTaskIncomedto = new QcCheckTaskIncomeDTO();
|
|
|
|
|
QcCheckTaskIncome income = incomeBatchLists.get(i);
|
|
|
|
|
BeanUtils.copyProperties(income,qcCheckTaskIncomedto);
|
|
|
|
|
//内层一个一个创建任务
|
|
|
|
|
AjaxResult ajaxResult = createIncomeTask(qcCheckTaskIncomedto);
|
|
|
|
|
if(!CollectionUtils.isEmpty(newIncomes)){
|
|
|
|
|
logger.info("工厂来料检验任务生成参数:" + JSONObject.toJSONString(newIncomes));
|
|
|
|
|
for(QcCheckTaskIncomeDTO income:newIncomes){
|
|
|
|
|
AjaxResult ajaxResult = createIncomeTask(income);
|
|
|
|
|
if(ajaxResult.isSuccess()){
|
|
|
|
|
batchRecordIds.add(qcCheckTaskIncomedto.getRecordId());
|
|
|
|
|
successNum = successNum + 1;
|
|
|
|
|
logger.info(poolName + "工厂的" + income.getCheckNo()+"来料检验创建任务成功++++++++++");
|
|
|
|
|
}else if(ajaxResult.isError()){
|
|
|
|
|
failNum = failNum +1;
|
|
|
|
|
logger.info(poolName + "工厂的" + income.getCheckNo()+"来料检验创建任务失败++++++++++");
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
logger.info("++++++++++++" + poolName + "工厂来料检验没有可创建的任务++++++++++");
|
|
|
|
|
}
|
|
|
|
|
//批量修改原表中的check_status和check_time
|
|
|
|
|
int upate = qcCheckTaskIncomeService.updateIncomeBatchList(batchRecordIds,taskTime);
|
|
|
|
|
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务结束:成功"+ successNum +"失败"+ failNum +"+++++");
|
|
|
|
|
return success();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -209,9 +227,7 @@ public class QcCheckTaskIncomeController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/createIncomeTask")
|
|
|
|
|
public AjaxResult createIncomeTask(@RequestBody QcCheckTaskIncomeDTO qcCheckTaskIncome0) {
|
|
|
|
|
QcCheckTaskIncome qcCheckTaskIncome = new QcCheckTaskIncome();
|
|
|
|
|
BeanUtils.copyProperties(qcCheckTaskIncome0, qcCheckTaskIncome);
|
|
|
|
|
public AjaxResult createIncomeTask(@RequestBody QcCheckTaskIncomeDTO qcCheckTaskIncome) {
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(qcCheckTaskIncome.getOrderNo())) {
|
|
|
|
|
return error("[orderNo]不能为空");
|
|
|
|
@ -222,12 +238,7 @@ public class QcCheckTaskIncomeController extends BaseController {
|
|
|
|
|
if (StringUtils.isBlank(qcCheckTaskIncome.getMaterialCode())) {
|
|
|
|
|
return error("[materialCode]不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(qcCheckTaskIncome.getCheckType())) {
|
|
|
|
|
return error("[checkType]不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(qcCheckTaskIncome.getFactoryCode())) {
|
|
|
|
|
return error("[factoryCode]不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(qcCheckTaskIncome.getSupplierCode())) {
|
|
|
|
|
return error("[supplierCode]不能为空");
|
|
|
|
|
}
|
|
|
|
@ -237,14 +248,13 @@ public class QcCheckTaskIncomeController extends BaseController {
|
|
|
|
|
if (qcCheckTaskIncome.getIncomeTime() == null) {
|
|
|
|
|
return error("[incomeTime]不能为空");
|
|
|
|
|
}
|
|
|
|
|
logger.info(qcCheckTaskIncome0.getFactoryCode() + "工厂来料检验任务生成开始================================");
|
|
|
|
|
logger.info(qcCheckTaskIncome0.getFactoryCode() + "工厂来料检验任务生成参数:" + JSONObject.toJSONString(qcCheckTaskIncome));
|
|
|
|
|
|
|
|
|
|
int r = qcCheckTaskIncomeService.insertQcCheckTaskIncome(qcCheckTaskIncome);
|
|
|
|
|
QcCheckTaskIncome income = new QcCheckTaskIncome();
|
|
|
|
|
BeanUtils.copyProperties(qcCheckTaskIncome,income);
|
|
|
|
|
int r = qcCheckTaskIncomeService.insertQcCheckTaskIncome(income);
|
|
|
|
|
if (r > 0) {
|
|
|
|
|
return toAjax(r);
|
|
|
|
|
}
|
|
|
|
|
return error(qcCheckTaskIncome0.getFactoryCode() + "工厂添加失败:请检查物料的关联检测项" );
|
|
|
|
|
return error("添加失败:请检查物料的关联检测项" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|