|
|
@ -1,9 +1,9 @@
|
|
|
|
package com.op.plan.service.impl;
|
|
|
|
package com.op.plan.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
import com.op.common.core.context.SecurityContextHolder;
|
|
|
|
import com.op.common.core.context.SecurityContextHolder;
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
@ -12,9 +12,11 @@ import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
import com.op.plan.domain.*;
|
|
|
|
import com.op.plan.domain.*;
|
|
|
|
import com.op.plan.domain.dto.WCSDTO;
|
|
|
|
import com.op.plan.domain.dto.WCSDTO;
|
|
|
|
|
|
|
|
import com.op.plan.domain.dto.WCSDataDTO;
|
|
|
|
|
|
|
|
import com.op.plan.domain.dto.WCSDataItemsDTO;
|
|
|
|
import com.op.plan.mapper.ProOrderWorkorderMapper;
|
|
|
|
import com.op.plan.mapper.ProOrderWorkorderMapper;
|
|
|
|
import com.op.plan.mapper.ProWetMaterialPlanDetailMapper;
|
|
|
|
import com.op.plan.mapper.ProWetMaterialPlanDetailMapper;
|
|
|
|
import com.op.system.api.RemoteSapService;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@ -33,7 +35,7 @@ import static com.op.common.core.web.domain.AjaxResult.success;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 湿料计划管理Service业务层处理
|
|
|
|
* 湿料计划管理Service业务层处理
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Open Platform
|
|
|
|
* @author zxl
|
|
|
|
* @date 2023-07-24
|
|
|
|
* @date 2023-07-24
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
@ -46,7 +48,7 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
|
|
|
|
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
|
|
|
|
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${wcs.url1}")
|
|
|
|
@Value("${wcs.url1}")
|
|
|
|
public String requestMaterialLoadNoUrl;
|
|
|
|
public String materialPlanSyncUrl;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询湿料计划管理
|
|
|
|
* 查询湿料计划管理
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -305,21 +307,63 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public AjaxResult syncWCS(@PathVariable String[] ids) {
|
|
|
|
public AjaxResult syncWCS(@PathVariable String id) {
|
|
|
|
String successid = "";
|
|
|
|
|
|
|
|
for(String id:ids){
|
|
|
|
|
|
|
|
//获取湿料计划
|
|
|
|
//获取湿料计划
|
|
|
|
WCSDTO wcsdto = new WCSDTO();
|
|
|
|
WCSDTO wcsdto = new WCSDTO();
|
|
|
|
wcsdto.setReqCode(id);//主计划id
|
|
|
|
wcsdto.setReqCode(id);//主计划id
|
|
|
|
wcsdto.setReqTime(DateUtils.getNowDate());
|
|
|
|
wcsdto.setReqTime(DateUtils.getNowDate());
|
|
|
|
List<ProWetMaterialPlanDetail> planDetails = proWetMaterialPlanDetailMapper.selectDetailListById(id);
|
|
|
|
List<ProWetMaterialPlanDetail> planDetails = proWetMaterialPlanDetailMapper.selectDetailListById(id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//罐
|
|
|
|
|
|
|
|
List<String> gList = planDetails.stream().map(ProWetMaterialPlanDetail::getBucketCode)
|
|
|
|
|
|
|
|
.distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
//罐-料
|
|
|
|
|
|
|
|
Map<String, String> glMap = planDetails.stream()
|
|
|
|
|
|
|
|
.collect(Collectors.toMap(ProWetMaterialPlanDetail::getBucketCode,
|
|
|
|
|
|
|
|
ProWetMaterialPlanDetail::getMaterialCode, (k1, k2) -> k1));
|
|
|
|
|
|
|
|
|
|
|
|
String sendResult = HttpUtils.sendPost(requestMaterialLoadNoUrl, JSON.toJSONString(wcsdto));
|
|
|
|
List<WCSDataDTO> data = new ArrayList<>();
|
|
|
|
WCSDTO resultdto = JSON.parseObject(sendResult,WCSDTO.class);
|
|
|
|
WCSDataDTO wCSDataDTO = null;
|
|
|
|
}
|
|
|
|
for (String g : gList) {
|
|
|
|
return success(successid+"同步成功");
|
|
|
|
wCSDataDTO = new WCSDataDTO();
|
|
|
|
|
|
|
|
wCSDataDTO.setSku(glMap.get(g));//罐
|
|
|
|
|
|
|
|
wCSDataDTO.setLoadNo(g);//料
|
|
|
|
|
|
|
|
List<WCSDataItemsDTO> unLoadItems = new ArrayList<>();//上位机集合
|
|
|
|
|
|
|
|
//罐-工单
|
|
|
|
|
|
|
|
List<ProWetMaterialPlanDetail> ggList = planDetails.stream()
|
|
|
|
|
|
|
|
.filter(plan -> plan.getBucketCode().equals(g))
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
WCSDataItemsDTO wCSDataItemsDTO = null;
|
|
|
|
|
|
|
|
for (ProWetMaterialPlanDetail gg : ggList) {
|
|
|
|
|
|
|
|
//根据工单查收坯机编码
|
|
|
|
|
|
|
|
String bucketCode = proOrderWorkorderMapper.getBucketCodeByWorkId(gg.getWorkorderId());
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(bucketCode)) {
|
|
|
|
|
|
|
|
wCSDataItemsDTO = new WCSDataItemsDTO();
|
|
|
|
|
|
|
|
wCSDataItemsDTO.setUnloadNo(bucketCode);
|
|
|
|
|
|
|
|
unLoadItems.add(wCSDataItemsDTO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wCSDataDTO.setUnLoadItems(unLoadItems);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wcsdto.setData(data);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String sendResult = HttpUtils.sendPost(materialPlanSyncUrl, JSON.toJSONString(wcsdto));
|
|
|
|
|
|
|
|
WCSDTO resultdto = JSON.parseObject(sendResult, WCSDTO.class);
|
|
|
|
|
|
|
|
if ("1".equals(resultdto.getCode())) {
|
|
|
|
|
|
|
|
return error(resultdto.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
return error("调用接口异常");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProWetMaterialPlan detail = new ProWetMaterialPlan();
|
|
|
|
|
|
|
|
detail.setId(id);
|
|
|
|
|
|
|
|
detail.setSyncFlag("Y");//已经同步的标识
|
|
|
|
|
|
|
|
proWetMaterialPlanMapper.updateProWetMaterialPlan(detail);
|
|
|
|
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -411,9 +455,28 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
public static void main(String args[]){
|
|
|
|
String s2="{\"reqTime\":\"2022-07-10 19:39:07.377\",\"reqCode\":\"dbee4f0c-ced7-463f-b19b-c83234cbd5b0\"}";
|
|
|
|
List<ProWetMaterialPlanDetail> planDetails = new ArrayList<>();
|
|
|
|
WCSDTO ps2= JSON.parseObject(s2,WCSDTO.class);
|
|
|
|
ProWetMaterialPlanDetail d1=new ProWetMaterialPlanDetail();
|
|
|
|
System.out.println(ps2);
|
|
|
|
d1.setBucketCode("LG1");
|
|
|
|
|
|
|
|
d1.setMaterialCode("WL00001");
|
|
|
|
|
|
|
|
planDetails.add(d1);
|
|
|
|
|
|
|
|
ProWetMaterialPlanDetail d2=new ProWetMaterialPlanDetail();
|
|
|
|
|
|
|
|
d2.setBucketCode("LG2");
|
|
|
|
|
|
|
|
d2.setMaterialCode("WL00002");
|
|
|
|
|
|
|
|
planDetails.add(d2);
|
|
|
|
|
|
|
|
ProWetMaterialPlanDetail d3=new ProWetMaterialPlanDetail();
|
|
|
|
|
|
|
|
d3.setBucketCode("LG1");
|
|
|
|
|
|
|
|
d3.setMaterialCode("WL00001");
|
|
|
|
|
|
|
|
planDetails.add(d3);
|
|
|
|
|
|
|
|
//罐
|
|
|
|
|
|
|
|
// List<String> gList = planDetails.stream().map(ProWetMaterialPlanDetail::getBucketCode).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// List<ProWetMaterialPlanDetail> glList = planDetails.stream()
|
|
|
|
|
|
|
|
// .map(e -> new ProWetPlanDetailDTO(e.getBucketCode(), e.getMaterialCode()))
|
|
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
|
|
//罐-料
|
|
|
|
|
|
|
|
Map<String, String> mapStream = planDetails.stream()
|
|
|
|
|
|
|
|
.collect(Collectors.toMap(ProWetMaterialPlanDetail::getBucketCode,ProWetMaterialPlanDetail::getMaterialCode, (k1, k2) -> k1));
|
|
|
|
|
|
|
|
System.out.println(mapStream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|