From d65c96710e431d91c7a07d7979ebd08bf7e91b4a Mon Sep 17 00:00:00 2001 From: zds <2388969634@qq.com> Date: Wed, 28 Sep 2022 17:14:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AutoformulaServiceImpl.java | 349 +++++++++++++----- 1 file changed, 259 insertions(+), 90 deletions(-) diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/pf/service/impl/AutoformulaServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/pf/service/impl/AutoformulaServiceImpl.java index 0ce13972..43c1ed9a 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/pf/service/impl/AutoformulaServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/pf/service/impl/AutoformulaServiceImpl.java @@ -123,7 +123,7 @@ public class AutoformulaServiceImpl implements AutoformulaService { String value_is_active = ""; if("1".equals(value)){ value_is_active = "1"; - }//.addParam("is_active",value_is_active) + } //获取库存集合 JSONArray ivts = new JSONArray(); for(int i=0;i= 0){ - if(C>0){ - JSONObject C_weight = new JSONObject(); - C_weight.put("formula_qty",C); - //钨分类id - C_weight.put("material_id","1503644362788179968"); - C_weight.put("material_name","碳粉"); - C_weight.put("material_code","09030104"); - C_weight.put("material_type","02"); - C_weight.put("is_need_move","0"); - C_weight.put("is_need_manage","1"); - C_weight.put("is_tan","100"); - C_weight.put("is_rf_xl","1"); - C_weight.put("ivt_level","01"); - C_weight.put("is_active","1"); - C_weight.put("quality_scode","01"); - cw_list.add(C_weight); - } bomdlt_Cr3C2.put("bom_ivt_qty",bom_ivt_qty); bomdlts_plan_map.put(bomdlt_Cr3C2.getString("stockrecord_id"),bomdlt_Cr3C2); //计算不需要移库的添加剂(抑制剂) @@ -749,6 +741,9 @@ public class AutoformulaServiceImpl implements AutoformulaService { yzj_map.put(tjj_material_id,tjj_map_jo); } }); + + //统计除钨以外其他总重 + AtomicReference total_sum = new AtomicReference<>(0.0); //判断已含添加剂与需配添加剂大小 yzj_map.forEach((key,tjj_map_now)->{ //需配添加剂重量 @@ -766,8 +761,49 @@ public class AutoformulaServiceImpl implements AutoformulaService { tjj_map_now.put("is_active","1"); tjj_map_now.put("quality_scode","01"); yzj_list.add(tjj_map_now); + total_sum.set(total_sum.get()+need_qty-finished_qty); } }); + if(C>0){ + JSONObject C_weight = new JSONObject(); + C_weight.put("formula_qty",C); + //钨分类id + C_weight.put("material_id","1503644362788179968"); + C_weight.put("material_name","碳粉"); + C_weight.put("material_code","09030104"); + C_weight.put("material_type","02"); + C_weight.put("is_need_move","0"); + C_weight.put("is_need_manage","1"); + C_weight.put("is_tan","100"); + C_weight.put("is_rf_xl","1"); + C_weight.put("ivt_level","01"); + C_weight.put("is_active","1"); + C_weight.put("quality_scode","01"); + cw_list.add(C_weight); + total_sum.set(total_sum.get()+C); + } + bomdlts_plan_map.forEach((key,bomdlts_plan_now)->{ + //需配添加剂重量 + double bom_ivt_qty_now = NumberUtil.round(bomdlts_plan_now.getDouble("bom_ivt_qty"),3).doubleValue(); + total_sum.set(total_sum.get() + bom_ivt_qty_now); + }); + double W = new_qty - total_sum.get(); + if(W>0){ + JSONObject W_weight = new JSONObject(); + W_weight.put("formula_qty",W); + //钨分类id + W_weight.put("material_id","1503644362234531840"); + W_weight.put("material_name","钨粉"); + W_weight.put("material_code","09030103"); + W_weight.put("material_type","02"); + W_weight.put("is_need_move","0"); + W_weight.put("is_need_manage","1"); + W_weight.put("is_rf_xl","0"); + W_weight.put("ivt_level","01"); + W_weight.put("is_active","1"); + W_weight.put("quality_scode","01"); + cw_list.add(W_weight); + } } }else{//大于等于2条库粗你明细时 //最后一个为X22p @@ -829,7 +865,7 @@ public class AutoformulaServiceImpl implements AutoformulaService { flag = false; }else{ //解得钨粉重量 - double C = X22_jian + Z_sum.get(); + double C = X22_jian; if(C<0){ flag = false; }else if(C>=0){ @@ -866,6 +902,9 @@ public class AutoformulaServiceImpl implements AutoformulaService { } }); } + + //统计除钨以外其他总重 + AtomicReference total_sum = new AtomicReference<>(0.0); //判断已含添加剂与需配添加剂大小 yzj_map.forEach((key,tjj_map_now)->{ //需配添加剂重量 @@ -883,8 +922,10 @@ public class AutoformulaServiceImpl implements AutoformulaService { tjj_map_now.put("is_active","1"); tjj_map_now.put("quality_scode","01"); yzj_list.add(tjj_map_now); + total_sum.set(total_sum.get()+need_qty-finished_qty); } }); + if(C>0){ JSONObject C_weight = new JSONObject(); C_weight.put("formula_qty",C); @@ -901,6 +942,29 @@ public class AutoformulaServiceImpl implements AutoformulaService { C_weight.put("is_active","1"); C_weight.put("quality_scode","01"); cw_list.add(C_weight); + total_sum.set(total_sum.get()+C); + } + bomdlts_plan_map.forEach((key,bomdlts_plan_now)->{ + //需配添加剂重量 + double bom_ivt_qty_now = NumberUtil.round(bomdlts_plan_now.getDouble("bom_ivt_qty"),3).doubleValue(); + total_sum.set(total_sum.get() + bom_ivt_qty_now); + }); + double W = new_qty - total_sum.get(); + if(W>0 && W>=0.001){ + JSONObject W_weight = new JSONObject(); + W_weight.put("formula_qty",W); + //钨分类id + W_weight.put("material_id","1503644362234531840"); + W_weight.put("material_name","钨粉"); + W_weight.put("material_code","09030103"); + W_weight.put("material_type","02"); + W_weight.put("is_need_move","0"); + W_weight.put("is_need_manage","1"); + W_weight.put("is_rf_xl","0"); + W_weight.put("ivt_level","01"); + W_weight.put("is_active","1"); + W_weight.put("quality_scode","01"); + cw_list.add(W_weight); } } } @@ -911,7 +975,7 @@ public class AutoformulaServiceImpl implements AutoformulaService { double X21_jian = ((c_balance/100.0)*(CT1_weight) - (CT1-X22c) - X22p)/(1-X21/100.0); //解得钨粉重量 - double C = X22p + X21_jian + Z_sum.get(); + double C = X22p + X21_jian; if(C<0){ throw new BadRequestException("加碳粉为负数,当前配粉无解!"); }else if(C>=0){ @@ -954,6 +1018,8 @@ public class AutoformulaServiceImpl implements AutoformulaService { } }); } + //统计除钨以外其他总重 + AtomicReference total_sum = new AtomicReference<>(0.0); //判断已含添加剂与需配添加剂大小 yzj_map.forEach((key,tjj_map_now)->{ //需配添加剂重量 @@ -971,8 +1037,10 @@ public class AutoformulaServiceImpl implements AutoformulaService { tjj_map_now.put("is_active","1"); tjj_map_now.put("quality_scode","01"); yzj_list.add(tjj_map_now); + total_sum.set(total_sum.get() + need_qty-finished_qty); } }); + if(C>0){ JSONObject C_weight = new JSONObject(); C_weight.put("formula_qty",C); @@ -989,6 +1057,29 @@ public class AutoformulaServiceImpl implements AutoformulaService { C_weight.put("is_active","1"); C_weight.put("quality_scode","01"); cw_list.add(C_weight); + total_sum.set(total_sum.get()+C); + } + bomdlts_plan_map.forEach((key,bomdlts_plan_now)->{ + //需配添加剂重量 + double bom_ivt_qty_now = NumberUtil.round(bomdlts_plan_now.getDouble("bom_ivt_qty"),3).doubleValue(); + total_sum.set(total_sum.get() + bom_ivt_qty_now); + }); + double W = new_qty - total_sum.get(); + if(W>0 && W>=0.001){ + JSONObject W_weight = new JSONObject(); + W_weight.put("formula_qty",W); + //钨分类id + W_weight.put("material_id","1503644362234531840"); + W_weight.put("material_name","钨粉"); + W_weight.put("material_code","09030103"); + W_weight.put("material_type","02"); + W_weight.put("is_need_move","0"); + W_weight.put("is_need_manage","1"); + W_weight.put("is_rf_xl","0"); + W_weight.put("ivt_level","01"); + W_weight.put("is_active","1"); + W_weight.put("quality_scode","01"); + cw_list.add(W_weight); } } } @@ -1494,7 +1585,7 @@ public class AutoformulaServiceImpl implements AutoformulaService { JSONArray ivts_new = new JSONArray(); for(int i=0;i0){ - JSONObject C_weight = new JSONObject(); - C_weight.put("formula_qty",C); - //碳化钨分类id - C_weight.put("material_id","1503644362788179968"); - C_weight.put("material_name","碳粉"); - C_weight.put("material_code","09030104"); - C_weight.put("material_type","02"); - C_weight.put("is_need_move","0"); - C_weight.put("is_need_manage","1"); - C_weight.put("is_tan","100"); - C_weight.put("is_rf_xl","1"); - C_weight.put("ivt_level","01"); - C_weight.put("is_active","1"); - C_weight.put("quality_scode","01"); - cw_list.add(C_weight); - } bomdlt_Cr3C2.put("bom_ivt_qty",bom_ivt_qty); bomdlts_plan_map.put(bomdlt_Cr3C2.getString("stockrecord_id"),bomdlt_Cr3C2); //计算不需要移库的添加剂 @@ -1838,6 +1912,32 @@ public class AutoformulaServiceImpl implements AutoformulaService { tjj_map.put(tjj_material_id,tjj_map_jo); } }); + //统计除钨以外其他总重 + AtomicReference total_sum = new AtomicReference<>(0.0); + + if(C>0){ + JSONObject C_weight = new JSONObject(); + C_weight.put("formula_qty",C); + //碳化钨分类id + C_weight.put("material_id","1503644362788179968"); + C_weight.put("material_name","碳粉"); + C_weight.put("material_code","09030104"); + C_weight.put("material_type","02"); + C_weight.put("is_need_move","0"); + C_weight.put("is_need_manage","1"); + C_weight.put("is_tan","100"); + C_weight.put("is_rf_xl","1"); + C_weight.put("ivt_level","01"); + C_weight.put("is_active","1"); + C_weight.put("quality_scode","01"); + cw_list.add(C_weight); + total_sum.set(total_sum.get() + C); + } + bomdlts_plan_map.forEach((key,bomdlts_plan_now)->{ + //需配添加剂重量 + double bom_ivt_qty_now = NumberUtil.round(bomdlts_plan_now.getDouble("bom_ivt_qty"),3).doubleValue(); + total_sum.set(total_sum.get() + bom_ivt_qty_now); + }); //判断已含添加剂与需配添加剂大小 tjj_map.forEach((key,tjj_map_now)->{ //需配添加剂重量 @@ -1855,8 +1955,26 @@ public class AutoformulaServiceImpl implements AutoformulaService { tjj_map_now.put("is_active","1"); tjj_map_now.put("quality_scode","01"); yzj_list.add(tjj_map_now); + total_sum.set(total_sum.get() + need_qty-finished_qty); } }); + double W = new_qty - total_sum.get(); + if(W>0){ + JSONObject W_weight = new JSONObject(); + W_weight.put("formula_qty",W); + //钨分类id + W_weight.put("material_id","1503644362234531840"); + W_weight.put("material_name","钨粉"); + W_weight.put("material_code","09030103"); + W_weight.put("material_type","02"); + W_weight.put("is_need_move","0"); + W_weight.put("is_need_manage","1"); + W_weight.put("is_rf_xl","0"); + W_weight.put("ivt_level","01"); + W_weight.put("is_active","1"); + W_weight.put("quality_scode","01"); + cw_list.add(W_weight); + } }else{//大于等于2条库粗你明细时 //最后一个为X22p JSONObject bomdlt_Cr3C2_X22p = bomdlts_Cr3C2.getJSONObject(bomdlts_Cr3C2.size()-1); @@ -1917,27 +2035,10 @@ public class AutoformulaServiceImpl implements AutoformulaService { flag = false; }else{ //解得钨粉重量 - double C = X22_jian + Z_sum.get(); + double C = X22_jian; if(C<0){ flag = false; }else if(C>=0){ - if(C>0){ - JSONObject C_weight = new JSONObject(); - C_weight.put("formula_qty",C); - //钨分类id - C_weight.put("material_id","1503644362788179968"); - C_weight.put("material_name","碳粉"); - C_weight.put("material_code","09030104"); - C_weight.put("material_type","02"); - C_weight.put("is_need_move","0"); - C_weight.put("is_need_manage","1"); - C_weight.put("is_tan","100"); - C_weight.put("is_rf_xl","1"); - C_weight.put("ivt_level","01"); - C_weight.put("is_active","1"); - C_weight.put("quality_scode","01"); - cw_list.add(C_weight); - } bomdlt_Cr3C2_X22p.put("bom_ivt_qty",bom_ivt_qty); bomdlts_plan_map.put(bomdlt_Cr3C2_X22p.getString("stockrecord_id"),bomdlt_Cr3C2_X22p); if(bom_ivt_qty<=0){ @@ -1971,6 +2072,32 @@ public class AutoformulaServiceImpl implements AutoformulaService { } }); } + //统计除钨以外其他总重 + AtomicReference total_sum = new AtomicReference<>(0.0); + + if(C>0){ + JSONObject C_weight = new JSONObject(); + C_weight.put("formula_qty",C); + //碳化钨分类id + C_weight.put("material_id","1503644362788179968"); + C_weight.put("material_name","碳粉"); + C_weight.put("material_code","09030104"); + C_weight.put("material_type","02"); + C_weight.put("is_need_move","0"); + C_weight.put("is_need_manage","1"); + C_weight.put("is_tan","100"); + C_weight.put("is_rf_xl","1"); + C_weight.put("ivt_level","01"); + C_weight.put("is_active","1"); + C_weight.put("quality_scode","01"); + cw_list.add(C_weight); + total_sum.set(total_sum.get() + C); + } + bomdlts_plan_map.forEach((key,bomdlts_plan_now)->{ + //需配添加剂重量 + double bom_ivt_qty_now = NumberUtil.round(bomdlts_plan_now.getDouble("bom_ivt_qty"),3).doubleValue(); + total_sum.set(total_sum.get() + bom_ivt_qty_now); + }); //判断已含添加剂与需配添加剂大小 tjj_map.forEach((key,tjj_map_now)->{ //需配添加剂重量 @@ -1988,8 +2115,26 @@ public class AutoformulaServiceImpl implements AutoformulaService { tjj_map_now.put("is_active","1"); tjj_map_now.put("quality_scode","01"); yzj_list.add(tjj_map_now); + total_sum.set(total_sum.get() + need_qty-finished_qty); } }); + double W = new_qty - total_sum.get(); + if(W>0){ + JSONObject W_weight = new JSONObject(); + W_weight.put("formula_qty",W); + //钨分类id + W_weight.put("material_id","1503644362234531840"); + W_weight.put("material_name","钨粉"); + W_weight.put("material_code","09030103"); + W_weight.put("material_type","02"); + W_weight.put("is_need_move","0"); + W_weight.put("is_need_manage","1"); + W_weight.put("is_rf_xl","0"); + W_weight.put("ivt_level","01"); + W_weight.put("is_active","1"); + W_weight.put("quality_scode","01"); + cw_list.add(W_weight); + } } } } @@ -1998,7 +2143,7 @@ public class AutoformulaServiceImpl implements AutoformulaService { // X21p减=[产品碳平衡*(X11p+X12p+X21p+X22p+Z已总) - (X11p* X11碳含量+X12p* X12碳含量+(X21p)* X21碳含量+Z已总+X22p)]/(1-X21碳含量) double X21_jian = ((c_balance/100.0)*(CT1_weight) - (CT1-X22c) - X22p)/(1-X21/100.0); //解得钨粉重量 - double C = X22p + X21_jian + Z_sum.get(); + double C = X22p + X21_jian; if(C<0){ throw new BadRequestException("加碳粉为负数,当前配粉无解!"); }else if(C>=0){ @@ -2007,24 +2152,6 @@ public class AutoformulaServiceImpl implements AutoformulaService { if(bom_ivt_qty<0){ throw new BadRequestException("碳化钨倒数第二条配粉结果为负数,当前配粉无解!"); } - if(C>0){ - JSONObject C_weight = new JSONObject(); - C_weight.put("formula_qty",C); - //钨分类id - C_weight.put("material_id","1503644362788179968"); - C_weight.put("material_name","碳粉"); - C_weight.put("material_code","09030104"); - C_weight.put("material_type","02"); - C_weight.put("is_need_move","0"); - C_weight.put("is_need_manage","1"); - C_weight.put("is_tan","100"); - C_weight.put("is_rf_xl","1"); - C_weight.put("ivt_level","01"); - C_weight.put("is_active","1"); - C_weight.put("quality_scode","01"); - cw_list.add(C_weight); - } - bomdlt_Cr3C2_X21p.put("bom_ivt_qty",bom_ivt_qty); bomdlts_plan_map.put(bomdlt_Cr3C2_X21p.getString("stockrecord_id"),bomdlt_Cr3C2_X21p); if(bom_ivt_qty<=0){ @@ -2059,6 +2186,32 @@ public class AutoformulaServiceImpl implements AutoformulaService { } }); } + //统计除钨以外其他总重 + AtomicReference total_sum = new AtomicReference<>(0.0); + + if(C>0){ + JSONObject C_weight = new JSONObject(); + C_weight.put("formula_qty",C); + //碳化钨分类id + C_weight.put("material_id","1503644362788179968"); + C_weight.put("material_name","碳粉"); + C_weight.put("material_code","09030104"); + C_weight.put("material_type","02"); + C_weight.put("is_need_move","0"); + C_weight.put("is_need_manage","1"); + C_weight.put("is_tan","100"); + C_weight.put("is_rf_xl","1"); + C_weight.put("ivt_level","01"); + C_weight.put("is_active","1"); + C_weight.put("quality_scode","01"); + cw_list.add(C_weight); + total_sum.set(total_sum.get() + C); + } + bomdlts_plan_map.forEach((key,bomdlts_plan_now)->{ + //需配添加剂重量 + double bom_ivt_qty_now = NumberUtil.round(bomdlts_plan_now.getDouble("bom_ivt_qty"),3).doubleValue(); + total_sum.set(total_sum.get() + bom_ivt_qty_now); + }); //判断已含添加剂与需配添加剂大小 tjj_map.forEach((key,tjj_map_now)->{ //需配添加剂重量 @@ -2076,8 +2229,26 @@ public class AutoformulaServiceImpl implements AutoformulaService { tjj_map_now.put("is_active","1"); tjj_map_now.put("quality_scode","01"); yzj_list.add(tjj_map_now); + total_sum.set(total_sum.get() + need_qty-finished_qty); } }); + double W = new_qty - total_sum.get(); + if(W>0){ + JSONObject W_weight = new JSONObject(); + W_weight.put("formula_qty",W); + //钨分类id + W_weight.put("material_id","1503644362234531840"); + W_weight.put("material_name","钨粉"); + W_weight.put("material_code","09030103"); + W_weight.put("material_type","02"); + W_weight.put("is_need_move","0"); + W_weight.put("is_need_manage","1"); + W_weight.put("is_rf_xl","0"); + W_weight.put("ivt_level","01"); + W_weight.put("is_active","1"); + W_weight.put("quality_scode","01"); + cw_list.add(W_weight); + } } } } @@ -2178,9 +2349,6 @@ public class AutoformulaServiceImpl implements AutoformulaService { } }); double W = new_qty - total_sum.get(); - /* if(W<0){ - throw new BadRequestException("加钨粉为负数,当前配粉无解!"); - }*/ if(W>0){ JSONObject W_weight = new JSONObject(); W_weight.put("formula_qty",W); @@ -2414,9 +2582,6 @@ public class AutoformulaServiceImpl implements AutoformulaService { } }); double W = new_qty - total_sum.get(); - /*if(W<0){ - throw new BadRequestException("加钨粉为负数,当前配粉无解!"); - }*/ if(W>0){ JSONObject W_weight = new JSONObject(); W_weight.put("formula_qty",W); @@ -2627,7 +2792,7 @@ public class AutoformulaServiceImpl implements AutoformulaService { JSONArray ivts_new = new JSONArray(); for(int i=0;i