Ver código fonte

feature 代码提交
1.增加获取排程状态信息的接口

xiahan 1 ano atrás
pai
commit
b7e914ce49

+ 2 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/GanttService.java

@@ -18,4 +18,6 @@ public interface GanttService {
                          List<String> productionLineId,List<String> equId,String  productionLineName,String  equName);
 
     List<ScheduleGanttVo> getListById(List<String> ids);
+
+    R getSchedulingState(String factoryId);
 }

+ 54 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/GanttServiceImpl.java

@@ -4,14 +4,22 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.rongwei.bscommon.sys.dao.ApsProcessOperationProcessEquDao;
+import com.rongwei.bscommon.sys.service.ApsProcessOperationBackupService;
 import com.rongwei.bscommon.sys.service.ApsProcessOperationService;
 import com.rongwei.bscommon.sys.service.GanttService;
+import com.rongwei.bsentity.domain.ApsProcessOperationBackupDo;
 import com.rongwei.bsentity.domain.ApsProcessOperationDo;
 import com.rongwei.bsentity.vo.GanttVos;
 import com.rongwei.bsentity.vo.ScheduleGanttVo;
+import com.rongwei.commonservice.service.RedisService;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommon.base.BaseDo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
+import com.rongwei.safecommon.utils.CXCommonUtils;
 import org.apache.commons.lang.StringUtils;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -50,11 +58,19 @@ public class GanttServiceImpl implements GanttService {
     public static final String DEFAULT_TYPE = "project";
     public static final String DEFAULT_RENDER = "split";
     public static final String COMBINED_PROCESSING = "合并加工";
+    public static final String SCHEDULING_STR = "%s-正在排程";
+    public static final String SCHEDULING_TO_BE_PUBLISHED_STR = "%s-排程结束待发布";
     private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
     @Autowired
     private ApsProcessOperationProcessEquDao apsProcessOperationProcessEquDao;
     @Autowired
     private ApsProcessOperationService apsProcessOperationService;
+    @Autowired
+    private RedissonClient redissonClient;
+    @Autowired
+    private RedisService redisService;
+    @Autowired
+    private ApsProcessOperationBackupService apsProcessOperationBackupService;
 
     /**
      * 根据条件获取gantt
@@ -143,6 +159,44 @@ public class GanttServiceImpl implements GanttService {
         return assembleGanttData(apsProcessOperationProcessEquDos);
     }
 
+    /**
+     * 获取排程状态信息
+     *
+     * @return
+     */
+    @Override
+    public R getSchedulingState(String factoryId) {
+        log.info("开始获取排程状态");
+        if (StringUtils.isBlank(factoryId)) {
+            SysUserVo currentUser = CXCommonUtils.getCurrentUser();
+            factoryId = currentUser.getOrganizationDoList().get(0).getFullpid().split(",")[1];
+        }
+        log.debug("判断工厂:{}是否正在排程", factoryId);
+        RLock rLock = redissonClient.getLock(factoryId);
+        log.debug("是否正在排程:{}", rLock.isLocked());
+        //正在排程直接返回
+        if (rLock.isLocked()) {
+            try {
+                SysUserVo sysUserVo = (SysUserVo) redisService.getRedisCatchObj("apsUser-" + factoryId);
+                return R.ok(String.format(SCHEDULING_STR, sysUserVo.getName()));
+            } catch (Exception e) {
+                log.error("获取当前排程用户失败,原因:{}", e.toString());
+                return R.error("获取排程用户失败,请联系管理员");
+            }
+
+        }
+        // 判断是否存在备份信息
+        List<ApsProcessOperationBackupDo> backUpInfo = apsProcessOperationBackupService.list(new LambdaQueryWrapper<ApsProcessOperationBackupDo>()
+                .eq(BaseDo::getDeleted, 0).eq(ApsProcessOperationBackupDo::getTenantid, factoryId));
+        if (backUpInfo.isEmpty()) {
+            log.debug("不存在排程备份信息");
+            // 不存在备份信息 直接返回
+            return R.ok("");
+        }
+        ApsProcessOperationBackupDo backupDo = backUpInfo.stream().filter(info -> StringUtils.isNotBlank(info.getBackupuser())).findFirst().get();
+        return R.ok(String.format(SCHEDULING_TO_BE_PUBLISHED_STR, backupDo.getBackupuser()));
+    }
+
     public String dateFormat(Date date) {
         if (date == null) {
             return "";

+ 19 - 5
cx-aps/cx-aps-server/src/main/java/com/rongwei/bsserver/controller/GanttController.java

@@ -29,6 +29,7 @@ public class GanttController {
 
     /**
      * 根据条件获取甘特图相关信息
+     *
      * @return
      */
     @GetMapping("/list")
@@ -36,44 +37,57 @@ public class GanttController {
     public R updateRelevantInformation(@RequestParam(name = "startTime", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date searchDate,
                                        @RequestParam(name = "factoryId") String factoryId,
                                        @RequestParam(name = "workshopId", required = false) String workshopId,
-                                       @RequestParam(name = "orderNo",required = false) String orderNo) {
+                                       @RequestParam(name = "orderNo", required = false) String orderNo) {
 //        return ganttService.getListByCondition(searchDate, factoryId, workshopId,orderNo);
         return R.ok();
     }
 
     /**
      * 根据条件获取甘特图相关信息
+     *
      * @param processGanttListVo
      * @return
      */
     @PostMapping("/processGanttList")
     public R processGanttList(@RequestBody ProcessGanttListVo processGanttListVo) {
-        return ganttService.getListByCondition(processGanttListVo.getStartTime(),processGanttListVo.getEndTime(), processGanttListVo.getFactoryId(),
+        return ganttService.getListByCondition(processGanttListVo.getStartTime(), processGanttListVo.getEndTime(), processGanttListVo.getFactoryId(),
                 processGanttListVo.getWorkshopId(), processGanttListVo.getOrderNo(),
                 processGanttListVo.getProductionLineId(), processGanttListVo.getEquId(),
-                processGanttListVo.getProductionLineName(),processGanttListVo.getEquName());
+                processGanttListVo.getProductionLineName(), processGanttListVo.getEquName());
     }
 
     /**
      * 获取下个作业(可能有多个)
+     *
      * @param ganttVosList
      * @return
      */
     @PostMapping("/getNextProcess")
-    public R getNextProcess(@RequestBody List<GanttVos> ganttVosList){
+    public R getNextProcess(@RequestBody List<GanttVos> ganttVosList) {
         List<GanttVos> nexts = ganttService.getNextProcess(ganttVosList, "next");
         return R.ok(nexts);
     }
 
     /**
      * 获取上个作业(可能有多个)
+     *
      * @param ganttVosList
      * @return
      */
     @PostMapping("/getPreProcess")
-    public R getPreProcess(@RequestBody List<GanttVos> ganttVosList){
+    public R getPreProcess(@RequestBody List<GanttVos> ganttVosList) {
         List<GanttVos> pres = ganttService.getNextProcess(ganttVosList, "pre");
         return R.ok(pres);
     }
 
+    /**
+     * 获取排程状态信息
+     *
+     * @return
+     */
+    @GetMapping("/scheduling/state")
+    public R getSchedulingState(@RequestParam(name = "factoryId",required = false) String factoryId) {
+        return ganttService.getSchedulingState(factoryId);
+    }
+
 }