zouyu
2025-10-23 d425460023114e81caedc7a0430f9246ed3bb839
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.ruoyi.inspect.service.impl;
 
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
import com.ruoyi.basic.pojo.IfsInventoryQuantity;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.utils.api.IfsApiUtils;
import com.ruoyi.inspect.dto.IfsPartPropsRecordDTO;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.*;
 
/**
* @author 27233
* @description 针对表【ifs_part_props_record(ifs订单零件属性记录表)】的数据库操作Service实现
* @createDate 2025-10-23 15:00:34
*/
@Slf4j
@Service
public class IfsPartPropsRecordServiceImpl extends ServiceImpl<IfsPartPropsRecordMapper, IfsPartPropsRecord>
    implements IfsPartPropsRecordService{
 
    @Autowired
    private IfsApiUtils ifsApiUtils;
 
    @Autowired
    private IfsInventoryQuantityMapper ifsInventoryQuantityMapper;
 
    @Autowired
    private IfsSplitOrderRecordMapper ifsSplitOrderRecordMapper;
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdateProps(IfsPartPropsRecordDTO ifsPartPropsRecord) {
        if(Objects.isNull(ifsPartPropsRecord)){
            throw new RuntimeException("参数不能为空");
        }
        //判断是新增还是更新
        String actionType = Objects.isNull(ifsPartPropsRecord.getId())?"New":"Modify";
        Map<String, Object> inAttrMap = new HashMap<>();
        inAttrMap.put("RECORD_ID", UUID.randomUUID().toString());
        inAttrMap.put("SYSCODE", "LIMS");
        inAttrMap.put("SYSMODEL", "库存物料批次属性修改");
        HashMap<String, Object> batchInfoMap = new HashMap<>();
        batchInfoMap.put("CONTRACT","ZTNS");//域
        batchInfoMap.put("PART_NO",ifsPartPropsRecord.getPartNo());//零件号
        batchInfoMap.put("LOT_BATCH_NO",ifsPartPropsRecord.getLotBatchNo());//批次号
        batchInfoMap.put("ATTR1",ifsPartPropsRecord.getDrumNo());//载具编号
        batchInfoMap.put("ATTR2",ifsPartPropsRecord.getStartMeterMark());//起始米标
        batchInfoMap.put("ATTR3",ifsPartPropsRecord.getEndMeterMark());//截止米标
        batchInfoMap.put("ATTR4", ifsPartPropsRecord.getInsulationColor());//绝缘颜色
        batchInfoMap.put("ATTR5",ifsPartPropsRecord.getOuterColor());//外护颜色
        batchInfoMap.put("ATTR8",ifsPartPropsRecord.getLetteringInfo());//印字信息
        batchInfoMap.put("ACTION_TYPE",actionType);//操作类型
        inAttrMap.put("BATCH_INFO", Collections.singletonList(batchInfoMap));
        Result result = ifsApiUtils.importPartLotAttr(JSONUtil.toJsonStr(inAttrMap));
        if(result.getCode()!=200){
            throw new RuntimeException("库存物料批次属性更新失败:"+result.getMessage());
        }
        return this.saveOrUpdate(ifsPartPropsRecord);
    }
 
    @Override
    public IfsPartPropsRecord getOneByIfsId(Long ifsId) {
        //查询ifs订单信息
        IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsId);
        if(Objects.isNull(ifsInventoryQuantity)){
            throw new RuntimeException("未找到对应的IFS订单信息");
        }
        //判断是否是拆分订单
        if(ifsInventoryQuantity.getIsSplitOrder().equals(1)){
            //查询拆分记录
            IfsSplitOrderRecord splitRecord = ifsSplitOrderRecordMapper.selectOne(Wrappers.<IfsSplitOrderRecord>lambdaQuery()
                    .eq(IfsSplitOrderRecord::getOrderNo, ifsInventoryQuantity.getOrderNo())
                    .eq(IfsSplitOrderRecord::getPartNo, ifsInventoryQuantity.getPartNo())
                    .eq(IfsSplitOrderRecord::getReleaseNo, ifsInventoryQuantity.getReleaseNo())
                    .eq(IfsSplitOrderRecord::getLineNo, ifsInventoryQuantity.getLineNo())
                    .eq(IfsSplitOrderRecord::getReceiptNo, ifsInventoryQuantity.getReceiptNo())
                    .eq(IfsSplitOrderRecord::getLotBatchNo, ifsInventoryQuantity.getUpdateBatchNo())
                    .eq(IfsSplitOrderRecord::getOrderNo, ifsInventoryQuantity.getOrderNo())
            );
            if(Objects.isNull(splitRecord)){
                throw new RuntimeException("未找到零件的拆分信息");
            }
            IfsPartPropsRecord ifsPartPropsRecord = new IfsPartPropsRecord();
            ifsPartPropsRecord.setDrumNo(splitRecord.getDrumNo());
            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"));
    }
}