add:合批模式添加成型计计算
This commit is contained in:
@@ -4888,6 +4888,8 @@ public class AutoformulaServiceImpl implements AutoformulaService {
|
||||
* @return
|
||||
*/
|
||||
JSONObject autoCalculationBy03_ruanfei(JSONObject json){
|
||||
WQLObject MD_PD_ProductMaterialSet = WQLObject.getWQLObject("MD_PD_ProductMaterialSet");
|
||||
WQLObject MD_PD_FormingMaterial = WQLObject.getWQLObject("MD_PD_FormingMaterial");
|
||||
//定义返回值
|
||||
JSONObject ret = new JSONObject();
|
||||
ret.put("chunfen_qty","-1");
|
||||
@@ -5205,7 +5207,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
|
||||
ret.put("chunfen_qty",sum_chunfen.get());
|
||||
rf_list2 = new JSONArray();
|
||||
xl_list2 = new JSONArray();
|
||||
cxj_list = new JSONArray();
|
||||
// cxj_list = new JSONArray();
|
||||
yzj_list = new JSONArray();
|
||||
cw_list = new JSONArray();
|
||||
}else{
|
||||
@@ -5406,7 +5408,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
|
||||
//若Cp<=Wp,更新Wp=Wp-Cp,结束
|
||||
if(Cp<=W){
|
||||
if(Cp>0){
|
||||
if(Cp > cw_limit_down){
|
||||
if(true){//Cp > cw_limit_down
|
||||
JSONObject C_weight = new JSONObject();
|
||||
C_weight.put("formula_qty",Cp);
|
||||
//钨分类id
|
||||
@@ -5425,7 +5427,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
|
||||
|
||||
double Wp = NumberUtil.round(W-Cp,6).doubleValue();
|
||||
if(Wp>0){
|
||||
if(Wp > cw_limit_down){
|
||||
if(true){//(Wp > cw_limit_down
|
||||
JSONObject W_weight = new JSONObject();
|
||||
W_weight.put("formula_qty",NumberUtil.round(Wp,6).doubleValue());
|
||||
//钨分类id
|
||||
@@ -5578,7 +5580,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
|
||||
if(C_bu>0){
|
||||
//Wp=Wp+W补
|
||||
Cp = Cp + C_bu;
|
||||
if(Cp > cw_limit_down){
|
||||
if(true){//cw_limit_down
|
||||
//计算非碳化钨需补重量
|
||||
double finalR3p_jian = R3p_jian;
|
||||
bj_bomdlts_map.forEach((key, bj_bomdlt)->{
|
||||
@@ -5691,7 +5693,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
|
||||
if(C_bu>0){
|
||||
//Wp=Wp+W补
|
||||
Cp = Cp + C_bu;
|
||||
if(Cp > cw_limit_down){
|
||||
if(true){//Cp > cw_limit_down
|
||||
JSONObject C_weight = new JSONObject();
|
||||
C_weight.put("formula_qty",Cp);
|
||||
//钨分类id
|
||||
@@ -5914,7 +5916,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
|
||||
}else{
|
||||
//Wp=Wp+W补
|
||||
W = W + W_bu;
|
||||
if(W <= cw_limit_down){
|
||||
if(true){//W <= cw_limit_down
|
||||
//用新料补足剩余部分
|
||||
bomdlts_need_map.forEach((key,bomdlt)->{
|
||||
//获取Y1、X1、X2….剩余>0的物料
|
||||
@@ -6024,7 +6026,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
|
||||
}
|
||||
//Wp=Wp+W补
|
||||
W = W + W_bu;
|
||||
if(W <= cw_limit_down){
|
||||
if(true){//W <= cw_limit_down
|
||||
//用新料补足剩余部分
|
||||
bomdlts_need_map.forEach((key,bomdlt)->{
|
||||
//获取Y1、X1、X2….剩余>0的物料
|
||||
@@ -6108,6 +6110,85 @@ public class AutoformulaServiceImpl implements AutoformulaService {
|
||||
throw new BadRequestException("满足条件的软废库存为0,请按其他模式配粉!");
|
||||
}
|
||||
}
|
||||
//3.计算成型剂
|
||||
JSONArray bomdlts2 = WQL.getWO("QPF_AUTOFORMULA01")
|
||||
.addParam("material_id",material_id)
|
||||
.addParam("is_need_manage","0")
|
||||
.addParam("flag","1")
|
||||
.process().getResultJSONArray(0);
|
||||
//各成型剂需配总量
|
||||
HashMap<String,JSONObject> bomdlts2_map = new HashMap<String,JSONObject>();
|
||||
for(int i=0;i<bomdlts2.size();i++){
|
||||
JSONObject bomdlt = bomdlts2.getJSONObject(i);
|
||||
double standard_rate = bomdlt.getDouble("standard_rate");
|
||||
//需配成型剂重量
|
||||
bomdlt.put("formula_qty",net_qty*standard_rate/100.0);
|
||||
//当前已配
|
||||
bomdlt.put("now_formula_qty",0);
|
||||
bomdlt.put("need_sum_qty",net_qty*standard_rate/100.0);
|
||||
bomdlts2_map.put(bomdlt.getString("material_id"),bomdlt);
|
||||
}
|
||||
rf_map.forEach((key, rf_dis)->{
|
||||
String set_material_id = rf_dis.getString("material_id");
|
||||
//R1p*纯粉系数
|
||||
double net_rate_qty = rf_dis.getDouble("formula_qty")*net_rate_map.get(set_material_id)/100.0;
|
||||
// double net_rate_qty = rf_dis.getDouble("net_rate_qty");
|
||||
JSONObject ProductMaterialSet = MD_PD_ProductMaterialSet.query("set_type='02' and material_id='"+material_id+"' and set_material_id='"+set_material_id+"'").uniqueResult(0);
|
||||
if(ProductMaterialSet == null){
|
||||
throw new BadRequestException("产品"+material_code+"未配置改配模式可配粉软废信息!");
|
||||
}
|
||||
//是否计算成型剂
|
||||
String is_calculate_forming = ProductMaterialSet.getString("is_calculate_forming");
|
||||
if("1".equals(is_calculate_forming)){
|
||||
//循环成型剂
|
||||
for(int k=0;k<bomdlts2.size();k++){
|
||||
JSONObject bomdlt2 = bomdlts2.getJSONObject(k);
|
||||
JSONObject FormingMaterial = MD_PD_FormingMaterial.query("material_id='"+bomdlt2.getString("material_id")+"'").uniqueResult(0);
|
||||
if(FormingMaterial==null){
|
||||
throw new BadRequestException("成型剂"+rf_dis.getString("material_code")+" "+rf_dis.getString("material_name")+"未配置配粉开单成型剂物料对应关系!");
|
||||
}
|
||||
String formingtype_id = FormingMaterial.getString("formingtype_id");
|
||||
//获取所含成型剂分类物料信息
|
||||
JSONArray cxj_ja = WQL.getWO("QPF_AUTOFORMULA01")
|
||||
.addParam("material_id",set_material_id)
|
||||
.addParam("formingtype_id",formingtype_id)
|
||||
.addParam("flag","4")
|
||||
.process().getResultJSONArray(0);
|
||||
for(int j=0;j<cxj_ja.size();j++){
|
||||
JSONObject cxj = cxj_ja.getJSONObject(j);
|
||||
//软废中bom对应成型剂开单时计算含量
|
||||
double calculate_rate = cxj.getDouble("calculate_rate");
|
||||
//软废中bom对应成型剂含量
|
||||
double standard_rate = cxj.getDouble("standard_rate")*calculate_rate/100.0;
|
||||
//当前成型剂含量
|
||||
double now = net_rate_qty*standard_rate/100.0;
|
||||
JSONObject bomdlt = bomdlts2_map.get(bomdlt2.getString("material_id"));
|
||||
//需配成型剂重量
|
||||
double now_formula_qty = bomdlt.getDouble("now_formula_qty")+now;
|
||||
bomdlt.put("now_formula_qty",now_formula_qty);
|
||||
bomdlts2_map.put(bomdlt2.getString("material_id"),bomdlt);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
bomdlts2_map.forEach((key,bomdlts2_now)->{
|
||||
//需配成型剂重量
|
||||
double formula_qty = bomdlts2_now.getDouble("formula_qty");
|
||||
//当前软废已配
|
||||
double now_formula_qty = bomdlts2_now.getDouble("now_formula_qty");
|
||||
//已配小于需配
|
||||
if(now_formula_qty<formula_qty){//已配软废0.5992,需要成型":500*0.2
|
||||
bomdlts2_now.put("formula_qty",formula_qty-now_formula_qty);
|
||||
bomdlts2_now.put("material_type","01");
|
||||
bomdlts2_now.put("is_need_move","0");
|
||||
bomdlts2_now.put("is_need_manage","0");
|
||||
bomdlts2_now.put("is_rf_xl","0");
|
||||
bomdlts2_now.put("ivt_level","01");
|
||||
bomdlts2_now.put("is_active","1");
|
||||
bomdlts2_now.put("quality_scode","01");
|
||||
cxj_list.add(bomdlts2_now);
|
||||
}
|
||||
});
|
||||
//处理新料
|
||||
JSONArray xl_list3 = new JSONArray();
|
||||
//重新分配总需配库存
|
||||
|
||||
Reference in New Issue
Block a user