xiongchao 3 роки тому
батько
коміт
6822b3cf3c

+ 22 - 0
platform-common/src/main/java/com/platform/common/util/DateUtils.java

@@ -34,6 +34,28 @@ public class DateUtils {
 
     private final static ZoneId ZONE_ID = ZoneId.systemDefault();
 
+    /**
+     * 当前时间所在一周的周一时间:00:00:00
+     *
+     * @return
+     */
+    public static LocalDateTime getTodayStartTime() {
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime monday = now.withHour(0).withMinute(0).withSecond(0);
+        return monday;
+    }
+
+    /**
+     * 得到本周周日:23:59:59
+     *
+     * @return yyyy-MM-dd
+     */
+    public static LocalDateTime getTodayEndTime() {
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime sunday = now.withHour(23).withMinute(59).withSecond(59);
+        return sunday;
+    }
+
     /**
      * 当前时间所在一周的周一时间:00:00:00
      *

+ 11 - 0
platform-common/src/main/java/com/platform/common/util/SecurityUtils.java

@@ -119,6 +119,17 @@ public class SecurityUtils {
         throw new BusinessException(ResultCode.BUSINESS_SIGN_IN_STATUS);
     }
 
+    /**
+     * 检查并获取用户,未登录不抛出异常
+     */
+    public OauthUser checkAndGetUser() {
+        Authentication authentication = getAuthentication();
+        if (authentication == null) {
+            return null;
+        }
+        return getUser(authentication);
+    }
+
     /**
      * 获取用户
      */

+ 4 - 1
platform-dao/src/main/java/com/platform/dao/dto/check/CheckJobDTO.java

@@ -24,7 +24,10 @@ import java.util.List;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = true)
 public class CheckJobDTO extends BaseDTO implements Serializable {
-
+    /**
+     * 实际执行人姓名
+     */
+    private String actualUser;
     /**
      * 主键
      */

+ 4 - 1
platform-dao/src/main/java/com/platform/dao/entity/check/CheckJob.java

@@ -24,7 +24,10 @@ import javax.persistence.Transient;
 @Accessors(chain = true)
 @Table(name = "t_check_job")
 public class CheckJob implements Serializable {
-
+    /**
+     * 实际执行人姓名
+     */
+    private String actualUser;
     /**
      * 主键
      */

+ 3 - 1
platform-dao/src/main/java/com/platform/dao/entity/repair/RepairApplicationForm.java

@@ -208,7 +208,9 @@ public class RepairApplicationForm implements Serializable {
      * 更新人
      */
     private String updateUserId;
-
+    /**
+     * 实际执行人姓名
+     */
     private String actualUser;
 
     /**

+ 4 - 1
platform-dao/src/main/java/com/platform/dao/vo/query/check/CheckJobVO.java

@@ -23,7 +23,10 @@ import java.util.List;
 @Data
 @Accessors(chain = true)
 public class CheckJobVO implements Serializable{
-
+    /**
+     * 实际执行人姓名
+     */
+    private String actualUser;
     /**
      * 主键
      */

+ 5 - 1
platform-dao/src/main/resources/mapper/check/CheckJobMapper.xml

@@ -8,6 +8,7 @@
                                      checkstandard.real_hours,
                                      checkjob.start_time,
                                      checkjob.end_time,
+                                     checkjob.actual_user,
                                      checkjob.type,
                                      checkjob.actual_start_time,
                                      checkjob.actual_end_time,
@@ -22,7 +23,7 @@
                                      checkjob.update_time
                         </sql>
     <sql id="Ref_Column_List">
-                                     checkjob.plan_id,
+                                     checkjob.plan_id,checkjob.actual_user,
                                      checkstandard.standard_hours,
                                      checkstandard.real_hours,
                                      checkjob.start_time,
@@ -163,6 +164,9 @@
         <if test="checkUserName != null and checkUserName != ''">
             and u.real_name like concat('%',#{checkUserName},'%')
         </if>
+        <if test="actualUser != null and actualUser != ''">
+            and checkjob.actual_user like concat('%',#{actualUser},'%')
+        </if>
     </sql>
     <select id="selectList" parameterType="com.platform.dao.dto.check.CheckJobDTO"
             resultType="com.platform.dao.vo.query.check.CheckJobVO">

+ 3 - 0
platform-dao/src/main/resources/mapper/repair/RepairApplicationFormMapper.xml

@@ -4,6 +4,7 @@
     <sql id="Base_Column_List">
         application.*,
         user.real_name as userName,
+        user2.real_name as repairUserName,
         sb.name as sbName,part.name as partName,
         sb.no as sbNo, sb.cph as sbCph, sb.model_id as modelId,
         error.name as repairErrorTypeName
@@ -14,6 +15,7 @@
         <include refid="Base_Column_List"/>
         from t_repair_application_form application
         left join t_sys_user user on application.user_id = user.user_id
+        left join t_sys_user user2 on application.repair_user_id = user2.user_id
         left join t_sb_info sb on application.sb_id = sb.id
         left join t_error_type error on application.repair_error_type_id = error.id
         left join t_part_info part on application.part_id = part.id
@@ -78,6 +80,7 @@
         <include refid="Base_Column_List"/>
         from t_repair_application_form application
         left join t_sys_user user on application.user_id = user.user_id
+        left join t_sys_user user2 on application.repair_user_id = user2.user_id
         left join t_sb_info sb on application.sb_id = sb.id
         left join t_part_info part on application.part_id = part.id
         left join t_error_type error on application.repair_error_type_id = error.id

+ 4 - 5
platform-rest/src/main/java/com/platform/rest/controller/check/CheckJobController.java

@@ -112,7 +112,6 @@ public class CheckJobController {
       return new R<>(checkJobService.selectPageList(checkJobDTO, pageNum, pageSize));
   }
 
-
   /**
    * 获取列表
    *
@@ -160,7 +159,7 @@ public class CheckJobController {
   }
 
   /**
-   * 执行点检任务
+   * 接收点检任务
    *
    * @param checkJobDTO 点检任务DTO
    * @return R
@@ -174,7 +173,7 @@ public class CheckJobController {
   }
 
   /**
-   * 修改任务
+   * 完成任务
    *
    * @param checkJobDTO 点检任务DTO
    * @return R
@@ -189,7 +188,7 @@ public class CheckJobController {
 
 
     /**
-     * 修改记录
+     * 批量接收
      *
      * @param ids
      * @return R
@@ -203,7 +202,7 @@ public class CheckJobController {
     }
 
     /**
-     * 修改记录
+     * 批量完成
      *
      * @param ids
      * @return R

+ 53 - 0
platform-rest/src/main/java/com/platform/rest/controller/mobile/IgnoreController.java

@@ -7,6 +7,7 @@ import com.platform.common.util.R;
 import com.platform.common.util.SecurityUtils;
 import com.platform.common.validation.group.AddGroup;
 import com.platform.common.validation.group.UpdateGroup;
+import com.platform.dao.dto.check.CheckJobDTO;
 import com.platform.dao.dto.repair.RepairApplicationFormDTO;
 import com.platform.dao.dto.sb.SbInfoDTO;
 import com.platform.dao.entity.sb.SbInfo;
@@ -18,6 +19,7 @@ import com.platform.dao.util.TreeUtil;
 import com.platform.dao.vo.export.sb.ExportSbInfoMeasureVO;
 import com.platform.dao.vo.export.sb.ExportSbInfoVO;
 import com.platform.dao.vo.index.GatherTaskVO;
+import com.platform.dao.vo.query.check.CheckJobVO;
 import com.platform.dao.vo.sb.SbInfoVO;
 import com.platform.office.poi.excel.ExcelImportUtil;
 import com.platform.office.poi.excel.entity.ImportParams;
@@ -100,4 +102,55 @@ public class IgnoreController {
         return R.success(new GatherTaskVO().setLubricationTask(lubricationTask).setRepairTask(repairTask));
     }
 
+    /**
+     * 通过id查询单条任务
+     *
+     * @param id 主键
+     * @return R
+     */
+    @GetMapping("/check/jobs/{id}")
+    public R<CheckJobVO> getCheckJobById(@PathVariable("id") String id){
+        return new R<>(checkJobService.getDetail(id));
+    }
+
+    /**
+     * 获取现场保养任务分页
+     *
+     * @param pageNum 当前页码
+     * @param pageSize 每页条数
+     * @param checkJobDTO 点检任务DTO
+     * @return R
+     */
+    @GetMapping("/check/jobs/page")
+    public R<AbstractPageResultBean<CheckJobVO>> query(CheckJobDTO checkJobDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
+        return new R<>(checkJobService.selectPageListMobile(checkJobDTO, pageNum, pageSize));
+    }
+
+    /**
+     * 接收点检任务
+     *
+     * @param checkJobDTO 点检任务DTO
+     * @return R
+     */
+    @SysLog("接收点检任务")
+    @PutMapping("/check/jobs/execute")
+    @PreAuthorize("@pms.hasPermission('check-polling-jobs-edit')")
+    public R executeJob(@Validated({UpdateGroup.class}) @RequestBody CheckJobDTO checkJobDTO) {
+        checkJobService.executeJob(checkJobDTO.getId());
+        return new R<>();
+    }
+
+    /**
+     * 完成任务
+     *
+     * @param checkJobDTO 点检任务DTO
+     * @return R
+     */
+    @SysLog("完成点检任务")
+    @PutMapping("/check/jobs/finish")
+    @PreAuthorize("@pms.hasPermission('check-polling-jobs-edit')")
+    public R finishJob(@Validated({UpdateGroup.class}) @RequestBody CheckJobDTO checkJobDTO) {
+        checkJobService.finishJob(checkJobDTO);
+        return new R<>();
+    }
 }

+ 10 - 0
platform-service/src/main/java/com/platform/service/check/CheckJobService.java

@@ -35,6 +35,16 @@ public interface CheckJobService extends IBaseService<CheckJob, CheckJobDTO> {
      */
     AbstractPageResultBean<CheckJobVO> selectPageList(CheckJobDTO record, int pageNum, int pageSize);
 
+    /**
+     * 分页查询
+     *
+     * @param record
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    AbstractPageResultBean<CheckJobVO> selectPageListMobile(CheckJobDTO record, int pageNum, int pageSize);
+
     /**
      * 统计数量
      *

+ 58 - 7
platform-service/src/main/java/com/platform/service/check/impl/CheckJobServiceImpl.java

@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
 import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.common.enums.DataFilterTypeEnum;
 import com.platform.common.exception.BusinessException;
+import com.platform.common.model.OauthUser;
 import com.platform.common.model.UserInfo;
 import com.platform.common.util.*;
 import com.platform.dao.bean.MyPage;
@@ -100,6 +101,31 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
         return new MyPage(mapper.selectList(model));
     }
 
+    /**
+     *
+     * 获取当日移动端现场任务:当日的任务
+     * 如果有sbId,则说明是查询某一台设备的任务,需要查询设备的显示使用人员账号
+     * @param model
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @Override
+    public AbstractPageResultBean<CheckJobVO> selectPageListMobile(CheckJobDTO model, int pageNum, int pageSize) {
+
+        // 查询设备的使用人员账户,通过该账户查询查询任务,状态不限制
+        SbInfo sbInfo = sbInfoService.getModelById(model.getSbId());
+        if(sbInfo != null){
+            if(sbInfo.getSaveUser() != null){
+                model.setCheckUserId(sbInfo.getSaveUser());
+            }
+        }
+        model.setSearchStartTime(DateUtils.getTodayStartTime());
+        model.setSearchEndTime(DateUtils.getTodayEndTime());
+        PageHelper.startPage(pageNum, pageSize);
+        return new MyPage(mapper.selectList(model));
+    }
+
     @Override
     public List<CheckJob> getModelListByDTO(CheckJobDTO model) {
         if (model.getFilter() != null && DataFilterTypeEnum.SELF.getValue() == model.getFilter().intValue()) {
@@ -690,10 +716,20 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
         }
         checkJob.setStatus(CheckJobStatusEnum.EXECUTING.getValue());
         checkJob.setActualStartTime(LocalDateTime.now());
-        UserInfo userInfo = SecurityUtils.getUser().getUserInfo();
-        checkJob.setUpdateTime(LocalDateTime.now());
-        checkJob.setUpdateUserId(userInfo.getUserId());
-        checkJob.setUpdateUserName(userInfo.getUsername());
+
+        OauthUser oauthUser = SecurityUtils.checkAndGetUser();
+        if(oauthUser==null){// 未登录,获取设备的使用人员
+            SbInfoVO sbInfoVO = sbInfoService.getById(checkJob.getSbId());
+            if (sbInfoVO == null) {
+                throw new BusinessException("设备不存在,无法完成任务");
+            }
+            checkJob.setUpdateUserId(sbInfoVO.getSaveUser());
+            checkJob.setUpdateUserName(sbInfoVO.getSaveUserName());
+        }else{
+            UserInfo userInfo = SecurityUtils.getUser().getUserInfo();
+            checkJob.setUpdateUserId(userInfo.getUserId());
+            checkJob.setUpdateUserName(userInfo.getUsername());
+        }
         mapper.updateByPrimaryKeySelective(checkJob);
     }
 
@@ -702,6 +738,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
      * 公
      * 里和台时的任务,需要定时器每天晚上定时来跑
      *
+     *  如果是移动端的,未登录,不需要获取用户信息,
      * @param dto
      */
     @Override
@@ -715,10 +752,21 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
         checkJob.setStatus(CheckJobStatusEnum.FINISHED.getValue());
         checkJob.setActualEndTime(now);
         checkJob.setRealHours(DateUtils.getDurationMinutes(checkJob.getActualStartTime(), checkJob.getActualEndTime()) + "");
-        UserInfo userInfo = SecurityUtils.getUser().getUserInfo();
+        OauthUser oauthUser = SecurityUtils.checkAndGetUser();
+        if(oauthUser==null){// 未登录,在获取设备的使用人员
+            SbInfoVO sbInfoVO = sbInfoService.getById(checkJob.getSbId());
+            if (sbInfoVO == null) {
+                throw new BusinessException("设备不存在,无法完成任务");
+            }
+            checkJob.setUpdateUserId(sbInfoVO.getSaveUser());
+            checkJob.setUpdateUserName(sbInfoVO.getSaveUserName());
+        }else{
+            UserInfo userInfo = SecurityUtils.getUser().getUserInfo();
+            checkJob.setUpdateUserId(userInfo.getUserId());
+            checkJob.setUpdateUserName(userInfo.getUsername());
+        }
         checkJob.setUpdateTime(now);
-        checkJob.setUpdateUserId(userInfo.getUserId());
-        checkJob.setUpdateUserName(userInfo.getUsername());
+
         // checkJob.setSbStatus(dto.getSbStatus());
         checkJob.setFeedback(dto.getFeedback());
         mapper.updateByPrimaryKeySelective(checkJob);
@@ -799,6 +847,9 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
         if(status !=null){
             weekendCriteria.andIn(CheckJob::getStatus, status);
         }
+
+        // 查询当日的任务数
+        weekendCriteria.andBetween(CheckJob::getStartTime, DateUtils.getTodayStartTime(), DateUtils.getTodayEndTime());
         return mapper.selectCountByExample(weekend);
     }
 

+ 8 - 18
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -191,16 +191,12 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
         weekend.weekendCriteria().andIsNotNull(RepairApplicationForm::getId).andEqualTo(RepairApplicationForm::getType, model.getType());
         int count = mapper.selectCountByExample(weekend);
-       /* UserInfo userInfo = SecurityUtils.getUserInfo();
-
-        // 未登录
-        if(userInfo != null){
-            model.setUserId(userInfo.getUserId());
-            if(StringUtils.isBlank(model.getActualUser())){
-                model.setActualUser(userInfo.getRealName());
-            }
-        }*/
-
+        // 查询对应的维修人,保存维修单
+        String sbId = model.getSbId();
+        SbInfoVO sb = sbInfoService.getById(sbId);
+        if (sb== null) {
+            throw new BusinessException("设备不存在,无法报修");
+        }
         if(StringUtils.isBlank(model.getActualUser())){
             UserInfo userInfo = SecurityUtils.getUserInfo();
             model.setUserId(userInfo.getUserId());
@@ -210,7 +206,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             sysUser.setRealName(model.getActualUser());
             SysUser sysUser1 = sysUserService.getModelByModel(sysUser);
             if(sysUser1 == null){
-                model.setUserId("1");
+                // 设置设备的使用人
+                model.setUserId(sb.getSaveUser());
             }else{
                 model.setUserId(sysUser1.getUserId());
             }
@@ -220,13 +217,6 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             model.setSource(1);
         }
 
-        // 查询对应的维修人,保存维修单
-        String sbId = model.getSbId();
-        SbInfoVO sb = sbInfoService.getById(sbId);
-        if (sb== null) {
-            throw new BusinessException("设备不存在,无法报修");
-        }
-
         model.setModelId(sb.getModelId());
         // 根据配置判断是否可以多个提交
         String only = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_ONLY_ONE.name());