From 2cf76b152d6dd556bade813ea843899e7d4ba42e Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期四, 21 八月 2025 09:05:10 +0800 Subject: [PATCH] art: 物料拉动增加发布时间 --- src/main/java/org/jeecg/modules/andon/service/impl/AndonOrderServiceImpl.java | 75 +++++++++++++++++++++++++++++++++++++ 1 files changed, 74 insertions(+), 1 deletions(-) diff --git a/src/main/java/org/jeecg/modules/andon/service/impl/AndonOrderServiceImpl.java b/src/main/java/org/jeecg/modules/andon/service/impl/AndonOrderServiceImpl.java index 1152cfd..e9b6a34 100644 --- a/src/main/java/org/jeecg/modules/andon/service/impl/AndonOrderServiceImpl.java +++ b/src/main/java/org/jeecg/modules/andon/service/impl/AndonOrderServiceImpl.java @@ -1,9 +1,18 @@ package org.jeecg.modules.andon.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.andon.entity.AndonResponseConfig; +import org.jeecg.modules.andon.mapper.AndonResponseConfigMapper; import org.jeecg.modules.andon.service.IAndonOrderService; import org.jeecg.modules.andon.entity.AndonOrder; import org.jeecg.modules.andon.mapper.AndonOrderMapper; +import org.jeecg.modules.feishu.service.FeishuUserService; +import org.jeecg.modules.system.entity.SysUser; +import org.jeecg.modules.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @@ -11,14 +20,78 @@ /** * @Description: 瀹夌伅宸ュ崟 * @Author: jeecg-boot - * @Date: 2025-07-10 + * @Date: 2025-07-10 * @Version: V1.0 */ @Service public class AndonOrderServiceImpl extends ServiceImpl<AndonOrderMapper, AndonOrder> implements IAndonOrderService { + @Autowired + private FeishuUserService feishuService; + @Autowired + private ISysUserService sysUserService; + + @Autowired + private AndonResponseConfigMapper andonResponseConfigMapper; @Override public List<AndonOrder> getAndonOrdersExceptYWC() { return baseMapper.getAndonOrdersExceptYWC(); } + + @Override + public String getPrimaryResponder(AndonOrder andonOrder) { + // 1. 鏍¢獙蹇呰鍙傛暟 + if (StringUtils.isBlank(andonOrder.getFactoryId()) || StringUtils.isBlank(andonOrder.getButtonId())) { + + return null; + } + + // 2. 鏌ヨ鍝嶅簲浜洪厤缃紙鍋囪瀛樺湪鍝嶅簲浜洪厤缃疄浣撳拰Mapper锛� + // 鏋勫缓鏌ヨ鏉′欢锛氬尮閰嶄骇绾縄D銆佸畨鐏被鍨婭D锛屼笖閰嶇疆涓哄惎鐢ㄧ姸鎬� + QueryWrapper<AndonResponseConfig> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("factory_id", andonOrder.getFactoryId()) + .eq("button_id", andonOrder.getButtonId()) + .eq("status", 1) // 1琛ㄧず鍚敤鐘舵�� + .last("limit 1"); // 鍙彇涓�鏉℃湁鏁堥厤缃� + + // 3. 鎵ц鏌ヨ + AndonResponseConfig config = andonResponseConfigMapper.selectOne(queryWrapper); + if (config == null) { + return null; + } + return config.getFirsterResponder(); + } + + @Override + public Result<String> handleAndonOrder(AndonOrder andonOrder) { + + // 璁剧疆宸ュ崟鐘舵�佷负澶勭悊涓� + andonOrder.setOrderStatus("3"); + + // 鑾峰彇鍝嶅簲鑰呯敤鎴峰悕 + String responderUsername = andonOrder.getResponder(); + + // 楠岃瘉鍝嶅簲鑰呯敤鎴峰悕涓嶄负绌� + if (StringUtils.isBlank(responderUsername)) { + return Result.error("鍝嶅簲鑰呬俊鎭笉鑳戒负绌�"); + } + + // 鏍规嵁鐢ㄦ埛鍚嶆煡璇㈢敤鎴蜂俊鎭� + SysUser sysUser = sysUserService.getOne( + new QueryWrapper<SysUser>().eq("username", responderUsername) + ); + + // 楠岃瘉鐢ㄦ埛鏄惁瀛樺湪 + if (sysUser == null) { + return Result.error("鎵句笉鍒扮敤鎴峰悕涓� " + responderUsername + " 鐨勭敤鎴�"); + } + // 璁剧疆鍝嶅簲鑰匢D + andonOrder.setResponder(sysUser.getId()); + andonOrder.setProcessor(sysUser.getId()); + // 鏇存柊宸ュ崟淇℃伅 + this.updateById(andonOrder); + + return Result.OK("澶勭悊鎴愬姛"); + } + } -- Gitblit v1.9.3