修改
This commit is contained in:
@@ -19,7 +19,6 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -150,28 +149,82 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
List<Map<String, Object>> listMap = EasyExcel.read(path).sheet(0).doReadSync();
|
||||
// listMap.remove(0);
|
||||
for (int i = 2; i < 86; i++) {
|
||||
//List<Map<String, Object>> listMap = EasyExcel.read(path).sheet(1).doReadSync();
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
for (int i = 3; i < listMap.size(); i++) {
|
||||
Map<String, Object> map = listMap.get(i);
|
||||
String package_box_sn = String.valueOf(map.get(17));
|
||||
String container_name = String.valueOf(map.get(9));
|
||||
String sale_order = String.valueOf(map.get(15));
|
||||
String no = String.valueOf(map.get(16));
|
||||
String customer_name = String.valueOf(map.get(21));
|
||||
String customer_description = String.valueOf(map.get(22));
|
||||
|
||||
/*//外库,计划内
|
||||
String package_box_sn = String.valueOf(map.get(16));
|
||||
String container_name = String.valueOf(map.get(8));
|
||||
String sale_order = String.valueOf(map.get(14));
|
||||
String no = String.valueOf(map.get(15));
|
||||
String customer_name = String.valueOf(map.get(20));
|
||||
String sap_pcsn = String.valueOf(map.get(9));
|
||||
String customer_description = String.valueOf(map.get(21));
|
||||
String product_name = String.valueOf(map.get(1));
|
||||
String product_description = String.valueOf(map.get(2));
|
||||
String date_of_FG_inbound = String.valueOf(map.get(11));
|
||||
String width = String.valueOf(map.get(22));
|
||||
String thickness = String.valueOf(map.get(23));
|
||||
String net_weight = String.valueOf(map.get(3));
|
||||
String length = String.valueOf(map.get(25));
|
||||
String is_un_plan_production = "0";*/
|
||||
|
||||
/*//外库,计划外分切
|
||||
String package_box_sn = String.valueOf(map.get(26));
|
||||
String container_name = String.valueOf(map.get(33));
|
||||
String sale_order = String.valueOf(map.get(29));
|
||||
//String no = String.valueOf(map.get(15));
|
||||
String customer_name = String.valueOf(map.get(30));
|
||||
String sap_pcsn = String.valueOf(map.get(33));
|
||||
String customer_description = String.valueOf(map.get(31));
|
||||
String product_name = String.valueOf(map.get(2));
|
||||
String product_description = String.valueOf(map.get(3));
|
||||
String date_of_FG_inbound = String.valueOf(map.get(11));
|
||||
String width = String.valueOf(map.get(23));
|
||||
String thickness = String.valueOf(map.get(24));
|
||||
String net_weight = String.valueOf(map.get(4));
|
||||
String length = String.valueOf(map.get(26));
|
||||
String is_un_plan_production = String.valueOf(map.get(27));
|
||||
String date_of_FG_inbound = String.valueOf(map.get(25));
|
||||
String width = String.valueOf(map.get(34));
|
||||
String thickness = String.valueOf(map.get(35));
|
||||
String net_weight = String.valueOf(map.get(37));
|
||||
String length = String.valueOf(map.get(38));
|
||||
String is_un_plan_production = "1";*/
|
||||
|
||||
if (StrUtil.isEmpty(package_box_sn)) {
|
||||
//成品库,计划内
|
||||
String package_box_sn = String.valueOf(map.get(18));
|
||||
String container_name = String.valueOf(map.get(10));
|
||||
String sale_order = String.valueOf(map.get(16));
|
||||
String no = String.valueOf(map.get(17));
|
||||
String customer_name = String.valueOf(map.get(22));
|
||||
String sap_pcsn = String.valueOf(map.get(9));
|
||||
String customer_description = String.valueOf(map.get(23));
|
||||
String product_name = String.valueOf(map.get(2));
|
||||
String product_description = String.valueOf(map.get(3));
|
||||
String date_of_FG_inbound = String.valueOf(map.get(12));
|
||||
String width = String.valueOf(map.get(24));
|
||||
String thickness = String.valueOf(map.get(25));
|
||||
String net_weight = String.valueOf(map.get(4));
|
||||
String length = String.valueOf(map.get(27));
|
||||
String is_un_plan_production = "0";
|
||||
|
||||
/*//成品库,计划外
|
||||
String package_box_sn = String.valueOf(map.get(26));
|
||||
String container_name = String.valueOf(map.get(34));
|
||||
String sale_order = String.valueOf(map.get(29));
|
||||
//String no = String.valueOf(map.get(17));
|
||||
String customer_name = String.valueOf(map.get(30));
|
||||
String sap_pcsn = String.valueOf(map.get(33));
|
||||
String customer_description = String.valueOf(map.get(31));
|
||||
String product_name = String.valueOf(map.get(2));
|
||||
String product_description = String.valueOf(map.get(3));
|
||||
String date_of_FG_inbound = String.valueOf(map.get(25));
|
||||
String width = String.valueOf(map.get(36));
|
||||
String thickness = String.valueOf(map.get(37));
|
||||
String net_weight = String.valueOf(map.get(5));
|
||||
String length = String.valueOf(map.get(40));
|
||||
String is_un_plan_production = "1";*/
|
||||
|
||||
/*if (StrUtil.isEmpty(package_box_sn)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的木箱唯一码为空!");
|
||||
}
|
||||
}*/
|
||||
if (StrUtil.isEmpty(sale_order)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的销售订单及行号为空!");
|
||||
}
|
||||
@@ -203,17 +256,14 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的计划外分切的子卷为空!");
|
||||
}
|
||||
|
||||
String material_code = String.valueOf(map.get(5));
|
||||
if (StrUtil.isEmpty(material_code)) {
|
||||
continue;
|
||||
}
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("workorder_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
jo.put("package_box_sn", package_box_sn);
|
||||
jo.put("sap_pcsn", container_name);
|
||||
jo.put("sap_pcsn", sap_pcsn);
|
||||
// jo.put("box_weight", BoxWeight);
|
||||
jo.put("quality_guaran_period", "90");
|
||||
jo.put("sale_order_name", sale_order + "-" + no);
|
||||
//jo.put("sale_order_name", sale_order);
|
||||
jo.put("customer_name", customer_name);
|
||||
jo.put("customer_description", customer_description);
|
||||
jo.put("product_name", product_name);
|
||||
@@ -221,6 +271,16 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
jo.put("date_of_FG_inbound", date_of_FG_inbound);
|
||||
jo.put("container_name", container_name);
|
||||
jo.put("width", width);
|
||||
if (StrUtil.isEmpty(thickness) || thickness.equals("null")) {
|
||||
//查询物料中的厚度
|
||||
JSONObject mater = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + jo.getString("product_name") + "'").uniqueResult(0);
|
||||
String code = mater.getString("material_name");
|
||||
code = code.replace("|", ",");
|
||||
String[] split = code.split(",");
|
||||
String last = split[2];
|
||||
String[] s = last.split("微");
|
||||
thickness = s[0];
|
||||
}
|
||||
jo.put("thickness", thickness);
|
||||
jo.put("net_weight", net_weight);
|
||||
jo.put("length", length);
|
||||
@@ -238,41 +298,66 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject row = rows.getJSONObject(i);
|
||||
String package_box_sn = row.getString("package_box_sn");
|
||||
if (StrUtil.isEmpty(package_box_sn) || package_box_sn.equals("null")) {
|
||||
continue;
|
||||
}
|
||||
double total_weight = 0;
|
||||
JSONArray box_rows = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '"+package_box_sn+"'").getResultJSONArray(0);
|
||||
JSONArray box_rows = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + package_box_sn + "'").getResultJSONArray(0);
|
||||
|
||||
//判断该木箱是否已经存在库内
|
||||
JSONObject str_jo = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + row.get("package_box_sn") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(str_jo)) {
|
||||
throw new BadRequestException("木箱:" + row.get("package_box_sn") + "已存在库内,请对数据进行核实!");
|
||||
}
|
||||
|
||||
//判断是否属于外库
|
||||
JSONObject goal_row = box_rows.getJSONObject(0);
|
||||
JSONObject stor_jo = new JSONObject();
|
||||
if (goal_row.getString("remark").contains("外库")){
|
||||
stor_jo = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_virtualstore = '1'").uniqueResult(0);
|
||||
}else {
|
||||
stor_jo = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_productstore = '1'").uniqueResult(0);
|
||||
}
|
||||
|
||||
//查询一个空的虚拟区货位
|
||||
JSONObject struct = WQL.getWO("PDA_ST_01").addParam("flag", "3").process().uniqueResult(0);
|
||||
JSONObject struct = WQL.getWO("PDA_ST_01").addParam("flag", "3").addParam("stor_id", stor_jo.getString("stor_id")).process().uniqueResult(0);
|
||||
for (int j = 0; j < box_rows.size(); j++) {
|
||||
JSONObject box_row = box_rows.getJSONObject(j);
|
||||
JSONObject ivt_jo = new JSONObject();
|
||||
//插入库存数据
|
||||
ivt_jo.put("stockrecord_id",IdUtil.getSnowflake(1,1).nextId());
|
||||
ivt_jo.put("struct_id",struct.getString("struct_id"));
|
||||
ivt_jo.put("struct_code",struct.getString("struct_code"));
|
||||
ivt_jo.put("struct_name",struct.getString("struct_name"));
|
||||
ivt_jo.put("region_id","");
|
||||
ivt_jo.put("quality_scode","01");
|
||||
ivt_jo.put("pcsn",box_row.getString("container_name"));
|
||||
ivt_jo.put("canuse_qty",box_row.getString("net_weight"));
|
||||
ivt_jo.put("frozen_qty",0);
|
||||
ivt_jo.put("ivt_qty",box_row.getString("net_weight"));
|
||||
ivt_jo.put("instorage_time",DateUtil.now());
|
||||
JSONObject mater = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '"+box_row.getString("product_name")+"'").uniqueResult(0);
|
||||
ivt_jo.put("material_id",mater.getString("material_id"));
|
||||
ivt_jo.put("qty_unit_id",mater.getString("base_unit_id"));
|
||||
ivt_jo.put("stockrecord_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
ivt_jo.put("struct_id", struct.getString("struct_id"));
|
||||
ivt_jo.put("struct_code", struct.getString("struct_code"));
|
||||
ivt_jo.put("struct_name", struct.getString("struct_name"));
|
||||
ivt_jo.put("region_id", "");
|
||||
ivt_jo.put("quality_scode", "01");
|
||||
ivt_jo.put("pcsn", box_row.getString("container_name"));
|
||||
ivt_jo.put("canuse_qty", box_row.getString("net_weight"));
|
||||
ivt_jo.put("frozen_qty", 0);
|
||||
ivt_jo.put("ivt_qty", box_row.getString("net_weight"));
|
||||
ivt_jo.put("instorage_time", DateUtil.now());
|
||||
JSONObject mater = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + box_row.getString("product_name") + "'").uniqueResult(0);
|
||||
ivt_jo.put("material_id", mater.getString("material_id"));
|
||||
ivt_jo.put("qty_unit_id", mater.getString("base_unit_id"));
|
||||
WQLObject.getWQLObject("st_ivt_structivt").insert(ivt_jo);
|
||||
total_weight += box_row.getDoubleValue("net_weight");
|
||||
}
|
||||
|
||||
//更新总重量
|
||||
HashMap<String,String> sub_map = new HashMap<>();
|
||||
sub_map.put("box_weight",total_weight+"");
|
||||
sub_map.put("status","2");
|
||||
HashMap<String, String> sub_map = new HashMap<>();
|
||||
//sub_map.put("box_weight", total_weight + "");
|
||||
//sub_map.put("quanlity_in_box", box_rows.size() + "");
|
||||
sub_map.put("status", "2");
|
||||
WQLObject.getWQLObject("pdm_bi_subpackagerelation").update(sub_map,"package_box_sn = '"+package_box_sn+"'");
|
||||
|
||||
//更新仓位字段
|
||||
struct.put("storagevehicle_code",package_box_sn);
|
||||
struct.put("storagevehicle_code", package_box_sn);
|
||||
WQLObject.getWQLObject("st_ivt_structattr").update(struct);
|
||||
|
||||
//更新点位字段
|
||||
HashMap<String, String> point_map = new HashMap<>();
|
||||
point_map.put("vehicle_code", package_box_sn);
|
||||
WQLObject.getWQLObject("SCH_BASE_Point").update(point_map, "point_code = '" + struct.getString("struct_code") + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user