fix:配粉作业接口优化
This commit is contained in:
@@ -8,20 +8,17 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.annotation.Log;
|
import org.nl.annotation.Log;
|
||||||
import org.nl.modules.mnt.service.dto.AppQueryCriteria;
|
import org.nl.wms.common.util.RedissonUtils;
|
||||||
import org.nl.wms.pf.service.FlourworkService;
|
import org.nl.wms.pf.service.FlourworkService;
|
||||||
import org.nl.wms.pf.service.FormingmaterialService;
|
|
||||||
import org.nl.wms.pf.service.dto.FormingmaterialDto;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Lxy
|
* @author Lxy
|
||||||
@@ -90,7 +87,11 @@ public class FlourworkController {
|
|||||||
@Log("自动叫料")
|
@Log("自动叫料")
|
||||||
@ApiOperation("自动叫料")
|
@ApiOperation("自动叫料")
|
||||||
public ResponseEntity<Object> autoCalledMater(@RequestBody JSONObject whereJson){
|
public ResponseEntity<Object> autoCalledMater(@RequestBody JSONObject whereJson){
|
||||||
return new ResponseEntity<>(flourworkService.autoCalledMater(whereJson),HttpStatus.OK);
|
AtomicReference<JSONObject> result = new AtomicReference<>(new JSONObject());
|
||||||
|
RedissonUtils.lock(a -> {
|
||||||
|
result.set(flourworkService.autoCalledMater(whereJson));
|
||||||
|
}, "autoCalledMater", 1);
|
||||||
|
return new ResponseEntity<>(result.get(),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/startWork")
|
@PostMapping("/startWork")
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ package org.nl.wms.pf.service;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,6 +67,9 @@ public interface FlourworkService {
|
|||||||
*/
|
*/
|
||||||
void outConfirm(JSONObject whereJson);
|
void outConfirm(JSONObject whereJson);
|
||||||
|
|
||||||
|
@Async
|
||||||
|
void asyncdown(ArrayList<JSONObject> objects);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 投料确认
|
* 投料确认
|
||||||
* @param whereJson /
|
* @param whereJson /
|
||||||
|
|||||||
@@ -33,12 +33,17 @@ import org.nl.wql.WQL;
|
|||||||
import org.nl.wql.core.bean.ResultBean;
|
import org.nl.wql.core.bean.ResultBean;
|
||||||
import org.nl.wql.core.bean.WQLObject;
|
import org.nl.wql.core.bean.WQLObject;
|
||||||
import org.nl.wql.util.WqlUtil;
|
import org.nl.wql.util.WqlUtil;
|
||||||
|
import org.springframework.aop.framework.AopContext;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -57,6 +62,10 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
private final MaterialbaseService materialbaseService;
|
private final MaterialbaseService materialbaseService;
|
||||||
private final WmsToAcsService wmsToAcsService;
|
private final WmsToAcsService wmsToAcsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Lazy
|
||||||
|
private FlourworkService flourworkService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||||
String is_all = MapUtil.getStr(whereJson, "is_all");
|
String is_all = MapUtil.getStr(whereJson, "is_all");
|
||||||
@@ -186,12 +195,70 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
|
|
||||||
JSONObject jsonFormMst = formTabMst.query("formula_id = '" + formula_id + "' and status <> '99'").uniqueResult(0);
|
JSONObject jsonFormMst = formTabMst.query("formula_id = '" + formula_id + "' and status <> '99'").uniqueResult(0);
|
||||||
if (ObjectUtil.isEmpty(jsonFormMst)) throw new BadRequestException("配方已完成");
|
if (ObjectUtil.isEmpty(jsonFormMst)) throw new BadRequestException("配方已完成");
|
||||||
|
String workorder_id = jsonFormMst.getString("workorder_id"); // 工令标识
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 查询需要移库的物料(配方明细表)条件:
|
* 查询需要移库的物料(配方明细表)条件:
|
||||||
* 1.状态等于10生成、20生产中
|
* 1.状态等于10生成、20生产中
|
||||||
* 2.是否需要移库 = 1
|
* 2.是否需要移库 = 1
|
||||||
* 3.按照配粉序号排序 ASC
|
* 3.按照配粉序号排序 ASC
|
||||||
*/
|
*/
|
||||||
|
// --------1.计算未领重量前置查询---------
|
||||||
|
// 查询当前配粉工位的所有上料位
|
||||||
|
JSONArray jsonDeviceArr = devicePointTab.query("device_uuid = '" + device_id + "' and point_type = '03'").getResultJSONArray(0);
|
||||||
|
String join = jsonDeviceArr.stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.map(row -> row.getString("point_uuid"))
|
||||||
|
.collect(Collectors.joining("','"));
|
||||||
|
|
||||||
|
// 当前上料位所有点位集合
|
||||||
|
JSONArray pointArr = WQLObject.getWQLObject("sch_base_point").query("point_id in ('" + join + "')").getResultJSONArray(0);
|
||||||
|
|
||||||
|
// 当前上料位所有点位可用数:根据pcsn和material_id 分组
|
||||||
|
String point_uuid_in = pointArr.stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.map(row -> row.getString("source_id"))
|
||||||
|
.collect(Collectors.joining("','"));
|
||||||
|
|
||||||
|
JSONArray jsonIvtArr = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "11")
|
||||||
|
.addParam("point_uuid_in", "('" + point_uuid_in + "')")
|
||||||
|
.process().getResultJSONArray(0);
|
||||||
|
|
||||||
|
//此工令移库数总和集合
|
||||||
|
JSONArray jsonMoveDtlArr = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "2")
|
||||||
|
.addParam("workorder_id", workorder_id)
|
||||||
|
.process().getResultJSONArray(0);
|
||||||
|
|
||||||
|
// --------2.生成移库单前置查询---------
|
||||||
|
// 查询全部可用重量集合 -- 库存数大于未领重量
|
||||||
|
JSONArray moveOutIvtAllArr = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "3").process().getResultJSONArray(0);
|
||||||
|
|
||||||
|
// 查询全部可用重量集合 -- 库存数大于0
|
||||||
|
JSONArray moveOutIvtAllArr2 = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "4").process().getResultJSONArray(0);
|
||||||
|
|
||||||
|
// 查询移入货位 -- 钴粉
|
||||||
|
List<JSONObject> moveInGFArr = WQL.getWO("QPDM_BI_FORMULA02")
|
||||||
|
.addParam("flag", "5")
|
||||||
|
.addParam("device_id", device_id)
|
||||||
|
.process().getResultJSONArray(0).stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 查询移入货位 -- 非钴粉
|
||||||
|
List<JSONObject> moveInNGFArr = WQL.getWO("QPDM_BI_FORMULA02")
|
||||||
|
.addParam("flag", "9")
|
||||||
|
.addParam("device_id", device_id)
|
||||||
|
.process().getResultJSONArray(0).stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 查询所有仓位
|
||||||
|
JSONArray attrArr = strucTab.query("1 = 1").getResultJSONArray(0);
|
||||||
|
|
||||||
|
// 生成移库单的所有集合
|
||||||
|
ArrayList<JSONObject> createMove = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
ArrayList<String> arr = new ArrayList<>();
|
ArrayList<String> arr = new ArrayList<>();
|
||||||
ArrayList<String> arr2 = new ArrayList<>();
|
ArrayList<String> arr2 = new ArrayList<>();
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
@@ -208,34 +275,29 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
*/
|
*/
|
||||||
// 1.计算剩余需投料: 剩余需投料=此配方明细的重量-已投料重量
|
// 1.计算剩余需投料: 剩余需投料=此配方明细的重量-已投料重量
|
||||||
double subQty = NumberUtil.sub(jsonFormDtl.getDoubleValue("formula_qty"), jsonFormDtl.getDoubleValue("put_qty"));
|
double subQty = NumberUtil.sub(jsonFormDtl.getDoubleValue("formula_qty"), jsonFormDtl.getDoubleValue("put_qty"));
|
||||||
// 2.查询当前配粉工位的所有上料位
|
// 2.查询当前可用数:当前可用数=sum(此配粉工位点位仓位此物料可用数)
|
||||||
JSONArray jsonDeviceArr = devicePointTab.query("device_uuid = '" + device_id + "' and point_type = '03'").getResultJSONArray(0);
|
|
||||||
// 3.查询当前可用数:当前可用数=sum(此配粉工位点位仓位此物料可用数)
|
|
||||||
double canuse_qty = 0.0; // 总当前可用数
|
double canuse_qty = 0.0; // 总当前可用数
|
||||||
if (ObjectUtil.isNotEmpty(jsonDeviceArr)) {
|
if (ObjectUtil.isNotEmpty(jsonDeviceArr)) {
|
||||||
for (int j = 0; j < jsonDeviceArr.size(); j++) {
|
// 总可用数
|
||||||
JSONObject json = jsonDeviceArr.getJSONObject(j);
|
canuse_qty = jsonIvtArr.stream()
|
||||||
JSONObject jsonObject = WQLObject.getWQLObject("sch_base_point").query("point_id ='" + json.getString("point_uuid") + "'").uniqueResult(0);
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
HashMap<String, String> map = new HashMap<>();
|
.filter(row -> row.getString("material_id").equals(material_id) && row.getString("pcsn").equals(pcsn))
|
||||||
map.put("flag", "1");
|
.mapToDouble(row -> row.getDoubleValue("canuse_qty")).sum();
|
||||||
map.put("point_uuid", jsonObject.getString("source_id"));
|
|
||||||
map.put("pcsn", pcsn);
|
|
||||||
map.put("material_id", material_id);
|
|
||||||
JSONObject jsonIvt = WQL.getWO("QPDM_BI_FORMULA02").addParamMap(map).process().uniqueResult(0);
|
|
||||||
if (ObjectUtil.isNotEmpty(jsonIvt))
|
|
||||||
canuse_qty = NumberUtil.add(canuse_qty, jsonIvt.getDoubleValue("canuse_qty"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 4.查询正在移库数:正在移库数=sum(未完成移库单、此工令、此物料移库数量)
|
|
||||||
String workorder_id = jsonFormMst.getString("workorder_id"); // 工令标识
|
// 3.查询正在移库数:正在移库数=sum(未完成移库单、此工令、此物料移库数量)
|
||||||
JSONObject jsonMoveDtl = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "2").addParam("workorder_id", workorder_id).addParam("material_id", material_id).addParam("pcsn", pcsn).process().uniqueResult(0);
|
|
||||||
double move_qty = 0.0; // 正在移库数
|
double move_qty = 0.0; // 正在移库数
|
||||||
if (ObjectUtil.isNotEmpty(jsonMoveDtl)) {
|
if (ObjectUtil.isNotEmpty(jsonMoveDtlArr)) {
|
||||||
move_qty = jsonMoveDtl.getDoubleValue("qty");
|
move_qty = jsonMoveDtlArr.stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.filter(row -> row.getString("material_id").equals(material_id) && row.getString("pcsn").equals(pcsn))
|
||||||
|
.mapToDouble(row -> row.getDoubleValue("qty")).sum();
|
||||||
|
|
||||||
}
|
}
|
||||||
// 5.计算未领重量:未领重量=剩余需投料 - 当前可用数 - 正在移库数
|
|
||||||
|
// 4.计算未领重量:未领重量=剩余需投料 - 当前可用数 - 正在移库数
|
||||||
double uncla_qty = Double.parseDouble(String.valueOf(NumberUtil.sub(subQty, canuse_qty, move_qty)));
|
double uncla_qty = Double.parseDouble(String.valueOf(NumberUtil.sub(subQty, canuse_qty, move_qty)));
|
||||||
// 6.判断物料是否为钴粉
|
// 5.判断物料是否为钴粉
|
||||||
boolean is_GF = materialbaseService.isAlongMaterType(MaterOptTypeEnum.GF.getCode(), material_id, null);
|
boolean is_GF = materialbaseService.isAlongMaterType(MaterOptTypeEnum.GF.getCode(), material_id, null);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -243,90 +305,130 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
*/
|
*/
|
||||||
// 1.查询移出货位:此物料批次、未锁定、可用数量>=未领重量,按可用数量排序的第一个货位物料; 取不到:此物料批次、未锁定
|
// 1.查询移出货位:此物料批次、未锁定、可用数量>=未领重量,按可用数量排序的第一个货位物料; 取不到:此物料批次、未锁定
|
||||||
JSONObject moveOutIvt = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "3").addParam("uncla_qty", String.valueOf(uncla_qty)).addParam("material_id", material_id).addParam("pcsn", pcsn).process().uniqueResult(0);
|
JSONObject moveOutIvt = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "3").addParam("uncla_qty", String.valueOf(uncla_qty)).addParam("material_id", material_id).addParam("pcsn", pcsn).process().uniqueResult(0);
|
||||||
|
|
||||||
|
double finalCanuse_qty = uncla_qty;
|
||||||
|
List<JSONObject> moveOutIvtAllFilterArr = moveOutIvtAllArr.stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.filter(row -> row.getString("material_id").equals(material_id)
|
||||||
|
&& row.getString("pcsn").equals(pcsn)
|
||||||
|
&& row.getDoubleValue("canuse_qty") >= finalCanuse_qty
|
||||||
|
)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 2.如果为空:说明需要进行多次生成移库任务
|
// 2.如果为空:说明需要进行多次生成移库任务
|
||||||
if (ObjectUtil.isEmpty(moveOutIvt)) {
|
if (ObjectUtil.isEmpty(moveOutIvtAllFilterArr)) {
|
||||||
JSONArray moveOutIvtArr = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "4").addParam("material_id", material_id).addParam("pcsn", pcsn).process().getResultJSONArray(0);
|
List<JSONObject> moveOutIvtArr = moveOutIvtAllArr2.stream()
|
||||||
if (ObjectUtil.isNotEmpty(moveOutIvtArr)) {
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
for (int k = 0; k < moveOutIvtArr.size(); k++) {
|
.filter(row -> row.getString("material_id").equals(material_id)
|
||||||
JSONObject jsonMoveOutIvt = moveOutIvtArr.getJSONObject(k); // 移出货位
|
&& row.getString("pcsn").equals(pcsn)
|
||||||
double canuse_qty1 = jsonMoveOutIvt.getDoubleValue("canuse_qty");
|
)
|
||||||
// 3.判断未领重量是否 <= 0 ,如果是则跳出循环
|
.collect(Collectors.toList());
|
||||||
if (uncla_qty <= 0) break;
|
|
||||||
// 4.查找移入货位,判断物料是否是钴粉
|
if (ObjectUtil.isEmpty(moveOutIvtArr)) {
|
||||||
JSONObject moveInIvt = new JSONObject();
|
|
||||||
if (is_GF) {
|
|
||||||
moveInIvt = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "5").addParam("device_id", whereJson.getString("device_id")).process().uniqueResult(0);
|
|
||||||
} else {
|
|
||||||
moveInIvt = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "9").addParam("device_id", whereJson.getString("device_id")).process().uniqueResult(0);
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isEmpty(moveInIvt)) break;
|
|
||||||
// 5.生成移库单
|
|
||||||
//校验点位是否有执行中任务:
|
|
||||||
;
|
|
||||||
JSONArray runingtask = WQLObject.getWQLObject("SCH_BASE_Task").query("next_point_code = '" + moveInIvt.getString("point_code") + "' and task_status <> '99' and is_delete = '0'").getResultJSONArray(0);
|
|
||||||
if (runingtask.size()>0){
|
|
||||||
throw new BadRequestException("分配点位存在未完成任务:"+moveInIvt.getString("point_code"));
|
|
||||||
}
|
|
||||||
JSONObject map = new JSONObject();
|
|
||||||
JSONArray tableData = new JSONArray();
|
|
||||||
map.put("bill_status", "10");
|
|
||||||
map.put("bill_type", "21");
|
|
||||||
map.put("biz_date", DateUtil.today());
|
|
||||||
map.put("stor_code", "01");
|
|
||||||
map.put("stor_id", "1473161852946092032");
|
|
||||||
map.put("stor_name", "原材料库");
|
|
||||||
JSONObject param = new JSONObject();
|
|
||||||
param.put("edit", true);
|
|
||||||
param.put("is_active", jsonMoveOutIvt.getString("is_active"));
|
|
||||||
param.put("ivt_level", jsonMoveOutIvt.getString("ivt_level"));
|
|
||||||
param.put("material_id", jsonMoveOutIvt.getString("material_id"));
|
|
||||||
param.put("pcsn", jsonMoveOutIvt.getString("pcsn"));
|
|
||||||
param.put("qty", jsonMoveOutIvt.getString("canuse_qty"));
|
|
||||||
param.put("qty_unit_id", jsonMoveOutIvt.getString("qty_unit_id"));
|
|
||||||
param.put("quality_scode", jsonMoveOutIvt.getString("quality_scode"));
|
|
||||||
JSONObject trunIn = strucTab.query("struct_code = '" + moveInIvt.getString("point_code") + "'").uniqueResult(0);
|
|
||||||
JSONObject trunOut = strucTab.query("struct_code = '" + jsonMoveOutIvt.getString("struct_code") + "'").uniqueResult(0);
|
|
||||||
param.put("turnin_sect_id", trunIn.getString("sect_id"));
|
|
||||||
param.put("turnin_sect_code", trunIn.getString("sect_code"));
|
|
||||||
param.put("turnin_sect_name", trunIn.getString("sect_name"));
|
|
||||||
param.put("turnin_struct_id", trunIn.getString("struct_id"));
|
|
||||||
param.put("turnin_struct_code", trunIn.getString("struct_code"));
|
|
||||||
param.put("turnin_struct_name", trunIn.getString("struct_name"));
|
|
||||||
param.put("turnout_sect_id", trunOut.getString("sect_id"));
|
|
||||||
param.put("turnout_sect_code", trunOut.getString("sect_code"));
|
|
||||||
param.put("turnout_sect_name", trunOut.getString("sect_name"));
|
|
||||||
param.put("turnout_struct_id", trunOut.getString("struct_id"));
|
|
||||||
param.put("turnout_struct_code", trunOut.getString("struct_code"));
|
|
||||||
param.put("turnout_struct_name", trunOut.getString("struct_name"));
|
|
||||||
param.put("storagevehicle_code", trunOut.getString("storagevehicle_code"));
|
|
||||||
param.put("work_status", "10");
|
|
||||||
param.put("source_billdtl_id", formuladtl_id);
|
|
||||||
tableData.add(param);
|
|
||||||
map.put("tableData", tableData);
|
|
||||||
String moveinv_id = handMoveStorService.insertDtl2(map);
|
|
||||||
// 6.下发移库单
|
|
||||||
JSONObject jsonMoveParam = new JSONObject();
|
|
||||||
jsonMoveParam.put("moveinv_id", moveinv_id);
|
|
||||||
handMoveStorService.handdown(jsonMoveParam);
|
|
||||||
// 7.下发移库单后减去未领重量
|
|
||||||
uncla_qty = NumberUtil.sub(uncla_qty, canuse_qty1);
|
|
||||||
// 回馈任务数
|
|
||||||
taskNum = String.valueOf(NumberUtil.add(taskNum, "1"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 没有找到移出货位 ,说明没有物料
|
// 没有找到移出货位 ,说明没有物料
|
||||||
arr.add(jsonFormDtl.getString("material_id"));
|
arr.add(jsonFormDtl.getString("material_id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < moveOutIvtArr.size(); j++) {
|
||||||
|
JSONObject jsonMoveOutIvt = moveOutIvtArr.get(j); // 移出货位
|
||||||
|
double canuse_qty1 = jsonMoveOutIvt.getDoubleValue("canuse_qty"); // 移出数量
|
||||||
|
|
||||||
|
// 判断未领重量是否 <= 0 ,如果是则跳出循环
|
||||||
|
if (uncla_qty <= 0) break;
|
||||||
|
|
||||||
|
// 查找移入货位,判断物料是否是钴粉
|
||||||
|
JSONObject moveInIvt = new JSONObject();
|
||||||
|
|
||||||
|
if (is_GF) {
|
||||||
|
if (ObjectUtil.isNotEmpty(moveInNGFArr)) {
|
||||||
|
moveInIvt = moveInGFArr.get(0);
|
||||||
|
moveInGFArr.remove(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ObjectUtil.isNotEmpty(moveInNGFArr)) {
|
||||||
|
moveInIvt = moveInNGFArr.get(0);
|
||||||
|
moveInNGFArr.remove(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(moveInIvt)) break;
|
||||||
|
|
||||||
|
// 校验点位是否有执行中的任务
|
||||||
|
JSONArray runingtask = WQLObject.getWQLObject("SCH_BASE_Task").query("next_point_code = '" + moveInIvt.getString("point_code") + "' and task_status <> '99' and is_delete = '0'").getResultJSONArray(0);
|
||||||
|
if (runingtask.size()>0){
|
||||||
|
throw new BadRequestException("分配点位存在未完成任务:"+moveInIvt.getString("point_code"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成移库单
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
JSONArray tableData = new JSONArray();
|
||||||
|
map.put("bill_status", "10");
|
||||||
|
map.put("bill_type", "21");
|
||||||
|
map.put("biz_date", DateUtil.today());
|
||||||
|
map.put("stor_code", "01");
|
||||||
|
map.put("stor_id", "1473161852946092032");
|
||||||
|
map.put("stor_name", "原材料库");
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
param.put("edit", true);
|
||||||
|
param.put("is_active", jsonMoveOutIvt.getString("is_active"));
|
||||||
|
param.put("ivt_level", jsonMoveOutIvt.getString("ivt_level"));
|
||||||
|
param.put("material_id", jsonMoveOutIvt.getString("material_id"));
|
||||||
|
param.put("pcsn", jsonMoveOutIvt.getString("pcsn"));
|
||||||
|
param.put("qty", jsonMoveOutIvt.getString("canuse_qty"));
|
||||||
|
param.put("qty_unit_id", jsonMoveOutIvt.getString("qty_unit_id"));
|
||||||
|
param.put("quality_scode", jsonMoveOutIvt.getString("quality_scode"));
|
||||||
|
|
||||||
|
JSONObject finalMoveInIvt = moveInIvt;
|
||||||
|
JSONObject trunIn = attrArr.stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.filter(row -> row.getString("struct_code").equals(finalMoveInIvt.getString("point_code")))
|
||||||
|
.collect(Collectors.toList()).get(0);
|
||||||
|
|
||||||
|
JSONObject trunOut = attrArr.stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.filter(row -> row.getString("struct_code").equals(jsonMoveOutIvt.getString("struct_code")))
|
||||||
|
.collect(Collectors.toList()).get(0);
|
||||||
|
|
||||||
|
param.put("turnin_sect_id", trunIn.getString("sect_id"));
|
||||||
|
param.put("turnin_sect_code", trunIn.getString("sect_code"));
|
||||||
|
param.put("turnin_sect_name", trunIn.getString("sect_name"));
|
||||||
|
param.put("turnin_struct_id", trunIn.getString("struct_id"));
|
||||||
|
param.put("turnin_struct_code", trunIn.getString("struct_code"));
|
||||||
|
param.put("turnin_struct_name", trunIn.getString("struct_name"));
|
||||||
|
param.put("turnout_sect_id", trunOut.getString("sect_id"));
|
||||||
|
param.put("turnout_sect_code", trunOut.getString("sect_code"));
|
||||||
|
param.put("turnout_sect_name", trunOut.getString("sect_name"));
|
||||||
|
param.put("turnout_struct_id", trunOut.getString("struct_id"));
|
||||||
|
param.put("turnout_struct_code", trunOut.getString("struct_code"));
|
||||||
|
param.put("turnout_struct_name", trunOut.getString("struct_name"));
|
||||||
|
param.put("storagevehicle_code", trunOut.getString("storagevehicle_code"));
|
||||||
|
param.put("work_status", "10");
|
||||||
|
param.put("source_billdtl_id", formuladtl_id);
|
||||||
|
tableData.add(param);
|
||||||
|
map.put("tableData", tableData);
|
||||||
|
createMove.add(map);
|
||||||
|
|
||||||
|
// 减去未领重量
|
||||||
|
uncla_qty = NumberUtil.sub(uncla_qty, canuse_qty1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 8.到这一步说明没有进入步骤 2
|
// 到这一步说明没有进入步骤 2
|
||||||
// 8.1 查找移入货位,判断物料是否是钴粉
|
// 查找移入货位,判断物料是否是钴粉
|
||||||
if (uncla_qty > 0) {
|
if (uncla_qty > 0) {
|
||||||
JSONObject moveInIvt2 = new JSONObject();
|
JSONObject moveInIvt2 = new JSONObject();
|
||||||
|
|
||||||
if (is_GF) {
|
if (is_GF) {
|
||||||
moveInIvt2 = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "5").addParam("device_id", whereJson.getString("device_id")).process().uniqueResult(0);
|
if (ObjectUtil.isNotEmpty(moveInNGFArr)) {
|
||||||
|
moveInIvt2 = moveInGFArr.get(0);
|
||||||
|
moveInGFArr.remove(0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
moveInIvt2 = WQL.getWO("QPDM_BI_FORMULA02").addParam("flag", "9").addParam("device_id", whereJson.getString("device_id")).process().uniqueResult(0);
|
if (ObjectUtil.isNotEmpty(moveInNGFArr)) {
|
||||||
|
moveInIvt2 = moveInNGFArr.get(0);
|
||||||
|
moveInNGFArr.remove(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(moveInIvt2)) {
|
if (ObjectUtil.isNotEmpty(moveInIvt2)) {
|
||||||
// 8.2 生成移库单
|
// 8.2 生成移库单
|
||||||
JSONObject map = new JSONObject();
|
JSONObject map = new JSONObject();
|
||||||
@@ -346,8 +448,18 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
param.put("qty", moveOutIvt.getString("canuse_qty"));
|
param.put("qty", moveOutIvt.getString("canuse_qty"));
|
||||||
param.put("qty_unit_id", moveOutIvt.getString("qty_unit_id"));
|
param.put("qty_unit_id", moveOutIvt.getString("qty_unit_id"));
|
||||||
param.put("quality_scode", moveOutIvt.getString("quality_scode"));
|
param.put("quality_scode", moveOutIvt.getString("quality_scode"));
|
||||||
JSONObject trunIn = strucTab.query("struct_code = '" + moveInIvt2.getString("point_code") + "'").uniqueResult(0);
|
|
||||||
JSONObject trunOut = strucTab.query("struct_code = '" + moveOutIvt.getString("struct_code") + "'").uniqueResult(0);
|
JSONObject finalMoveInIvt = moveInIvt2;
|
||||||
|
JSONObject trunIn = attrArr.stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.filter(row -> row.getString("struct_code").equals(finalMoveInIvt.getString("point_code")))
|
||||||
|
.collect(Collectors.toList()).get(0);
|
||||||
|
|
||||||
|
JSONObject trunOut = attrArr.stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.filter(row -> row.getString("struct_code").equals(moveOutIvt.getString("struct_code")))
|
||||||
|
.collect(Collectors.toList()).get(0);
|
||||||
|
|
||||||
param.put("turnin_sect_id", trunIn.getString("sect_id"));
|
param.put("turnin_sect_id", trunIn.getString("sect_id"));
|
||||||
param.put("turnin_sect_code", trunIn.getString("sect_code"));
|
param.put("turnin_sect_code", trunIn.getString("sect_code"));
|
||||||
param.put("turnin_sect_name", trunIn.getString("sect_name"));
|
param.put("turnin_sect_name", trunIn.getString("sect_name"));
|
||||||
@@ -365,25 +477,49 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
param.put("source_billdtl_id", formuladtl_id);
|
param.put("source_billdtl_id", formuladtl_id);
|
||||||
tableData.add(param);
|
tableData.add(param);
|
||||||
map.put("tableData", tableData);
|
map.put("tableData", tableData);
|
||||||
String moveinv_id = handMoveStorService.insertDtl2(map);
|
createMove.add(map);
|
||||||
// 6.下发移库单
|
|
||||||
JSONObject jsonMoveParam = new JSONObject();
|
|
||||||
jsonMoveParam.put("moveinv_id", moveinv_id);
|
|
||||||
handMoveStorService.handdown(jsonMoveParam);
|
|
||||||
// 回馈任务数
|
|
||||||
taskNum = String.valueOf(NumberUtil.add(taskNum, "1"));
|
|
||||||
} else {
|
} else {
|
||||||
arr2.add(String.valueOf(i));
|
arr2.add(String.valueOf(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
String nickName = SecurityUtils.getNickName();
|
||||||
|
// 创建移库单并下发
|
||||||
|
ArrayList<JSONObject> objects = new ArrayList<>();
|
||||||
|
for (JSONObject map : createMove) {
|
||||||
|
// 移库单创建
|
||||||
|
String moveinv_id = handMoveStorService.insertDtl2(map);
|
||||||
|
// 下发
|
||||||
|
JSONObject jsonMoveParam = new JSONObject();
|
||||||
|
jsonMoveParam.put("moveinv_id", moveinv_id);
|
||||||
|
jsonMoveParam.put("currentUserId", currentUserId);
|
||||||
|
jsonMoveParam.put("nickName", nickName);
|
||||||
|
objects.add(jsonMoveParam);
|
||||||
|
|
||||||
|
taskNum = String.valueOf(NumberUtil.add(taskNum, "1"));
|
||||||
|
}
|
||||||
if (dtlArr.size() == arr.size()) throw new BadRequestException("叫料失败,此配方明细没有符合的库存");
|
if (dtlArr.size() == arr.size()) throw new BadRequestException("叫料失败,此配方明细没有符合的库存");
|
||||||
if (dtlArr.size() == arr2.size()) throw new BadRequestException("叫料失败,配粉间没有空位");
|
if (dtlArr.size() == arr2.size()) throw new BadRequestException("叫料失败,配粉间没有空位");
|
||||||
result.put("task", taskNum);
|
result.put("task", taskNum);
|
||||||
|
flourworkService.asyncdown(objects);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void asyncdown(ArrayList<JSONObject> objects){
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
for (JSONObject json : objects) {
|
||||||
|
handMoveStorService.handdown(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void startWork(JSONObject whereJson) {
|
public void startWork(JSONObject whereJson) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
输入.device_id TYPEAS s_string
|
输入.device_id TYPEAS s_string
|
||||||
输入.formula_id TYPEAS s_string
|
输入.formula_id TYPEAS s_string
|
||||||
输入.storagevehicle_id TYPEAS s_string
|
输入.storagevehicle_id TYPEAS s_string
|
||||||
|
输入.point_uuid_in TYPEAS f_string
|
||||||
|
|
||||||
|
|
||||||
[临时表]
|
[临时表]
|
||||||
@@ -75,6 +76,27 @@
|
|||||||
ENDQUERY
|
ENDQUERY
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
|
IF 输入.flag = "11"
|
||||||
|
QUERY
|
||||||
|
SELECT
|
||||||
|
SUM(ivt.canuse_qty) AS canuse_qty,
|
||||||
|
ivt.material_id,
|
||||||
|
ivt.pcsn
|
||||||
|
FROM
|
||||||
|
ST_IVT_StructIvt ivt
|
||||||
|
WHERE
|
||||||
|
1=1
|
||||||
|
|
||||||
|
OPTION 输入.point_uuid_in <> ""
|
||||||
|
ivt.struct_id in 输入.point_uuid_in
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
group by ivt.material_id,ivt.pcsn
|
||||||
|
|
||||||
|
ENDSELECT
|
||||||
|
ENDQUERY
|
||||||
|
ENDIF
|
||||||
|
|
||||||
IF 输入.flag = "2"
|
IF 输入.flag = "2"
|
||||||
QUERY
|
QUERY
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.nl.wms.st.instor.service;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PC端出入库新增
|
* PC端出入库新增
|
||||||
@@ -375,6 +377,18 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
|
|||||||
//定义返回数据
|
//定义返回数据
|
||||||
JSONObject ret = new JSONObject();
|
JSONObject ret = new JSONObject();
|
||||||
|
|
||||||
|
// 点位集合
|
||||||
|
List<JSONObject> pointList = wo_Point.query("1 = 1").getResultJSONArray(0)
|
||||||
|
.stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 任务集合
|
||||||
|
List<JSONObject> taskList = wo_Task.query("is_delete = '0' and taskdtl_type='07' and task_status='01'")
|
||||||
|
.getResultJSONArray(0).stream()
|
||||||
|
.map(row -> JSON.parseObject(row.toString()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
String nickName = SecurityUtils.getNickName();
|
String nickName = SecurityUtils.getNickName();
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
@@ -420,14 +434,32 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
|
|||||||
jo.put("turnin_struct_id", turnin_struct_id);
|
jo.put("turnin_struct_id", turnin_struct_id);
|
||||||
jo.put("turnin_struct_code", row.getString("turnin_struct_code"));
|
jo.put("turnin_struct_code", row.getString("turnin_struct_code"));
|
||||||
jo.put("turnin_struct_name", row.getString("turnin_struct_name"));
|
jo.put("turnin_struct_name", row.getString("turnin_struct_name"));
|
||||||
|
|
||||||
//查询移入点位
|
//查询移入点位
|
||||||
JSONObject point = wo_Point.query("source_id='" + turnin_struct_id + "'").uniqueResult(0);
|
JSONObject point = new JSONObject();
|
||||||
|
List<JSONObject> pointArr = pointList.stream()
|
||||||
|
.filter(a -> a.getString("source_id").equals(turnin_struct_id))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(pointArr)) {
|
||||||
|
point = pointArr.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONObject point = wo_Point.query("source_id='" + turnin_struct_id + "'").uniqueResult(0);
|
||||||
if (point == null) {
|
if (point == null) {
|
||||||
throw new BadRequestException(row.getString("turnin_struct_code") + "仓位数据异常,找不到对应点位!");
|
throw new BadRequestException(row.getString("turnin_struct_code") + "仓位数据异常,找不到对应点位!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断是否已生成过了任务,无未生成则插入任务
|
//判断是否已生成过了任务,无未生成则插入任务
|
||||||
JSONObject task = wo_Task.query("is_delete = '0' and taskdtl_type='07' and task_status='01' and start_point_code='" + jo.getString("start_point_code") + "'").uniqueResult(0);
|
JSONObject task = new JSONObject();
|
||||||
if (task != null) {
|
List<JSONObject> taskArr = taskList.stream()
|
||||||
|
.filter(a -> a.getString("start_point_code").equals(jo.getString("start_point_code")))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (ObjectUtil.isNotEmpty(taskArr)) {
|
||||||
|
task = taskArr.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(task)) {
|
||||||
jo.put("task_id", task.getString("task_id"));
|
jo.put("task_id", task.getString("task_id"));
|
||||||
} else {
|
} else {
|
||||||
task = new JSONObject();
|
task = new JSONObject();
|
||||||
@@ -455,6 +487,7 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
|
|||||||
task.put("priority", "1");
|
task.put("priority", "1");
|
||||||
wo_Task.insert(task);
|
wo_Task.insert(task);
|
||||||
jo.put("task_id", task_id);
|
jo.put("task_id", task_id);
|
||||||
|
taskList.add(task);
|
||||||
}
|
}
|
||||||
//插入明细表
|
//插入明细表
|
||||||
wo_dtl.insert(jo);
|
wo_dtl.insert(jo);
|
||||||
@@ -939,8 +972,8 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
|
|||||||
|
|
||||||
HandMoveStorAcsTask handMoveStorAcsTask = new HandMoveStorAcsTask();
|
HandMoveStorAcsTask handMoveStorAcsTask = new HandMoveStorAcsTask();
|
||||||
|
|
||||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
Long currentUserId = whereJson.getLong("currentUserId");
|
||||||
String nickName = SecurityUtils.getNickName();
|
String nickName = whereJson.getString("nickName");
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
|
|
||||||
String moveinv_id = whereJson.getString("moveinv_id");
|
String moveinv_id = whereJson.getString("moveinv_id");
|
||||||
|
|||||||
Reference in New Issue
Block a user