fix: 系统优化

This commit is contained in:
2023-05-19 17:45:22 +08:00
parent 1ab3878fe2
commit 2bcc3197cc
14 changed files with 233 additions and 34 deletions

View File

@@ -78,7 +78,41 @@ public class FaultDeviceServiceImpl implements FaultDeviceService {
JSONObject result = SpringContextHolder.getBean(WmsToAcsServiceImpl.class).realTimefaultInfo(param);
JSONArray data = result.getJSONArray("data");
JSONObject test1 = new JSONObject();
JSONObject result2 = SpringContextHolder.getBean(WmsToAcsServiceImpl.class).queryDeviceInfo(null);
JSONObject jsonData = result2.getJSONObject("data");
JSONArray data1 = new JSONArray();
if (ObjectUtil.isNotEmpty(jsonData)) {
JSONArray jsonA1 = jsonData.getJSONArray("jsonA1");
JSONArray jsonLK = jsonData.getJSONArray("jsonLK");
data1.addAll(jsonA1);
data1.addAll(jsonLK);
}
for (int i = 0; i < data1.size(); i++) {
JSONObject jsonObject = data1.getJSONObject(i);
double electricity = jsonObject.getDoubleValue("electricity");
if (electricity <= 30) {
// 新增一条agv报警信息
JSONObject json = new JSONObject();
String car_no = jsonObject.getString("car_no");
if (StrUtil.equals(car_no, "1")) {
json.put("device_name", "一楼1号AGV");
} else if (StrUtil.equals(car_no, "2")) {
json.put("device_name", "二楼1号AGV");
} else if (StrUtil.equals(car_no, "3")) {
json.put("device_name", "二楼2号AGV");
}
json.put("device_code", jsonObject.getString("car_no"));
json.put("fault_code", "99");
json.put("fault_info", "电量不足");
json.put("fault_type", "agv_error_type");
data.add(json);
}
}
// 根据入参处理对应数据
JSONArray objects = new JSONArray();
@@ -124,7 +158,6 @@ public class FaultDeviceServiceImpl implements FaultDeviceService {
}
// 获取报警码
JSONObject jsonFault = faultTab.query("fault_type = '" + json.getString("fault_type") + "' and fault_code = '" + json.getString("fault_code") + "'").uniqueResult(0);

View File

@@ -173,7 +173,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
/* // 测试数据
JSONArray data = result.getJSONArray("data");
JSONObject a = new JSONObject();
a.put("electricity", "86");
a.put("electricity", "30");
a.put("status_name", "空闲");
a.put("car_no", "1");
a.put("task_code", "");

View File

@@ -18,7 +18,9 @@ public enum RegionTypeEnum {
ZZ01("15","中转区","1582995342054526976"),
LKRK("16","密集库入库输送线","1585164789083148288"),
LKCK("17","密集库出库输送线","1585167595403874304"),
XN01("18","虚拟区","1586913215886004224");
XN01("18","虚拟区","1586913215886004224"),
PD01("19","盘点区","1645705331612979200")
;
private String name;
private String code;

View File

@@ -13,10 +13,12 @@ import org.nl.modules.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.system.service.user.ISysUserService;
import org.nl.system.service.user.dao.SysUser;
import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl;
import org.nl.wms.st.inbill.service.StorPublicService;
import org.nl.wms.st.returns.service.impl.InAndOutRetrunServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -187,17 +189,23 @@ public class InbillServiceImpl {
//回传MES
if (StrUtil.equals(mst_jo.getString("bill_type"), "0001")) {
//1.回传MES
//查询该入库单下的所有箱子回传
JSONArray box_rows = WQL.getWO("QST_IVT_INANDOUTRETRUN").addParam("iostorinv_id",mst_jo.getString("iostorinv_id")).addParam("flag","2").process().getResultJSONArray(0);
for (int j = 0; j < box_rows.size(); j++) {
JSONObject box_row = box_rows.getJSONObject(j);
// 调用接口回传
JSONObject paramMesMst = new JSONObject();
paramMesMst.put("PackageBoxSN",box_row.getString("box_no"));
SysUser sysUser = iSysUserService.getById(box_row.getString("input_optid"));
paramMesMst.put("User",sysUser.getUsername());
// new LmsToMesServiceImpl().childRollFGInboundComplete(paramMesMst);
InAndOutRetrunServiceImpl bean = SpringContextHolder.getBean(InAndOutRetrunServiceImpl.class);
JSONObject param = new JSONObject();
JSONArray rows = new JSONArray();
rows.add(mst_jo);
param.put("rows", rows);
try {
bean.uploadMES(param);
} catch (Exception e) {
System.out.println(e.getMessage());
log.info(e.getMessage());
} finally {
mst_jo.put("is_upload", "1");
mst_jo.put("upload_mes", "1");
mst_jo.put("upload_optid", SecurityUtils.getCurrentUserId());
mst_jo.put("upload_time", DateUtil.now());
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(mst_jo);
}
}
//回传SAP

View File

@@ -97,4 +97,12 @@ public class HandMoveStorController {
handMoveStorService.handdown(whereJson);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@PostMapping("/checkReturn")
@Log("盘点回库")
@ApiOperation("盘点回库")
public ResponseEntity<Object> checkReturn() {
handMoveStorService.checkReturn();
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -85,4 +85,9 @@ public interface HandMoveStorService {
* @param whereJson /
*/
void handdown(JSONObject whereJson);
/**
* 盘点回库
*/
void checkReturn();
}

View File

@@ -863,11 +863,17 @@ public class CheckServiceImpl implements CheckService {
@Transactional(rollbackFor = Exception.class)
public void confirmBtn(JSONObject whereJson) {
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_CheckMst");
WQLObject dtlTab = WQLObject.getWQLObject("st_ivt_checkdtl");
JSONObject jsonMst = mstTab.query("check_id = '" + whereJson.getString("check_id") + "'").uniqueResult(0);
jsonMst.put("status", "99");
mstTab.update(jsonMst);
JSONObject jsonObject = new JSONObject();
jsonObject.put("status", "99");
dtlTab.update(jsonObject,"check_id = '"+whereJson.getString("check_id")+"'");
}
@Override

View File

@@ -557,7 +557,9 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
for (int i = 0; i < rows.size(); i++) {
JSONObject row = rows.getJSONObject(i);
String storagevehicle_code = row.getString("storagevehicle_code");
ids.append("'");
if (i == 0) {
ids.append("'");
}
if (!Struct_map.containsKey(storagevehicle_code)) {
Struct_map.put(storagevehicle_code, row);
}
@@ -610,6 +612,7 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
task.put("task_id", task_id);
task.put("task_code", task_code);
task.put("task_type", "010505");
task.put("acs_task_type", "7");
task.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
task.put("point_code1", jo.getString("start_point_code"));
task.put("point_code2", point.getString("point_code"));
@@ -1188,11 +1191,11 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
map.put("work_status", "02");
wo_dtl.update(map, "is_issued='0' and task_id='" + task.getString("task_id") + "'");
//更新任务为已下发
map.put("task_status", "02");
map.put("task_status", "05");
map.put("update_optid", currentUserId + "");
map.put("update_optname", nickName);
map.put("update_time", now);
wo_Task.update(map, "is_delete ='0' and task_status='01' and task_id='" + task_id + "'");
wo_Task.update(map, "is_delete ='0' and task_id='" + task_id + "'");
} else {
throw new BadRequestException("任务下发失败,请稍后重试!");
}
@@ -1205,6 +1208,91 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
wo_mst.update(map, "moveinv_id='" + moveinv_id + "'");
}
@Override
@Transactional(rollbackFor = Exception.class)
public void checkReturn() {
/*
* 将所有盘点位上的木箱生成移库单并下发任务
*/
WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr"); // 仓位表
// 1.找出所有需要盘点的移库的木箱
JSONArray boxArr = attrTab.query("sect_id = '" + RegionTypeEnum.PD01.getId() + "' and IFNULL(storagevehicle_code,'') <> '' and is_used = '1' and is_delete = '0' order by block_num ASC,out_order_seq DESC").getResultJSONArray(0);
if (ObjectUtil.isEmpty(boxArr)) throw new BadRequestException("没有需要盘点回库的木箱!");
// 2.判断是否有被锁定的木箱
boolean is_lock = boxArr.stream().map(row -> (JSONObject) row)
.anyMatch(row -> !StrUtil.equals(row.getString("lock_type"), "1"));
if (is_lock) throw new BadRequestException("木箱存在被锁定,请检查!");
/* for (int i = 0; i < boxArr.size(); i++) {
JSONObject json = boxArr.getJSONObject(i);
// 3.判断木箱是否存在未完成的盘点单
WQL.getWO("QST_IVT_HANDMOVESTOR").addParam("flag", "8").addParam("storagevehicle_code",json.getString("storagevehicle_code"));
}*/
// 3.判断木箱是否存在未完成的盘点单
boxArr.forEach(row -> {
JSONObject json = WQL.getWO("QST_IVT_HANDMOVESTOR").addParam("flag", "8").addParam("storagevehicle_code", ((JSONObject) row).getString("storagevehicle_code")).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(json))
throw new BadRequestException("此木箱的盘点单据未完成:"+json.getString("storagevehicle_code"));
});
// 4.生成移库单
for (int i = 0; i < boxArr.size(); i++) {
JSONObject json = boxArr.getJSONObject(i);
// 找一个移入仓位
RawAssistIStorService rawAssistIStorService = SpringContextHolder.getBean(RawAssistIStorService.class);
JSONObject moveParamIn = new JSONObject();
moveParamIn.put("box_no", json.getString("storagevehicle_code"));
moveParamIn.put("sect_id", RegionTypeEnum.ZC01.getId());
moveParamIn.put("layer_num", json.getString("layer_num"));
JSONObject jsonMoveIn = rawAssistIStorService.autoDisMove(moveParamIn);
if (ObjectUtil.isEmpty(jsonMoveIn)) throw new BadRequestException("没有可用暂存位");
JSONObject jsonMst = new JSONObject(); // 主表
jsonMst.put("bill_type", "31");
jsonMst.put("buss_type", "31");
jsonMst.put("bill_status", "10");
jsonMst.put("biz_date", DateUtil.today());
jsonMst.put("stor_code", "CP01");
jsonMst.put("stor_id", "1582991156504039424");
jsonMst.put("stor_name", "成品仓库");
jsonMst.put("is_task", "1");
JSONArray dtlArr = new JSONArray(); // 明细
// 组织明细
JSONArray jsonIvt = WQL.getWO("QST_IVT_HANDMOVESTOR").addParam("flag", "35").addParam("package_box_sn", json.getString("storagevehicle_code")).process().getResultJSONArray(0);
jsonIvt.forEach(row -> {
((JSONObject) row).put("wrok_status", "10");
((JSONObject) row).put("turnin_sect_id", jsonMoveIn.getString("sect_id"));
((JSONObject) row).put("turnin_sect_code", jsonMoveIn.getString("sect_code"));
((JSONObject) row).put("turnin_sect_name", jsonMoveIn.getString("sect_name"));
((JSONObject) row).put("turnin_struct_id", jsonMoveIn.getString("struct_id"));
((JSONObject) row).put("turnin_struct_code", jsonMoveIn.getString("struct_code"));
((JSONObject) row).put("turnin_struct_name", jsonMoveIn.getString("struct_name"));
dtlArr.add(row);
});
jsonMst.put("tableData", dtlArr);
String moveinv_id = insertDtl2(jsonMst);
// 下发任务
JSONObject taskParam = new JSONObject();
taskParam.put("moveinv_id",moveinv_id);
taskParam.put("bill_type",jsonMst.getString("jsonMst"));
handdown(taskParam);
}
}
@Transactional(rollbackFor = Exception.class)
public Integer isBlock(JSONObject whereJson) {
String placement_type = whereJson.getString("placement_type");

View File

@@ -413,5 +413,24 @@
ENDQUERY
ENDIF
IF 输入.flag = "8"
QUERY
SELECT
dtl.*
FROM
st_ivt_checkdtl dtl
LEFT JOIN st_ivt_checkmst mst ON mst.check_id = dtl.check_id
WHERE
mst.is_delete = '0'
and dtl.status not in ('3','5','99')
OPTION 输入.storagevehicle_code <> ""
dtl.storagevehicle_code = 输入.storagevehicle_code
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -4208,7 +4208,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
jo_mst.put("update_optid", currentUserId + "");
jo_mst.put("update_optname", nickName);
jo_mst.put("update_time", now);
jo_mst.put("out_stor_id", "");
jo_mst.put("out_stor_id", out_jo.getString("stor_id"));
mst_wql.insert(jo_mst);
for (int i = 0; i < dis_rows.size(); i++) {
@@ -4222,9 +4222,10 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
dis_row.put("seq_no", i + 1);
dis_row.put("bill_status", "30");
dis_row.put("real_qty", "0");
dis_row.put("vbeln", dtl_row.getString("vbeln"));
dis_row.put("source_billdtl_id", dtl_row.getString("iostorinvdtl_id"));
dis_row.put("source_bill_type", mst_row.getString("bill_type"));
dis_row.put("source_bill_code", mst_row.getString("bill_code"));
dis_row.put("source_bill_code", dtl_row.getString("source_bill_code"));
dis_row.put("source_bill_table", "ST_IVT_IOStorInvDtl");
dis_row.put("assign_qty", dis_row.getString("plan_qty"));
dis_row.put("unassign_qty", "0");

View File

@@ -2,6 +2,7 @@ package org.nl.wms.st.returns.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
@@ -534,20 +535,20 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
JSONObject jsonDis = disArr.getJSONObject(j);
JSONObject paramDis = new JSONObject();
paramDis.put("ZDBSQD", jsonDtl.getString("vbeln"));
paramDis.put("VBELN", jsonDtl.getString("source_bill_code"));
paramDis.put("ZVBELN", jsonDtl.getString("source_bill_code"));
JSONObject jsonMater = materTab.query("material_id = '" + jsonDis.getString("material_id") + "'").uniqueResult(0);
paramDis.put("MATNR", jsonMater.getString("material_code"));
paramDis.put("LGORT1", jo_mst.getString("stor_code"));
paramDis.put("LGORT2", jo_mst.getString("stor_code"));
JSONObject jsonStorOut = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_id = '" + jo_mst.getString("out_stor_id") + "'").uniqueResult(0);
paramDis.put("LGORT2", jsonStorOut.getString("stor_code"));
paramDis.put("LGORT1", jsonStorOut.getString("stor_code"));
JSONObject jsonSub = subTab.query("container_name = '" + jsonDis.getString("pcsn") + "'").uniqueResult(0);
paramDis.put("ZHL02", jsonSub.getString("width"));
paramDis.put("ZZWLHD", jsonSub.getString("thickness"));
paramDis.put("CHARG", jsonDis.getString("pcsn"));
paramDis.put("KALAB", jsonDis.getString("plan_qty"));
paramDis.put("CHARG", jsonSub.getString("sap_pcsn"));
paramDis.put("KALAB", NumberUtil.round(jsonDis.getDoubleValue("plan_qty"),3));
paramDis.put("WERKS", "2460");
paramSapMstArr.add(paramDis);
}
@@ -563,7 +564,6 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
jo_mst.put("upload_optid", SecurityUtils.getCurrentUserId());
jo_mst.put("upload_time", DateUtil.now());
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(jo_mst);
}
// 改切出库
@@ -881,20 +881,20 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
JSONObject jsonDis = disArr.getJSONObject(j);
JSONObject paramDis = new JSONObject();
paramDis.put("ZDBSQD", jsonDtl.getString("vbeln"));
paramDis.put("VBELN", jsonDtl.getString("source_bill_code"));
paramDis.put("ZVBELN", jsonDtl.getString("source_bill_code"));
JSONObject jsonMater = materTab.query("material_id = '" + jsonDis.getString("material_id") + "'").uniqueResult(0);
paramDis.put("MATNR", jsonMater.getString("material_code"));
paramDis.put("LGORT1", jo_mst.getString("stor_code"));
paramDis.put("LGORT2", jo_mst.getString("stor_code"));
JSONObject jsonStorOut = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_id = '" + jo_mst.getString("out_stor_id") + "'").uniqueResult(0);
paramDis.put("LGORT2", jsonStorOut.getString("stor_code"));
paramDis.put("LGORT1", jsonStorOut.getString("stor_code"));
JSONObject jsonSub = subTab.query("container_name = '" + jsonDis.getString("pcsn") + "'").uniqueResult(0);
paramDis.put("ZHL02", jsonSub.getString("width"));
paramDis.put("ZZWLHD", jsonSub.getString("thickness"));
paramDis.put("CHARG", jsonDis.getString("pcsn"));
paramDis.put("KALAB", jsonDis.getString("plan_qty"));
paramDis.put("CHARG", jsonSub.getString("sap_pcsn"));
paramDis.put("KALAB", NumberUtil.round(jsonDis.getDoubleValue("plan_qty"),3));
paramDis.put("WERKS", "2460");
paramSapMstArr.add(paramDis);
}