yangys
2024-03-28 23a939ed820ee32f9a4309f9c81b7bab5a566f30
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
package com.qianwen.smartman.modules.cps.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.lang.invoke.SerializedLambda;
import java.util.List;
import com.qianwen.smartman.common.constant.ExtCacheConstant;
import com.qianwen.smartman.common.enums.GlobalWcsTypeEnum;
import com.qianwen.smartman.common.utils.Lambda;
import com.qianwen.core.cache.utils.CacheUtil;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.cps.convert.GlobalWcsConvert;
import com.qianwen.smartman.modules.cps.entity.GlobalWcs;
import com.qianwen.smartman.modules.cps.entity.GlobalWcsOfRps;
import com.qianwen.smartman.modules.cps.mapper.GlobalWcsMapper;
import com.qianwen.smartman.modules.cps.service.IGlobalWcsService;
import com.qianwen.smartman.modules.cps.vo.WcsAchievementsUpdateVO;
import com.qianwen.smartman.modules.cps.vo.WcsAndAchievementsVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
@Service
 
public class GlobalWcsServiceImpl extends ServiceImpl<GlobalWcsMapper, GlobalWcs> implements IGlobalWcsService {
    
 
    @Override // org.springblade.modules.cps.service.IGlobalWcsService
    public List<GlobalWcs> getGlobalWcsList(GlobalWcsTypeEnum globalWcsTypeEnum) {
         return list(Wrappers.<GlobalWcs>lambdaQuery().eq(GlobalWcs::getType, globalWcsTypeEnum.getType()).orderByAsc(GlobalWcs::getSeq));
         /*
        return list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> {
            return v0.getType();
        }, globalWcsTypeEnum.getType())).orderByAsc((v0) -> {
            return v0.getSeq();
        }));*/
    }
 
    @Override // org.springblade.modules.cps.service.IGlobalWcsService
    public List<WcsAndAchievementsVO> getWcsAndAchievements() {
        return ((GlobalWcsMapper) this.baseMapper).wcsAndAchievements();
    }
 
    @Override // org.springblade.modules.cps.service.IGlobalWcsService
    public GlobalWcs getByCode(String code, GlobalWcsTypeEnum globalWcsTypeEnum) {
        return getOne(Lambda.eq(GlobalWcs::getCode, code).eq(GlobalWcs::getType, globalWcsTypeEnum.getType()));
        /*
        return (GlobalWcs) getOne((Wrapper) Lambda.eq((v0) -> {
            return v0.getCode();
        }, code).eq((v0) -> {
            return v0.getType();
        }, globalWcsTypeEnum.getType()));*/
    }
 
    @Override // org.springblade.modules.cps.service.IGlobalWcsService
    @Transactional
    public void updateWcsAndAchievements(WcsAchievementsUpdateVO wcsAchievements) {
         boolean update = lambdaUpdate()
                 .set(Func.isNotBlank(wcsAchievements.getName()), GlobalWcs::getName, wcsAchievements.getName())
                 .set(Func.isNotBlank(wcsAchievements.getColor()), GlobalWcs::getColor, wcsAchievements.getColor())
                 .eq(GlobalWcs::getCode, wcsAchievements.getCode()).update();
         /*
        ((LambdaUpdateChainWrapper) ((LambdaUpdateChainWrapper) ((LambdaUpdateChainWrapper) lambdaUpdate().set(Func.isNotBlank(wcsAchievements.getName()), (v0) -> {
            return v0.getName();
        }, wcsAchievements.getName())).set(Func.isNotBlank(wcsAchievements.getColor()), (v0) -> {
            return v0.getColor();
        }, wcsAchievements.getColor())).eq((v0) -> {
            return v0.getCode();
        }, wcsAchievements.getCode())).update();*/
        GlobalWcsOfRps globalWcsOfRps = new GlobalWcsOfRps();
        globalWcsOfRps.setCode(wcsAchievements.getCode());
        globalWcsOfRps.setRps(wcsAchievements.getRps());
        globalWcsOfRps.setIsPlan(wcsAchievements.getIsPlan());
        globalWcsOfRps.insertOrUpdate();
        CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE);
    }
 
    @Override // org.springblade.modules.cps.service.IGlobalWcsService
    @Transactional
    public boolean insertWcsAndAchievements(WcsAchievementsUpdateVO wcsAchievementsUpdateVO) {
        if (count(Lambda.eq((v0) -> {
            return v0.getCode();
        }, wcsAchievementsUpdateVO.getCode())) > 0) {
            throw new ServiceException("编码已经存在");
        }
        GlobalWcs globalWcs = GlobalWcsConvert.INSTANCE.convert(wcsAchievementsUpdateVO);
        globalWcs.setType(GlobalWcsTypeEnum.FEEDBACK.getType());
        GlobalWcsOfRps globalWcsOfRps = new GlobalWcsOfRps();
        globalWcsOfRps.setCode(wcsAchievementsUpdateVO.getCode());
        globalWcsOfRps.setRps(wcsAchievementsUpdateVO.getRps());
        globalWcsOfRps.setIsPlan(wcsAchievementsUpdateVO.getIsPlan());
        globalWcsOfRps.insertOrUpdate();
        CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE);
        return save(globalWcs);
    }
}