This commit is contained in:
zds
2022-12-08 14:17:15 +08:00
parent ddf34c272d
commit 7eaaf831a9
4 changed files with 111 additions and 28 deletions

View File

@@ -944,8 +944,8 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
throw new BadRequestException("系列模板产能未配置!");
}
String device_id = jo.getString("device_id");
String plan_finish_date2 = jo.getString("plan_finish_date2");
Date plan_finish_date = DateUtil.parse(plan_finish_date2);
String finish_date = jo.getString("plan_finish_date2");
Date plan_finish_date = DateUtil.parse(finish_date);
double fact_weight = jo.getDouble("fact_weight");
double standard_weight = jo.getDouble("standard_weight");
//批次数量
@@ -974,52 +974,49 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
int yu = pcsn_num%totalproducecapacity_qty;
if(yu > 0){
jo.put("planstart_date",start_date);
Date planend_date = DateUtil.offsetDay(planstart_date,days-1);
jo.put("planend_date",DateUtil.formatDate(planend_date));
jo.put("planend_date",finish_date);
jo.put("workorder_type","01");
jo.put("product_weight",standard_weight*yu);
jo.put("product_num",yu);
jo.put("product_series_id",jo.getString("product_series"));
this.createDay(jo);
//当前开始日期前的一个工作日为下一个开始日期
this.createDay2(jo);
//当前结束日期前的一个工作日为下一个开始日期
JSONObject before_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "10")
.addParam("planstart_date", start_date)
.addParam("planstart_date", finish_date)
.addParam("device_id", device_id)
.process()
.uniqueResult(0);
if(before_day ==null){
throw new BadRequestException("未配置"+start_date+"前的工作日历!");
throw new BadRequestException("未配置"+finish_date+"前的工作日历!");
}
//更新参数
start_date = before_day.getString("factory_date");
planstart_date = DateUtil.parse(start_date);
finish_date = before_day.getString("factory_date");
plan_finish_date = DateUtil.parse(finish_date);
pcsn_num = pcsn_num - yu;
fact_weight = fact_weight - yu*standard_weight;
}
else{
jo.put("planstart_date",start_date);
//重新计算结束日期
Date planend_date = DateUtil.offsetDay(planstart_date,days-1);
jo.put("planend_date",DateUtil.formatDate(planend_date));
jo.put("planend_date",finish_date);
jo.put("workorder_type","01");
jo.put("product_weight",standard_weight*totalproducecapacity_qty);
jo.put("product_num",totalproducecapacity_qty);
jo.put("product_series_id",jo.getString("product_series"));
this.createDay(jo);
this.createDay2(jo);
//当前开始日期前的一个工作日为下一个开始日期
JSONObject before_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "10")
.addParam("planstart_date", start_date)
.addParam("planstart_date", finish_date)
.addParam("device_id", device_id)
.process()
.uniqueResult(0);
if(before_day ==null){
throw new BadRequestException("未配置"+start_date+"前的工作日历!");
throw new BadRequestException("未配置"+finish_date+"前的工作日历!");
}
//更新参数
start_date = before_day.getString("factory_date");
planstart_date = DateUtil.parse(start_date);
finish_date = before_day.getString("factory_date");
plan_finish_date = DateUtil.parse(finish_date);
pcsn_num = pcsn_num - totalproducecapacity_qty;
fact_weight = fact_weight - totalproducecapacity_qty*standard_weight;
}
@@ -1027,13 +1024,12 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
}
else{
jo.put("planstart_date",start_date);
Date planend_date = DateUtil.offsetDay(planstart_date,days-1);
jo.put("planend_date",DateUtil.formatDate(planend_date));
jo.put("planend_date",finish_date);
jo.put("workorder_type","01");
jo.put("product_weight",fact_weight);
jo.put("product_num",pcsn_num);
jo.put("product_series_id",jo.getString("product_series"));
this.createDay(jo);
this.createDay2(jo);
}
}
@@ -1133,6 +1129,65 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
new_jo.put("remark", json.getString("remark"));
JSONObject product = pdm_bi_productdeptpcsn.query("org_code='"+json.getString("plan_org_code")+"'").uniqueResult(0);
new_jo.put("plan_org_name", product.getString("org_name"));
new_jo.put("product_series", json.getString("product_series_id"));
MPS_BD_ProductDailyPlan.insert(new_jo);
return new_jo;
}
@Transactional(rollbackFor = Exception.class)
public JSONObject createDay2(JSONObject json) {
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
WQLObject pdm_bi_productdeptpcsn = WQLObject.getWQLObject("pdm_bi_productdeptpcsn");
WQLObject MPS_BD_ProductDailyPlan = WQLObject.getWQLObject("MPS_BD_ProductDailyPlan");
JSONObject new_jo = new JSONObject();
// 插入主表
new_jo.put("dailyplan_id", IdUtil.getSnowflake(1, 1).nextId());
String workorder_code = CodeUtil.getNewCode("R_CODE");
new_jo.put("plan_code", workorder_code);
new_jo.put("weight_unit_id", "1");
new_jo.put("weight_unit_name", "千克\\公斤");
new_jo.put("status", "01");
new_jo.put("create_id", currentUserId);
new_jo.put("create_name", nickName);
new_jo.put("create_time", now);
new_jo.put("workorder_type", json.getString("workorder_type"));
new_jo.put("plan_id", json.getString("plan_id"));
new_jo.put("plan_org_code", json.getString("plan_org_code"));
new_jo.put("material_id", json.getString("material_id"));
new_jo.put("product_weight", json.getString("product_weight"));
new_jo.put("product_num", json.getString("product_num"));
new_jo.put("plan_finish_date", json.getString("plan_finish_date"));
new_jo.put("product_series_id", json.getString("product_series_id"));
new_jo.put("device_id", json.getString("device_id"));
new_jo.put("planend_date", json.getString("planend_date"));
String planend_date = json.getString("planend_date");
Date date = DateUtil.parse(planend_date);
//生产日数
int days = this.getDays(json.getString("material_id"));
//计算最后一天的开始日期
Date planstart_date = DateUtil.offsetDay(date,-(days-1));
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "9")
.addParam("planstart_date", DateUtil.formatDate(planstart_date))
.addParam("device_id", json.getString("device_id"))
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+ DateUtil.formatDate(planstart_date)+"前的工作日历!");
}
String start_date = last_day.getString("factory_date");
new_jo.put("planstart_date", start_date);
new_jo.put("remark", json.getString("remark"));
JSONObject product = pdm_bi_productdeptpcsn.query("org_code='"+json.getString("plan_org_code")+"'").uniqueResult(0);
new_jo.put("plan_org_name", product.getString("org_name"));

View File

@@ -981,9 +981,35 @@ public class AcceptFormulaServiceImpl implements AcceptFormulaService {
//该批次配粉重量
double X22p = bomdlt_Cr3C2.getDouble("bom_ivt_qty");
// X21p减=[(X21p)* X21碳含量+软废含碳量-产品碳平衡*(X21p+软废碳化钨)]/X21碳含量
AtomicReference<Double> Z_sum = new AtomicReference<>(0.0);
AtomicReference<Double> Z_sum_per = new AtomicReference<>(0.0);
//计算不需要移库的添加剂(抑制剂)
yzj_map.forEach((key,tjj_map_jo)->{
//获取添加剂id
String tjj_material_id = tjj_map_jo.getString("material_id");
JSONObject tjj_finished = WQL.getWO("QPF_AUTOFORMULA02")
.addParam("material_id",bomdlt_Cr3C2.getString("material_id"))
.addParam("pcsn",material_pcsn)
.addParam("item_material_id",tjj_material_id)
.addParam("flag","5")
.process()
.uniqueResult(0);
if(tjj_finished!=null){
//质保书含量比
double value = tjj_finished.getDouble("value");
//当前含量重量
double finished = X22p*value/100.0;
//累计各碳化钨中已含添加剂重量百分比
Z_sum_per.set(Z_sum_per.get() + value/100.0);
//累计各碳化钨中已含添加剂重量
Z_sum.set(Z_sum.get() + finished);
}
});
// X1减 = [X1p* X1碳含量-X1p*产品碳平衡- X1p*Z总含量比*产品碳平衡]/(X1碳含量-Z总含量比*产品碳平衡)
//解得钨粉重量
double X22_jian = (CT1 - (c_balance/100.0)*(CT1_weight)) / (X22/100.0);
double X22_jian = (CT1 -(c_balance/100.0)*CT1_weight- Z_sum.get()*(c_balance/100.0)) / (X22/100.0 - Z_sum_per.get()*(c_balance/100.0));
//更新碳化钨配粉重量
double bom_ivt_qty = X22p-X22_jian;
if(bom_ivt_qty<=0){
@@ -992,7 +1018,7 @@ public class AcceptFormulaServiceImpl implements AcceptFormulaService {
bomdlt_Cr3C2.put("bom_ivt_qty",bom_ivt_qty);
bomdlts_plan_map.put(bomdlt_Cr3C2.getString("material_id"),bomdlt_Cr3C2);
AtomicReference<Double> Z_sum = new AtomicReference<>(0.0);
AtomicReference<Double> Z_sum2 = new AtomicReference<>(0.0);
//计算不需要移库的添加剂(抑制剂)
yzj_map.forEach((key,tjj_map_jo)->{
//获取添加剂id
@@ -1012,7 +1038,7 @@ public class AcceptFormulaServiceImpl implements AcceptFormulaService {
//当前含量重量
double finished = bom_ivt_qty*value/100.0;
//累计各碳化钨中已含添加剂重量
Z_sum.set(Z_sum.get() + finished);
Z_sum2.set(Z_sum2.get() + finished);
//累计各碳化钨中已含添加剂重量
tjj_map_jo.put("finished_qty",finished_qty+finished);
yzj_map.put(tjj_material_id,tjj_map_jo);
@@ -1037,7 +1063,7 @@ public class AcceptFormulaServiceImpl implements AcceptFormulaService {
yzj_list.add(tjj_map_now);
}
});
double W = X22_jian + Z_sum.get();
double W = X22_jian + Z_sum2.get();
if(W>0){
JSONObject W_weight = new JSONObject();
W_weight.put("formula_qty",W);

View File

@@ -548,7 +548,7 @@ export default {
}
const values = data.map(item => Number(item[column.property]))
if (column.property === 'formula_qty') {
sums[index] = values.reduce((prev, curr) => {
const total = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return prev + curr
@@ -556,6 +556,7 @@ export default {
return prev
}
}, 0)
sums[index] = parseFloat(total).toFixed(4)
sums[index]
}
})

View File

@@ -361,7 +361,7 @@ export default {
}
const values = data.map(item => Number(item[column.property]))
if (column.property === 'formula_qty') {
sums[index] = values.reduce((prev, curr) => {
const total = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return prev + curr
@@ -369,6 +369,7 @@ export default {
return prev
}
}, 0)
sums[index] = parseFloat(total).toFixed(4)
sums[index]
}
})