From 5aec14c5b8733d1e175bb9b7c6415ecadedf4ba9 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期一, 07 七月 2025 21:40:52 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationStandardServiceImpl.java | 186 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 186 insertions(+), 0 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationStandardServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationStandardServiceImpl.java new file mode 100644 index 0000000..8ba1b11 --- /dev/null +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationStandardServiceImpl.java @@ -0,0 +1,186 @@ +package org.jeecg.modules.eam.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.common.util.SimpleVersionGenerateUtil; +import org.jeecg.modules.eam.base.entity.BaseFactory; +import org.jeecg.modules.eam.base.entity.BaseFactoryUser; +import org.jeecg.modules.eam.base.service.IBaseFactoryService; +import org.jeecg.modules.eam.base.service.IBaseFactoryUserService; +import org.jeecg.modules.eam.constant.MaintenanceStandardStatusEnum; +import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationStandardEnum; +import org.jeecg.modules.eam.entity.EamMaintenanceStandard; +import org.jeecg.modules.eam.entity.EamMaintenanceStandardDetail; +import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationStandard; +import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationStandardDetail; +import org.jeecg.modules.eam.mapper.EamTechnicalStatusEvaluationStandardMapper; +import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationStandardRequest; +import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationStandardDetailService; +import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationStandardService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Description: 鎶�鏈姸鎬侀壌瀹氳鑼� + * @Author: jeecg-boot + * @Date: 2025-07-07 + * @Version: V1.0 + */ +@Service +public class EamTechnicalStatusEvaluationStandardServiceImpl extends ServiceImpl<EamTechnicalStatusEvaluationStandardMapper, EamTechnicalStatusEvaluationStandard> implements IEamTechnicalStatusEvaluationStandardService { + + @Autowired + private IBaseFactoryUserService baseFactoryUserService; + @Autowired + private IBaseFactoryService baseFactoryService; + @Autowired + private IEamTechnicalStatusEvaluationStandardDetailService standardDetailService; + + @Override + public IPage<EamTechnicalStatusEvaluationStandard> queryPageList(Page<EamTechnicalStatusEvaluationStandard> page, EamTechnicalStatusEvaluationStandard query) { + QueryWrapper<EamTechnicalStatusEvaluationStandard> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("ems.del_flag", CommonConstant.DEL_FLAG_0); + //鐢ㄦ埛鏁版嵁鏉冮檺 + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (sysUser == null) { + return page; + } + if (StringUtils.isNotBlank(sysUser.getEamEquipmentIds())) { + //閫夋嫨浜嗚澶囷紝鏍规嵁璁惧id杩囨护璁惧 + List<String> equipArr = Arrays.asList(sysUser.getEamEquipmentIds().split(",")); + queryWrapper.in("e.equipment_code", equipArr); + } else { + //娌℃湁閫夋嫨璁惧锛屾牴鎹腑蹇冭繃婊よ澶� + List<BaseFactoryUser> baseFactoryUserList = baseFactoryUserService. + list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId, sysUser.getId())); + if (!CollectionUtils.isEmpty(baseFactoryUserList)) { + List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList()); + List<String> factoryCode = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList()); + queryWrapper.in("e.factory_code", factoryCode); + } else { + return page; + } + } + if (query != null) { + //缂栫爜 妯$硦鏌ヨ + if (StringUtils.isNotBlank(query.getStandardCode())) { + queryWrapper.like("ems.standard_code", query.getStandardCode()); + } + //鍚嶇О 妯$硦鏌ヨ + if (StringUtils.isNotBlank(query.getStandardName())) { + queryWrapper.like("ems.standard_name", query.getStandardName()); + } + //璁惧 + if (StringUtils.isNotBlank(query.getEquipmentId())) { + queryWrapper.eq("ems.equipment_id", query.getEquipmentId()); + } + + //淇濆吇鍒嗙被 + if (StringUtils.isNotBlank(query.getStandardStatus())) { + queryWrapper.eq("ems.standard_status", query.getStandardStatus()); + } + } + queryWrapper.orderByDesc("ems.create_time"); + return this.getBaseMapper().queryPageList(page, queryWrapper); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean addEamTechnicalStatusEvaluationStandard(EamTechnicalStatusEvaluationStandardRequest request) { + EamTechnicalStatusEvaluationStandard entity = new EamTechnicalStatusEvaluationStandard(); + BeanUtils.copyProperties(request, entity); + entity.setStandardStatus(TechnicalStatusEvaluationStandardEnum.WAIT_SUBMIT.name()); + //鐗堟湰閫掑 + entity.setStandardVersion(SimpleVersionGenerateUtil.getInitVersion()); + //璁惧澶勭悊 + entity.setEquipmentId(request.getEquipmentId()); + //鍒犻櫎鏍囪 + entity.setDelFlag(CommonConstant.DEL_FLAG_0); + //閲嶅鎬ф牎楠� + EamTechnicalStatusEvaluationStandard exist = checkDuplicate(entity.getEquipmentId(), null); + if(exist != null){ + throw new JeecgBootException("瑙勮寖宸插瓨鍦紝涓嶈兘閲嶅娣诲姞锛�"); + } + this.getBaseMapper().insert(entity); + //澶勭悊鏄庣粏鏁版嵁 + if(CollectionUtil.isNotEmpty(request.getTableDetailList())) { + request.getTableDetailList().forEach(tableDetail -> { + tableDetail.setStandardId(entity.getId()); + }); + standardDetailService.saveBatch(request.getTableDetailList()); + } + return true; + } + + @Override + public EamTechnicalStatusEvaluationStandard checkDuplicate(String equipmentId, String id) { + LambdaQueryWrapper<EamTechnicalStatusEvaluationStandard> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(EamTechnicalStatusEvaluationStandard::getEquipmentId, equipmentId); + queryWrapper.eq(EamTechnicalStatusEvaluationStandard::getDelFlag, CommonConstant.DEL_FLAG_0); + //寰呮彁浜ゃ�佸惎鐢ㄧ姸鎬� + queryWrapper.in(EamTechnicalStatusEvaluationStandard::getStandardStatus, Arrays.asList(TechnicalStatusEvaluationStandardEnum.ENABLE.name(), TechnicalStatusEvaluationStandardEnum.WAIT_SUBMIT.name())); + queryWrapper.orderByDesc(EamTechnicalStatusEvaluationStandard::getStandardVersion); + if(StringUtils.isNotBlank(id)){ + queryWrapper.ne(EamTechnicalStatusEvaluationStandard::getId, id); + } + List<EamTechnicalStatusEvaluationStandard> list = this.getBaseMapper().selectList(queryWrapper); + if(CollectionUtil.isEmpty(list)) { + return null; + } + return list.get(0); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean editEamTechnicalStatusEvaluationStandard(EamTechnicalStatusEvaluationStandardRequest request) { + EamTechnicalStatusEvaluationStandard entity = this.getBaseMapper().selectById(request.getId()); + if(entity == null){ + throw new JeecgBootException("缂栬緫鐨勬暟鎹凡鍒犻櫎锛岃鍒锋柊閲嶈瘯锛�"); + } + entity.setStandardName(request.getStandardName()); + entity.setEvaluationPeriod(request.getEvaluationPeriod()); + this.getBaseMapper().updateById(entity); + //澶勭悊璇︽儏 + if(CollectionUtil.isNotEmpty(request.getTableDetailList())) { + List<EamTechnicalStatusEvaluationStandardDetail> addList = new ArrayList<>(); + List<EamTechnicalStatusEvaluationStandardDetail> updateList = new ArrayList<>(); + request.getTableDetailList().forEach(tableDetail -> { + tableDetail.setStandardId(entity.getId()); + if(tableDetail.getId() == null){ + addList.add(tableDetail); + }else { + updateList.add(tableDetail); + } + }); + if(CollectionUtil.isNotEmpty(addList)){ + standardDetailService.saveBatch(addList); + } + if(CollectionUtil.isNotEmpty(updateList)){ + standardDetailService.updateBatchById(updateList); + } + } + if(CollectionUtil.isNotEmpty(request.getRemoveDetailList())) { + List<String> ids = request.getRemoveDetailList().stream().map(EamTechnicalStatusEvaluationStandardDetail::getId).collect(Collectors.toList()); + standardDetailService.removeBatchByIds(ids); + } + return true; + } +} -- Gitblit v1.9.3