李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
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
package com.chinaztt.mes.quality.utils;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.chinaztt.mes.quality.entity.Result;
import com.chinaztt.mes.quality.mapper.ResultMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
 
/**
 * @Author: cxf
 * @Date: 2021/06/01 16:00
 */
@Service
@AllArgsConstructor
public class ResultUtils {
 
    private ResultMapper resultMapper;
 
    /**
     * 质检增加检验记录
     */
    public synchronized void addOrUpdateResult(String systemNo, String partBatchNo, String status, Boolean isSelfQualified,
                                               Boolean isQualified, Boolean isUsed, Long workstationId, Long partId, Long applyId, String applyType) {
        Result result = new Result();
        result.setCheckStatus(status);
        result.setIsQualified(isQualified);
        result.setIsSelfQualified(isSelfQualified);
        result.setIsUsed(isUsed);
        result.setWorkstationId(workstationId);
        result.setApplyId(applyId);
        result.setApplyType(applyType);
        Result repeatResult = resultMapper.selectOne(Wrappers.<Result>query().lambda()
                .eq(Result::getSystemNo, systemNo)
                .eq(Result::getPartBatchNo, partBatchNo)
                .eq(Result::getPartId, partId)
                .eq(Result::getApplyType, applyType)
                .eq(Result::getIsErp, false));
        if (repeatResult != null) {
            result.setId(repeatResult.getId());
            resultMapper.updateById(result);
        } else {
            result.setSystemNo(systemNo);
            result.setPartBatchNo(partBatchNo);
            result.setPartId(partId);
            resultMapper.insert(result);
        }
    }
}