入库任务执行触发给产线控制系统发生产准备完成请求
This commit is contained in:
parent
b8a861c5c1
commit
3e1d3f95d1
@ -94,55 +94,55 @@ public class BaseKnifeServiceImpl implements IBaseKnifeService {
|
||||
List<HashMap<String, Object>> hashMapList = new ArrayList<>();
|
||||
|
||||
// 根据台账实例ID获取出库实例列表,并遍历
|
||||
WmsOutPlanDetailEntity wmsOutPlanDetailEntityQuery = new WmsOutPlanDetailEntity();
|
||||
wmsOutPlanDetailEntityQuery.setBaseKnifeId(nowBaseKnife.getBaseKnifeId());
|
||||
List<WmsOutPlanDetailEntity> wmsOutPlanDetailEntityList = this.wmsOutPlanDetailEntityMapper.selectWmsOutPlanDetailEntityList(wmsOutPlanDetailEntityQuery);
|
||||
wmsOutPlanDetailEntityList.forEach(nowWmsOutPlanDetailEntity -> {
|
||||
// 根据出库实例对象获取出库计划明细
|
||||
WmsOutPlanDetail wmsOutPlanDetail = this.wmsOutPlanMapper.selectWmsOutPlanDetailById(nowWmsOutPlanDetailEntity.getWmsOutPlanDetailId());
|
||||
|
||||
// 根据计划明细获得出库计划
|
||||
WmsOutPlan wmsOutPlan = this.wmsOutPlanMapper.selectWmsOutPlanByWmsOutPlanId(wmsOutPlanDetail.getWmsOutPlanId());
|
||||
|
||||
// 根据出库计划获得出库类型
|
||||
WmsBusinessType wmsBusinessType = this.wmsBusinessTypeMapper.selectWmsBusinessTypeByTypeId(wmsOutPlan.getWmsBusinessTypeId().toString());
|
||||
|
||||
// 设定出库信息数据
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
/* 来自计划 */
|
||||
hashMap.put("planCode", wmsOutPlan.getPlanCode()); // 计划编号
|
||||
hashMap.put("planStatus", wmsOutPlan.getPlanState()); // 计划状态
|
||||
hashMap.put("planType", wmsOutPlan.getPlanType()); // 计划类型
|
||||
hashMap.put("useUsername", wmsOutPlan.getRecipientUsername()); // 领用人
|
||||
/* 来自出入库计划类型 */
|
||||
hashMap.put("planTypeId", wmsBusinessType.getTypeId()); // 出库类型ID
|
||||
hashMap.put("planTypeCode", wmsBusinessType.getCode()); // 出库类型编码
|
||||
hashMap.put("planTypeName", wmsBusinessType.getName()); // 出库类型名称
|
||||
/* 来自计划明细 */
|
||||
hashMap.put("detailBatchNum", wmsOutPlanDetail.getDetailBatchNum()); // 明细批次
|
||||
hashMap.put("wmStorageAreaId", wmsOutPlanDetail.getWmStorageAreaId()); // 库位ID
|
||||
hashMap.put("wmStorageAreaCode", wmsOutPlanDetail.getWmStorageAreaCode()); // 库位编码
|
||||
hashMap.put("wmStorageAreaName", wmsOutPlanDetail.getWmStorageAreaName()); // 库位名称
|
||||
hashMap.put("detailStatus", wmsOutPlanDetail.getDetailState()); // 明细状态
|
||||
hashMap.put("isToolSetting", nowWmsOutPlanDetailEntity.getIsToolSetting()); // 是否对刀
|
||||
hashMap.put("toolSettingParam", nowWmsOutPlanDetailEntity.getToolSettingParam()); // 对刀参数
|
||||
|
||||
/* 实体 */
|
||||
String outTime = null;
|
||||
if (nowWmsOutPlanDetailEntity.getCreateTime() != null)
|
||||
outTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(nowWmsOutPlanDetailEntity.getCreateTime());
|
||||
hashMap.put("outTime", outTime); // 出库时间
|
||||
hashMapList.add(hashMap);
|
||||
|
||||
// 注入出库信息对象
|
||||
nowBaseKnife.setOutInfoList(hashMapList);
|
||||
});
|
||||
|
||||
// 构建入库信息
|
||||
WmsInPlanDetailEntity wmsInPlanDetailEntityQuery = new WmsInPlanDetailEntity();
|
||||
wmsInPlanDetailEntityQuery.setKnifeId(nowBaseKnife.getBaseKnifeId());
|
||||
List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = wmsInPlanDetailEntityService.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntityQuery);
|
||||
nowBaseKnife.setInInfoList(wmsInPlanDetailEntityList);
|
||||
// WmsOutPlanDetailEntity wmsOutPlanDetailEntityQuery = new WmsOutPlanDetailEntity();
|
||||
// wmsOutPlanDetailEntityQuery.setBaseKnifeId(nowBaseKnife.getBaseKnifeId());
|
||||
// List<WmsOutPlanDetailEntity> wmsOutPlanDetailEntityList = this.wmsOutPlanDetailEntityMapper.selectWmsOutPlanDetailEntityList(wmsOutPlanDetailEntityQuery);
|
||||
// wmsOutPlanDetailEntityList.forEach(nowWmsOutPlanDetailEntity -> {
|
||||
// // 根据出库实例对象获取出库计划明细
|
||||
// WmsOutPlanDetail wmsOutPlanDetail = this.wmsOutPlanMapper.selectWmsOutPlanDetailById(nowWmsOutPlanDetailEntity.getWmsOutPlanDetailId());
|
||||
//
|
||||
// // 根据计划明细获得出库计划
|
||||
// WmsOutPlan wmsOutPlan = this.wmsOutPlanMapper.selectWmsOutPlanByWmsOutPlanId(wmsOutPlanDetail.getWmsOutPlanId());
|
||||
//
|
||||
// // 根据出库计划获得出库类型
|
||||
// WmsBusinessType wmsBusinessType = this.wmsBusinessTypeMapper.selectWmsBusinessTypeByTypeId(wmsOutPlan.getWmsBusinessTypeId().toString());
|
||||
//
|
||||
// // 设定出库信息数据
|
||||
// HashMap<String, Object> hashMap = new HashMap<>();
|
||||
// /* 来自计划 */
|
||||
// hashMap.put("planCode", wmsOutPlan.getPlanCode()); // 计划编号
|
||||
// hashMap.put("planStatus", wmsOutPlan.getPlanState()); // 计划状态
|
||||
// hashMap.put("planType", wmsOutPlan.getPlanType()); // 计划类型
|
||||
// hashMap.put("useUsername", wmsOutPlan.getRecipientUsername()); // 领用人
|
||||
// /* 来自出入库计划类型 */
|
||||
// hashMap.put("planTypeId", wmsBusinessType.getTypeId()); // 出库类型ID
|
||||
// hashMap.put("planTypeCode", wmsBusinessType.getCode()); // 出库类型编码
|
||||
// hashMap.put("planTypeName", wmsBusinessType.getName()); // 出库类型名称
|
||||
// /* 来自计划明细 */
|
||||
// hashMap.put("detailBatchNum", wmsOutPlanDetail.getDetailBatchNum()); // 明细批次
|
||||
// hashMap.put("wmStorageAreaId", wmsOutPlanDetail.getWmStorageAreaId()); // 库位ID
|
||||
// hashMap.put("wmStorageAreaCode", wmsOutPlanDetail.getWmStorageAreaCode()); // 库位编码
|
||||
// hashMap.put("wmStorageAreaName", wmsOutPlanDetail.getWmStorageAreaName()); // 库位名称
|
||||
// hashMap.put("detailStatus", wmsOutPlanDetail.getDetailState()); // 明细状态
|
||||
// hashMap.put("isToolSetting", nowWmsOutPlanDetailEntity.getIsToolSetting()); // 是否对刀
|
||||
// hashMap.put("toolSettingParam", nowWmsOutPlanDetailEntity.getToolSettingParam()); // 对刀参数
|
||||
//
|
||||
// /* 实体 */
|
||||
// String outTime = null;
|
||||
// if (nowWmsOutPlanDetailEntity.getCreateTime() != null)
|
||||
// outTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(nowWmsOutPlanDetailEntity.getCreateTime());
|
||||
// hashMap.put("outTime", outTime); // 出库时间
|
||||
// hashMapList.add(hashMap);
|
||||
//
|
||||
// // 注入出库信息对象
|
||||
// nowBaseKnife.setOutInfoList(hashMapList);
|
||||
// });
|
||||
//
|
||||
// // 构建入库信息
|
||||
// WmsInPlanDetailEntity wmsInPlanDetailEntityQuery = new WmsInPlanDetailEntity();
|
||||
// wmsInPlanDetailEntityQuery.setKnifeId(nowBaseKnife.getBaseKnifeId());
|
||||
// List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = wmsInPlanDetailEntityService.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntityQuery);
|
||||
// nowBaseKnife.setInInfoList(wmsInPlanDetailEntityList);
|
||||
|
||||
// 查询基础物料
|
||||
if ("PRODUCT".equals(nowBaseKnife.getItemOrProduct())) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ktg.mes.wm.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ktg.common.annotation.Log;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
@ -9,12 +10,17 @@ import com.ktg.common.enums.BusinessType;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.common.utils.poi.ExcelUtil;
|
||||
import com.ktg.mes.cal.utils.CalendarUtil;
|
||||
import com.ktg.mes.md.domain.*;
|
||||
import com.ktg.mes.md.service.IBaseKnifeService;
|
||||
import com.ktg.mes.md.service.IMdItemService;
|
||||
import com.ktg.mes.wm.domain.*;
|
||||
import com.ktg.mes.wm.service.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -23,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import static com.ktg.generator.util.MultiModuleCodeGenerator.generateTaskCode;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -57,6 +64,7 @@ public class WmsInTaskController extends BaseController {
|
||||
private final WmsZdTaskMapper wmsZdTaskMapper;
|
||||
private final WmStorageAreaMapper wmStorageAreaMapper;
|
||||
private final BaseKnifeLockedMapper baseKnifeLockedMapper;
|
||||
private final MyConfig myConfig;
|
||||
|
||||
/**
|
||||
* 查询入库任务列表
|
||||
@ -151,7 +159,7 @@ public class WmsInTaskController extends BaseController {
|
||||
@PostMapping("/open/issueBatch/{ids}")
|
||||
@ResponseBody
|
||||
@Transactional
|
||||
public AjaxResult issueBatch(@PathVariable String[] ids) {
|
||||
public AjaxResult issueBatch(@PathVariable String[] ids) throws IOException {
|
||||
for (String taskId : ids) {
|
||||
// 获取任务信息
|
||||
WmsInTask wmsInTask = wmsInTaskService.selectWmsInTaskById(taskId);
|
||||
@ -261,7 +269,13 @@ public class WmsInTaskController extends BaseController {
|
||||
baseKnifeService.updateBaseKnife(baseKnife);
|
||||
|
||||
// 检测订单是否完成,完成则出库整刀
|
||||
if (this.checkFinal(baseKnifeLocked.getPlanSheet())) this.createOutTask(baseKnifeLocked.getPlanSheet());
|
||||
if (this.checkFinal(baseKnifeLocked.getPlanSheet())) {
|
||||
try {
|
||||
this.createOutTask(baseKnifeLocked.getPlanSheet());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 订单解绑
|
||||
baseKnife.setPlanSheet(null);
|
||||
@ -363,7 +377,7 @@ public class WmsInTaskController extends BaseController {
|
||||
|
||||
// 检查订单完成状态
|
||||
@Transactional
|
||||
public void createOutTask(String planSheet) {
|
||||
public void createOutTask(String planSheet) throws IOException {
|
||||
// 构建出库计划
|
||||
WmsOutPlan outPlan = new WmsOutPlan();
|
||||
outPlan.setPlanCode(planSheet);
|
||||
@ -479,5 +493,70 @@ public class WmsInTaskController extends BaseController {
|
||||
|
||||
productionArrangements.setStatus(1);
|
||||
productionArrangementsMapper.updateProductionArrangements(productionArrangements);
|
||||
|
||||
// 给产线控制系统发指令
|
||||
this.productionArrangementsIsOk(productionArrangements);
|
||||
|
||||
}
|
||||
|
||||
// 调用生产准备完成接口
|
||||
public void productionArrangementsIsOk(ProductionArrangements productionArrangements) throws IOException {
|
||||
// 产线控制系统生产准备完成接口
|
||||
String url = myConfig.getProductionControlPath() + "/cutterapi/cutComplete";
|
||||
|
||||
// 请求客户端
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
// 构建请求数据
|
||||
Map<String, Object> requestMap = new HashMap<>();
|
||||
requestMap.put("prodordercode", productionArrangements.getPlanSheet());
|
||||
requestMap.put("result", "0");
|
||||
requestMap.put("completetime", CalendarUtil.getDateTimeStr());
|
||||
|
||||
// 获取工艺信息
|
||||
BaseTechnologyBom technologyBomWrapper = new BaseTechnologyBom();
|
||||
technologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
|
||||
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(technologyBomWrapper);
|
||||
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
baseKnifeWrapper.setPlanSheet(productionArrangements.getPlanSheet());
|
||||
|
||||
// 获取刀具信息
|
||||
List<Map<String, String>> cutterList = new ArrayList<>();
|
||||
technologyBomList.forEach(baseTechnologyBom -> {
|
||||
baseKnifeWrapper.setKnifeCode(baseTechnologyBom.getKnifeCode());
|
||||
List<BaseKnife> baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
|
||||
baseKnifeList.forEach(baseKnife -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("specno", baseTechnologyBom.getProcessCode());
|
||||
map.put("code", baseKnife.getKnifeCode());
|
||||
map.put("name", baseKnife.getKnifeName());
|
||||
map.put("life", baseKnife.getKnifeLife().toString());
|
||||
cutterList.add(map);
|
||||
});
|
||||
});
|
||||
requestMap.put("cutterinfo", cutterList);
|
||||
|
||||
// 构建请求数据
|
||||
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
||||
okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(mediaType, JSON.toJSONString(requestMap));
|
||||
|
||||
// 请求体
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.post(requestBody)
|
||||
.build();
|
||||
|
||||
// 发送请求
|
||||
try(Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful())
|
||||
throw new IOException("Unexpected code " + response);
|
||||
|
||||
// 请求响应
|
||||
String responseBody = response.body().string();
|
||||
System.out.println(responseBody);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
productionArrangements = productionArrangementsMapper.selectProductionArrangementsList(productionArrangementsWrapper).get(0);
|
||||
}
|
||||
|
||||
// 出库基础物料, 根据图号查询出库计划,如果不存在生成计划,存在则往计划中添加任务
|
||||
// 出库基础物料, 根据订单号查询出库计划,如果不存在生成计划,存在则往计划中添加任务
|
||||
WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(zdTask.getCode());
|
||||
if (outPlan == null) {
|
||||
// 构建新的出库计划
|
||||
@ -237,7 +237,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
baseKnife.setKnifeLife(100);
|
||||
baseKnife.setKnifeFineState(1);
|
||||
baseKnife.setIsValid(1);
|
||||
// 判断是否需要锁定整刀
|
||||
// 判断是否需要锁定整刀,来自订单的组装任务需要锁定
|
||||
if (lockedFlag) {
|
||||
baseKnife.setIsLocked(1);
|
||||
baseKnife.setKnifeFineState(1);
|
||||
@ -280,6 +280,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
int bomCount = mbbProduBom.getStandardDosage();
|
||||
for (BaseKnife wmsBaseKnife : baseKnifeList) {
|
||||
if (bomCount > 0) {
|
||||
// 绑定到组装任务 和 整刀父id
|
||||
wmsBaseKnife.setZdTaskId(zdTask.getWmsZdTaskId());
|
||||
wmsBaseKnife.setIsLocked(1);
|
||||
wmsBaseKnife.setParentId(baseKnife.getBaseKnifeId());
|
||||
@ -397,6 +398,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
public String getProductRfid(Long itemId, int i){
|
||||
MdItem mdItem = mdItemMapper.selectMdItemById(itemId);
|
||||
|
||||
// 获取最大的RFID 然后加1 : RFID为物料的编码加序号
|
||||
List<BaseKnife> baseKnifeList = baseKnifeMapper.selectBaseKnifeListByMbbBdMrlId(itemId);
|
||||
if (baseKnifeList.isEmpty()) return mdItem.getItemCode() + String.format("%04d", 1);
|
||||
else {
|
||||
@ -491,16 +493,6 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
wmsInTask.setCreateTime(DateUtils.getNowDate());
|
||||
wmsInTaskMapper.insertWmsInTask(wmsInTask);
|
||||
|
||||
// // 整 刀台账设为有效
|
||||
// baseKnifeList.forEach(baseKnife -> {
|
||||
// baseKnife.setIsValid(0);
|
||||
// baseKnife.setCreateTime(DateUtils.getNowDate());
|
||||
// baseKnifeMapper.updateBaseKnife(baseKnife);
|
||||
// });
|
||||
//
|
||||
// // 检测订单是否完成,完成则出库整刀
|
||||
// if (zdTask.getPlanSheet() != null && this.checkFinal(zdTask.getPlanSheet())) this.createOutTask(zdTask.getPlanSheet());
|
||||
|
||||
// 更新组装任务
|
||||
zdTask.setStatus("2");
|
||||
zdTask.setQtyOk(zdTask.getProductIdQty());
|
||||
@ -519,216 +511,4 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
}
|
||||
}
|
||||
|
||||
// 检查订单完成状态
|
||||
public Boolean checkFinal(String planSheet){
|
||||
// 获取订单记录
|
||||
ProductionArrangements productionArrangements = productionArrangementsMapper.selectProductionArrangementsByPlanSheet(planSheet);
|
||||
BaseTechnologyBom baseTechnologyBomWrapper = new BaseTechnologyBom();
|
||||
baseTechnologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
|
||||
List<BaseTechnologyBom> baseTechnologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(baseTechnologyBomWrapper);
|
||||
|
||||
// 判断订单锁定的物料是否足够
|
||||
Map<String, Integer> coutMap = new HashMap<>();
|
||||
for (BaseTechnologyBom technologyBom : baseTechnologyBomList) {
|
||||
coutMap.merge(technologyBom.getKnifeCode(), technologyBom.getKnifeCount(), Integer::sum);
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
baseKnifeWrapper.setPlanSheet(planSheet);
|
||||
baseKnifeWrapper.setKnifeCode(technologyBom.getKnifeCode());
|
||||
List<BaseKnife> baseKnifePlanSheetList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
|
||||
if (baseKnifePlanSheetList.size() < coutMap.get(technologyBom.getKnifeCode())) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查订单完成状态
|
||||
@Transactional
|
||||
public void createOutTask(String planSheet) throws IOException {
|
||||
// 构建出库计划
|
||||
WmsOutPlan outPlan = new WmsOutPlan();
|
||||
outPlan.setPlanCode(planSheet);
|
||||
outPlan.setWmsBusinessTypeId(16L);
|
||||
outPlan.setPlanState("1");
|
||||
outPlan.setPlanType("ZDCK");
|
||||
outPlan.setCreateBy(getUsername());
|
||||
outPlan.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutPlanMapper.insertWmsOutPlan(outPlan);
|
||||
|
||||
// 所有的物料
|
||||
List<BaseKnife> baseKnifeResultList = new ArrayList<>();
|
||||
|
||||
// 获取订单记录
|
||||
ProductionArrangements productionArrangements = productionArrangementsMapper.selectProductionArrangementsByPlanSheet(planSheet);
|
||||
BaseTechnologyBom baseTechnologyBomWrapper = new BaseTechnologyBom();
|
||||
baseTechnologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
|
||||
List<BaseTechnologyBom> baseTechnologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(baseTechnologyBomWrapper);
|
||||
|
||||
// 判断订单锁定的物料是否足够
|
||||
Map<String, Integer> coutMap = new HashMap<>();
|
||||
for (BaseTechnologyBom technologyBom : baseTechnologyBomList)
|
||||
coutMap.merge(technologyBom.getKnifeCode(), technologyBom.getKnifeCount(), Integer::sum);
|
||||
|
||||
for (Map.Entry<String, Integer> item : coutMap.entrySet()) {
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
baseKnifeWrapper.setPlanSheet(planSheet);
|
||||
baseKnifeWrapper.setKnifeCode(item.getKey());
|
||||
List<BaseKnife> baseKnifeLockedList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
|
||||
if (baseKnifeLockedList.size() == item.getValue()) baseKnifeResultList.addAll(baseKnifeLockedList);
|
||||
}
|
||||
|
||||
String batchNum = "SCZBPC01";
|
||||
// 出库任务,进行整刀的出库
|
||||
HashMap<Long, HashMap<String, List<BaseKnife>>> baseKnifeHashMapMap = new HashMap<>();
|
||||
|
||||
// 遍历构建map
|
||||
baseKnifeResultList.forEach(item -> {
|
||||
// 判断当前物料主键是否已经被收录
|
||||
baseKnifeHashMapMap.computeIfAbsent(item.getMbbBdMrlId(), k -> new HashMap<>());
|
||||
|
||||
// 判断当前库位编码是否已经被收录
|
||||
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).computeIfAbsent(item.getAreaCode(), k -> new ArrayList<>());
|
||||
|
||||
// 对当前台账对象进行收录
|
||||
baseKnifeHashMapMap.get(item.getMbbBdMrlId()).get(item.getAreaCode()).add(item);
|
||||
|
||||
// 修改出库状态
|
||||
item.setKnifeFineState(2);
|
||||
baseKnifeMapper.updateBaseKnife(item);
|
||||
});
|
||||
|
||||
// 生成出库计划明细
|
||||
WmsOutPlan outPlanTemp = outPlan;
|
||||
baseKnifeHashMapMap.keySet().forEach(mdItemId -> {
|
||||
MdItem mdItemOutPlan = mdItemMapper.selectMdItemById(mdItemId);
|
||||
// 根据库位编码遍历
|
||||
baseKnifeHashMapMap.get(mdItemId).keySet().forEach(areaCode -> {
|
||||
// 获得库位对象
|
||||
WmStorageArea wmStorageAreaOutPlan = wmStorageAreaMapper.selectWmStorageAreaByAreaCode(areaCode);
|
||||
|
||||
WmsOutPlanDetail outPlanDetail = new WmsOutPlanDetail();
|
||||
outPlanDetail.setWmsOutPlanId(outPlanTemp.getWmsOutPlanId());
|
||||
outPlanDetail.setMdItemId(mdItemId);
|
||||
outPlanDetail.setMdItemCode(mdItemOutPlan.getItemCode());
|
||||
outPlanDetail.setMdItemName(mdItemOutPlan.getItemName());
|
||||
outPlanDetail.setMdItemUnit(mdItemOutPlan.getUnitName());
|
||||
outPlanDetail.setPlannedQuantity(baseKnifeHashMapMap.get(mdItemId).get(areaCode).size());
|
||||
outPlanDetail.setRealQuantity(baseKnifeHashMapMap.get(mdItemId).get(areaCode).size());
|
||||
outPlanDetail.setDetailBatchNum(batchNum);
|
||||
outPlanDetail.setWmStorageAreaId(wmStorageAreaOutPlan.getAreaId());
|
||||
outPlanDetail.setWmStorageAreaCode(wmStorageAreaOutPlan.getAreaCode());
|
||||
outPlanDetail.setWmStorageAreaName(wmStorageAreaOutPlan.getAreaName());
|
||||
outPlanDetail.setDetailState("1");
|
||||
outPlanDetail.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutPlanMapper.insertWmsOutPlanDetail(outPlanDetail);
|
||||
|
||||
// 遍历台账对象
|
||||
baseKnifeHashMapMap.get(mdItemId).get(areaCode).forEach(item -> {
|
||||
// 构建出库计划明细实体
|
||||
WmsOutPlanDetailEntity wmsOutPlanDetailEntity = new WmsOutPlanDetailEntity();
|
||||
wmsOutPlanDetailEntity.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
|
||||
wmsOutPlanDetailEntity.setBaseKnifeId(item.getBaseKnifeId());
|
||||
wmsOutPlanDetailEntity.setAreaCode(item.getAreaCode());
|
||||
wmsOutPlanDetailEntity.setItemOrProduct(item.getItemOrProduct());
|
||||
wmsOutPlanDetailEntity.setKnifeCode(item.getKnifeCode());
|
||||
wmsOutPlanDetailEntity.setKnifeName(item.getKnifeName());
|
||||
wmsOutPlanDetailEntity.setPlanSheet(item.getPlanSheet());
|
||||
wmsOutPlanDetailEntity.setKnifeLife(item.getKnifeLife());
|
||||
wmsOutPlanDetailEntity.setResetCount(item.getResetCount());
|
||||
wmsOutPlanDetailEntity.setKnifeUnit(item.getKnifeUnit());
|
||||
wmsOutPlanDetailEntity.setSafeStock(item.getKnifeType());
|
||||
wmsOutPlanDetailEntity.setStandardQuantity(item.getStandardQuantity());
|
||||
wmsOutPlanDetailEntity.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutPlanDetailEntityMapper.insertWmsOutPlanDetailEntity(wmsOutPlanDetailEntity);
|
||||
});
|
||||
|
||||
// 生成出库任务
|
||||
WmsOutTask wmsOutTask = new WmsOutTask();
|
||||
wmsOutTask.setWmsOutPlanId(outPlanTemp.getWmsOutPlanId());
|
||||
wmsOutTask.setWmsOutPlanCode(outPlanTemp.getPlanCode());
|
||||
wmsOutTask.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId());
|
||||
// 出库类型 12组刀出库
|
||||
wmsOutTask.setWmsBusinessTypeId(12L);
|
||||
wmsOutTask.setTaskCode(generateTaskCode("CKT"));
|
||||
wmsOutTask.setTaskNumber(outPlanDetail.getPlannedQuantity());
|
||||
wmsOutTask.setOutNumber(outPlanDetail.getRealQuantity());
|
||||
wmsOutTask.setWmStorageAreaId(outPlanDetail.getWmStorageAreaId());
|
||||
wmsOutTask.setBatchNum(batchNum);
|
||||
wmsOutTask.setMdItemId(outPlanDetail.getMdItemId());
|
||||
wmsOutTask.setMdItemCode(outPlanDetail.getMdItemCode());
|
||||
wmsOutTask.setMdItemName(outPlanDetail.getMdItemName());
|
||||
wmsOutTask.setMdItemUnit(outPlanDetail.getMdItemUnit());
|
||||
wmsOutTask.setTaskState("0");
|
||||
wmsOutTask.setRecipientUsername("");
|
||||
wmsOutTask.setCreateTime(DateUtils.getNowDate());
|
||||
wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
|
||||
});
|
||||
});
|
||||
|
||||
productionArrangements.setStatus(1);
|
||||
productionArrangementsMapper.updateProductionArrangements(productionArrangements);
|
||||
|
||||
// 给产线控制系统发指令
|
||||
productionArrangementsIsOk(productionArrangements);
|
||||
}
|
||||
|
||||
// 调用生产准备完成接口
|
||||
public void productionArrangementsIsOk(ProductionArrangements productionArrangements) throws IOException {
|
||||
// 产线控制系统生产准备完成接口
|
||||
String url = myConfig.getProductionControlPath() + "/cutterapi/cutComplete";
|
||||
|
||||
// 请求客户端
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
// 构建请求数据
|
||||
Map<String, Object> requestMap = new HashMap<>();
|
||||
requestMap.put("prodordercode", productionArrangements.getPlanSheet());
|
||||
requestMap.put("result", "0");
|
||||
requestMap.put("completetime", CalendarUtil.getDateTimeStr());
|
||||
|
||||
// 获取工艺信息
|
||||
BaseTechnologyBom technologyBomWrapper = new BaseTechnologyBom();
|
||||
technologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
|
||||
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(technologyBomWrapper);
|
||||
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
baseKnifeWrapper.setPlanSheet(productionArrangements.getPlanSheet());
|
||||
|
||||
// 获取刀具信息
|
||||
List<Map<String, String>> cutterList = new ArrayList<>();
|
||||
technologyBomList.forEach(baseTechnologyBom -> {
|
||||
baseKnifeWrapper.setKnifeCode(baseTechnologyBom.getKnifeCode());
|
||||
List<BaseKnife> baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
|
||||
baseKnifeList.forEach(baseKnife -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("specno", baseTechnologyBom.getProcessCode());
|
||||
map.put("code", baseKnife.getKnifeCode());
|
||||
map.put("name", baseKnife.getKnifeName());
|
||||
map.put("life", baseKnife.getKnifeLife().toString());
|
||||
cutterList.add(map);
|
||||
});
|
||||
});
|
||||
requestMap.put("cutterinfo", cutterList);
|
||||
|
||||
// 构建请求数据
|
||||
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
||||
RequestBody requestBody = RequestBody.create(mediaType, JSON.toJSONString(requestMap));
|
||||
|
||||
// 请求体
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.post(requestBody)
|
||||
.build();
|
||||
|
||||
// 发送请求
|
||||
try(Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful())
|
||||
throw new IOException("Unexpected code " + response);
|
||||
|
||||
// 请求响应
|
||||
String responseBody = response.body().string();
|
||||
System.out.println(responseBody);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user