rev:配粉开单合批模式球磨时间计算

This commit is contained in:
2023-06-09 13:58:10 +08:00
parent c172453084
commit 01980f65df
3 changed files with 76 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
import org.nl.wms.basedata.master.service.MaterialbaseService;
import org.nl.wms.pf.service.AutoformulaService;
import org.nl.wms.pf.service.InitformulaService;
import org.nl.wql.WQL;
@@ -30,6 +31,7 @@ import java.util.stream.Collectors;
@Slf4j
public class AutoformulaServiceImpl implements AutoformulaService {
private final InitformulaService initformulaService;
private final MaterialbaseService materialbaseService;
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject autoCalculation(Map map) {
@@ -4877,14 +4879,56 @@ public class AutoformulaServiceImpl implements AutoformulaService {
}
dtl_new.add(jo);
}
/*
* 计算出球磨时间
*/
// 1.找出所有软废
List<JSONObject> rfList = dtl_new.stream()
.map(row -> (JSONObject) row)
.filter(row -> ObjectUtil.isNotEmpty(row.getString("material_type_id")))
.filter(row -> materialbaseService.isAlongMaterType(MaterOptTypeEnum.RF.getCode(), row.getString("material_id"), null))
.collect(Collectors.toList());
// 2.找出所有软废bom中最后一个碳化钨
ArrayList<Double> numList = new ArrayList<>(); // 球磨时间集合
rfList.forEach(row -> {
// 截取软废的类型
String code = row.getString("material_code");
String rf_type = code.substring(code.lastIndexOf('-') + 1);
// 找此软废bom最后一个碳化钨
JSONObject rfBomdtl = WQL.getWO("QPF_AUTOFORMULA02")
.addParam("material_id", row.getString("material_id"))
.addParam("flag", "9")
.process()
.uniqueResult(0);
if (ObjectUtil.isNotEmpty(rfBomdtl)) {
// 找到此碳化钨此软废类型的球磨时间
JSONObject jsonAllData = PDM_BI_WasteBallTime.query("material_id = '" + rfBomdtl.getString("material_id") + "'").uniqueResult(0).getJSONObject("alldata");
if (ObjectUtil.isEmpty(jsonAllData)) numList.add(0.0);
numList.add(jsonAllData.getDouble(rf_type));
}
});
// 3.找出最大的球磨时间
double time = 0.0;
if (ObjectUtil.isNotEmpty(numList)) {
time = numList.stream()
.filter(row -> row != 99)
.max(Comparator.comparingDouble(row -> row)).get();
}
JSONObject result = new JSONObject();
result.put("tableDtl",dtl_new);
result.put("chunfen_qty",chunfen_qty);
result.put("ball_time",ball_time);
result.put("time",time);
return result;
}
/**
* 合批含软废
* @param json

View File

@@ -370,3 +370,25 @@
ENDQUERY
ENDIF
IF 输入.flag = "9"
QUERY
SELECT
bomdtl.*
FROM
MD_PD_ProductBOM bom
LEFT JOIN md_pd_productbomdtl bomdtl ON bom.bom_id = bomdtl.bom_id
LEFT JOIN md_me_materialbase mater ON mater.material_id = bomdtl.material_id
LEFT JOIN md_pb_classstandard class ON mater.material_type_id = class.class_id
WHERE
1 = 1
AND bom.is_delete = '0'
AND bom.is_used = '1'
AND class.class_code = '09030101'
OPTION 输入.material_id <> ""
bom.material_id = 输入.material_id
ENDOPTION
ORDER BY bomdtl.seqno DESC
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -1099,6 +1099,9 @@ export default {
autoformula.autoCalculation(this.form).then(res => {
this.crud.notify('自动计算成功!')
this.chunfen_qty = res.chunfen_qty
if (res.time !== 0.0 && res.time !== undefined) {
this.form.ball_time = res.time
}
this.fullscreenLoading = false
if ((parseFloat(this.chunfen_qty) > 0) && (parseFloat(this.chunfen_qty) < parseFloat(this.form.workorder_qty))) {
this.$confirm('软废纯粉重量为' + parseFloat(this.chunfen_qty).toFixed(3) + '公斤,不足工令重量,是否继续?')
@@ -1112,6 +1115,9 @@ export default {
this.form2.total_qty1 = 0
this.form2.add_qty1 = 0
this.ball_time = res2.ball_time
if (res2.time !== 0.0 && res2.time !== undefined) {
this.form.ball_time = res2.time
}
if ((parseFloat(this.ball_time) > 0)) {
this.form.ball_time = parseFloat(this.ball_time)
}
@@ -1162,6 +1168,9 @@ export default {
this.tableDtl = res.tableDtl
this.form2.total_qty1 = 0
this.form2.add_qty1 = 0
if (res.time !== 0.0 && res.time !== undefined) {
this.form.ball_time = res.time
}
for (let i = 0; i < this.tableDtl.length; i++) {
const row = this.tableDtl[i]
row.edit = true