rev:成品出入库功能
This commit is contained in:
Binary file not shown.
@@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ldjun
|
* @author ldjun
|
||||||
@@ -266,13 +267,17 @@ public class PointServiceImpl implements PointService {
|
|||||||
@Override
|
@Override
|
||||||
public List<Map> selectPoint(String type) {
|
public List<Map> selectPoint(String type) {
|
||||||
List list = new ArrayList<>();
|
List list = new ArrayList<>();
|
||||||
Map<String, String> map = new HashMap<>();
|
|
||||||
map.put("text","ARK01");
|
|
||||||
map.put("value","A区入库01");
|
|
||||||
list.add(map);
|
|
||||||
if (!StringUtils.isEmpty(type)){
|
if (!StringUtils.isEmpty(type)){
|
||||||
if (type.equals("1")){
|
if (type.equals("1")){
|
||||||
JSONArray result = this.getPoint(MapOf.of("area_type", ConstantParam.RK_POINT));
|
JSONArray result = this.getPoint(MapOf.of("area_type", ConstantParam.RK_POINT));
|
||||||
|
if (result.size()>0){
|
||||||
|
result.forEach(o -> {
|
||||||
|
Map<String, String> map1 = new HashMap<>();
|
||||||
|
map1.put("value",((JSONObject)o).getString("point_code"));
|
||||||
|
map1.put("text",((JSONObject)o).getString("point_name"));
|
||||||
|
list.add(map1);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (type.equals("2")){
|
if (type.equals("2")){
|
||||||
Pageable pageable =PageRequest.of(0,999);
|
Pageable pageable =PageRequest.of(0,999);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.wms.st.in.rest;
|
package org.nl.wms.st.in.rest;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -13,6 +14,8 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nl.common.enums.AcsTaskEnum;
|
||||||
import org.nl.common.enums.StatusEnum;
|
import org.nl.common.enums.StatusEnum;
|
||||||
import org.nl.common.handler.LockProcess;
|
import org.nl.common.handler.LockProcess;
|
||||||
|
import org.nl.common.utils.MapOf;
|
||||||
import org.nl.common.utils.RedissonUtils;
|
import org.nl.common.utils.RedissonUtils;
|
||||||
import org.nl.common.utils.SecurityUtils;
|
import org.nl.common.utils.SecurityUtils;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
@@ -165,10 +168,10 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
row.put("assign_qty", row.getDoubleValue("plan_qty"));
|
row.put("assign_qty", row.getDoubleValue("plan_qty"));
|
||||||
row.put("plan_qty", row.getDoubleValue("plan_qty"));
|
row.put("plan_qty", row.getDoubleValue("plan_qty"));
|
||||||
String plan_qty = row.getString("plan_qty");
|
String plan_qty = row.getString("plan_qty");
|
||||||
total_qty += Double.parseDouble(plan_qty);
|
if (!StringUtils.isEmpty(plan_qty)){
|
||||||
|
total_qty += Double.parseDouble(plan_qty);
|
||||||
|
}
|
||||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").insert(row);
|
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").insert(row);
|
||||||
|
|
||||||
// 插入分配表
|
// 插入分配表
|
||||||
JSONObject dis = new JSONObject();
|
JSONObject dis = new JSONObject();
|
||||||
dis.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId() + "");
|
dis.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId() + "");
|
||||||
@@ -351,7 +354,7 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public void divStruct(JSONObject whereJson) {
|
public void divStruct(JSONObject whereJson) {
|
||||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
WQLObject structattrTab = WQLObject.getWQLObject("st_ivt_structattr");
|
||||||
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
|
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
|
||||||
|
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
@@ -372,7 +375,7 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
//查询主表信息
|
//查询主表信息
|
||||||
JSONObject mst = WQLObject.getWQLObject("st_ivt_iostorinv").query("iostorinv_id = '" + map.get("iostorinv_id") + "'").uniqueResult(0);
|
JSONObject mst = WQLObject.getWQLObject("st_ivt_iostorinv").query("iostorinv_id = '" + map.get("iostorinv_id") + "'").uniqueResult(0);
|
||||||
|
|
||||||
JSONObject jsonDis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinvdis_id = '" + map.getString("iostorinvdis_id") + "'").uniqueResult(0);
|
JSONObject jsonDis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinv_id = '" + map.getString("iostorinv_id") + "'").uniqueResult(0);
|
||||||
// 校验是否已分配
|
// 校验是否已分配
|
||||||
if (ObjectUtil.isNotEmpty(jsonDis.getString("struct_id"))) {
|
if (ObjectUtil.isNotEmpty(jsonDis.getString("struct_id"))) {
|
||||||
throw new BadRequestException("该明细已分配,无法继续分配!");
|
throw new BadRequestException("该明细已分配,无法继续分配!");
|
||||||
@@ -388,8 +391,8 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
JSONObject jsonParam = new JSONObject();
|
JSONObject jsonParam = new JSONObject();
|
||||||
JSONObject jsonPoint = new JSONObject();
|
JSONObject jsonPoint = new JSONObject();
|
||||||
if (whereJson.containsKey("sect_id")) {
|
if (whereJson.containsKey("sect_id")) {
|
||||||
jsonParam.put("sect_code", whereJson.get("sect_code"));
|
jsonParam.put("sect_code", whereJson.get("sect_id"));
|
||||||
jsonParam.put("stor_id", whereJson.get("stor_id"));
|
jsonParam.put("product_area", whereJson.get("stor_id"));
|
||||||
jsonParam.put("material_id", jsonDtl.getString("material_id"));
|
jsonParam.put("material_id", jsonDtl.getString("material_id"));
|
||||||
jsonPoint = this.autoDis(jsonParam);
|
jsonPoint = this.autoDis(jsonParam);
|
||||||
is_length = jsonPoint.getString("is_length");
|
is_length = jsonPoint.getString("is_length");
|
||||||
@@ -401,19 +404,22 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
throw new BadRequestException("未查询到适用点位!");
|
throw new BadRequestException("未查询到适用点位!");
|
||||||
}
|
}
|
||||||
|
|
||||||
region_code = jsonPoint.getString("region_code");
|
region_code = jsonPoint.getString("sect_code");
|
||||||
region_name = jsonPoint.getString("region_name");
|
region_name = jsonPoint.getString("sect_name");
|
||||||
point_id = jsonPoint.getString("point_id");
|
point_id = jsonPoint.getString("struct_id");
|
||||||
point_code = jsonPoint.getString("point_code");
|
point_code = jsonPoint.getString("struct_code");
|
||||||
point_name = jsonPoint.getString("point_name");
|
point_name = jsonPoint.getString("struct_name");
|
||||||
} else {
|
} else {
|
||||||
// 指定货位: 判断所选货位是否满足物料
|
// 指定货位: 判断所选货位是否满足物料
|
||||||
// 判断物料是否超长
|
// 判断物料是否超长
|
||||||
JSONObject jsonMater = materTab.query("material_id = '" + map.getString("material_id") + "'").uniqueResult(0);
|
double material_length= 0;
|
||||||
|
double material_length_up=9999;
|
||||||
String length_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MATERIAL_LENGTH_UP").getValue();
|
if (!StringUtils.isEmpty(map.getString("material_id"))){
|
||||||
double material_length = jsonMater.getDoubleValue("length");
|
JSONObject jsonMater = materTab.query("material_id = '" + map.getString("material_id") + "'").uniqueResult(0);
|
||||||
double material_length_up = Double.valueOf(length_up);
|
String length_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MATERIAL_LENGTH_UP").getValue();
|
||||||
|
material_length = jsonMater.getDoubleValue("length");
|
||||||
|
material_length_up = Double.valueOf(length_up);
|
||||||
|
}
|
||||||
|
|
||||||
if (material_length > material_length_up) {
|
if (material_length > material_length_up) {
|
||||||
throw new BadRequestException("物料超长,请自动分配");
|
throw new BadRequestException("物料超长,请自动分配");
|
||||||
@@ -434,18 +440,17 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
dis_map.put("struct_name", point_name);
|
dis_map.put("struct_name", point_name);
|
||||||
|
|
||||||
//锁定货位
|
//锁定货位
|
||||||
JSONObject jsonPoint1 = pointTab.query("point_id = '" + point_id + "'").uniqueResult(0);
|
JSONObject jsonPoint1 = structattrTab.query("struct_id = '" + point_id + "'").uniqueResult(0);
|
||||||
jsonPoint1.put("lock_type", StatusEnum.LOCK_ON.getCode());
|
structattrTab.update(MapOf.of("lock_type", StatusEnum.LOCK_ON.getCode()),"struct_id = '" + point_id + "'");
|
||||||
pointTab.update(jsonPoint1);
|
|
||||||
// 判断是否需要锁定两个货位
|
// 判断是否需要锁定两个货位
|
||||||
if (StrUtil.equals(is_length, "1")) {
|
if (StrUtil.equals(is_length, "1")) {
|
||||||
JSONObject jsonPoint2 = pointTab.query("point_id = '" + jsonPoint1.getString("control_point") + "'").uniqueResult(0);
|
JSONObject jsonPoint2 = structattrTab.query("struct_id = '" + jsonPoint1.getString("control_point") + "'").uniqueResult(0);
|
||||||
jsonPoint2.put("lock_type", StatusEnum.LOCK_ON.getCode());
|
jsonPoint2.put("lock_type", StatusEnum.LOCK_ON.getCode());
|
||||||
pointTab.update(jsonPoint2);
|
structattrTab.update(jsonPoint2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新分配明细
|
// 更新分配明细iostorinv_id -> 1646796745134444544
|
||||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(dis_map, "iostorinvdtl_id = '" + map.get("iostorinvdtl_id") + "'");
|
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(dis_map, "iostorinv_id = '" + map.get("iostorinv_id") + "'");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 更新库存
|
* 更新库存
|
||||||
@@ -597,7 +602,7 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
ProductInTask task = new ProductInTask();
|
ProductInTask task = new ProductInTask();
|
||||||
|
|
||||||
JSONObject task_form = new JSONObject();
|
JSONObject task_form = new JSONObject();
|
||||||
task_form.put("task_type", "010501");
|
task_form.put("task_type", AcsTaskEnum.TASK_STRUCT_IN.getCode());
|
||||||
task_form.put("start_device_code", point_code);
|
task_form.put("start_device_code", point_code);
|
||||||
task_form.put("next_device_code", ios_dis.getString("struct_code"));
|
task_form.put("next_device_code", ios_dis.getString("struct_code"));
|
||||||
task_form.put("vehicle_code", map.getString("storagevehicle_code"));
|
task_form.put("vehicle_code", map.getString("storagevehicle_code"));
|
||||||
@@ -613,25 +618,57 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
|
|
||||||
//in_point data
|
//in_point data
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void createPdaTask(JSONObject param) {
|
public void createPdaTask(JSONObject param) {
|
||||||
Assert.notEmpty(new Object[]{param,param.getJSONArray("data")},"参数不能为空");
|
Assert.notEmpty(new Object[]{param,param.getJSONArray("data")},"参数不能为空");
|
||||||
|
WQLObject structattrTab = WQLObject.getWQLObject("st_ivt_structattr");
|
||||||
|
WQLObject vehicleTab = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
|
||||||
|
WQLObject vehicleMaterialTab = WQLObject.getWQLObject("md_pb_storagevehicleext");
|
||||||
|
WQLObject disTab = WQLObject.getWQLObject("st_ivt_iostorinvdis");
|
||||||
|
WQLObject ioStorInv = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
||||||
|
|
||||||
|
|
||||||
RedissonUtils.lock(() -> {
|
RedissonUtils.lock(() -> {
|
||||||
String point = param.getString("point");
|
String point = param.getString("point");
|
||||||
String vehicle_code = param.getString("vehicle_code");
|
String vehicle_code = param.getString("vehicle_code");
|
||||||
JSONArray data = param.getJSONArray("data");
|
JSONArray data = param.getJSONArray("arr");
|
||||||
//"data": [
|
|
||||||
// {
|
|
||||||
// "sale_code":"DD1213213",
|
|
||||||
// "order_line_code":"L_DD1213213",
|
|
||||||
// "material_spec":"SP/232",
|
|
||||||
// "in_qry": "123",
|
|
||||||
// "material_code": "24021962S",
|
|
||||||
// "material_name": "三通法兰"
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
|
|
||||||
|
JSONObject jsonVehicle = vehicleTab.query("storagevehicle_code = '" + vehicle_code + "' and is_delete = '0' and is_used = '1'").uniqueResult(0);
|
||||||
|
if (ObjectUtil.isEmpty(jsonVehicle)) throw new BadRequestException("载具不存在");
|
||||||
|
JSONArray vehicleMaterial = vehicleMaterialTab.query("storagevehicle_code = '" + vehicle_code + "' and material_id IS not NULL ").getResultJSONArray(0);
|
||||||
|
if (vehicleMaterial.size()>0){
|
||||||
|
throw new BadRequestException("载具已被占用");
|
||||||
|
}
|
||||||
|
//创建出入库表单
|
||||||
|
String iostorinvId = this.insertDtl(new JSONObject(MapOf.of("tableData", data, "product_code", "A1"
|
||||||
|
, "bill_type", "0002", "biz_date", DateUtil.now().substring(0, 10), "bill_status", "10")));
|
||||||
|
//绑定载具
|
||||||
|
disTab.update(MapOf.of("storagevehicle_id",jsonVehicle.getString("storagevehicle_id")
|
||||||
|
,"storagevehicle_code", jsonVehicle.getString("storagevehicle_code")),"iostorinv_id = '" + iostorinvId + "'");
|
||||||
|
JSONObject structatt = ioStorInv.query("iostorinv_id = '" + iostorinvId + "'").uniqueResult(0);
|
||||||
|
//分配点位
|
||||||
|
JSONArray tableMater = new JSONArray();
|
||||||
|
tableMater.add(structatt);
|
||||||
|
JSONObject dtl_row = new JSONObject();
|
||||||
|
dtl_row.put("material_id","");
|
||||||
|
this.divStruct(new JSONObject(MapOf.of("dtl_row",dtl_row,"stor_id","A1","sect_id","KQ001",
|
||||||
|
"checked",true,"product_area","A1","sect_code","RCK001","tableMater",tableMater)));
|
||||||
|
//创建任务
|
||||||
|
JSONObject disInfo = disTab.query("iostorinv_id = '" + iostorinvId + "'").uniqueResult(0);
|
||||||
|
ProductInTask task = new ProductInTask();
|
||||||
|
JSONObject task_form = new JSONObject();
|
||||||
|
task_form.put("task_type", AcsTaskEnum.TASK_STRUCT_IN.getCode());
|
||||||
|
task_form.put("start_device_code", point);
|
||||||
|
task_form.put("next_device_code", disInfo.getString("struct_code"));
|
||||||
|
task_form.put("vehicle_code", disInfo.getString("storagevehicle_code"));
|
||||||
|
task_form.put("product_area", "A1");
|
||||||
|
String task_id = task.createTask(task_form);
|
||||||
|
HashMap map = MapOf.of("point_code", disInfo.getString("struct_code"), "struct_id", disInfo.getString("struct_id"), "struct_name", disInfo.getString("struct_name"),
|
||||||
|
"task_id", task_id, "work_status", "01");
|
||||||
|
//跟新明细表状态
|
||||||
|
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(map, "iostorinv_id = '" + iostorinvId + "'");
|
||||||
|
|
||||||
},"pda#createPdaTask",3);
|
},"pda#createPdaTask",5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -648,16 +685,24 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
JSONObject struct_jo = new JSONObject();
|
JSONObject struct_jo = new JSONObject();
|
||||||
String material_id = whereJson.getString("material_id");
|
String material_id = whereJson.getString("material_id");
|
||||||
String sect_code = whereJson.getString("sect_code");
|
String sect_code = whereJson.getString("sect_code");
|
||||||
String product_area = whereJson.getString("stor_id");
|
String product_area = whereJson.getString("product_area");
|
||||||
|
|
||||||
JSONObject jsonMater = materTab.query("material_id = '" + material_id + "'").uniqueResult(0);
|
|
||||||
|
|
||||||
// 判断物料是否超长
|
// 判断物料是否超长
|
||||||
|
double material_length= 0;
|
||||||
|
double material_length_up=9999;
|
||||||
|
double material_weight = 0;
|
||||||
|
double material_weight_up = 9999;
|
||||||
|
String weight_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MATERIAL_WEIGHT_UP").getValue();
|
||||||
String length_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MATERIAL_LENGTH_UP").getValue();
|
String length_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MATERIAL_LENGTH_UP").getValue();
|
||||||
double material_length = jsonMater.getDoubleValue("length");
|
if (!StringUtils.isEmpty(material_id)){
|
||||||
double material_length_up = Double.valueOf(length_up);
|
JSONObject jsonMater = materTab.query("material_id = '" + material_id + "'").uniqueResult(0);
|
||||||
|
material_length = jsonMater.getDoubleValue("length");
|
||||||
|
material_length_up = Double.valueOf(length_up);
|
||||||
|
material_weight = jsonMater.getDoubleValue("net_weight");
|
||||||
|
material_weight_up = Double.valueOf(weight_up);
|
||||||
|
}
|
||||||
|
|
||||||
if (material_length > material_length_up) {
|
if (material_length > 99999 /*material_length_up*/) {
|
||||||
// 超长:找一层两个货位:超长判断
|
// 超长:找一层两个货位:超长判断
|
||||||
JSONArray pointArr = WQL.getWO("QST_IVT_DIS_01").addParam("flag", "1")
|
JSONArray pointArr = WQL.getWO("QST_IVT_DIS_01").addParam("flag", "1")
|
||||||
.addParam("sect_code", sect_code)
|
.addParam("sect_code", sect_code)
|
||||||
@@ -668,7 +713,6 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
// 查询此点位对应的点位是否是无货未锁定状态
|
// 查询此点位对应的点位是否是无货未锁定状态
|
||||||
JSONObject jsonControlPoint = pointTab.query("point_id = '" + json.getString("control_point") +
|
JSONObject jsonControlPoint = pointTab.query("point_id = '" + json.getString("control_point") +
|
||||||
"' and is_delete = '0' and is_used = '1' and point_status = '1' and lock_type = '0'").uniqueResult(0);
|
"' and is_delete = '0' and is_used = '1' and point_status = '1' and lock_type = '0'").uniqueResult(0);
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(jsonControlPoint)) {
|
if (ObjectUtil.isNotEmpty(jsonControlPoint)) {
|
||||||
json.put("is_length", "1");
|
json.put("is_length", "1");
|
||||||
struct_jo = json;
|
struct_jo = json;
|
||||||
@@ -679,9 +723,6 @@ public class ProductInServiceImpl implements ProductInService {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 未超长:判断是否超重
|
// 未超长:判断是否超重
|
||||||
String weight_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MATERIAL_WEIGHT_UP").getValue();
|
|
||||||
double material_weight = jsonMater.getDoubleValue("net_weight");
|
|
||||||
double material_weight_up = Double.valueOf(weight_up);
|
|
||||||
|
|
||||||
if (material_weight > material_weight_up) {
|
if (material_weight > material_weight_up) {
|
||||||
// 超重: 尽量放在一层
|
// 超重: 尽量放在一层
|
||||||
|
|||||||
Reference in New Issue
Block a user