From 7d5d6d104b0ad994b62b53683d752b4fec61b8c1 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期二, 15 七月 2025 21:13:29 +0800 Subject: [PATCH] art: 技术状态鉴定工单-字段转译 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderChangeServiceImpl.java | 196 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 192 insertions(+), 4 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderChangeServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderChangeServiceImpl.java index 774fecb..e12b83f 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderChangeServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderChangeServiceImpl.java @@ -1,19 +1,207 @@ package org.jeecg.modules.eam.service.impl; +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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.constant.DataBaseConstant; +import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.eam.constant.BusinessCodeConst; +import org.jeecg.modules.eam.constant.HfTemplateCategoryEnum; +import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationOrderChangeStatusEnum; +import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationOrderStatusEnum; +import org.jeecg.modules.eam.entity.EamBaseHFCode; +import org.jeecg.modules.eam.entity.EamEquipment; +import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationOrder; import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationOrderChange; import org.jeecg.modules.eam.mapper.EamTechnicalStatusEvaluationOrderChangeMapper; +import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationOrderChangeQuery; +import org.jeecg.modules.eam.service.IEamBaseHFCodeService; +import org.jeecg.modules.eam.service.IEamEquipmentService; import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationOrderChangeService; +import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationOrderService; +import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; +import org.jeecg.modules.system.entity.BaseFactory; +import org.jeecg.modules.system.entity.BaseFactoryUser; +import org.jeecg.modules.system.service.IBaseFactoryService; +import org.jeecg.modules.system.service.IBaseFactoryUserService; +import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.*; +import java.util.stream.Collectors; /** * @Description: 鎶�鏈姸鎬侀壌瀹氬伐鍗曞彉鏇� * @Author: jeecg-boot - * @Date: 2025-07-09 + * @Date: 2025-07-09 * @Version: V1.0 */ -@Service -public class EamTechnicalStatusEvaluationOrderChangeServiceImpl extends ServiceImpl<EamTechnicalStatusEvaluationOrderChangeMapper, EamTechnicalStatusEvaluationOrderChange> implements IEamTechnicalStatusEvaluationOrderChangeService { +@Service("IEamTechnicalStatusEvaluationOrderChangeService") +public class EamTechnicalStatusEvaluationOrderChangeServiceImpl extends ServiceImpl<EamTechnicalStatusEvaluationOrderChangeMapper, EamTechnicalStatusEvaluationOrderChange> implements IEamTechnicalStatusEvaluationOrderChangeService, FlowCallBackServiceI { + @Autowired + private IBaseFactoryUserService baseFactoryUserService; + @Autowired + private IBaseFactoryService baseFactoryService; + @Autowired + private IEamTechnicalStatusEvaluationOrderService evaluationOrderService; + @Autowired + private IEamEquipmentService equipmentService; + @Autowired + private ISysBusinessCodeRuleService businessCodeRuleService; + @Autowired + private IEamBaseHFCodeService hfCodeService; + @Override + public IPage<EamTechnicalStatusEvaluationOrderChange> queryPageList(Page<EamTechnicalStatusEvaluationOrderChange> page, EamTechnicalStatusEvaluationOrderChangeQuery query) { + QueryWrapper<EamTechnicalStatusEvaluationOrderChange> 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)) { + Set<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toSet()); + Set<String> factoryCodeList = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet()); + queryWrapper.in("e.factory_org_code", factoryCodeList); + } else { + return page; + } + } + if (query != null) { + //缂栫爜 妯$硦鏌ヨ + if (StringUtils.isNotBlank(query.getChangeOrderNum())) { + queryWrapper.like("ems.change_order_num", query.getChangeOrderNum()); + } + //璁惧 + if (StringUtils.isNotBlank(query.getEquipmentId())) { + queryWrapper.eq("ems.equipment_id", query.getEquipmentId()); + } + + //淇濆吇鍒嗙被 + if (StringUtils.isNotBlank(query.getChangeStatus())) { + queryWrapper.eq("ems.change_status", query.getChangeStatus()); + } + if (query.getDateBegin() != null && query.getDateEnd() != null) { + queryWrapper.between("ems.apply_date", query.getDateBegin(), query.getDateEnd()); + } + //鎺掑簭 + if (StringUtils.isNotBlank(query.getColumn()) && StringUtils.isNotBlank(query.getOrder())) { + String column = query.getColumn(); + if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { + column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); + } + if (DataBaseConstant.SQL_ASC.equalsIgnoreCase(query.getOrder())) { + queryWrapper.orderByAsc("ems." + oConvertUtils.camelToUnderline(column)); + } else { + queryWrapper.orderByDesc("ems." + oConvertUtils.camelToUnderline(column)); + } + } else { + queryWrapper.orderByDesc("ems.create_time"); + } + } else { + queryWrapper.orderByDesc("ems.create_time"); + } + return this.getBaseMapper().queryPageList(page, queryWrapper); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean addTechnicalStatusEvaluationOrderChange(EamTechnicalStatusEvaluationOrderChange request) { + //鏌ヨ宸ュ崟 + EamTechnicalStatusEvaluationOrder order = evaluationOrderService.getById(request.getOrderId()); + if (order == null) { + throw new JeecgBootException("閴村畾宸ュ崟涓嶅瓨鍦紝鎿嶄綔澶辫触锛�"); + } + //鏌ヨ璁惧 + EamEquipment equipment = equipmentService.getById(request.getEquipmentId()); + if (equipment == null) { + throw new JeecgBootException("璁惧淇℃伅涓嶅瓨鍦紝鎿嶄綔澶辫触锛�"); + } + //鐢ㄦ埛鏁版嵁鏉冮檺 + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (sysUser == null) { + throw new JeecgBootException("鐧诲綍鐢ㄦ埛淇℃伅涓虹┖锛屾搷浣滃け璐ワ紒"); + } + String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.TECHNICAL_STATUS_EVALUATION_ORDER_CHANG_CODE_RULE); + request.setChangeOrderNum(codeSeq); + request.setId(null); + request.setChangeStatus(TechnicalStatusEvaluationOrderChangeStatusEnum.WAIT_SUBMIT.name()); + request.setDelFlag(CommonConstant.DEL_FLAG_0); + request.setApplicant(sysUser.getUsername()); + request.setApplyDate(new Date()); + request.setFactoryOrgCode(equipment.getFactoryOrgCode()); + //鎶�鏈姸鎬侀壌瀹氳〃 + EamBaseHFCode eamBaseHFCode = hfCodeService.selectByCategory(HfTemplateCategoryEnum.TECHNICAL_STATUS_EVALUATION_ORDER_CHANG.name()); + if (eamBaseHFCode == null) { + throw new JeecgBootException("鏈厤缃妧鏈姸鎬侀壌瀹氬彉鏇寸殑HF缂栫爜锛屾坊鍔犲け璐ワ紒"); + } + request.setHfCode(eamBaseHFCode.getHfCode()); + this.getBaseMapper().insert(request); + boolean b = evaluationOrderService.updateEvaluationStatus(request.getOrderId(), TechnicalStatusEvaluationOrderStatusEnum.CHANGING.name()); + if (!b) { + throw new JeecgBootException("鎶�鏈姸鎬侀壌瀹氬伐鍗曠姸鎬佸彉鏇村け璐ワ紝鏃犳硶鍙樻洿锛�"); + } + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean editTechnicalStatusEvaluationOrderChange(EamTechnicalStatusEvaluationOrderChange request) { + EamTechnicalStatusEvaluationOrderChange entity = this.getBaseMapper().selectById(request.getId()); + if(entity == null) { + throw new JeecgBootException("缂栬緫鐨勬暟鎹凡鍒犻櫎锛岃鍒锋柊閲嶈瘯锛�"); + } + if(!TechnicalStatusEvaluationOrderChangeStatusEnum.WAIT_SUBMIT.name().equals(entity.getChangeStatus())) { + throw new JeecgBootException("鍙湁寰呮彁浜ょ姸鎬佹墠鍙紪杈戯紒"); + } + entity.setApplyReason(request.getApplyReason()); + entity.setDeferredEvaluationDate(request.getDeferredEvaluationDate()); + this.getBaseMapper().updateById(entity); + return true; + } + + @Override + public void afterFlowHandle(FlowMyBusiness business) { + business.getTaskNameId();//鎺ヤ笅鏉ュ鎵圭殑鑺傜偣 + business.getValues();//鍓嶇浼犺繘鏉ョ殑鍙傛暟 + business.getActStatus(); + } + + @Override + public Object getBusinessDataById(String dataId) { + return this.getById(dataId); + } + + @Override + public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) { + return null; + } + + @Override + public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { + //涓氬姟鏄惁骞查娴佺▼锛屼笟鍔″共棰勶紝娴佺▼骞查锛屾寚瀹氫汉鍛樿繘琛屽鐞� + //鑾峰彇涓嬩竴姝ュ鐞嗕汉 + Object object = values.get("NextAssignee"); + return (List<String>) object; + } } -- Gitblit v1.9.3