3254194295 před 2 roky
rodič
revize
8583310840

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/dto/repair/RepairApplicationFormDTO.java

@@ -27,6 +27,8 @@ import java.util.List;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = true)
 public class RepairApplicationFormDTO extends BaseDTO implements Serializable {
+
+    private Integer roleFlag;
     /**
      * 1:查询报修单,2:查询维修单
      */

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/mapper/repair/RepairApplicationFormMapper.java

@@ -65,4 +65,8 @@ public interface RepairApplicationFormMapper extends MyMapper<RepairApplicationF
     List<RepairApplicationFormVO> getRepairCount(RepairApplicationFormDTO dto);
 
     void updateLongYan(RepairApplicationForm model);
+
+    RepairApplicationFormVO getFirstRepairApplicationFormVO(RepairApplicationFormDTO repairApplicationFormDTO);
+
+    int getRepairCount1(RepairApplicationFormDTO repairApplicationFormDTO);
 }

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/mapper/store/InStoreFormMapper.java

@@ -21,6 +21,10 @@ import java.util.List;
  */
 @Component
 public interface InStoreFormMapper extends MyMapper<InStoreForm> {
+    BigDecimal getInStoreFormCount1(InStoreFormDTO dto);
+
+    InStoreFormVO getRentleInStoreForm(InStoreFormDTO dto);
+
     /**
      * 分页查询
      * @param dto

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/mapper/store/OutStoreFormMapper.java

@@ -23,6 +23,10 @@ import java.util.List;
  */
 @Component
 public interface OutStoreFormMapper extends MyMapper<OutStoreForm> {
+
+    BigDecimal getOutStoreFormCount1(OutStoreFormDTO outStoreFormDTO);
+
+    OutStoreFormVO getRentleOutStoreForm(OutStoreFormDTO outStoreFormDTO);
     /**
      * 分页查询
      * @param dto

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/vo/repair/RepairApplicationFormVO.java

@@ -27,6 +27,8 @@ import java.util.List;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = true)
 public class RepairApplicationFormVO extends BaseVO implements Serializable {
+    private Integer repairCount;
+
     private String name;
     /**
      * 报修人员id
@@ -378,4 +380,6 @@ public class RepairApplicationFormVO extends BaseVO implements Serializable {
      * 二次派工原因
      */
     private String remarkTwo;
+
+    private Integer roleFlag;
 }

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

@@ -316,4 +316,34 @@
         select name from t_sys_dept
         where dept_id=#{id}
     </select>
+
+    <select id="getFirstRepairApplicationFormVO" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
+    resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
+        select * from t_repair_application_form
+        <where>
+            <if test="userId!=null and userId!=''">
+                and user_id=#{userId}
+            </if>
+            <if test="repairUserId!=null and repairUserId!=''">
+                and repair_user_id=#{repairUserId}
+            </if>
+            <if test="dispatchUserId!=null and dispatchUserId!=''">
+                and dispatch_user_id=#{dispatchUserId}
+            </if>
+            <if test="statusList != null and statusList.size > 0">
+                AND status in
+                <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        order by update_time desc
+        limit 1
+    </select>
+
+    <select id="getRepairCount1" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
+            resultType="int">
+        select count(*) from t_repair_application_form
+        where status=#{status} and repair_user_id=#{repairUserId}
+    </select>
 </mapper>

+ 16 - 0
platform-dao/src/main/resources/mapper/store/InStoreFormMapper.xml

@@ -190,5 +190,21 @@ GROUP BY
         where store.store_id=#{storeId}
     </select>
 
+    <select id="getRentleInStoreForm" parameterType="com.platform.dao.dto.store.InStoreFormDTO"
+            resultType="com.platform.dao.vo.query.store.InStoreFormVO">
+        select form.* from t_in_store_form form join t_store store
+        where store.id=form.store_id
+        and user_id=#{userId}
+        order by form.update_time desc
+        limit 1
+    </select>
+
+    <select id="getInStoreFormCount1" parameterType="com.platform.dao.dto.store.InStoreFormDTO"
+            resultType="BigDecimal">
+        select count(1) from t_in_store_form form join t_store store
+        on store.id=form.store_id
+        where user_id=#{userId}
+    </select>
+
 
 </mapper>

+ 16 - 0
platform-dao/src/main/resources/mapper/store/OutStoreFormMapper.xml

@@ -167,4 +167,20 @@
         where store.store_id=#{storeId}
     </select>
 
+    <select id="getRentleOutStoreForm" parameterType="com.platform.dao.dto.store.OutStoreFormDTO"
+            resultType="com.platform.dao.vo.query.store.OutStoreFormVO">
+        select form.* from t_out_store_form form join t_store store
+        where store.id=form.store_id
+        and user_id=#{userId}
+        order by form.update_time desc
+        limit 1
+    </select>
+
+    <select id="getOutStoreFormCount1" parameterType="com.platform.dao.dto.store.OutStoreFormDTO"
+            resultType="BigDecimal">
+        select count(1) from t_out_store_form form join t_store store
+        on store.id=form.store_id
+        where user_id=#{userId}
+    </select>
+
 </mapper>

+ 30 - 0
platform-rest/src/main/java/com/platform/rest/controller/repair/RepairApplicationFormController.java

@@ -1,11 +1,15 @@
 package com.platform.rest.controller.repair;
 
+import com.platform.common.constant.CommonConstants;
+import com.platform.common.model.UserInfo;
 import com.platform.common.util.BeanConverterUtil;
 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.repair.RepairApplicationFormDTO;
 import com.platform.dao.enums.RepairApplicationFormTypeEnum;
+import com.platform.dao.enums.SysRoleCodeEnum;
 import com.platform.dao.util.ExcelUtil;
 import com.platform.dao.vo.NoticeNumberVO;
 import com.platform.dao.vo.export.repair.ExportRepairApplicationFormVO;
@@ -346,4 +350,30 @@ public class RepairApplicationFormController {
         return new R<>(noticeNumberVO);
     }
 
+    @SysLog("获取报修人或维修人或维修主管,或仓库管理员下的‘最近的一个工单")
+    @GetMapping("/getRepairApplicationForm")
+    public R getRepairApplicationForm() {
+//        UserInfo userInfo=new UserInfo();
+//        List list=new ArrayList();
+////        list.add("维修人员");
+//        list.add("workplace_store_manage");
+//        userInfo.setUserId("1");
+//        userInfo.setRoleCodes(list);
+
+        UserInfo userInfo= SecurityUtils.getUserInfo();
+        // 根据用户的角色来定
+        StringBuilder roleCodes = new StringBuilder();
+        userInfo.getRoleCodes().forEach(item-> {
+            roleCodes.append(item).append(",");
+        });
+        String role = roleCodes.toString();
+        if(role.contains(SysRoleCodeEnum.REPAIR_MANAGE.name())||role.contains(SysRoleCodeEnum.REPAIR_EXAMINE.name())||
+                role.contains(SysRoleCodeEnum.Maintenance.name())){
+            return new R(repairApplicationFormService.getRepairApplicationFormVO());
+        }else if(role.contains(CommonConstants.WORKPLACE_STORE_NORMAL)||role.contains(CommonConstants.WORKPLACE_STORE_MANAGE)){
+            return new R(repairApplicationFormService.getStoreForm());
+        }
+        return new R<>(null);
+    }
+
 }

+ 5 - 0
platform-service/src/main/java/com/platform/service/repair/RepairApplicationFormService.java

@@ -1,5 +1,6 @@
 package com.platform.service.repair;
 
+import com.platform.common.util.R;
 import com.platform.dao.bean.MyVOPage;
 import com.platform.dao.dto.check.CheckJobDTO;
 import com.platform.dao.dto.repair.RepairApplicationFormDTO;
@@ -28,6 +29,10 @@ import java.util.List;
  */
 public interface RepairApplicationFormService extends IBaseService<RepairApplicationForm, RepairApplicationFormDTO> {
 
+    public R getStoreForm();
+
+    public RepairApplicationFormVO getRepairApplicationFormVO();
+
     public List<RepairApplicationFormVO> getVOListByDTO(RepairApplicationFormDTO model);
 
     /**

+ 99 - 0
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -22,15 +22,20 @@ import com.platform.dao.dto.check.CheckJobDTO;
 import com.platform.dao.dto.repair.RepairApplicationFormDTO;
 import com.platform.dao.dto.repair.RepairFeeDTO;
 import com.platform.dao.dto.sb.SbInfoDTO;
+import com.platform.dao.dto.store.InStoreFormDTO;
+import com.platform.dao.dto.store.OutStoreFormDTO;
 import com.platform.dao.dto.upms.SysUserDTO;
 import com.platform.dao.entity.repair.RepairApplicationForm;
 import com.platform.dao.entity.repair.RepairReason;
 import com.platform.dao.entity.sb.SbInfo;
+import com.platform.dao.entity.store.InStoreForm;
 import com.platform.dao.entity.upms.SysFile;
 import com.platform.dao.entity.upms.SysUser;
 import com.platform.dao.enums.*;
 import com.platform.dao.mapper.check.CheckJobMapper;
 import com.platform.dao.mapper.repair.*;
+import com.platform.dao.mapper.store.InStoreFormMapper;
+import com.platform.dao.mapper.store.OutStoreFormMapper;
 import com.platform.dao.mapper.upms.SysUserMapper;
 import com.platform.dao.mapper.upms.SysUserRoleMapper;
 import com.platform.dao.mapper.workplace.WorkplaceBacklogMapper;
@@ -40,6 +45,8 @@ import com.platform.dao.vo.SysUserRoleVO;
 import com.platform.dao.vo.SysUserVO;
 import com.platform.dao.vo.query.check.CheckJobVO;
 import com.platform.dao.vo.query.repair.RepairFeeVO;
+import com.platform.dao.vo.query.store.InStoreFormVO;
+import com.platform.dao.vo.query.store.OutStoreFormVO;
 import com.platform.dao.vo.query.workplace.WorkplaceRepairVO;
 import com.platform.dao.vo.repair.RepairApplicationFormVO;
 import com.platform.dao.vo.report.RepairReport24VO;
@@ -94,6 +101,9 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     private final CheckJobMapper checkJobMapper;
     private final WorkplaceBacklogMapper workplaceBacklogMapper;
     private final ActivitiController activitiController;
+    private final InStoreFormMapper inStoreFormMapper;
+    private final OutStoreFormMapper outStoreFormMapper;
+
 
     @Override
     public NoticeNumberVO getNoticeNumberVO() {
@@ -243,6 +253,95 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         return new MyVOPage<>(mapper.selectPageList(record));
     }
 
+    @Override
+    public R getStoreForm() {
+        UserInfo userInfo=SecurityUtils.getUserInfo();
+//        UserInfo userInfo=new UserInfo();
+//        List list=new ArrayList();
+////        list.add("维修人员");
+//        list.add("workplace_store_manage");
+//        userInfo.setUserId("1");
+//        userInfo.setRoleCodes(list);
+//        userInfo.setSuperAdmin(0);
+        InStoreFormDTO inStoreFormDTO=new InStoreFormDTO();
+        inStoreFormDTO.setUserId(userInfo.getUserId());
+        OutStoreFormVO outStoreFormVO=new OutStoreFormVO();
+        InStoreFormVO inStoreFormVO=inStoreFormMapper.getRentleInStoreForm(inStoreFormDTO);
+        BigDecimal count=inStoreFormMapper.getInStoreFormCount1(inStoreFormDTO);
+        if(inStoreFormVO!=null){
+            inStoreFormVO.setInStoreNum(count);
+            return new R(inStoreFormVO);
+        }else{
+            OutStoreFormDTO outStoreFormDTO=new OutStoreFormDTO();
+            outStoreFormDTO.setUserId(userInfo.getUserId());
+            outStoreFormVO=outStoreFormMapper.getRentleOutStoreForm(outStoreFormDTO);
+            if(outStoreFormVO!=null){
+                BigDecimal count1=outStoreFormMapper.getOutStoreFormCount1(outStoreFormDTO);
+                outStoreFormVO.setOutStoreNum(count1);
+                return new R(outStoreFormVO);
+            }else {
+                return null;
+            }
+        }
+    }
+
+    @Override
+    public RepairApplicationFormVO getRepairApplicationFormVO() {
+        RepairApplicationFormDTO repairApplicationFormDTO=new RepairApplicationFormDTO();
+        RepairApplicationFormVO repairApplicationFormVO=new RepairApplicationFormVO();
+        UserInfo userInfo=SecurityUtils.getUserInfo();
+//        UserInfo userInfo=new UserInfo();
+//        List list=new ArrayList();
+//        list.add("维修人员");
+//        list.add("Maintenance");
+//        userInfo.setUserId("629ec2cc6f900a3658c4726f");
+//        userInfo.setRoleCodes(list);
+//        userInfo.setSuperAdmin(0);
+        // 根据用户的角色来定
+        StringBuilder roleCodes = new StringBuilder();
+        userInfo.getRoleCodes().forEach(item-> {
+            roleCodes.append(item).append(",");
+        });
+        String role = roleCodes.toString();
+        if(userInfo.getSuperAdmin() == 0){ // 非超级管理员
+            if(role.contains(SysRoleCodeEnum.REPAIR_MANAGE.name())){
+                // 维修主管
+                repairApplicationFormDTO.setDispatchUserId(userInfo.getUserId());
+                repairApplicationFormDTO.getStatusList().add(RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
+                repairApplicationFormDTO.getStatusList().add(RepairApplicationFormStatusEnum.WAIT_SUBMIT.getValue());
+                repairApplicationFormDTO.setRoleFlag(1);
+            }else if(role.contains(SysRoleCodeEnum.REPAIR_EXAMINE.name())){
+                // 报修+终审
+                repairApplicationFormDTO.setUserId(userInfo.getUserId());
+                repairApplicationFormDTO.getStatusList().add(RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
+                repairApplicationFormDTO.getStatusList().add(RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue());
+                repairApplicationFormDTO.setRoleFlag(2);
+            }else if(role.contains(SysRoleCodeEnum.Maintenance.name())){
+                repairApplicationFormDTO.setRepairUserId(userInfo.getUserId());
+                repairApplicationFormDTO.setRoleFlag(3);
+                repairApplicationFormVO=mapper.getFirstRepairApplicationFormVO(repairApplicationFormDTO);
+                repairApplicationFormVO.setRoleFlag(3);
+            }
+        }
+        int count=0;
+        if(repairApplicationFormVO.getRoleFlag()==3){
+            //获取该用户下所有维修中数字
+            repairApplicationFormDTO.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
+            count=mapper.getRepairCount1(repairApplicationFormDTO);
+            repairApplicationFormVO.setRepairCount(count);
+            return repairApplicationFormVO;
+        }
+        repairApplicationFormVO=mapper.getFirstRepairApplicationFormVO(repairApplicationFormDTO);
+        repairApplicationFormDTO.setStatus(repairApplicationFormVO.getStatus());
+        count=mapper.getRepairCount1(repairApplicationFormDTO);
+        repairApplicationFormVO.setRepairCount(count);
+        return repairApplicationFormVO;
+
+
+    }
+
+
+
     @Override
     public List<RepairApplicationFormVO> getVOListByDTO(RepairApplicationFormDTO model) {
         List<RepairApplicationFormVO> list = mapper.selectPageList(model);