代码更新

This commit is contained in:
2022-07-09 17:22:03 +08:00
parent 66ab560113
commit a5faa15fa8
4 changed files with 222 additions and 63 deletions

View File

@@ -411,6 +411,10 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
public Map<String, Object> confirmOutStore2(Map<String, String> jsonObject) {
String input_optid = MapUtil.getStr(jsonObject, "input_optid");
String input_optname = MapUtil.getStr(jsonObject, "input_optname");
String source_billdtl_id = MapUtil.getStr(jsonObject, "source_billdtl_id");
String source_bill_type = MapUtil.getStr(jsonObject, "source_bill_type");
String source_bill_code = MapUtil.getStr(jsonObject, "source_bill_code");
String source_bill_table = MapUtil.getStr(jsonObject, "source_bill_table");
Long currentUserId = SecurityUtils.getCurrentUserId();
UserDto userDto = userService.findById(currentUserId);
// 仓位属性表【ST_IVT_StructAttr】
@@ -569,6 +573,7 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
invrow.put("syscompanyid", userDto.getDept().getId());
invrow.put("is_delete", "0");
invrow.put("is_upload", "0");
//明细
invdtl.put("iostorinvdtl_id", iostorinvdtl_id);
@@ -586,6 +591,10 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
invdtl.put("real_qty", out_qty);
invdtl.put("assign_qty", out_qty);
invdtl.put("unassign_qty", "0");
invdtl.put("source_billdtl_id", source_billdtl_id);
invdtl.put("source_bill_type", source_bill_type);
invdtl.put("source_bill_code", source_bill_code);
invdtl.put("source_bill_table", source_bill_table);
//分配
disjo.put("iostorinvdis_id", iostorinvdis_id);
disjo.put("iostorinvdtl_id", iostorinvdtl_id);

View File

@@ -531,6 +531,7 @@ public class FlourworkServiceImpl implements FlourworkService {
WQLObject formMstTab = WQLObject.getWQLObject("PDM_BI_Formula"); // 配方主表
WQLObject formDtlTab = WQLObject.getWQLObject("PDM_BI_FormulaDtl"); // 配方明细表
WQLObject workTab = WQLObject.getWQLObject("PDM_BI_WorkOrder"); // 工令表
WQLObject formDtlJobTab = WQLObject.getWQLObject("PDM_BI_FormulaDtlJob"); // 配方明细作业表
WQLObject formBuckeTab = WQLObject.getWQLObject("PDM_BI_FormulaBucketRecord"); // 配粉间桶记录表
@@ -554,6 +555,8 @@ public class FlourworkServiceImpl implements FlourworkService {
*/
JSONObject jsonFormDtl = formDtlTab.query("formuladtl_id = '" + jsonFormDtlJob.getString("formuladtl_id") + "'").uniqueResult(0);
JSONObject jsonFormMst = formMstTab.query("formula_id = '" + jsonFormDtl.getString("formula_id") + "'").uniqueResult(0);
JSONObject jsonWork = workTab.query("workorder_id = '" + jsonFormMst.getString("workorder_id") + "'").uniqueResult(0);
// 1.如果是
if (StrUtil.equals(jsonFormDtl.getString("is_need_move"), "1")) {
// 调用配粉出库并确认参数point_code货位storagevehicle_code载具号type配粉出库类型bucketunique桶号out_qty出库数量
@@ -570,6 +573,10 @@ public class FlourworkServiceImpl implements FlourworkService {
map.put("out_qty", jsonFormDtlJob.getString("outconfirm_qty"));
map.put("input_optid", jsonFormDtlJob.getString("create_id"));
map.put("input_optname", jsonFormDtlJob.getString("create_name"));
map.put("source_billdtl_id", jsonWork.getString("workorder_id"));
map.put("source_bill_type", jsonWork.getString("workorder_type"));
map.put("source_bill_code", jsonWork.getString("workorder_code"));
map.put("source_bill_table", "PDM_BI_WorkOrder");
handPFOutIvtService.confirmOutStore2(map);
} else {
// 2.如果不是

View File

@@ -22,8 +22,10 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
import org.nl.modules.security.service.dto.JwtUserDto;
import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.utils.SpringContextHolder;
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
import org.nl.wms.basedata.master.service.ClassstandardService;
import org.nl.wms.basedata.master.service.MaterialbaseService;
@@ -473,93 +475,154 @@ public class FormulaServiceImpl implements FormulaService {
@Override
@Transactional(rollbackFor = Exception.class)
public void preview(HttpServletResponse response, Map whereJson) throws IOException {
/* String formula_id = MapUtil.getStr(whereJson, "formula_id");
String formula_id = MapUtil.getStr(whereJson, "formula_id");
WQLObject formMstTab = WQLObject.getWQLObject("PDM_BI_Formula"); // 配方主表
WQLObject formDtlTab = WQLObject.getWQLObject("PDM_BI_FormulaDtl"); // 配方明细表
WQLObject workTab = WQLObject.getWQLObject("PDM_BI_WorkOrder"); // 工令表
WQLObject deptTab = WQLObject.getWQLObject("sys_dept"); // 部门表
WQLObject storageTab = WQLObject.getWQLObject("tool_local_storage"); // 文件表
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase"); // 物料表
WQLObject materExtTab = WQLObject.getWQLObject("MD_ME_ProducMaterialExt"); // 成品扩展属性表
WQLObject paraTab = WQLObject.getWQLObject("PDM_BI_WorkProcedureParaProduct"); // 工艺参数表
WQLObject workTaskTab = WQLObject.getWQLObject("PDM_BI_WorkTask"); // 工令工序任务表
WQLObject classTab = WQLObject.getWQLObject("md_pb_classstandard"); // 分类表
JSONObject jsonMst = formMstTab.query("formula_id ='" + formula_id + "'").uniqueResult(0);
String material_id = jsonMst.getString("material_id");
JSONObject jsonMater = materTab.query("material_id ='" + material_id + "'").uniqueResult(0);
JSONObject jsonStor = storageTab.query("source_bill_id = '" + material_id + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonStor)) throw new BadRequestException("此物料模板不存在,请先上传模板");
JSONObject jsonWork = workTab.query("workorder_id = '" + jsonMst.getString("workorder_id") + "'").uniqueResult(0);
JSONObject jsonDept = deptTab.query("dept_id = '" + jsonWork.getString("org_id") + "'").uniqueResult(0);
JSONObject jsonMaterExt = materExtTab.query("material_id = '" + material_id + "'").uniqueResult(0);
JSONObject json98jj = paraTab.query("material_id = '" + material_id + "' and para_code = 'QM001'").uniqueResult(0);
JSONObject json92jj = paraTab.query("material_id = '" + material_id + "' and para_code = 'QM002'").uniqueResult(0);
// 设置文件名和防止乱码现象
String fileName = URLEncoder.encode(jsonMater.getString("material_code")+"---"+jsonMst.getString("pcsn"), "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename*=UTf-8''"+fileName+".xlsx");
// 获取输出流
ServletOutputStream outputStream = response.getOutputStream();
String template = jsonStor.getString("path");
String template = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("EXCEL_PATH").getValue();
// String template = "D:\\work\\工艺控制卡模板.xlsx";
// 创建模板工作簿
ExcelWriter workBook = EasyExcel.write(outputStream, DataDto.class).withTemplate(template).build();
// 获取第一个sheet
WriteSheet sheet = EasyExcel.writerSheet().build();
// 查询配方明细
ArrayList<HashMap<String,String>> data = new ArrayList<>();
JSONArray dtlArr = formDtlTab.query("formula_id ='" + formula_id + "'").getResultJSONArray(0);
for (int i = 0; i < dtlArr.size(); i++) {
JSONObject json = dtlArr.getJSONObject(i);
String material_id1 = json.getString("material_id");
// 判断明细是物料明细还是分类
JSONObject jsonClassOrMater = new JSONObject();
if (StrUtil.equals(json.getString("material_type"), "01")) {
jsonClassOrMater = materTab.query("material_id ='"+material_id1+"'").uniqueResult(0);
} else {
jsonClassOrMater = classTab.query("class_id = '"+material_id1+"'").uniqueResult(0);
}
// 判断物料是原料还是辅料
boolean is_YL = false;
boolean is_FL = false;
if (StrUtil.equals(json.getString("material_type"), "01")) {
is_YL = materialbaseService.isAlongMaterType(MaterOptTypeEnum.YL.getCode(), material_id1, null);
is_FL = materialbaseService.isAlongMaterType(MaterOptTypeEnum.FL.getCode(), material_id1, null);
} else {
String class_idStr = MaterOptTypeEnum.YL.getClass_idStr();
String class_ids = classstandardService.getAllChildIdStr(class_idStr);
if (class_ids.contains(material_id1)) {
is_YL = true;
}
String class_idStr2 = MaterOptTypeEnum.FL.getClass_idStr();
String class_ids2 = classstandardService.getAllChildIdStr(class_idStr2);
if (class_ids2.contains(material_id1)) {
is_FL = true;
}
}
String classIdsFl = classstandardService.getAllChildIdStr(MaterOptTypeEnum.FL.getClass_idStr());
// 单组填充
String planstart_time = jsonMst.getString("create_time");
if (is_YL) {
HashMap<String, String> mapYL = new HashMap<>();
if (StrUtil.equals(json.getString("material_type"), "01")) {
mapYL.put("raw_material_name",jsonClassOrMater.getString("material_name"));
} else {
mapYL.put("raw_material_name",jsonClassOrMater.getString("class_name"));
}
mapYL.put("raw_pcsn",json.getString("pcsn"));
mapYL.put("raw_weight",json.getString("formula_qty"));
data.add(mapYL);
HashMap<String, Object> oneMap = new HashMap<>();
// 工令相关
oneMap.put("material_code", jsonMater.getString("material_code"));
if (ObjectUtil.isNotEmpty(jsonDept)) oneMap.put("dept_name", jsonDept.getString("name"));
if (ObjectUtil.isNotEmpty(jsonMaterExt)) oneMap.put("old_mark", jsonMaterExt.getString("old_mark"));
oneMap.put("pcsn", jsonMst.getString("pcsn"));
oneMap.put("weight",NumberUtil.round(jsonWork.getString("workorder_qty"),3));
if (ObjectUtil.isNotEmpty(planstart_time)) {
oneMap.put("date_time", planstart_time.substring(0,10));
}
// 球磨相关
oneMap.put("ball_rate",NumberUtil.mul(jsonWork.getDoubleValue("workorder_qty"),jsonMaterExt.getDoubleValue("ball_rate")));
oneMap.put("liquid_rate",NumberUtil.mul(jsonWork.getDoubleValue("workorder_qty"),jsonMaterExt.getDoubleValue("liquid_rate")));
if (ObjectUtil.isNotEmpty(json98jj)) {
if (StrUtil.equals(json98jj.getString("value"), "1.00")) {
oneMap.put("para_name", json98jj.getString("para_name"));
}
if (is_FL) {
HashMap<String, String> mapFL = new HashMap<>();
if (StrUtil.equals(json.getString("material_type"), "01")) {
mapFL.put("fu_material_name",jsonClassOrMater.getString("material_name"));
} else {
mapFL.put("fu_material_name",jsonClassOrMater.getString("class_name"));
}
mapFL.put("fu_pcsn",json.getString("pcsn"));
mapFL.put("fu_weight",json.getString("formula_qty"));
data.add(mapFL);
}
if (ObjectUtil.isNotEmpty(json92jj)) {
if (StrUtil.equals(json92jj.getString("value"), "1.00")) {
oneMap.put("para_name", json92jj.getString("para_name"));
}
}
JSONObject jsonQM13 = paraTab.query("material_id = '" + material_id + "' and para_code = 'QM013'").uniqueResult(0);
JSONObject jsonQM14 = paraTab.query("material_id = '" + material_id + "' and para_code = 'QM014'").uniqueResult(0);
JSONObject jsonPW02 = paraTab.query("material_id = '" + material_id + "' and para_code = 'PW002'").uniqueResult(0);
JSONObject jsonPW03 = paraTab.query("material_id = '" + material_id + "' and para_code = 'PW003'").uniqueResult(0);
JSONObject jsonPW04 = paraTab.query("material_id = '" + material_id + "' and para_code = 'PW004'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonQM13)) oneMap.put("number_1", jsonQM13.getString("value"));
if (ObjectUtil.isNotEmpty(jsonQM14)) oneMap.put("number_2", jsonQM14.getString("value"));
if (ObjectUtil.isNotEmpty(jsonPW02)) {
oneMap.put("number_8", jsonPW02.getString("value"));
}
if (ObjectUtil.isNotEmpty(jsonPW03)) {
String value = jsonPW03.getString("value");
String value_1 = NumberUtil.sub(value, "100").toString();
String value_2 = NumberUtil.add(value, "100").toString();
oneMap.put("number_4", value);
oneMap.put("number_5", value_1 + "~" + value_2);
}
if (ObjectUtil.isNotEmpty(jsonPW04)) {
String value = jsonPW04.getString("value");
String value_1 = NumberUtil.sub(value, "3").toString();
String value_2 = NumberUtil.add(value, "2").toString();
String value_3 = NumberUtil.sub(value, "5").toString();
String value_4 = NumberUtil.add(value, "7").toString();
oneMap.put("number_6", value_1 + "-" + value_2);
oneMap.put("number_7", value_3 + "~" + value_4);
}
// 系列设备
JSONObject jsonWorkTask_QM = workTaskTab.query("workorder_id = '" + jsonWork.getString("workorder_id") + "' and workprocedure_code = 'GX002'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonWorkTask_QM)) {
HashMap<String, String> map1 = new HashMap<>();
map1.put("flag", "3");
map1.put("product_series_id", jsonWorkTask_QM.getString("product_series_id"));
map1.put("workprocedure_id", jsonWorkTask_QM.getString("workprocedure_id"));
JSONObject jsonDevice1 = WQL.getWO("QPF_POINTCARD01").addParamMap(map1).process().uniqueResult(0);
map1.put("flag", "4");
JSONObject jsonDevice2= WQL.getWO("QPF_POINTCARD01").addParamMap(map1).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonDevice1) && ObjectUtil.isNotEmpty(jsonDevice2)) {
String device_code_1 = jsonDevice1.getString("device_code").substring(4, 6);
String device_code_2 = jsonDevice2.getString("device_code").substring(4, 6);
oneMap.put("device1", device_code_1 + "-" + device_code_2);
}
}
// 多组填充
workBook.fill(data, sheet);
// 需手动关流
workBook.finish();*/
String formula_id = MapUtil.getStr(whereJson, "formula_id");
JSONObject jsonWorkTask_PW = workTaskTab.query("workorder_id = '" + jsonWork.getString("workorder_id") + "' and workprocedure_code = 'GX003'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonWorkTask_PW)) {
HashMap<String, String> map2 = new HashMap<>();
map2.put("flag", "5");
map2.put("product_series_id", jsonWorkTask_PW.getString("product_series_id"));
map2.put("workprocedure_id", jsonWorkTask_PW.getString("workprocedure_id"));
JSONObject jsonDevice3= WQL.getWO("QPF_POINTCARD01").addParamMap(map2).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonDevice3)) oneMap.put("device2",jsonDevice3.getString("device_name"));
}
// 球磨
oneMap.put("ball_speed", jsonMaterExt.getString("ball_speed"));
JSONObject jsonQM08 = paraTab.query("material_id = '" + material_id + "' and para_code = 'QM008'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonQM08)) oneMap.put("number_3", jsonQM08.getString("value"));
oneMap.put("create_name", jsonMst.getString("create_name"));
// 查询配方明细-辅料
HashMap<String, String> map = new HashMap<>();
map.put("flag", "1");
map.put("classIds", classIdsFl);
map.put("formula_id", formula_id);
JSONArray flArr = WQL.getWO("QPF_POINTCARD01").addParamMap(map).process().getResultJSONArray(0);
ArrayList<HashMap<String,Object>> flData = new ArrayList<>();
if (ObjectUtil.isNotEmpty(flArr)) {
for (int i = 0; i < flArr.size(); i++) {
HashMap<String, Object> mapFL = new HashMap<>();
JSONObject jsonObject = flArr.getJSONObject(i);
mapFL.put("fl_material_name",jsonObject.getString("material_name"));
mapFL.put("fl_weight",NumberUtil.round(jsonObject.getString("formula_qty"),3));
flData.add(mapFL);
}
}
workBook.fill(oneMap, sheet);
workBook.fill(new FillWrapper("data", flData), sheet);
// workBook.fill(ylData, sheet);
workBook.finish();
/* String formula_id = MapUtil.getStr(whereJson, "formula_id");
WQLObject formMstTab = WQLObject.getWQLObject("PDM_BI_Formula"); // 配方主表
WQLObject formDtlTab = WQLObject.getWQLObject("PDM_BI_FormulaDtl"); // 配方明细表
@@ -673,7 +736,7 @@ public class FormulaServiceImpl implements FormulaService {
workBook.fill(new FillWrapper("data1", ylData), sheet);
workBook.fill(new FillWrapper("data2", flData), sheet);
// workBook.fill(ylData, sheet);
workBook.finish();
workBook.finish();*/
}
@Override

View File

@@ -16,6 +16,8 @@
输入.flag TYPEAS s_string
输入.formula_id TYPEAS s_string
输入.classIds TYPEAS f_string
输入.product_series_id TYPEAS s_string
输入.workprocedure_id TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -49,7 +51,7 @@
PDM_BI_FormulaDtl dtl
INNER JOIN md_me_materialbase mater ON dtl.material_id = mater.material_id
WHERE
1=1
dtl.is_need_manage = '0'
OPTION 输入.formula_id <> ""
dtl.formula_id = 输入.formula_id
@@ -69,7 +71,7 @@
PDM_BI_FormulaDtl dtl
INNER JOIN md_pb_classstandard class ON dtl.material_id = class.class_id
WHERE
1=1
dtl.is_need_manage = '0'
OPTION 输入.formula_id <> ""
dtl.formula_id = 输入.formula_id
@@ -129,6 +131,84 @@
ORDER BY seq_no ASC
LIMIT 8,100
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
workDevice.*,
device.device_code
FROM
MPS_BD_CapacityTemplateWorkDevice workDevice
LEFT JOIN EM_BI_DeviceInfo device ON workDevice.device_id = device.device_id
WHERE
device.is_produceuse = '1'
AND device.is_active = '1'
OPTION 输入.product_series_id <> ""
workDevice.product_series_id = 输入.product_series_id
ENDOPTION
OPTION 输入.workprocedure_id <> ""
workDevice.workprocedure_id = 输入.workprocedure_id
ENDOPTION
order by device.device_code ASC
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
workDevice.*,
device.device_code
FROM
MPS_BD_CapacityTemplateWorkDevice workDevice
LEFT JOIN EM_BI_DeviceInfo device ON workDevice.device_id = device.device_id
WHERE
device.is_produceuse = '1'
AND device.is_active = '1'
OPTION 输入.product_series_id <> ""
workDevice.product_series_id = 输入.product_series_id
ENDOPTION
OPTION 输入.workprocedure_id <> ""
workDevice.workprocedure_id = 输入.workprocedure_id
ENDOPTION
order by device.device_code DESC
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "5"
QUERY
SELECT
workDevice.*,
device.device_name
FROM
MPS_BD_CapacityTemplateWorkDevice workDevice
LEFT JOIN EM_BI_DeviceInfo device ON workDevice.device_id = device.device_id
WHERE
device.is_produceuse = '1'
AND device.is_active = '1'
OPTION 输入.product_series_id <> ""
workDevice.product_series_id = 输入.product_series_id
ENDOPTION
OPTION 输入.workprocedure_id <> ""
workDevice.workprocedure_id = 输入.workprocedure_id
ENDOPTION
order by device.device_code ASC
ENDSELECT
ENDQUERY
ENDIF