From 1dbc8f9ee50b2979decba91ea177f275c09833b4 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 21 五月 2025 09:03:01 +0800 Subject: [PATCH] art: 设备管理-三保-三保数据库设计变更代码修改 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java | 136 ++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 126 insertions(+), 10 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java index be7c6ea..1f075cc 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java @@ -1,5 +1,6 @@ package org.jeecg.modules.eam.service.impl; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -7,6 +8,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; +import org.flowable.engine.TaskService; +import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.DataBaseConstant; import org.jeecg.common.exception.JeecgBootException; @@ -20,14 +23,19 @@ import org.jeecg.modules.eam.request.EamEquipmentLeanOutQuery; import org.jeecg.modules.eam.service.IEamEquipmentLeanOutService; import org.jeecg.modules.eam.service.IEamEquipmentService; -import org.jeecg.modules.system.service.IMdcProductionService; +import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; +import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; +import org.jeecg.modules.flowable.apithird.service.FlowCommonService; +import org.jeecg.modules.flowable.service.IFlowDefinitionService; +import org.jeecg.modules.flowable.service.IFlowTaskService; +import org.jeecg.modules.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.Arrays; -import java.util.List; +import java.util.*; /** * @Description: 璁惧鍊熷嚭褰掕繕 @@ -35,14 +43,25 @@ * @Date: 2025-05-13 * @Version: V1.0 */ -@Service -public class EamEquipmentLeanOutServiceImpl extends ServiceImpl<EamEquipmentLeanOutMapper, EamEquipmentLeanOut> implements IEamEquipmentLeanOutService { +@Service("IEamEquipmentLeanOutService") +public class EamEquipmentLeanOutServiceImpl extends ServiceImpl<EamEquipmentLeanOutMapper, EamEquipmentLeanOut> implements IEamEquipmentLeanOutService, FlowCallBackServiceI { @Resource private EamEquipmentLeanOutMapper equipmentLeanOutMapper; @Autowired private IEamEquipmentService eamEquipmentService; @Autowired - private IMdcProductionService mdcProductionService; + private FlowCommonService flowCommonService; + @Autowired + private IFlowDefinitionService flowDefinitionService; + @Autowired + private IFlowMyBusinessService flowMyBusinessService; + @Autowired + private TaskService taskService; + @Autowired + private IFlowTaskService flowTaskService; + + @Autowired + private ISysUserService sysUserService; @Override public IPage<EamEquipmentLeanOut> queryPageList(Page<EamEquipmentLeanOut> page, EamEquipmentLeanOutQuery query) { @@ -130,7 +149,7 @@ if (entity == null) { throw new JeecgBootException("瑕佺紪杈戠殑鏁版嵁涓嶅瓨鍦紝璇峰埛鏂伴噸璇曪紒"); } - if(!EquipmentLeanOutStatusEnum.WAIT_SUBMIT.name().equals(entity.getLeanStatus())) { + if (!EquipmentLeanOutStatusEnum.WAIT_SUBMIT.name().equals(entity.getLeanStatus())) { throw new JeecgBootException("褰撳墠鏁版嵁鐘舵�佷笉鍏佽缂栬緫锛�"); } //妫�鏌ヨ澶� @@ -168,7 +187,7 @@ if (entity == null) { throw new JeecgBootException("瑕佹彁浜ょ殑鏁版嵁涓嶅瓨鍦紝璇峰埛鏂伴噸璇曪紒"); } - if(!EquipmentLeanOutStatusEnum.WAIT_SUBMIT.name().equals(entity.getLeanStatus())) { + if (!EquipmentLeanOutStatusEnum.WAIT_SUBMIT.name().equals(entity.getLeanStatus())) { throw new JeecgBootException("褰撳墠鏁版嵁鐘舵�佷笉鍏佽缂栬緫锛�"); } //妫�鏌ヨ澶� @@ -188,11 +207,108 @@ updateWrapper.eq("id", id); updateWrapper.eq("lean_person", sysUser.getUsername()); boolean success = super.update(updateWrapper); - if(success) { + if (success) { equipment.setAssetStatus(AssetStatusEnum.LEAN_OUT.name()); eamEquipmentService.updateById(equipment); } - //鍚姩瀹℃壒娴佺▼ TODO + //鍚姩瀹℃壒娴佺▼ + flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getCode() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧鍊熺敤", + entity.getId(), "IEamEquipmentLeanOutService", "equipment_lean_out", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", entity.getId()); + if (StrUtil.isEmpty(entity.getLeanReason())) { + variables.put("organization", "鏂板鍊熺敤宸ュ崟榛樿鍚姩娴佺▼"); + variables.put("comment", "鏂板鍊熺敤宸ュ崟榛樿鍚姩娴佺▼"); + } else { + variables.put("organization", entity.getLeanReason()); + variables.put("comment", entity.getLeanReason()); + } + variables.put("proofreading", true); + List<String> usernames = new ArrayList<>(); + usernames.add(equipment.getEquipmentManager()); + variables.put("NextAssignee", usernames); + Result result = flowDefinitionService.startProcessInstanceByKey("equipment_lean_out", variables); + if (result != null) { + return result.isSuccess(); + } return true; } + + @Override + @Transactional(rollbackFor = Exception.class) + public EamEquipmentLeanOut approval(EamEquipmentLeanOut eamEquipmentLeanOut) { + try { + // 妫�鏌ヨ姹傚弬鏁� + if (!isValidRequest(eamEquipmentLeanOut)) { + throw new JeecgBootException("闈炴硶鍙傛暟"); + } + if (EquipmentLeanOutStatusEnum.WAIT_APPROVAL.name().equals(eamEquipmentLeanOut.getLeanStatus())) { + eamEquipmentLeanOut.setLeanStatus(EquipmentLeanOutStatusEnum.WAIT_RETURN.name()); + // 寰呭綊杩� + } else if (EquipmentLeanOutStatusEnum.WAIT_RETURN.name().equals(eamEquipmentLeanOut.getLeanStatus())) { + // 寰呯‘璁� + eamEquipmentLeanOut.setLeanStatus(EquipmentLeanOutStatusEnum.WAIT_CONFIRM.name()); + } else if (EquipmentLeanOutStatusEnum.WAIT_CONFIRM.name().equals(eamEquipmentLeanOut.getLeanStatus())) { + // 宸插畬鎴� + eamEquipmentLeanOut.setLeanStatus(EquipmentLeanOutStatusEnum.COMPLETE.name()); + } + // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛 + LoginUser sysUser = getCurrentUser(); + if (sysUser == null || StrUtil.isBlank(sysUser.getId())) { + throw new JeecgBootException("璐﹀彿涓嶅瓨鍦�"); + } + // 瀹℃壒浜� + eamEquipmentLeanOut.setApprovalUser(sysUser.getUsername()); + //妫�鏌ヨ澶� + EamEquipment equipment = eamEquipmentService.getById(eamEquipmentLeanOut.getEquipmentId()); + if (equipment == null) { + throw new JeecgBootException("璁惧涓嶅瓨鍦紒"); + } + eamEquipmentLeanOut.setLeanPerson(sysUser.getUsername()); + this.updateById(eamEquipmentLeanOut); + // 鑾峰彇娴佺▼涓氬姟璁板綍 + return eamEquipmentLeanOut; + } catch (Exception e) { + throw new JeecgBootException("鎿嶄綔澶辫触锛�" + e.getMessage()); + } + } + + + @Override + public void afterFlowHandle(FlowMyBusiness business) { + business.getTaskNameId();//鎺ヤ笅鏉ュ鎵圭殑鑺傜偣 + business.getValues();//鍓嶇浼犺繘鏉ョ殑鍙傛暟 + business.getActStatus(); + } + + + private boolean isValidRequest(EamEquipmentLeanOut request) { + return StrUtil.isNotBlank(request.getCode()) && StrUtil.isNotBlank(request.getEquipmentId()); + } + + private LoginUser getCurrentUser() { + try { + return (LoginUser) SecurityUtils.getSubject().getPrincipal(); + } catch (Exception e) { + return null; + } + } + + @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