package com.qianwen.smartman.modules.smis.service.impl; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.common.constant.ExtCacheConstant; import com.qianwen.smartman.common.enums.GlobalWcsTypeEnum; import com.qianwen.smartman.common.utils.Lambda; import com.qianwen.smartman.modules.smis.convert.GlobalWcsConvert; import com.qianwen.smartman.modules.smis.entity.GlobalWcs; import com.qianwen.smartman.modules.smis.entity.GlobalWcsOfRps; import com.qianwen.smartman.modules.smis.mapper.GlobalWcsMapper; import com.qianwen.smartman.modules.smis.service.IGlobalWcsService; import com.qianwen.smartman.modules.smis.vo.WcsAchievementsUpdateVO; import com.qianwen.smartman.modules.smis.vo.WcsAndAchievementsVO; @Service public class GlobalWcsServiceImpl extends ServiceImpl implements IGlobalWcsService { @Override public List getGlobalWcsList(GlobalWcsTypeEnum globalWcsTypeEnum) { return list(Wrappers.lambdaQuery().eq(GlobalWcs::getType, globalWcsTypeEnum.getType()).orderByAsc(GlobalWcs::getSeq)); } @Override public List getWcsAndAchievements() { return this.baseMapper.wcsAndAchievements(); } @Override public GlobalWcs getByCode(String code, GlobalWcsTypeEnum globalWcsTypeEnum) { return getOne(Lambda.eq(GlobalWcs::getCode, code).eq(GlobalWcs::getType, globalWcsTypeEnum.getType())); } @Override @Transactional public void updateWcsAndAchievements(WcsAchievementsUpdateVO wcsAchievements) { 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(); GlobalWcsOfRps globalWcsOfRps = new GlobalWcsOfRps(); globalWcsOfRps.setCode(wcsAchievements.getCode()); globalWcsOfRps.setRps(wcsAchievements.getRps()); globalWcsOfRps.setIsPlan(wcsAchievements.getIsPlan()); globalWcsOfRps.insertOrUpdate(); CacheUtil.clear(ExtCacheConstant.COLLECT_WORKSTATION, Boolean.FALSE); } @Override @Transactional public boolean insertWcsAndAchievements(WcsAchievementsUpdateVO wcsAchievementsUpdateVO) { if (count(Lambda.eq(GlobalWcs::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.COLLECT_WORKSTATION, Boolean.FALSE); return save(globalWcs); } }