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);
|
}
|
}
|