opt:mes接口优化
This commit is contained in:
@@ -45,6 +45,13 @@ public interface MdPbStoragevehicleextMapper extends BaseMapper<MdPbStoragevehic
|
||||
*/
|
||||
List<JSONObject> queryAll( @Param("param") Map whereJson);
|
||||
|
||||
/**
|
||||
* 查询
|
||||
* @param whereJson 查询条件
|
||||
* @return IPage<List>
|
||||
*/
|
||||
List<JSONObject> queryAllIn( @Param("param") Map whereJson);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页条件
|
||||
|
||||
@@ -130,7 +130,9 @@
|
||||
ext.supp_name,
|
||||
attr.struct_code,
|
||||
attr.struct_name,
|
||||
attr.stor_code,
|
||||
attr.stor_name,
|
||||
attr.sect_code,
|
||||
attr.sect_name,
|
||||
mater.material_code,
|
||||
mater.material_name,
|
||||
@@ -177,6 +179,68 @@
|
||||
ORDER BY ext.create_time Desc
|
||||
</select>
|
||||
|
||||
<select id="queryAllIn" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
ext.group_id as storagevehicleext_id,
|
||||
ext.storagevehicle_code,
|
||||
ext.pcsn,
|
||||
ext.qty_unit_name,
|
||||
ext.qty,
|
||||
ext.frozen_qty,
|
||||
ext.remark,
|
||||
ext.create_time,
|
||||
ext.supp_code,
|
||||
ext.supp_name,
|
||||
attr.struct_code,
|
||||
attr.struct_name,
|
||||
attr.stor_code,
|
||||
attr.stor_name,
|
||||
attr.sect_code,
|
||||
attr.sect_name,
|
||||
mater.material_code,
|
||||
mater.material_name,
|
||||
mater.material_model
|
||||
FROM
|
||||
md_pb_groupplate ext
|
||||
INNER JOIN st_ivt_structattr attr ON ext.storagevehicle_code = attr.storagevehicle_code
|
||||
INNER JOIN md_me_materialbase mater ON mater.material_id = ext.material_id
|
||||
<where>
|
||||
1 = 1 and ext.`status`='01'
|
||||
<if test="param.stor_id != null and param.stor_id != ''">
|
||||
AND
|
||||
attr.stor_id = #{param.stor_id}
|
||||
</if>
|
||||
|
||||
<if test="param.sect_id != null and param.sect_id != ''">
|
||||
AND
|
||||
attr.sect_id = #{param.sect_id}
|
||||
</if>
|
||||
|
||||
<if test="param.sect_code != null and param.sect_code != ''">
|
||||
AND
|
||||
attr.sect_code = #{param.sect_code}
|
||||
</if>
|
||||
|
||||
|
||||
<if test="param.struct_code != null and param.struct_code != ''">
|
||||
AND
|
||||
(attr.struct_code LIKE #{param.struct_code} or
|
||||
attr.struct_name LIKE #{param.struct_code} )
|
||||
</if>
|
||||
|
||||
<if test="param.material_code != null and param.material_code != ''">
|
||||
AND
|
||||
(mater.material_code LIKE CONCAT('%', #{param.material_code},'%') or
|
||||
mater.material_name LIKE CONCAT('%', #{param.material_code},'%') )
|
||||
</if>
|
||||
|
||||
<if test="param.pcsn != null and param.pcsn != ''">
|
||||
AND
|
||||
ext.pcsn LIKE #{param.pcsn}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY ext.create_time Desc
|
||||
</select>
|
||||
|
||||
<select id="queryCanuseSum" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
|
||||
@@ -49,10 +49,10 @@ public class MesToWmsController {
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getStructIvt")
|
||||
@PostMapping("/getStructIvt")
|
||||
@Log("查询库存")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getStructIvt(@RequestParam JSONObject whereJson) {
|
||||
return new ResponseEntity<>(pdaIosOutService.getStructivtByMaterialAndSectCode(whereJson), HttpStatus.OK);
|
||||
public ResponseEntity<Object> getStructIvt(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(mesToWmsService.getStructivt(whereJson), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,9 @@ public class EXTConstant {
|
||||
* 回传MES接口地址
|
||||
*/
|
||||
public final static String UPLOAD_MES_API = "";
|
||||
|
||||
/**
|
||||
* MES获取物料详情请求地址
|
||||
*/
|
||||
public final static String GET_MATERIAL_INFO_MES_API = "mom/lms";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.ext_manage.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.ext_manage.dto.mes.MesBackMaterialRequestDto;
|
||||
import org.nl.wms.ext_manage.dto.mes.MesCallMaterialRequestDto;
|
||||
import org.nl.wms.ext_manage.dto.mes.MesResponse;
|
||||
@@ -26,4 +27,11 @@ public interface MesToWmsService {
|
||||
* @return MesResponse
|
||||
*/
|
||||
MesResponse backMaterial(MesBackMaterialRequestDto dto);
|
||||
|
||||
/**
|
||||
* MES 查询库存信息
|
||||
* @param
|
||||
* @return MesResponse
|
||||
*/
|
||||
MesResponse getStructivt(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.nl.wms.ext_manage.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;
|
||||
@@ -23,6 +22,7 @@ import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleinfo;
|
||||
import org.nl.wms.basedata_manage.service.dao.Sectattr;
|
||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper;
|
||||
import org.nl.wms.ext_manage.dto.mes.MesBackMaterialRequestDto;
|
||||
import org.nl.wms.ext_manage.dto.mes.MesCallMaterialRequestDto;
|
||||
import org.nl.wms.ext_manage.dto.mes.MesResponse;
|
||||
@@ -54,9 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.nl.common.utils.ValidationUtil.assertNotBlankJson;
|
||||
import static org.nl.wms.warehouse_manage.enums.IOSEnum.GROUP_PLATE_STATUS;
|
||||
|
||||
/**
|
||||
@@ -111,12 +109,6 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
@Autowired
|
||||
private IMdPbStoragevehicleinfoService iMdPbStoragevehicleinfoService;
|
||||
|
||||
/**
|
||||
* 入库服务
|
||||
*/
|
||||
@Autowired
|
||||
private IInBillService iRawAssistIStorService;
|
||||
|
||||
/**
|
||||
* 基础物料服务
|
||||
*/
|
||||
@@ -133,10 +125,10 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
private ISchBaseTaskService taskService;
|
||||
|
||||
/**
|
||||
* 任务工厂服务
|
||||
* 载具扩展属性mapper
|
||||
*/
|
||||
@Autowired
|
||||
private TaskFactory taskFactory;
|
||||
@Resource
|
||||
private MdPbStoragevehicleextMapper mdPbStoragevehicleextMapper;
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
@@ -544,6 +536,11 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MesResponse getStructivt(JSONObject whereJson) {
|
||||
return MesResponse.requestParamOk(mdPbStoragevehicleextMapper.queryAllIn(whereJson));
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织入库插入数据
|
||||
* @param whereJson {
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package org.nl.wms.sch_manage.service.util;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata_manage.service.impl.MdMeMaterialbaseServiceImpl;
|
||||
import org.nl.wms.ext_manage.service.util.AcsResponse;
|
||||
import org.nl.wms.sch_manage.service.util.dto.MaterialInfoRequestDto;
|
||||
import org.nl.wms.sch_manage.service.util.dto.MaterialInfoRespondDataRecordDto;
|
||||
import org.nl.wms.sch_manage.service.util.dto.MaterialInfoRespondDto;
|
||||
import org.nl.wms.system_manage.enums.SysParamConstant;
|
||||
import org.nl.wms.system_manage.enums.TagNameEnum;
|
||||
import org.nl.wms.system_manage.service.param.ISysParamService;
|
||||
import org.nl.wms.system_manage.service.param.dao.Param;
|
||||
import org.reflections.Reflections;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.nl.wms.ext_manage.enums.EXTConstant.GET_MATERIAL_INFO_MES_API;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@Order(value = 1)
|
||||
public class GetMaterialFromMesTask {
|
||||
|
||||
private static Set<Class<? extends AbstractTask>> subTypes;
|
||||
|
||||
@Autowired
|
||||
private ISysParamService paramService;
|
||||
|
||||
/**
|
||||
* 物料基础数据服务
|
||||
*/
|
||||
@Autowired
|
||||
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
|
||||
|
||||
|
||||
// 类加载时候执行扫描
|
||||
static {
|
||||
Reflections reflections = new Reflections("org.nl.wms.sch_manage.service.util.tasks");
|
||||
subTypes = reflections.getSubTypesOf(AbstractTask.class);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void run(String params) {
|
||||
MDC.put(TagNameEnum.TAG_NAME.getTag(), TagNameEnum.AUTO_TASK_SEND.getTag());
|
||||
log.info("定时器正在执行【从MES获取物料】任务调度...");
|
||||
getMaterial(params);
|
||||
log.info("定时器执行【从MES获取物料】任务调度结束...");
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时下发任务
|
||||
*/
|
||||
private void getMaterial(String params) {
|
||||
Param mesUrlParam = paramService.findByCode(SysParamConstant.MES_URL);
|
||||
if (ObjectUtil.isEmpty(mesUrlParam)) {
|
||||
log.error("系统参数表中:" + SysParamConstant.MES_URL + "不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
String url = mesUrlParam.getValue() + GET_MATERIAL_INFO_MES_API;
|
||||
try {
|
||||
MaterialInfoRequestDto requestDto = JSONObject.parseObject(params,MaterialInfoRequestDto.class);
|
||||
if (CollectionUtils.isEmpty(requestDto.getData())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(StringUtils.isBlank(requestDto.getData().get(0).getUpdateTimeBegin())){
|
||||
requestDto.getData().get(0).setUpdateTimeBegin(DateUtil.formatDate(DateUtil.offsetDay(new Date(),-6)));
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(requestDto.getData().get(0).getUpdateTimeEnd())){
|
||||
requestDto.getData().get(0).setUpdateTimeEnd(DateUtil.formatDate(DateUtil.offsetDay(new Date(),1)));
|
||||
}
|
||||
log.info("请求MES下发物料信息,入参=【{}】",JSONObject.toJSONString(requestDto));
|
||||
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(JSONObject.toJSONString(requestDto))
|
||||
.execute().body();
|
||||
|
||||
JSONObject result = JSONObject.parseObject(resultMsg);
|
||||
log.info("请求MES下发物料信息,返回参=【{}】" , result.toString());
|
||||
MaterialInfoRespondDto respondDto = JSONObject.toJavaObject(result, MaterialInfoRespondDto.class);
|
||||
|
||||
List<MaterialInfoRespondDataRecordDto> materialInfoRespondDataRecordDtoList = respondDto.getData().getRecords();
|
||||
|
||||
if (materialInfoRespondDataRecordDtoList == null || materialInfoRespondDataRecordDtoList.isEmpty()) {
|
||||
log.warn("MES返回物料数据为空,无需同步");
|
||||
return;
|
||||
}
|
||||
|
||||
for (MaterialInfoRespondDataRecordDto mesRecord : materialInfoRespondDataRecordDtoList) {
|
||||
String materialCode = mesRecord.getMaterial_code();
|
||||
if (StringUtils.isBlank(materialCode)) {
|
||||
log.warn("MES物料数据material_code为空,跳过");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 根据material_code查询本地是否存在
|
||||
boolean exists = iMdMeMaterialbaseService.lambdaQuery()
|
||||
.eq(MdMeMaterialbase::getMaterial_code, materialCode)
|
||||
.count() > 0;
|
||||
|
||||
// 组装本地实体
|
||||
MdMeMaterialbase material = new MdMeMaterialbase();
|
||||
material.setMaterial_code(materialCode);
|
||||
material.setMaterial_name(mesRecord.getMaterial_name());
|
||||
material.setMaterial_id(mesRecord.getId());
|
||||
// material.setMaterial_spec(mesRecord.getMaterialModel());
|
||||
material.setMaterial_model(mesRecord.getMaterial_type());
|
||||
|
||||
|
||||
|
||||
if (exists) {
|
||||
// 更新
|
||||
iMdMeMaterialbaseService.lambdaUpdate()
|
||||
.eq(MdMeMaterialbase::getMaterial_code, materialCode)
|
||||
.update(material);
|
||||
log.info("更新本地物料成功,materialCode={}", materialCode);
|
||||
} else {
|
||||
// 新增
|
||||
material.setCreate_time(DateUtil.now());
|
||||
material.setCreate_name("MES");
|
||||
material.setCreate_id("MES");
|
||||
iMdMeMaterialbaseService.save(material);
|
||||
log.info("新增本地物料成功,materialCode={}", materialCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
//网络不通
|
||||
String msg = e.getMessage();
|
||||
log.error("连接失败:{}", msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.wms.sch_manage.service.util.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: zhengxuming
|
||||
*/
|
||||
@Data
|
||||
public class MaterialInfoRequestDataDto {
|
||||
private String materialCode;
|
||||
private String updateTimeBegin;
|
||||
private String updateTimeEnd;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.nl.wms.sch_manage.service.util.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: zhengxuming
|
||||
*/
|
||||
@Data
|
||||
public class MaterialInfoRequestDto {
|
||||
private String action;
|
||||
private String model;
|
||||
private Integer pageNumber = 1;
|
||||
private Integer pageSize = 999999;
|
||||
private List<MaterialInfoRequestDataDto> data;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.nl.wms.sch_manage.service.util.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: zhengxuming
|
||||
*/
|
||||
@Data
|
||||
public class MaterialInfoRespondDataDto {
|
||||
private Integer total;
|
||||
private Integer size;
|
||||
private Integer current;
|
||||
private Integer pages;
|
||||
private List<MaterialInfoRespondDataRecordDto> records;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.nl.wms.sch_manage.service.util.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: zhengxuming
|
||||
*/
|
||||
@Data
|
||||
public class MaterialInfoRespondDataRecordDto {
|
||||
private String tenant_id;
|
||||
private String process;
|
||||
private String code;
|
||||
private String create_time;
|
||||
private String create_dept;
|
||||
private String material_form;
|
||||
private String updateUserName;
|
||||
private String createUserName;
|
||||
private String create_by;
|
||||
private String material_type;
|
||||
private String update_time;
|
||||
private String material_classify;
|
||||
private String id;
|
||||
private String material_mark;
|
||||
private String update_by;
|
||||
private String material_name;
|
||||
private String material_code;
|
||||
private String material_description;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.wms.sch_manage.service.util.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: zhengxuming
|
||||
*/
|
||||
@Data
|
||||
public class MaterialInfoRespondDto {
|
||||
private Integer code;
|
||||
private Boolean success;
|
||||
private String message;
|
||||
private MaterialInfoRespondDataDto data;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user