Merge remote-tracking branch 'origin/master_merge' into master_merge

This commit is contained in:
2025-02-20 09:56:05 +08:00
8 changed files with 255 additions and 49 deletions

View File

@@ -28,17 +28,17 @@ import org.nl.common.utils.IdUtil;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.system.service.param.ISysParamService;
import org.nl.system.service.param.dao.Param;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.pda.st.service.impl.PrintServiceImpl;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -88,6 +88,11 @@ public class LashManageServiceImpl implements LashManageService {
*/
private final IschBaseTaskService ischBaseTaskService;
/**
* 任务服务
*/
private final ISysParamService iSysParamService;
@Override
@Transactional
public void createLashTask(JSONObject whereJson) {
@@ -317,79 +322,121 @@ public class LashManageServiceImpl implements LashManageService {
@Override
public JSONObject applyTab(JSONObject whereJson) {
// 载具扩展属性表
WQLObject extTab = WQLObject.getWQLObject("md_pb_storagevehicleext");
// 任务表
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
WQLObject md_pb_storagevehicleext = WQLObject.getWQLObject("md_pb_storagevehicleext");
// TODO 贴标流程
JSONObject result = new JSONObject();
//设备号
String device_code = whereJson.getString("device_code");
//载具号
String vehicle_code = whereJson.getString("vehicle_code");
//查询托盘对应的载具号
JSONObject vehicle_ext = WQLObject.getWQLObject("md_pb_storagevehicleext").query("storagevehicle_code = '" + vehicle_code + "'").uniqueResult(0);
//查询托盘详细信息
JSONObject vehicle_ext = md_pb_storagevehicleext.query("storagevehicle_code = '" + vehicle_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(vehicle_ext)) {
throw new BadRequestException("未查询到托盘对应的扩展属性");
}
//判断木箱信息是否为空
String box_no = vehicle_ext.getString("pcsn");
if (StrUtil.isEmpty(box_no)) {
throw new BadRequestException("未查询到托盘绑定了相关木箱!");
throw new BadRequestException("未查询到托盘:"+vehicle_code+"绑定了相关木箱!");
}
// 查询木箱信息
BstIvtBoxinfo boxDao = iBstIvtBoxinfoService.getOne(
new QueryWrapper<BstIvtBoxinfo>().lambda()
.eq(BstIvtBoxinfo::getBox_no, vehicle_ext.getString("pcsn"))
BstIvtBoxinfo boxinfo = iBstIvtBoxinfoService.getOne(
new QueryWrapper<BstIvtBoxinfo>().lambda().eq(BstIvtBoxinfo::getBox_no, box_no)
);
// 根据木箱料号查询木箱类型信息
MdpbBoxtype boxTypeDao = iMdpbBoxtypeService.getById(boxDao.getMaterial_code());
if (ObjectUtil.isEmpty(boxTypeDao)) {
throw new BadRequestException("木箱类型信息不存在!木箱料号为:" + boxDao.getMaterial_code());
//判断木箱类型信息是否为空
if (StrUtil.isEmpty(boxinfo.getMaterial_code())) {
throw new BadRequestException("木箱料号未设置木箱类型信息:bst_ivt_boxinfo!");
}
// 根据木箱料号查询木箱类型信息
MdpbBoxtype boxType = iMdpbBoxtypeService.getById(boxinfo.getMaterial_code());
if (ObjectUtil.isEmpty(boxType)) {
throw new BadRequestException("木箱类型信息不存在!木箱料号为:" + boxinfo.getMaterial_code());
}
// 返回参数
result.put("length", boxDao.getBox_length());
result.put("width", boxDao.getBox_width());
result.put("height", boxDao.getBox_high());
result.put("case", boxDao.getMaterial_code());
result.put("length", boxinfo.getBox_length());
result.put("width", boxinfo.getBox_width());
result.put("height", boxinfo.getBox_high());
result.put("case", boxinfo.getMaterial_code());
// 捆扎模板
if (ObjectUtil.isEmpty(boxType.getLash_num())) {
throw new BadRequestException("捆扎模版不能为空!");
}
result.put("bindingTemplate", boxType.getLash_num());
// 第一次捆扎次数
if (ObjectUtil.isEmpty(boxType.getLash_num_one())) {
throw new BadRequestException("第一次捆扎数量不能为空!");
}
result.put("bundleTimes", boxType.getLash_num_one());
// 木箱结构
if (ObjectUtil.isEmpty(boxType.getBox_structure())) {
throw new BadRequestException("木箱结构不能为空!");
}
result.put("box_structure", boxType.getBox_structure());
// 是否捆扎: 如果是返检或者反切的则不需要捆扎(找最近的木箱出库单据)
if (ObjectUtil.isEmpty(boxTypeDao.getNeed_lash_one())) {
if (ObjectUtil.isEmpty(boxType.getNeed_lash_one())) {
throw new BadRequestException("第一次是否捆扎不能为空!");
}
String isBinding = boxTypeDao.getNeed_lash_one();
JSONObject jsonMst = stIvtIostorinvOutMapper.queryBoxOutInfo(boxDao.getBox_no());
String isBinding = boxType.getNeed_lash_one();
JSONObject jsonMst = stIvtIostorinvOutMapper.queryBoxOutInfo(boxinfo.getBox_no());
if (ObjectUtil.isNotEmpty(jsonMst)) {
if (jsonMst.getString("bill_type").equals(IOSEnum.OUT_TYPE.code("改切出库"))
|| jsonMst.getString("bill_type").equals(IOSEnum.OUT_TYPE.code("返检出库"))) {
isBinding = IOSEnum.IS_NOTANDYES.code("");
}
}
// 是否捆扎
result.put("isBinding", isBinding);
// TODO 是否贴标
result.put("isLabeling", IOSEnum.IS_SEND.code(""));
// TODO 贴标数量
result.put("printQty", "4");
// TODO 贴标模版
result.put("labelingTemplate", boxDao.getLash_num());
// 捆扎模板
if (ObjectUtil.isEmpty(boxTypeDao.getLash_num())) {
throw new BadRequestException("捆扎模版不能为空!");
}
result.put("bindingTemplate", boxTypeDao.getLash_num());
result.put("labelingTemplate", "403");
// TODO 打印机
result.put("printDevice", "1");
// TODO 贴标数量
result.put("printQty", "1");
// 第一次捆扎次数
if (ObjectUtil.isEmpty(boxTypeDao.getLash_num_one())) {
throw new BadRequestException("第一次捆扎数量不能为空!");
//判断系统参数是否贴标
String is_labeling = iSysParamService.findByCode("is_labeling2").getValue();
if (is_labeling.equals("1")) {
result.put("isLabeling", IOSEnum.IS_SEND.code(""));
String labelingTemplate = iSysParamService.findByCode("labelingTemplate").getValue();
result.put("labelingTemplate", labelingTemplate);
Param label_num = null;
//CK2019,CK2015
if(device_code.equals("CK2019") || device_code.equals("CK2015")){
label_num = iSysParamService.findMinByCode(device_code);
String print_code = label_num.getCode();
JSONObject print_info = WQLObject.getWQLObject("pdm_bi_printinfo").query("print_name = '" + print_code + "'").uniqueResult(0);
JSONObject print_jo = new JSONObject();
print_jo.put("box_no", box_no);
print_jo.put("print_type", print_info.getString("print_id"));
new PrintServiceImpl().customerPrintBY2(print_jo);
result.put("printDevice", print_info.getString("print_code"));
// 贴标成功:更新系统参数贴标次数
String label_num_up = label_num.getValue();
String now_num = NumberUtil.sub(label_num_up, "1").toString();
label_num.setValue(now_num);
iSysParamService.update(label_num);
// 判断是否到达预警值
String label_num_down = iSysParamService.findByCode("label_num_down").getValue();
if (Integer.valueOf(label_num_down) >= Integer.valueOf(now_num)) {
result.put("message", "标签纸数量过低,请更换!");
}
}else{
throw new BadRequestException("贴标请求设备点位异常:"+device_code);
}
}
result.put("bundleTimes", boxTypeDao.getLash_num_one());
// 木箱结构
if (ObjectUtil.isEmpty(boxTypeDao.getBox_structure())) {
throw new BadRequestException("木箱结构不能为空!");
}
result.put("box_structure", boxTypeDao.getBox_structure());
return result;
}

View File

@@ -52,9 +52,9 @@ public interface LashManageService {
* bundleTimes: 第一次捆扎数量
* box_structure: 木箱结构
* box_structure: 木箱结构
* bundleTimes: 捆扎次数
* isLabeling: 是否贴标
* labelingTemplate: 贴标模板
* bundleTimes: 捆扎次数
* printQty: 贴标数量
* printDevice: 使用打印机
* }

View File

@@ -70,7 +70,7 @@ public class DruidFilter extends FilterEventAdapter {
}
executeSql = SQLUtils.format(executeSql, JdbcUtils.MYSQL, params);
}
log.info("[----SQL----][update][数据库:{}][ SQL: {} ]",database, executeSql);
log.info("[----SQL----][update][执行结果:{}][数据库:{}][ SQL: {} ]",count,database, executeSql);
}
super.statementExecuteAfter(statement, sql, result);
}

View File

@@ -55,4 +55,6 @@ public interface ISysParamService extends IService<Param> {
* @return Param
*/
Param findByCode(String code);
Param findMinByCode(String code);
}

View File

@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -103,4 +104,13 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
Param param = paramMapper.selectOne(queryWrapper);
return param;
}
@Override
public Param findMinByCode(String code) {
QueryWrapper<Param> queryWrapper = new QueryWrapper<>();
queryWrapper.like("code", code);
queryWrapper.orderByDesc("value");
List<Param> param = paramMapper.selectList(queryWrapper);
return param.get(0);
}
}

View File

@@ -33,6 +33,16 @@ public interface PrintService {
*/
JSONObject customerPrint2(JSONObject whereJson);
/**
* 二期贴标数据组织
*
* @param whereJson /
* @return JSONObject /
*/
JSONObject customerPrintBY2(JSONObject whereJson);
/**
* 获取单据类型
*

View File

@@ -319,6 +319,143 @@ public class PrintServiceImpl implements PrintService {
return jo;
}
@Override
public JSONObject customerPrintBY2(JSONObject whereJson) {
JSONObject jo = new JSONObject();
WQLObject printTab = WQLObject.getWQLObject("pdm_bi_printinfo");
WQLObject custTab = WQLObject.getWQLObject("md_cs_customerbase");
WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation");
String box_no = whereJson.getString("box_no");
JSONObject box_jo = subTab.query("package_box_sn = '" + box_no + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(box_jo)) {
throw new BadRequestException("未查询到木箱相关信息!");
}
//组织木箱打印信息
//箱号
String package_box_sn = box_jo.getString("package_box_sn");
String package_box_sn1 = "";
String package_box_sn2 = "";
try {
// 木箱1
package_box_sn1 = package_box_sn.substring(0, package_box_sn.indexOf("@") + 1);
// 木箱2
package_box_sn2 = package_box_sn.substring(package_box_sn.indexOf("@") + 1, package_box_sn.length());
} catch (Exception e) {
package_box_sn2 = package_box_sn;
}
//订单号
String sale_order_name = box_jo.getString("sale_order_name");
//品名
String product_description = box_jo.getString("product_description");
//物料号
String product_name = box_jo.getString("product_name");
//规格: 厚度*幅宽
String width = box_jo.getString("thickness_request") + "*" + box_jo.getString("width_standard");
//入库日期:取此箱子中最晚的入库日期
JSONObject jsonInbound = subTab.query("package_box_sn = '" + box_no + "' order by date_of_fg_inbound DESC").uniqueResult(0);
String date_of_FG_inbound = jsonInbound.getString("date_of_fg_inbound");
String box_weight = NumberUtil.round(box_jo.getString("box_weight"), 2).toString();
//生产日期:取此箱子中最晚的生产日期
JSONObject jsonProduction = subTab.query("package_box_sn = '" + box_no + "' order by date_of_production DESC").uniqueResult(0);
String date_of_production = jsonProduction.getString("date_of_production");
//批号
String pcsn = jsonProduction.getString("date_of_production");
if (ObjectUtil.isNotEmpty(pcsn)) {
pcsn = pcsn.replaceAll("[[\\s-:punct:]]", "");
}
//卷数
String quanlity_in_box = box_jo.getString("quanlity_in_box");
//保质期
String quality_guaran_period = box_jo.getString("quality_guaran_period");
//检验员
String nspector = "1";
//储存条件
String storage_conditions = "";
// 根据客户条件选择对应模板
JSONObject jsonCust = custTab.query("cust_code = '" + box_jo.getString("customer_name") + "' and is_delete = '0' and is_used = '1'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonCust)) {
throw new BadRequestException("客户不存在或未启用");
}
if (ObjectUtil.isEmpty(jsonCust.getString("bz_print_no"))) {
throw new BadRequestException("请先设置客户打印模板");
}
String bz_print_no = jsonCust.getString("bz_print_no");
double weight = 0;
JSONArray rows = WQL.getWO("PDA_ST_01").addParam("flag", "5").addParam("box_no", box_no).process().getResultJSONArray(0);
for (int i = 0; i < rows.size(); i++) {
JSONObject row = rows.getJSONObject(i);
weight += row.getDoubleValue("net_weight");
}
// 生成txt文件
JSONObject jsonPrint = printTab.query("print_id = '" + whereJson.getString("print_type") + "'").uniqueResult(0);
//10.1.3.21/LMSPrinter/
String filePath = jsonPrint.getString("print_route") + "外包标签.txt";
FileWriter fw = null;
try {
File file = new File(filePath);
if (!file.exists()) {
file.createNewFile();
}
fw = new FileWriter(filePath);
OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(file), "utf-8");
BufferedWriter bw = new BufferedWriter(write);
bw.write("bz_print_no,package_box_sn1,package_box_sn2,sale_order_name,product_description,product_name,width,pcsn,date_of_FG_inbound,box_weight,date_of_production,quanlity_in_box,quality_guaran_period,nspector,storage_conditions,weight,customer_name,customer_description,thickness,mass_per_unit_area,length,box_type,sap_pcsn,box_length,box_width,box_high,material_type,joint_type\n");
bw.write(bz_print_no + ","
+ package_box_sn1 + ","
+ package_box_sn2 + ","
+ sale_order_name + ","
+ product_description + ","
+ product_name + ","
+ width + ","
+ pcsn + ","
+ date_of_FG_inbound + ","
+ box_weight + "KG,"
+ date_of_production + ","
+ quanlity_in_box + ","
+ quality_guaran_period + ","
+ nspector + ","
+ storage_conditions + ","
+ NumberUtil.round(weight, 2).toString() + "KG,"
+ box_jo.getString("customer_name") + ","
+ box_jo.getString("customer_description") + ","
+ box_jo.getString("thickness") + ","
+ box_jo.getString("mass_per_unit_area") + ","
+ NumberUtil.round(box_jo.getString("length"), 2) + ","
+ box_jo.getString("box_type") + ","
+ box_jo.getString("sap_pcsn") + ","
+ box_jo.getString("box_length") + ","
+ box_jo.getString("box_width") + ","
+ box_jo.getString("box_high") + ","
+ box_jo.getString("material_type") + ","
+ NumberUtil.round(box_jo.getString("joint_type"),2) + "\n"
);
bw.close();
jo.put("message", "打印成功!");
} catch (Exception e) {
jo.put("message", "打印失败!" + e.getMessage());
} finally {
try {
if(fw != null){
fw.close();
}
} catch (Exception e) {
jo.put("message", "打印失败!" + e.getMessage());
}
}
return jo;
}
@Override
public JSONObject printType(JSONObject whereJson) {
JSONArray rows = WQL.getWO("PDA_ST_01").addParam("flag", "6").process().getResultJSONArray(0);

View File

@@ -249,7 +249,7 @@ public class StorPublicServiceImpl implements StorPublicService {
throw new BadRequestException("输入数据异常,请检查");
}
if (jo_in.getDoubleValue("frozen_qty") < 0) {
throw new BadRequestException("冻结数不允许为负数");
throw new BadRequestException("库存冻结数异常,请联系管理员分析处理单据");
}
wql.update(jo_in, "stockrecord_id='" + jo_in.getString("stockrecord_id") + "'");
} else {