From c935e18fab3604e493de29b164ea4019244bb182 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期四, 21 五月 2026 17:59:58 +0800
Subject: [PATCH] 对外Mes查询外购订单零件批次属性接口开发
---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/IfsPartPropsRecordServiceImpl.java | 80 ++++++++++++++++++++++++++++++++++++---
1 files changed, 73 insertions(+), 7 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/IfsPartPropsRecordServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/IfsPartPropsRecordServiceImpl.java
index 89fb4c2..d3c3072 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/IfsPartPropsRecordServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/IfsPartPropsRecordServiceImpl.java
@@ -1,26 +1,33 @@
package com.ruoyi.inspect.service.impl;
-import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson2.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.dto.IfsInventoryQuantityDto;
import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
import com.ruoyi.basic.pojo.IfsInventoryQuantity;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.enums.OrderType;
import com.ruoyi.common.utils.api.IfsApiUtils;
import com.ruoyi.inspect.dto.IfsPartPropsRecordDTO;
+import com.ruoyi.inspect.mapper.IfsPartPropsRecordMapper;
import com.ruoyi.inspect.mapper.IfsSplitOrderRecordMapper;
import com.ruoyi.inspect.pojo.IfsPartPropsRecord;
import com.ruoyi.inspect.pojo.IfsSplitOrderRecord;
import com.ruoyi.inspect.service.IfsPartPropsRecordService;
-import com.ruoyi.inspect.mapper.IfsPartPropsRecordMapper;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
+import java.math.BigDecimal;
import java.util.*;
/**
@@ -42,6 +49,9 @@
@Autowired
private IfsSplitOrderRecordMapper ifsSplitOrderRecordMapper;
+ @Autowired
+ private IfsPartPropsRecordMapper ifsPartPropsRecordMapper;
+
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveOrUpdateProps(IfsPartPropsRecordDTO ifsPartPropsRecord) {
@@ -55,7 +65,7 @@
inAttrMap.put("SYSCODE", "LIMS");
inAttrMap.put("SYSMODEL", "搴撳瓨鐗╂枡鎵规灞炴�т慨鏀�");
HashMap<String, Object> batchInfoMap = new HashMap<>();
- batchInfoMap.put("CONTRACT","ZTNS");//鍩�
+ batchInfoMap.put("CONTRACT",ifsPartPropsRecord.getContract());//鍩�
batchInfoMap.put("PART_NO",ifsPartPropsRecord.getPartNo());//闆朵欢鍙�
batchInfoMap.put("LOT_BATCH_NO",ifsPartPropsRecord.getLotBatchNo());//鎵规鍙�
batchInfoMap.put("ATTR1",ifsPartPropsRecord.getDrumNo());//杞藉叿缂栧彿
@@ -68,14 +78,16 @@
batchInfoMap.put("ATTR24","0");//鍒嗗壊棰勭暀鏁伴噺
batchInfoMap.put("ACTION_TYPE",actionType);//鎿嶄綔绫诲瀷
inAttrMap.put("BATCH_INFO", Collections.singletonList(batchInfoMap));
- Result result = ifsApiUtils.importPartLotAttr(JSONUtil.toJsonStr(inAttrMap));
+ Result result = ifsApiUtils.importPartLotAttr(ifsPartPropsRecord.getContract(),JSONUtil.toJsonStr(inAttrMap));
if(result.getCode()!=200){
throw new RuntimeException("搴撳瓨鐗╂枡鎵规灞炴�ф洿鏂板け璐ワ細"+result.getMessage());
}
return this.saveOrUpdate(ifsPartPropsRecord);
}
+
@Override
+ @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
public IfsPartPropsRecord getOneByIfsId(Long ifsId) {
//鏌ヨifs璁㈠崟淇℃伅
IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsId);
@@ -102,12 +114,66 @@
ifsPartPropsRecord.setLetteringInfo(splitRecord.getLetteringInfo());
ifsPartPropsRecord.setInsulationColor(splitRecord.getInsulationColor());
ifsPartPropsRecord.setOuterColor(splitRecord.getOuterColor());
- ifsPartPropsRecord.setDrumNo(splitRecord.getDrumNo());
- ifsPartPropsRecord.setDrumNo(splitRecord.getDrumNo());
return ifsPartPropsRecord;
}
- return this.getOne(Wrappers.<IfsPartPropsRecord>lambdaQuery().eq(IfsPartPropsRecord::getIfsInventoryId,ifsId).last("limit 1"));
+ //鏌ヨ鎵规灞炴�ц褰�
+ IfsPartPropsRecord propsRecord = this.getOne(Wrappers.<IfsPartPropsRecord>lambdaQuery().eq(IfsPartPropsRecord::getIfsInventoryId, ifsId).last("limit 1"));
+ if(ObjectUtil.isNotEmpty(propsRecord)){
+ return propsRecord;
+ }
+ //鏌ヨifs鎵规灞炴�ц褰曪紝鏈夊氨鍏堟柊澧炲埌鏁版嵁搴�
+ Map<String, Object> queryMap = new HashMap<>();
+ queryMap.put("LOT_BATCH_NO",ifsInventoryQuantity.getUpdateBatchNo());
+ queryMap.put("PART_NO",ifsInventoryQuantity.getPartNo());
+ Result queryPartLotResult = ifsApiUtils.queryPartLotAttr(ifsInventoryQuantity.getContract(), JSONUtil.toJsonStr(queryMap));
+ if(queryPartLotResult.getCode()==200){
+ JSONObject entries = JSONUtil.parseObj(queryPartLotResult.getData());
+ JSONArray listInfo = entries.getJSONArray("LIST_INFO");
+ if(!listInfo.isEmpty()){
+ Map<String,Object> parseObject = com.alibaba.fastjson2.JSONObject.parseObject(JSONUtil.toJsonStr(listInfo.get(0)), new TypeReference<Map<String, Object>>() {}.getType());
+ IfsPartPropsRecord ifsPartPropsRecord = new IfsPartPropsRecord();
+ ifsPartPropsRecord.setIfsInventoryId(ifsInventoryQuantity.getId());//ifs璁㈠崟id
+ ifsPartPropsRecord.setDrumNo(parseObject.get("ATTR1").toString());//杞藉叿缂栧彿
+ BigDecimal startMeterMark = ObjectUtils.isNotEmpty(parseObject.get("ATTR2"))?new BigDecimal(parseObject.get("ATTR2").toString()):BigDecimal.ZERO;
+ BigDecimal endMeterMark = ObjectUtils.isNotEmpty(parseObject.get("ATTR3"))?new BigDecimal(parseObject.get("ATTR3").toString()):BigDecimal.ZERO;
+ ifsPartPropsRecord.setStartMeterMark(startMeterMark);//璧峰绫虫爣
+ ifsPartPropsRecord.setEndMeterMark(endMeterMark);//鎴绫虫爣
+ ifsPartPropsRecord.setOuterColor(parseObject.get("ATTR4").toString());//澶栨姢棰滆壊
+ ifsPartPropsRecord.setInsulationColor(parseObject.get("ATTR5").toString());//缁濈紭棰滆壊
+ ifsPartPropsRecord.setLetteringInfo(parseObject.get("ATTR8").toString());//鍗板瓧淇℃伅
+ ifsPartPropsRecordMapper.insert(ifsPartPropsRecord);
+ }
+ }
+ return this.getOne(Wrappers.<IfsPartPropsRecord>lambdaQuery().eq(IfsPartPropsRecord::getIfsInventoryId, ifsId).last("limit 1"));
}
+
+ @Override
+ public IfsPartPropsRecordDTO getOneByContract(IfsInventoryQuantityDto ifsInventoryQuantityDto) {
+ return baseMapper.selectOneByContract(ifsInventoryQuantityDto);
+ }
+
+ @Override
+ public IfsPartPropsRecordDTO getIfsPartProps(IfsInventoryQuantityDto ifsPartPropsRecordDTO) {
+ validateParams(ifsPartPropsRecordDTO);
+ ifsPartPropsRecordDTO.setOrderType(OrderType.WG.getValue());
+ return baseMapper.selectOneByContract(ifsPartPropsRecordDTO);
+ }
+
+ void validateParams(IfsInventoryQuantityDto ifsPartPropsRecordDTO){
+ if(Objects.isNull(ifsPartPropsRecordDTO)){
+ throw new RuntimeException("浼犲叆鍙傛暟涓嶈兘涓虹┖");
+ }
+ if(StringUtils.isBlank(ifsPartPropsRecordDTO.getContract())){
+ throw new RuntimeException("宸ュ巶鍩熶笉鑳戒负绌�");
+ }
+ if(StringUtils.isBlank(ifsPartPropsRecordDTO.getUpdateBatchNo())){
+ throw new RuntimeException("鎵规鍙蜂笉鑳戒负绌�");
+ }
+ if(StringUtils.isBlank(ifsPartPropsRecordDTO.getPartNo())){
+ throw new RuntimeException("闆朵欢鍙蜂笉鑳戒负绌�");
+ }
+ }
+
}
--
Gitblit v1.9.3