Explorar o código

Merge branch 'dev' of http://192.168.1.43:3000/v2/zd-parents into dev

chaiyunlong %!s(int64=2) %!d(string=hai) anos
pai
achega
a7388ebd39

+ 22 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabXxpDutyController.java

@@ -5,6 +5,7 @@ import com.zd.common.core.annotation.PreAuthorize;
 import com.zd.common.core.log.BusinessType;
 import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.ExcelUtil;
+import com.zd.common.core.utils.StringUtils;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.laboratory.domain.LabWhitelist;
 import com.zd.laboratory.domain.XxpDuty;
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -100,6 +102,26 @@ public class LabXxpDutyController extends BaseController
 
 
     /**
+     * 根据时间获取值班详情
+     */
+    @ApiOperation(value = "根据时间获取值班详情")
+    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_DUTY + PerFun.QUERY)
+    @GetMapping(value = "/getInfoByDate")
+    public TableDataInfo<XxpDutyVO> getInfoByDate(XxpDuty xxpDuty)
+    {
+        startPage();
+        List<XxpDutyVO> listVo = xxpDutyService.selectInfoByDate(xxpDuty);
+        XxpDuty newDuty = new XxpDuty();
+        for (XxpDutyVO duty:listVo) {
+            newDuty.setSubjectId(duty.getSubjectId());
+            newDuty.setDutyTime(xxpDuty.getDutyTime());
+            List<XxpDuty> list =xxpDutyService.selectXxpDutyList(newDuty);
+            duty.setDutyList(list);
+        }
+        return getDataTable(listVo);
+    }
+
+    /**
      * 新增值班
      */
     @ApiOperation(value = "新增值班")

+ 43 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabXxpInspectionController.java

@@ -9,6 +9,7 @@ import com.zd.common.core.web.controller.BaseController;
 import com.zd.laboratory.domain.LabWhitelist;
 import com.zd.laboratory.domain.XxpClassify;
 import com.zd.laboratory.domain.XxpInspection;
+import com.zd.laboratory.domain.vo.XxpInspectionVO;
 import com.zd.laboratory.service.IXxpClassifyService;
 import com.zd.laboratory.service.IXxpInspectionService;
 import com.zd.model.domain.ResultData;
@@ -22,7 +23,8 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 巡查Controller
@@ -55,6 +57,46 @@ public class LabXxpInspectionController extends BaseController
     }
 
     /**
+     * 查询巡查列表(根据时间段)
+     */
+    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_XXP_INSPECTION + PerFun.LIST)
+    @GetMapping("/listYmd")
+    @ApiOperation(value = "查询巡查列表")
+    public List<XxpInspectionVO> listYmd(XxpInspectionVO inspectionVO)
+    {
+        Map<String,XxpInspectionVO> allMap = new LinkedHashMap<>();
+        //startPage();
+        //获取时间段内签到人员总数
+        List<XxpInspectionVO> signinList = xxpInspectionService.selectListSignin(inspectionVO);
+        Optional.ofNullable(signinList).orElseGet(Collections::emptyList)
+                .stream()
+                .forEach(a->{
+                    a.setNoSignedInCount(0);
+                    allMap.put(a.getDutyTime(),a);
+                });
+
+        //获取时间段内签到人员总数
+        List<XxpInspectionVO> notSigninLlist = xxpInspectionService.selectListNotSignin(inspectionVO);
+        Optional.ofNullable(notSigninLlist).orElseGet(Collections::emptyList)
+                .stream()
+                .forEach(a->{
+                    if(allMap.get(a.getDutyTime())!=null){
+                        XxpInspectionVO newInspectionVo = allMap.get(a.getDutyTime());
+                        newInspectionVo.setNoSignedInCount(a.getNoSignedInCount());
+                        allMap.put(a.getDutyTime(),newInspectionVo);
+                    }else{
+                        a.setSignInCount(0);
+                        allMap.put(a.getDutyTime(),a);
+                    }
+
+                });
+        return Optional.ofNullable(allMap.entrySet()).orElseGet(Collections::emptySet)
+                .stream()
+                .map(a->a.getValue())
+                .collect(Collectors.toList());
+    }
+
+    /**
      * 导出巡查列表
      */
     @ApiOperation(value = "导出巡查列表")

+ 34 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/XxpInspectionVO.java

@@ -0,0 +1,34 @@
+package com.zd.laboratory.domain.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.zd.laboratory.domain.XxpInspection;
+import com.zd.model.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @Author: xxf
+ * @Date: 2023/03/27/15:44
+ * @Description:
+ */
+@Data
+public class XxpInspectionVO extends XxpInspection {
+
+    /**
+     * 签到总数
+     */
+    private Integer signInCount;
+
+    /**
+     * 未签到总数
+     */
+    private Integer noSignedInCount;
+    /**
+     * 值班时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private String dutyTime;
+
+}

+ 7 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/XxpDutyMapper.java

@@ -76,4 +76,11 @@ public interface XxpDutyMapper
      * @return
      */
     public XxpDutyVO selectSubAndUserSum(Date dutyTime);
+
+    /***
+     * 根据时间查询实验室
+     * @param xxpDuty
+     * @return
+     */
+    public List<XxpDutyVO> selectInfoByDate(XxpDuty xxpDuty);
 }

+ 16 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/XxpInspectionMapper.java

@@ -2,6 +2,7 @@ package com.zd.laboratory.mapper;
 
 import com.zd.laboratory.domain.XxpClassify;
 import com.zd.laboratory.domain.XxpInspection;
+import com.zd.laboratory.domain.vo.XxpInspectionVO;
 
 import java.util.List;
 
@@ -61,4 +62,19 @@ public interface XxpInspectionMapper
      * @return 结果
      */
     public int deleteXxpInspectionByIds(Long[] ids);
+
+    /***
+     * 查询某时间段内签到人数集合
+     * @param inspectionVO
+     * @return
+     */
+    public List<XxpInspectionVO> selectListSignin(XxpInspectionVO inspectionVO);
+
+    /***
+     * 查询某时间段内未签到人数集合
+     * @param inspectionVO
+     * @return
+     */
+    public List<XxpInspectionVO> selectListNotSignin(XxpInspectionVO inspectionVO);
+
 }

+ 7 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/IXxpDutyService.java

@@ -79,4 +79,11 @@ public interface IXxpDutyService
      * @return
      */
     public XxpDutyVO selectSubAndUserSum(Date dutyTime);
+
+    /***
+     * 根据时间查询实验室
+     * @param xxpDuty
+     * @return
+     */
+    public List<XxpDutyVO> selectInfoByDate(XxpDuty xxpDuty);
 }

+ 15 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/IXxpInspectionService.java

@@ -1,6 +1,7 @@
 package com.zd.laboratory.service;
 
 import com.zd.laboratory.domain.XxpInspection;
+import com.zd.laboratory.domain.vo.XxpInspectionVO;
 
 import java.util.List;
 
@@ -63,4 +64,18 @@ public interface IXxpInspectionService
      * @return 结果
      */
     public int deleteXxpInspectionById(Long id);
+
+    /***
+     * 查询某时间段内签到人数集合
+     * @param inspectionVO
+     * @return
+     */
+    public List<XxpInspectionVO> selectListSignin(XxpInspectionVO inspectionVO);
+
+    /***
+     * 查询某时间段内未签到人数集合
+     * @param inspectionVO
+     * @return
+     */
+    public List<XxpInspectionVO> selectListNotSignin(XxpInspectionVO inspectionVO);
 }

+ 5 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/XxpClassifyDetailedServiceImpl.java

@@ -1,6 +1,8 @@
 package com.zd.laboratory.service.impl;
 
+import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.security.TokenService;
+import com.zd.common.core.utils.StringUtils;
 import com.zd.laboratory.domain.XxpClassifyDetail;
 import com.zd.laboratory.mapper.XxpClassifyDetailedMapper;
 import com.zd.laboratory.service.IXxpClassifyDetailedService;
@@ -72,6 +74,9 @@ public class XxpClassifyDetailedServiceImpl implements IXxpClassifyDetailedServi
      */
     @Override
     public int updateXxpClassifyDetailed(XxpClassifyDetail classifyDetailed) {
+        if(StringUtils.isNull(classifyDetailed.getId()) ){
+            throw new ServiceException("ID不能为空!");
+        }
         SysUser sysUser = tokenService.getLoginUser().getSysUser();
         classifyDetailed.setUpdateBy(sysUser.getNickName());
         classifyDetailed.setUpdateTime(new Date());

+ 15 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/XxpDutyServiceImpl.java

@@ -89,8 +89,8 @@ public class XxpDutyServiceImpl implements IXxpDutyService
                             .setCreateById(sysUser.getUserId()).setCreateBy(sysUser.getNickName());
                     xxpDutyVO.setUserId(xxpDutyVO.getSysUserList().get(p).getUserId());
                     xxpDutyVO.setCreateTime(new Date());
-                    xxpDutyVO.setDeptId(sysUser.getDept().getDeptId());
-                    xxpDutyVO.setDeptName(sysUser.getDept().getDeptName());
+                    xxpDutyVO.setDeptId(xxpDutyVO.getSysUserList().get(p).getDept().getDeptId());
+                    xxpDutyVO.setDeptName(xxpDutyVO.getSysUserList().get(p).getDept().getDeptName());
                     xxpDutyMapper.insertXxpDuty(xxpDutyVO);
                 }
             }
@@ -153,4 +153,17 @@ public class XxpDutyServiceImpl implements IXxpDutyService
     public XxpDutyVO selectSubAndUserSum(Date dutyTime) {
         return xxpDutyMapper.selectSubAndUserSum(dutyTime);
     }
+
+    /***
+     * 根据时间查询实验室
+     * @param xxpDuty
+     * @return
+     */
+    @Override
+    public List<XxpDutyVO> selectInfoByDate(XxpDuty xxpDuty) {
+        if(StringUtils.isNull(xxpDuty.getDutyTime())){
+            throw new ServiceException("查询时间不能为空!");
+        }
+        return xxpDutyMapper.selectInfoByDate(xxpDuty);
+    }
 }

+ 21 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/XxpInspectionServiceImpl.java

@@ -4,6 +4,7 @@ import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.StringUtils;
 import com.zd.laboratory.domain.XxpClassify;
 import com.zd.laboratory.domain.XxpInspection;
+import com.zd.laboratory.domain.vo.XxpInspectionVO;
 import com.zd.laboratory.mapper.XxpClassifyMapper;
 import com.zd.laboratory.mapper.XxpInspectionMapper;
 import com.zd.laboratory.service.IXxpClassifyService;
@@ -108,4 +109,24 @@ public class XxpInspectionServiceImpl implements IXxpInspectionService
     public int deleteXxpInspectionById(Long id) {
         return xxpInspectionMapper.deleteXxpInspectionById(id);
     }
+
+    /***
+     * 查询某时间段内签到人数集合
+     * @param inspectionVO
+     * @return
+     */
+    @Override
+    public List<XxpInspectionVO> selectListSignin(XxpInspectionVO inspectionVO) {
+        return xxpInspectionMapper.selectListSignin(inspectionVO);
+    }
+
+    /***
+     * 查询某时间段内未签到人数集合
+     * @param inspectionVO
+     * @return
+     */
+    @Override
+    public List<XxpInspectionVO> selectListNotSignin(XxpInspectionVO inspectionVO) {
+        return xxpInspectionMapper.selectListNotSignin(inspectionVO);
+    }
 }

+ 9 - 1
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/XxpDutyMapper.xml

@@ -52,7 +52,7 @@
             <if test="userType != null ">and t.user_type = #{userType}</if>
             <if test="subjectId != null ">and t.subject_id = #{subjectId}</if>
             <if test="subjectName != null and subjectName != '' ">and t.subject_name = #{subjectName}</if>
-            <if test="deptId != null ">and t.dept_id = #{deptId}</if>
+            <if test="deptId != null ">and ( t.dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId} ,ancestors )) or t.dept_id = #{deptId} )</if>
             <if test="deptName != null ">and t.dept_name = #{deptName}</if>
             <if test="college != null ">and t.college = #{college}</if>
             <if test="dutyTime != null  ">and t.duty_time =#{dutyTime}</if>
@@ -65,6 +65,7 @@
                 and t.duty_time &lt;= str_to_date(#{endTime}, '%Y-%m-%d')
             </if>
         </where>
+        order by create_time desc
     </select>
 
     <select id="selectXxpDutyById" resultMap="XxpDutyResult">
@@ -168,4 +169,11 @@
              ) t
     </select>
 
+    <select id="selectInfoByDate" parameterType="com.zd.laboratory.domain.XxpDuty" resultType="com.zd.laboratory.domain.vo.XxpDutyVO">
+        select subject_id,subject_name from xxp_duty t
+        where t.duty_time=#{dutyTime}
+        <if test="deptId != null ">and ( t.dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId} ,ancestors )) or t.dept_id = #{deptId} )</if>
+        GROUP BY t.subject_id, t.subject_name
+    </select>
+
 </mapper>

+ 46 - 1
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/XxpInspectionMapper.xml

@@ -28,7 +28,7 @@
                sign_out,
                dept_id,
                dept_name,
-               timediff(sign_out,sign_in) residence_time,
+               timediff(sign_out, sign_in) residence_time,
                create_time
         from xxp_inspection t
     </sql>
@@ -129,4 +129,49 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="selectListSignin" parameterType="com.zd.laboratory.domain.XxpInspection"
+            resultType="com.zd.laboratory.domain.vo.XxpInspectionVO">
+        select dutyTime, count(1) signInCount
+        from (
+        select date_format(sign_in, '%Y-%m-%d') dutyTime, user_id
+        from xxp_inspection i
+        where sign_out is not null
+        and sign_in is not null
+        and sign_in &gt;= #{beginTime}
+        and sign_in &lt;= #{endTime}
+        <if test="deptId != null ">and ( i.dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId}
+            ,ancestors )) or i.dept_id = #{deptId} )
+        </if>
+        GROUP BY date_format(sign_in, '%Y-%m-%d'), user_id
+        ) t
+        GROUP BY dutyTime
+        ORDER by dutyTime
+    </select>
+
+    <select id="selectListNotSignin" parameterType="com.zd.laboratory.domain.XxpInspection"
+            resultType="com.zd.laboratory.domain.vo.XxpInspectionVO">
+        select dutyTime, count(1) noSignedInCount
+        from (
+        select du.duty_time dutyTime,
+        du.user_id,
+        du.subject_id,
+        (select count(1)
+        from xxp_inspection i
+        where i.user_id = du.user_id
+        and date_format(i.sign_in, '%Y-%m-%d') =
+        date_format(du.duty_time, '%Y-%m-%d')
+        and i.subject_id = du.subject_id ) noSignedInCount
+        from xxp_duty du
+        where du.duty_time &gt;= #{beginTime}
+        and du.duty_time &lt;= #{endTime}
+        <if test="deptId != null ">and ( du.dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId}
+            ,ancestors )) or du.dept_id = #{deptId} )
+        </if>
+        ) t
+        where noSignedInCount = 0
+        GROUP BY dutyTime
+        ORDER BY dutyTime
+    </select>
+
 </mapper>