fix 与mes对接
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package org.nl.wms.autotask;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.MesUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 反馈mes
|
||||
* @Date: 2023/7/6
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class FeedbackMes {
|
||||
public void run(){
|
||||
WQLObject feedbackRecord = WQLObject.getWQLObject("mes_feedback_record");
|
||||
// 获取未反馈完成的数据
|
||||
JSONArray array = feedbackRecord.query("is_success = '0'").getResultJSONArray(0);
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject record = array.getJSONObject(i);
|
||||
// 重发
|
||||
MesUtil.retransmission(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,6 +222,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
param.put("vehicle_code", vehicle_code);
|
||||
param.put("task_code", whereJson.getString("task_code"));
|
||||
param.put("workorder_code", whereJson.getString("workorder_code"));
|
||||
param.put("container_id", whereJson.getString("container_id"));
|
||||
|
||||
GjxSendMaterialTask taskBean = SpringContextHolder.getBean(GjxSendMaterialTask.class);
|
||||
String task_id = taskBean.createTask(param); // 创建任务
|
||||
@@ -245,6 +246,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
param.put("vehicle_code", vehicle_code);
|
||||
param.put("material_num", material_num);
|
||||
param.put("material_code", whereJson.getString("material_code"));
|
||||
param.put("container_id", whereJson.getString("container_id"));
|
||||
param.put("task_code", whereJson.getString("task_code"));
|
||||
// 创建任务
|
||||
YqxCallMaterialTask taskBean = SpringContextHolder.getBean(YqxCallMaterialTask.class);
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
|
||||
package org.nl.wms.ext.mes.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.wms.ext.mes.service.FeedbackRecordService;
|
||||
import org.nl.wms.ext.mes.service.dto.FeedbackRecordDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-07-06
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "mes对接信息记录管理")
|
||||
@RequestMapping("/api/feedbackRecord")
|
||||
@Slf4j
|
||||
public class FeedbackRecordController {
|
||||
|
||||
private final FeedbackRecordService feedbackRecordService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询mes对接信息记录")
|
||||
@ApiOperation("查询mes对接信息记录")
|
||||
//@SaCheckPermission("@el.check('feedbackRecord:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
|
||||
return new ResponseEntity<>(feedbackRecordService.queryAll(whereJson,page),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增mes对接信息记录")
|
||||
@ApiOperation("新增mes对接信息记录")
|
||||
//@SaCheckPermission("@el.check('feedbackRecord:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody FeedbackRecordDto dto){
|
||||
feedbackRecordService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改mes对接信息记录")
|
||||
@ApiOperation("修改mes对接信息记录")
|
||||
//@SaCheckPermission("@el.check('feedbackRecord:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody FeedbackRecordDto dto){
|
||||
feedbackRecordService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除mes对接信息记录")
|
||||
@ApiOperation("删除mes对接信息记录")
|
||||
//@SaCheckPermission("@el.check('feedbackRecord:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
feedbackRecordService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/retransmission")
|
||||
@Log("重发")
|
||||
@ApiOperation("重发")
|
||||
//@SaCheckPermission("@el.check('feedbackRecord:add')")
|
||||
public ResponseEntity<Object> retransmission(@RequestBody JSONObject row){
|
||||
feedbackRecordService.retransmission(row);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
}
|
||||
@@ -83,5 +83,19 @@ public class MesToWmsController {
|
||||
public ResponseEntity<Object> releaseCpPointArea(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(mesToWmsService.releaseCpPointArea(param), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/outboundReport")
|
||||
@Log("出库上报")
|
||||
@ApiOperation("出库上报")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> outboundReport(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(mesToWmsService.outboundReport(param), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/inboundReport")
|
||||
@Log("入库上报")
|
||||
@ApiOperation("入库上报")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> inboundReport(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(mesToWmsService.inboundReport(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package org.nl.wms.ext.mes.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.ext.mes.service.dto.FeedbackRecordDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @description 服务接口
|
||||
* @date 2023-07-06
|
||||
**/
|
||||
public interface FeedbackRecordService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @param whereJson 条件参数
|
||||
* @return List<FeedbackRecordDto>
|
||||
*/
|
||||
List<FeedbackRecordDto> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param feedback_id ID
|
||||
* @return FeedbackRecord
|
||||
*/
|
||||
FeedbackRecordDto findById(String feedback_id);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
*
|
||||
* @param code code
|
||||
* @return FeedbackRecord
|
||||
*/
|
||||
FeedbackRecordDto findByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param dto /
|
||||
*/
|
||||
void create(FeedbackRecordDto dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param dto /
|
||||
*/
|
||||
void update(FeedbackRecordDto dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(String[] ids);
|
||||
|
||||
/**
|
||||
* 重发
|
||||
* @param row
|
||||
*/
|
||||
void retransmission(JSONObject row);
|
||||
}
|
||||
@@ -25,4 +25,8 @@ public interface MesToWmsService {
|
||||
JSONObject finishMaterialOut(JSONObject param);
|
||||
|
||||
JSONObject releaseCpPointArea(JSONObject param);
|
||||
|
||||
JSONObject outboundReport(JSONObject param);
|
||||
|
||||
JSONObject inboundReport(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.nl.wms.ext.mes.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @description /
|
||||
* @date 2023-07-06
|
||||
**/
|
||||
@Data
|
||||
public class FeedbackRecordDto implements Serializable {
|
||||
|
||||
/**
|
||||
* 反馈标识
|
||||
*/
|
||||
private String feedback_id;
|
||||
|
||||
/**
|
||||
* 反馈编码
|
||||
*/
|
||||
private String feedback_code;
|
||||
|
||||
/**
|
||||
* 相应编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 响应信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 请求报文
|
||||
*/
|
||||
private String request_param;
|
||||
|
||||
/**
|
||||
* 响应结果
|
||||
*/
|
||||
private String response_param;
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
private String is_success;
|
||||
|
||||
/**
|
||||
* 记录时间
|
||||
*/
|
||||
private String record_time;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
|
||||
package org.nl.wms.ext.mes.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.config.MapOf;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.core.engine.object.WO;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.ext.mes.service.FeedbackRecordService;
|
||||
import org.nl.wms.ext.mes.service.dto.FeedbackRecordDto;
|
||||
import org.nl.wms.sch.MesUtil;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @description 服务实现
|
||||
* @date 2023-07-06
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class FeedbackRecordServiceImpl implements FeedbackRecordService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String feedback_code = ObjectUtil.isNotEmpty(whereJson.get("feedback_code"))
|
||||
? whereJson.get("feedback_code").toString()
|
||||
: null;
|
||||
String is_success = ObjectUtil.isNotEmpty(whereJson.get("is_success"))
|
||||
? whereJson.get("is_success").toString()
|
||||
: null;
|
||||
WO queryMesFeedbackRecord = WQL.getWO("QUERY_MES_FEEDBACK_RECORD");
|
||||
JSONObject jsonObject = queryMesFeedbackRecord
|
||||
.addParamMap(MapOf.of("flag", "1", "feedback_code", feedback_code, "is_success", is_success))
|
||||
.pageQuery(WqlUtil.getHttpContext(page), "record_time DESC");
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FeedbackRecordDto> queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("mes_feedback_record");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(FeedbackRecordDto.class);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeedbackRecordDto findById(String feedback_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("mes_feedback_record");
|
||||
JSONObject json = wo.query("feedback_id = '" + feedback_id + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(FeedbackRecordDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeedbackRecordDto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("mes_feedback_record");
|
||||
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(FeedbackRecordDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(FeedbackRecordDto dto) {
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("mes_feedback_record");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.insert(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(FeedbackRecordDto dto) {
|
||||
FeedbackRecordDto entity = this.findById(dto.getFeedback_id());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("mes_feedback_record");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.update(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(String[] ids) {
|
||||
WQLObject wo = WQLObject.getWQLObject("mes_feedback_record");
|
||||
for (String feedback_id : ids) {
|
||||
wo.delete("feedback_id = '" + feedback_id + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void retransmission(JSONObject row) {
|
||||
MDC.put("log_file_type", "WMS手动重发反馈给MES");
|
||||
WQLObject wo = WQLObject.getWQLObject("mes_feedback_record");
|
||||
JSONObject feedbackCode = wo.query("feedback_code = '" + row.getString("feedback_code") + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(feedbackCode)) {
|
||||
throw new BadRequestException("反馈数据不存在!");
|
||||
}
|
||||
// if (feedbackCode.getString("is_success").equals("1")) {
|
||||
// throw new BadRequestException("任务号:" + feedbackCode.getString("feedback_code") + " 已经反馈成功!");
|
||||
// }
|
||||
// 重发反馈
|
||||
MesUtil.retransmission(row);
|
||||
MDC.remove("log_file_type");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package org.nl.wms.ext.mes.service.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -44,6 +43,9 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
throw new BadRequestException("工单不能为空");
|
||||
}
|
||||
JSONObject materialCode = materialTab.query("material_code = '" + param.getString("material_code") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(materialCode)) {
|
||||
throw new BadRequestException("物料为空,请同步物料!");
|
||||
}
|
||||
JSONObject deviceCode = deviceTab.query("extend_code = '" + param.getString("device_code") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(deviceCode)) {
|
||||
throw new BadRequestException("设备编码错误!");
|
||||
@@ -82,7 +84,7 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
// param.put("workorder_id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
// param.put("device_id", "1654663217064054784");
|
||||
// param.put("device_code", deviceCodeKX);
|
||||
workOrderTab.insert(param);
|
||||
// workOrderTab.insert(param);
|
||||
String deviceCodeWX = deviceCode.getString("device_code") + "WX";
|
||||
String deviceCodeKS = deviceCode.getString("device_code") + "KS";
|
||||
String deviceCodeKX = deviceCode.getString("device_code") + "KX";
|
||||
@@ -281,4 +283,74 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
result.put("message", "操作成功");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject outboundReport(JSONObject param) {
|
||||
MDC.put("log_file_type", "MES人工出库");
|
||||
String pointCode = param.getString("point_code");
|
||||
log.info("出库点位:{}", pointCode);
|
||||
// 清空点位
|
||||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONObject pointObj = pointTable.query("point_code = '" + pointCode + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(pointObj)) {
|
||||
throw new BadRequestException("货位号不能为空!");
|
||||
}
|
||||
pointObj.put("lock_type", "1");
|
||||
pointObj.put("point_status", "1");
|
||||
pointObj.put("vehicle_type", "");
|
||||
pointObj.put("vehicle_code", "");
|
||||
pointObj.put("vehicle_qty", "0");
|
||||
pointObj.put("container_id", "");
|
||||
pointObj.put("material_id", "");
|
||||
pointObj.put("pcsn", "");
|
||||
pointObj.put("ivt_qty", "");
|
||||
pointObj.put("instorage_time", "");
|
||||
pointObj.put("update_optid", "3");
|
||||
pointObj.put("update_optname", "MES系统");
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTable.update(pointObj);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", 200);
|
||||
result.put("message", "操作成功");
|
||||
MDC.remove("log_file_type");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject inboundReport(JSONObject param) {
|
||||
MDC.put("log_file_type", "MES人工入库");
|
||||
log.info("入库参数:{}", param);
|
||||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); // 点位
|
||||
WQLObject materialTable = WQLObject.getWQLObject("md_me_materialbase"); // 点位
|
||||
String materialCode = param.getString("material_code");
|
||||
String pointCode = param.getString("point_code");
|
||||
if (ObjectUtil.isEmpty(materialCode)) {
|
||||
throw new BadRequestException("物料编码不能为空!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(pointCode)) {
|
||||
throw new BadRequestException("货位编码不能为空!");
|
||||
}
|
||||
JSONObject materialObj = materialTable.query("material_code = '" + materialCode + "'")
|
||||
.uniqueResult(0);
|
||||
JSONObject pointObj = pointTable.query("point_code = '" + pointCode + "'")
|
||||
.uniqueResult(0);
|
||||
pointObj.put("lock_type", "1");
|
||||
pointObj.put("point_status", "3");
|
||||
pointObj.put("vehicle_type", param.getString("vehicle_type"));
|
||||
pointObj.put("vehicle_code", param.getString("vehicle_code"));
|
||||
pointObj.put("vehicle_qty", "1");
|
||||
pointObj.put("container_id", param.getString("container_id"));
|
||||
pointObj.put("material_id", materialObj.getString("material_id"));
|
||||
pointObj.put("ivt_qty", param.getString("qty"));
|
||||
pointObj.put("instorage_time", DateUtil.now());
|
||||
pointObj.put("update_optid", "3");
|
||||
pointObj.put("update_optname", "MES系统");
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTable.update(pointObj);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", 200);
|
||||
result.put("message", "操作成功");
|
||||
MDC.remove("log_file_type");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
[交易说明]
|
||||
交易名: 反馈记录表
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.feedback_code TYPEAS s_string
|
||||
输入.is_success TYPEAS s_string
|
||||
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
IF 输入.flag = "1"
|
||||
QUERY
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
mes_feedback_record
|
||||
WHERE
|
||||
1 = 1
|
||||
OPTION 输入.feedback_code <> ""
|
||||
feedback_code like "%" 输入.feedback_code "%"
|
||||
ENDOPTION
|
||||
OPTION 输入.is_success <> ""
|
||||
is_success = 输入.is_success
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
@@ -31,6 +31,9 @@ public class WorkorderDto implements Serializable {
|
||||
/** 物料标识 */
|
||||
private Long material_id;
|
||||
|
||||
/** 货柜id */
|
||||
private String container_id;
|
||||
|
||||
/** 载具类型 */
|
||||
private String vehicle_type;
|
||||
|
||||
|
||||
@@ -396,7 +396,7 @@ public class WorkorderServiceImpl implements WorkordeService {
|
||||
row.put("update_time", now);
|
||||
row.put("order_status", "5");
|
||||
workorderTab.update(row);
|
||||
if (deviceCode.equals("YQX01WX") || deviceCode.equals("YQX01KS")) {
|
||||
if (deviceCode.equals("YQX01WX") || deviceCode.equals("YQX01KS") || deviceCode.equals("YQX01KX")) {
|
||||
JSONObject jsonObject = workOrderCacheTab.query("device_code = '" + deviceCode + "'", "update_time").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonObject)) {
|
||||
// 找不到就推出
|
||||
|
||||
@@ -88,13 +88,14 @@
|
||||
ShiftOrder.produce_date <= 输入.end_time
|
||||
ENDOPTION
|
||||
OPTION 输入.produceorder_code <> ""
|
||||
ShiftOrder.produceorder_code like 输入.produceorder_code
|
||||
ShiftOrder.workorder_code like 输入.produceorder_code
|
||||
ENDOPTION
|
||||
OPTION 输入.material <> ""
|
||||
(
|
||||
material.material_code like 输入.material or
|
||||
material.material_name like 输入.material or
|
||||
material.material_spec like 输入.material
|
||||
material.material_spec like 输入.material or
|
||||
ShiftOrder.container_id like 输入.material
|
||||
)
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.nl.wms.sch;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@@ -13,7 +15,9 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -29,12 +33,14 @@ import java.util.Map;
|
||||
*/
|
||||
@Slf4j
|
||||
public class MesUtil {
|
||||
|
||||
// static final String endpointUrl = "http://helptimely.com:7722/Timely4100_15_yonyu/services/HtWebService"; // 替换为实际的 WebService 地址
|
||||
static final String endpointUrl = "http://192.168.4.111:8080/mes/services/HtWebService"; // 替换为实际的 WebService 地址
|
||||
public static JSONObject taskFeedback(JSONObject param, String finterfaceid) {
|
||||
MDC.put("log_file_type", "WMS任务完成反馈给MES");
|
||||
// String endpointUrl = "http://helptimely.com:7722/Timely4100_15_yonyu/services/HtWebService"; // 替换为实际的 WebService 地址
|
||||
String endpointUrl = "http://192.168.4.111:8080/mes/services/HtWebService"; // 替换为实际的 WebService 地址
|
||||
JSONObject result = new JSONObject();
|
||||
JSONObject resObj = new JSONObject();
|
||||
String requestXml = null; // 请求报文
|
||||
String fsn502 = param.getString("fsn502");
|
||||
String fscanserialid001 = param.getString("fscanserialid001");
|
||||
String fpacknumberpl695 = param.getString("fpacknumberpl695");
|
||||
@@ -69,7 +75,7 @@ public class MesUtil {
|
||||
items.add(ir);
|
||||
req.put("items", items);
|
||||
// xml报文
|
||||
String requestXml = parseXmlStr(JSON.toJSONString(req));
|
||||
requestXml = parseXmlStr(JSON.toJSONString(req));
|
||||
// 设置请求体
|
||||
StringEntity entity = new StringEntity(requestXml, "UTF-8");
|
||||
httpPost.setEntity(entity);
|
||||
@@ -106,12 +112,74 @@ public class MesUtil {
|
||||
result.put("message", resObj.get("ErrorMessage"));
|
||||
} finally {
|
||||
// 不管成不成功,记录数据
|
||||
|
||||
WQLObject feedbackRecord = WQLObject.getWQLObject("mes_feedback_record");
|
||||
JSONObject feedbacks = new JSONObject();
|
||||
feedbacks.put("feedback_id", IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
feedbacks.put("feedback_code", task_code);
|
||||
feedbacks.put("code", resObj.getString("ErrorCode"));
|
||||
feedbacks.put("message", resObj.getString("ErrorMessage"));
|
||||
feedbacks.put("request_param", requestXml);
|
||||
feedbacks.put("response_param", resObj);
|
||||
feedbacks.put("is_success", resObj.getString("ErrorCode").equals("0") ? "1" : "0");
|
||||
feedbacks.put("record_time", DateUtil.now());
|
||||
feedbackRecord.insert(feedbacks);
|
||||
}
|
||||
MDC.remove("log_file_type");
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 重发 */
|
||||
public static void retransmission(JSONObject param) {
|
||||
log.info("反馈数据: {}", param);
|
||||
// 获取请求报文
|
||||
String requestParam = param.getString("request_param");
|
||||
log.info("请求报文: {}", requestParam);
|
||||
Map<String, String> stringMap = new HashMap<>();
|
||||
JSONObject resObj = new JSONObject();
|
||||
try {
|
||||
// 创建 HttpClient
|
||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
// 创建请求
|
||||
HttpPost httpPost = new HttpPost(endpointUrl);
|
||||
httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8");
|
||||
// 设置请求体
|
||||
StringEntity entity = new StringEntity(requestParam, "UTF-8");
|
||||
httpPost.setEntity(entity);
|
||||
|
||||
// 发送请求并获取响应
|
||||
HttpResponse response = httpClient.execute(httpPost);
|
||||
|
||||
// 读取响应
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
||||
String line;
|
||||
StringBuilder responseContent = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
responseContent.append(line);
|
||||
}
|
||||
reader.close();
|
||||
// 处理响应结果
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
stringMap = parseXml2Map(String.valueOf(responseContent), new HashMap<>());
|
||||
log.info("Response Code: " + statusCode);
|
||||
log.info("Response Body: " + stringMap);
|
||||
String s = stringMap.get("Body.postResponse.return");
|
||||
resObj = JSON.parseObject(s);
|
||||
log.info("响应结果: {}", resObj);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
} finally {
|
||||
// 不管成不成功,修改数据
|
||||
WQLObject feedbackRecord = WQLObject.getWQLObject("mes_feedback_record");
|
||||
param.put("code", resObj.getString("ErrorCode"));
|
||||
param.put("message", resObj.getString("ErrorMessage"));
|
||||
param.put("response_param", resObj);
|
||||
param.put("is_success", resObj.getString("ErrorCode").equals("0") ? "1" : "0");
|
||||
param.put("record_time", DateUtil.now());
|
||||
feedbackRecord.update(param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得要发送的webservice的xml形式的参数
|
||||
*
|
||||
|
||||
@@ -48,6 +48,9 @@ public class PointDto implements Serializable {
|
||||
/** 设备编码 */
|
||||
private String device_code;
|
||||
|
||||
/** 货柜id */
|
||||
private String container_id;
|
||||
|
||||
/** MES设备编码 */
|
||||
private String mes_device_code;
|
||||
|
||||
|
||||
@@ -347,10 +347,12 @@ public class PointServiceImpl implements PointService {
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("point_status", "1");
|
||||
object.put("vehicle_code", "");
|
||||
object.put("vehicle_type", "");
|
||||
object.put("vehicle_qty", "0");
|
||||
object.put("task_id", "");
|
||||
object.put("material_id", "");
|
||||
object.put("container_id", "");
|
||||
object.put("pcsn", "");
|
||||
object.put("ivt_qty", "");
|
||||
object.put("instorage_time", "");
|
||||
|
||||
@@ -148,7 +148,7 @@ public class DPJCallVehicleTask extends AbstractAcsTask {
|
||||
.addParamMap(query)
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
// PointUpdateUtil.updatePoint(array);
|
||||
PointUpdateUtil.updatePoint(array);
|
||||
|
||||
// 选择一个空位
|
||||
JSONObject endPoint = WQL.getWO("DPJ_AUTOTASK")
|
||||
|
||||
@@ -88,6 +88,7 @@ public class YqxCallMaterialTask extends AbstractAcsTask {
|
||||
material_point.put("lock_type", "1");
|
||||
material_point.put("point_status", "1");
|
||||
material_point.put("material_id", "");
|
||||
material_point.put("container_id", "");
|
||||
material_point.put("vehicle_type", "");
|
||||
material_point.put("vehicle_code", "");
|
||||
pointTab.update(material_point);
|
||||
@@ -137,11 +138,15 @@ public class YqxCallMaterialTask extends AbstractAcsTask {
|
||||
JSONObject taskObj = taskArr.getJSONObject(i);
|
||||
String material_id = taskObj.getString("material_id");
|
||||
String vehicle_type = taskObj.getString("vehicle_type");
|
||||
String request_param = taskObj.getString("request_param");
|
||||
JSONObject requestObj = JSONObject.parseObject(request_param);
|
||||
String containerId = requestObj.getString("container_id"); // 柜号id
|
||||
JSONObject queryParam = new JSONObject();
|
||||
queryParam.put("flag", "1");
|
||||
queryParam.put("material_id", material_id);
|
||||
queryParam.put("region_code", "YSQA01");
|
||||
queryParam.put("vehicle_type", vehicle_type );
|
||||
// queryParam.put("vehicle_type", vehicle_type);
|
||||
queryParam.put("containerId", containerId);
|
||||
// 查找养生A区,如果最后一个位置有货,直接搬走,如果没货,就作为等待点。先让agv到达等待点
|
||||
// 1、根据物料id查找养生A区物料点
|
||||
JSONObject materialPoint = WQL.getWO("QSCH_yqxCallMAterial_01").addParamMap(queryParam).process().uniqueResult(0);
|
||||
@@ -176,7 +181,7 @@ public class YqxCallMaterialTask extends AbstractAcsTask {
|
||||
}
|
||||
// 等待点上锁
|
||||
// waitPoints.put("lock_type", "2");
|
||||
pointTab.update(waitPoints);
|
||||
// pointTab.update(waitPoints);
|
||||
|
||||
taskObj.put("point_code3", waitPoints.getString("point_code"));
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
@@ -326,13 +331,17 @@ public class YqxCallMaterialTask extends AbstractAcsTask {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); // 任务表
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); // 点位表
|
||||
JSONObject hcTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
String request_param = hcTask.getString("request_param");
|
||||
JSONObject requestObj = JSONObject.parseObject(request_param);
|
||||
String containerId = requestObj.getString("container_id"); // 柜号id
|
||||
if (ObjectUtil.isEmpty(hcTask)) throw new BadRequestException("任务ID: " + task_id + "的任务不存在!");
|
||||
JSONObject waitPoint = pointTab.query("point_code = '" + hcTask.getString("point_code3") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(waitPoint)) throw new BadRequestException("油漆线二次下发等待点编码错误!");
|
||||
JSONObject materialPoint = WQL.getWO("QSCH_yqxCallMAterial_01").addParamMap(MapOf.of(
|
||||
"flag", "3", "material_id", hcTask.getString("material_id"),
|
||||
"region_code", "YSQA01", "vehicle_type", hcTask.getString("vehicle_type"),
|
||||
"block_num", waitPoint.getString("block_num"), "row_num", waitPoint.getString("row_num")
|
||||
"block_num", waitPoint.getString("block_num"), "row_num", waitPoint.getString("row_num"),
|
||||
"containerId", containerId
|
||||
)).process().uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(materialPoint)) {
|
||||
throw new BadRequestException("养生A区暂无所需物料!"); // 此时车会停止
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
输入.flag TYPEAS s_string
|
||||
输入.region_code TYPEAS s_string
|
||||
输入.material_id TYPEAS s_string
|
||||
输入.containerId TYPEAS s_string
|
||||
输入.vehicle_type TYPEAS s_string
|
||||
输入.block_num TYPEAS s_string
|
||||
输入.row_num TYPEAS s_string
|
||||
@@ -46,12 +47,7 @@
|
||||
IF 输入.flag = "1"
|
||||
QUERY
|
||||
SELECT
|
||||
p.point_id,
|
||||
p.point_code,
|
||||
p.point_name,
|
||||
p.block_num,
|
||||
p.col_num,
|
||||
p.row_num
|
||||
p.*
|
||||
FROM
|
||||
SCH_BASE_Point p
|
||||
WHERE
|
||||
@@ -61,6 +57,9 @@
|
||||
OPTION 输入.material_id <> ""
|
||||
p.material_id = 输入.material_id
|
||||
ENDOPTION
|
||||
OPTION 输入.containerId <> ""
|
||||
p.container_id = 输入.containerId
|
||||
ENDOPTION
|
||||
OPTION 输入.region_code <> ""
|
||||
p.region_code = 输入.region_code
|
||||
ENDOPTION
|
||||
@@ -96,12 +95,7 @@
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
p.point_id,
|
||||
p.point_code,
|
||||
p.point_name,
|
||||
p.block_num,
|
||||
p.col_num,
|
||||
p.row_num
|
||||
p.*
|
||||
FROM
|
||||
SCH_BASE_Point p
|
||||
WHERE
|
||||
@@ -111,6 +105,9 @@
|
||||
OPTION 输入.material_id <> ""
|
||||
p.material_id = 输入.material_id
|
||||
ENDOPTION
|
||||
OPTION 输入.containerId <> ""
|
||||
p.container_id = 输入.containerId
|
||||
ENDOPTION
|
||||
OPTION 输入.region_code <> ""
|
||||
p.region_code = 输入.region_code
|
||||
ENDOPTION
|
||||
|
||||
@@ -94,8 +94,7 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
JSONObject requestObj = task.getJSONObject("request_param");
|
||||
JSONObject endPoint = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
//工单标识
|
||||
String workorder_id = requestObj.getString("material_info_id");
|
||||
JSONObject workorderObj = workOrderTab.query("workorder_id", workorder_id).uniqueResult(0);
|
||||
JSONObject workorderObj = workOrderTab.query("workorder_id = '" + workOrderId + "'").uniqueResult(0);
|
||||
JSONObject order = orderTab.query("workorder_id = '" + workOrderId + "'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(endPoint)) {
|
||||
@@ -114,6 +113,7 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
endPoint.put("pcsn", DateUtil.format(DateUtil.parse(DateUtil.today()), "yyyyMMdd"));
|
||||
endPoint.put("ivt_qty", requestObj.getString("qty"));
|
||||
endPoint.put("standing_time", workorderObj.getString("standing_time"));
|
||||
endPoint.put("container_id", workorderObj.getString("container_id"));
|
||||
endPoint.put("vehicle_code", taskObj.getString("vehicle_code"));
|
||||
endPoint.put("vehicle_type", taskObj.getString("vehicle_type"));
|
||||
endPoint.put("update_time", DateUtil.now());
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user