代码更新

This commit is contained in:
2022-10-15 16:06:23 +08:00
parent 901a7443ee
commit df0323aaa8
6 changed files with 189 additions and 3 deletions

View File

@@ -148,4 +148,11 @@ public class MaterialParametersController {
public ResponseEntity<Object> getSeries() {
return new ResponseEntity<>(materialParametersService.getSeries(), HttpStatus.OK);
}
@PostMapping("/sync")
@Log("同步")
@ApiOperation("同步-产品系列")
public ResponseEntity<Object> sync(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(materialParametersService.sync(whereJson),HttpStatus.OK);
}
}

View File

@@ -85,4 +85,10 @@ public interface MaterialParametersService {
* 查询基础分类-产品系列
*/
JSONArray getSeries();
/**
* 同步
* @param whereJson /
*/
JSONObject sync(JSONObject whereJson);
}

View File

@@ -5,6 +5,7 @@ package org.nl.wms.basedata.master.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
@@ -20,6 +21,7 @@ import org.nl.wms.basedata.master.service.MaterialParametersService;
import org.nl.wms.basedata.master.service.MaterialbaseService;
import org.nl.wms.basedata.master.service.dto.MaterialParametersDto;
import org.nl.wms.basedata.master.service.dto.MaterialbaseDto;
import org.nl.wms.basedata.pdm.service.impl.WastecchangeServiceImpl;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.util.WqlUtil;
@@ -318,4 +320,149 @@ public class MaterialParametersServiceImpl implements MaterialParametersService
return resultJSONArray;
}
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject sync(JSONObject whereJson) {
/*
* 1.PG粉碳平衡修正
* 2.软废碳平衡修正
*/
WQLObject productMstTab = WQLObject.getWQLObject("MD_PD_ProductBOM"); // 产品bom单主表
WQLObject productDtlTab = WQLObject.getWQLObject("MD_PD_ProductBOMDtl"); // 产品bom单明细表
WQLObject wasTab = WQLObject.getWQLObject("PDM_BI_WasteCChange"); // 软废碳平衡修正表
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase"); // 物料表
WQLObject extTab = WQLObject.getWQLObject("MD_ME_ProducMaterialExt"); // 成品物料扩展信息表
JSONObject result = new JSONObject();
// 1.判断此物料是PG粉还是RF
boolean is_pgf = materialbaseService.isAlongMaterType(MaterOptTypeEnum.PGF.getCode(), whereJson.getString("material_id"), null);
boolean is_rf = materialbaseService.isAlongMaterType(MaterOptTypeEnum.RF.getCode(), whereJson.getString("material_id"), null);
String material_id = whereJson.getString("material_id");
JSONObject jsonMater = materTab.query("material_id = '" + material_id + "'").uniqueResult(0);
JSONObject jsonExtMater = extTab.query("material_id = '" + material_id + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonExtMater)) throw new BadRequestException("此PGF扩展属性不存在");
if (is_pgf) {
/*
* PG粉碳平衡修正
* 1.查询此PG粉产品bom明细表第一个碳化钨
* 2.查询此碳化钨 软废碳平衡修正表获得全部软废类型的值
* 3.查询软废:物料表,软废编码 = PG粉编码 + '-CF'
* 4.依次修改16种软废类型的碳平衡
* 软废碳平衡=pg粉碳平衡+CF修正值
*/
// 1.查询此物料的产品bom明细表中第一个出现的碳化钨
// 查主表
JSONObject jsonProductMst = productMstTab.query("material_id = '" + material_id + "' and is_used = '1' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonProductMst)) throw new BadRequestException("此产品没有创建bom单或者已删除、未启用");
// 查明细
JSONArray productDtlArr = productDtlTab.query("bom_id = '" + jsonProductMst.getString("bom_id") + "' order by seqno ASC").getResultJSONArray(0);
if (ObjectUtil.isEmpty(productDtlArr)) throw new BadRequestException("此产品bom单暂无明细");
// 找出第一个碳化钨
String thw_material_id = "";
for (int i = 0; i < productDtlArr.size(); i++) {
JSONObject jsonProductDtl = productDtlArr.getJSONObject(i);
boolean is_thw = materialbaseService.isAlongMaterType(MaterOptTypeEnum.THW.getCode(), jsonProductDtl.getString("material_id"), null);
if (is_thw) {
thw_material_id = jsonProductDtl.getString("material_id");
break;
}
}
// 2.查询此碳化钨 软废碳平衡修正表获得全部软废类型的值 并转化成数组(便于处理数据)
JSONObject jsonThwMater = materTab.query("material_id = '" + thw_material_id + "'").uniqueResult(0);
JSONObject jsonWas = wasTab.query("material_id = '" + thw_material_id + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonWas)) throw new BadRequestException("此碳化钨软废修正数据不存在:"+jsonThwMater.getString("material_code"));
// 将此碳化钨的软废类型转化为数组
JSONArray wasArr = new WastecchangeServiceImpl().contentShift(jsonWas);
// 3.查询软废:物料表,软废编码 = PG粉编码 + '-CF' (以软废类型CF为例)
for (int j = 0; j < wasArr.size(); j++) {
JSONObject jsonWasDtl = wasArr.getJSONObject(j);
String rf_type_code = jsonMater.getString("material_code") +"-"+jsonWasDtl.getString("name");
JSONObject jsonRfMater = materTab.query("material_code = '" + rf_type_code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonRfMater)) {
// 4.依次修改16种软废类型的碳平衡: 软废碳平衡=pg粉碳平衡+CF修正值
JSONObject jsonRfExt = extTab.query("material_id = '" + jsonRfMater.getString("material_id") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonRfExt)) throw new BadRequestException("此软废扩展信息不存在:"+rf_type_code);
double rf_c_balance = NumberUtil.add(jsonExtMater.getDoubleValue("c_balance"), jsonWasDtl.getDoubleValue("value"));
jsonRfExt.put("c_balance", String.valueOf(rf_c_balance));
extTab.update(jsonRfExt);
}
}
result.put("c_balance", "");
}
if (is_rf) {
/*
* 软废粉碳平衡修正:
* 1.找PG粉查物料表 PG粉编码 = 此软废编码去掉最后一个'-'和后面的内容
* 2.找碳化钨此PG粉产品BOM明细第一个碳化钨
* 3.找修正值:废类型为编码最后'-'后的内容 如JZ16-P-A2-20-JY 软废类型就是 JY
* 查此碳化钨的软废修正表对应的软废类型:软废碳平衡=pg粉碳平衡+此软废修正值
* 4.最后将计算后的值返回给页面
*/
// 1.找PG粉查物料表 PG粉编码 = 此软废编码去掉最后一个'-'和后面的内容
String pg_material_code = jsonMater.getString("material_code").substring(0, jsonMater.getString("material_code").lastIndexOf("-"));
JSONObject jsonPgfMater = materTab.query("material_code = '" + pg_material_code + "'").uniqueResult(0);
// 2.找碳化钨此PG粉产品BOM明细第一个碳化钨
// 查主表
JSONObject jsonProductMst = productMstTab.query("material_id = '" + jsonPgfMater.getString("material_id") + "' and is_used = '1' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonProductMst)) throw new BadRequestException("此产品没有创建bom单或者已删除、未启用"+pg_material_code);
// 查明细
JSONArray productDtlArr = productDtlTab.query("bom_id = '" + jsonProductMst.getString("bom_id") + "' order by seqno ASC").getResultJSONArray(0);
if (ObjectUtil.isEmpty(productDtlArr)) throw new BadRequestException("此产品bom单暂无明细"+pg_material_code);
// 找出第一个碳化钨
String thw_material_id = "";
for (int i = 0; i < productDtlArr.size(); i++) {
JSONObject jsonProductDtl = productDtlArr.getJSONObject(i);
boolean is_thw = materialbaseService.isAlongMaterType(MaterOptTypeEnum.THW.getCode(), jsonProductDtl.getString("material_id"), null);
if (is_thw) {
thw_material_id = jsonProductDtl.getString("material_id");
break;
}
}
// 3.找修正值:废类型为编码最后'-'后的内容
JSONObject jsonThwMater = materTab.query("material_id = '" + thw_material_id + "'").uniqueResult(0);
JSONObject jsonWas = wasTab.query("material_id = '" + thw_material_id + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonWas)) throw new BadRequestException("此碳化钨软废修正数据不存在:"+jsonThwMater.getString("material_name"));
// 将此碳化钨的软废类型转化为数组
JSONArray wasArr = new WastecchangeServiceImpl().contentShift(jsonWas);
String rf_type_code = jsonMater.getString("material_code").substring(jsonMater.getString("material_code").lastIndexOf("-")+1,jsonMater.getString("material_code").length());
double value = 0;
for (int j = 0; j < wasArr.size(); j++) {
JSONObject jsonWasDtl = wasArr.getJSONObject(j);
if (StrUtil.equals(rf_type_code, jsonWasDtl.getString("name"))) {
value = jsonWasDtl.getDoubleValue("value");
break;
}
}
// 软废碳平衡=pg粉碳平衡+此软废修正值
JSONObject jsonPgfExt = extTab.query("material_id = '" + jsonPgfMater.getString("material_id") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonPgfExt)) throw new BadRequestException("此PG粉扩展属性不存在"+pg_material_code);
double c_balance = NumberUtil.add(jsonPgfExt.getDoubleValue("c_balance"), value);
result.put("c_balance", String.valueOf(c_balance));
}
return result;
}
}

View File

@@ -197,7 +197,7 @@
mst.is_delete = '0'
AND file.is_delete = '0'
AND mst.maint_object = '02'
AND mst.invstatus not in ('01')
AND mst.invstatus in ('02','03')
OPTION 输入.device_code <> ""
(file.device_code like 输入.device_code or
@@ -369,7 +369,7 @@
mst.is_delete = '0'
AND file.is_delete = '0'
AND mst.maint_object = '01'
AND mst.invstatus not in ('01')
AND mst.invstatus in ('02','03')
OPTION 输入.device_code <> ""
(file.device_code like 输入.device_code or

View File

@@ -55,4 +55,12 @@ export function getSeries() {
})
}
export default { add, edit, del, save, queryMaterialParam, getUploadTemplate, getSeries }
export function sync(data) {
return request({
url: 'api/MaterialParameters/sync',
method: 'post',
data
})
}
export default { add, edit, del, save, queryMaterialParam, getUploadTemplate, getSeries, sync }

View File

@@ -214,6 +214,7 @@
<el-col :span="8">
<el-form-item label="碳平衡" prop="c_balance">
<el-input-number :precision="3" :step="0.001" :max="100" v-model="formData.c_balance" :controls="false" placeholder="%" style="width: 200px;"/>
<el-button type="success" icon="el-icon-refresh" :loading="sync_flg" @click="sync">同步</el-button>
</el-form-item>
</el-col>
</el-row>
@@ -328,6 +329,7 @@ export default {
dialogUpload: false,
PicDialog: false,
serieseList: [],
sync_flg: false,
prules: {
is_auto_open: [
{ required: true, message: '不能为空', trigger: 'blur' }
@@ -471,6 +473,22 @@ export default {
},
submitUpload() {
const flag = this.$refs.upload.submit()
},
sync() {
const data = this.formData
this.sync_flg = true
crudMaterialparameters.sync(data).then(res => {
debugger
if (res.c_balance === '') {
this.crud.notify('同步成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
} else {
this.formData.c_balance = res.c_balance
this.crud.notify('同步成功,请确认', CRUD.NOTIFICATION_TYPE.SUCCESS)
}
this.sync_flg = false
}).catch(() => {
this.sync_flg = false
})
}
}
}