Explorar o código

电子信息牌功能代码

xuxiaofei %!s(int64=2) %!d(string=hai) anos
pai
achega
69767f403d

+ 21 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabXxpDutyController.java

@@ -9,6 +9,7 @@ import com.zd.common.core.web.controller.BaseController;
 import com.zd.laboratory.domain.LabWhitelist;
 import com.zd.laboratory.domain.XxpDuty;
 import com.zd.laboratory.domain.XxpInspection;
+import com.zd.laboratory.domain.vo.XxpDutyVO;
 import com.zd.laboratory.service.IXxpDutyService;
 import com.zd.laboratory.service.IXxpInspectionService;
 import com.zd.model.domain.ResultData;
@@ -55,6 +56,24 @@ public class LabXxpDutyController extends BaseController
     }
 
     /**
+     * 查询值班列表(按实时间查询)
+     */
+    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_DUTY + PerFun.LIST)
+    @GetMapping("/listYmd")
+    @ApiOperation(value = "查询值班列表")
+    public TableDataInfo<XxpDutyVO> listGroup(XxpDuty xxpDuty)
+    {
+        //startPage();
+        List<XxpDutyVO> list = xxpDutyService.selectDutyYmdById(xxpDuty);
+        for (XxpDutyVO duty:list) {
+            XxpDutyVO vo= xxpDutyService.selectSubAndUserSum(duty.getDutyTime());
+            duty.setSubSum(vo.getSubSum());
+            duty.setUserSum(vo.getSubSum());
+        }
+        return getDataTable(list);
+    }
+
+    /**
      * 导出值班列表
      */
     @ApiOperation(value = "导出值班列表")
@@ -87,9 +106,9 @@ public class LabXxpDutyController extends BaseController
     @PreAuthorize(hasPermi = PerPrefix.LABORATORY_DUTY + PerFun.ADD)
     @Log(title = "值班", businessType = BusinessType.INSERT)
     @PostMapping
-    public ResultData add(@RequestBody XxpDuty xxpDuty)
+    public ResultData add(@RequestBody XxpDutyVO xxpDutyVO)
     {
-        return ResultData.result(xxpDutyService.insertXxpDuty(xxpDuty));
+        return ResultData.result(xxpDutyService.insertXxpDuty(xxpDutyVO));
     }
 
 

+ 9 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/XxpCardInfo.java

@@ -8,7 +8,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.ToString;
 import lombok.experimental.Accessors;
-import org.hibernate.validator.constraints.Length;
 
 import java.util.Date;
 
@@ -57,7 +56,7 @@ public class XxpCardInfo extends BaseEntity {
      */
     @Excel(name = "学院Id")
     @ApiModelProperty(value = "学院Id")
-    private Long locationId;
+    private Long collegeId;
 
     /**
      * 位置
@@ -222,4 +221,12 @@ public class XxpCardInfo extends BaseEntity {
     public void setDeptName(String deptName) {
         this.deptName = deptName;
     }
+
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
 }

+ 0 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/XxpClassify.java

@@ -1,7 +1,6 @@
 package com.zd.laboratory.domain;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonProperty;
 import com.zd.model.annotation.Excel;
 import com.zd.model.entity.BaseEntity;
 import io.swagger.annotations.ApiModel;
@@ -9,8 +8,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.ToString;
 import lombok.experimental.Accessors;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import org.hibernate.validator.constraints.Length;
 
 import java.util.Date;

+ 1 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/XxpDuty.java

@@ -105,6 +105,7 @@ public class XxpDuty extends BaseEntity {
      * 值班时间
      */
     @Excel(name = "值班时间")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     @ApiModelProperty(value = "值班时间")
     private Date dutyTime;
 

+ 2 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/XxpInspection.java

@@ -64,6 +64,7 @@ public class XxpInspection extends BaseEntity {
      * 签到时间
      */
     @Excel(name = "签到时间 ")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "签到时间 ")
     private Date signIn;
 
@@ -71,6 +72,7 @@ public class XxpInspection extends BaseEntity {
      * 签退时间
      */
     @Excel(name = "签退时间 ")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "签退时间 ")
     private Date signOut;
 

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

@@ -1,7 +1,9 @@
 package com.zd.laboratory.mapper;
 
 import com.zd.laboratory.domain.XxpDuty;
+import com.zd.laboratory.domain.vo.XxpDutyVO;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -60,4 +62,18 @@ public interface XxpDutyMapper
      * @return 结果
      */
     public int deleteXxpDutyByIds(Long[] ids);
+
+    /***
+     * 根据时间段查询有数据的时间列表
+     * @param xxpDuty
+     * @return
+     */
+    public List<XxpDutyVO> selectDutyYmdById(XxpDuty xxpDuty);
+
+    /***
+     * 查询某个具体时间下的实验室和人员总数
+     * @param dutyTime
+     * @return
+     */
+    public XxpDutyVO selectSubAndUserSum(Date dutyTime);
 }

+ 18 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/IXxpDutyService.java

@@ -1,7 +1,9 @@
 package com.zd.laboratory.service;
 
 import com.zd.laboratory.domain.XxpDuty;
+import com.zd.laboratory.domain.vo.XxpDutyVO;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -33,10 +35,10 @@ public interface IXxpDutyService
     /**
      * 新增值班
      *
-     * @param xxpDuty 值班
+     * @param xxpDutyVO 值班
      * @return 结果
      */
-    public int insertXxpDuty(XxpDuty xxpDuty);
+    public int insertXxpDuty(XxpDutyVO xxpDutyVO);
 
 
 
@@ -63,4 +65,18 @@ public interface IXxpDutyService
      * @return 结果
      */
     public int deleteXxpDutyById(Long id);
+
+    /***
+     * 根据时间段查询有数据的时间列表
+     * @param xxpDuty
+     * @return
+     */
+    public List<XxpDutyVO> selectDutyYmdById(XxpDuty xxpDuty);
+
+    /***
+     * 查询某个具体时间下的实验室和人员总数
+     * @param dutyTime
+     * @return
+     */
+    public XxpDutyVO selectSubAndUserSum(Date dutyTime);
 }

+ 21 - 7
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/XxpCardInfoServiceImpl.java

@@ -3,12 +3,15 @@ package com.zd.laboratory.service.impl;
 import com.zd.common.core.security.TokenService;
 import com.zd.laboratory.domain.XxpCardInfo;
 import com.zd.laboratory.domain.XxpInspection;
+import com.zd.laboratory.mapper.XxpCardInfoMapper;
 import com.zd.laboratory.mapper.XxpInspectionMapper;
 import com.zd.laboratory.service.IXxpCardInfoService;
 import com.zd.laboratory.service.IXxpInspectionService;
+import com.zd.model.entity.SysUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -21,7 +24,7 @@ import java.util.List;
 public class XxpCardInfoServiceImpl implements IXxpCardInfoService
 {
     @Autowired
-    private IXxpCardInfoService xxpCardInfoService;
+    private XxpCardInfoMapper xxpCardInfoMapper;
 
     @Autowired
     private TokenService tokenService;
@@ -35,7 +38,7 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
      */
     @Override
     public XxpCardInfo selectXxpCardInfoById(Long id) {
-        return xxpCardInfoService.selectXxpCardInfoById(id);
+        return xxpCardInfoMapper.selectXxpCardInfoById(id);
     }
 
     /**
@@ -46,7 +49,7 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
      */
     @Override
     public List<XxpCardInfo> selectXxpCardInfoList(XxpCardInfo xxpCardInfo) {
-        return xxpCardInfoService.selectXxpCardInfoList(xxpCardInfo);
+        return xxpCardInfoMapper.selectXxpCardInfoList(xxpCardInfo);
     }
 
     /**
@@ -57,7 +60,13 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
      */
     @Override
     public int insertXxpCardInfo(XxpCardInfo xxpCardInfo) {
-        return xxpCardInfoService.insertXxpCardInfo(xxpCardInfo);
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+        xxpCardInfo.setCreateBy(sysUser.getNickName());
+        xxpCardInfo.setCreateTime(new Date());
+        xxpCardInfo.setUserId(sysUser.getUserId());
+        xxpCardInfo.setDeptId(sysUser.getDept().getDeptId());
+        xxpCardInfo.setDeptName(sysUser.getDept().getDeptName());
+        return xxpCardInfoMapper.insertXxpCardInfo(xxpCardInfo);
     }
 
     /**
@@ -68,7 +77,10 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
      */
     @Override
     public int updateXxpCardInfo(XxpCardInfo xxpCardInfo) {
-        return xxpCardInfoService.updateXxpCardInfo(xxpCardInfo);
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+        xxpCardInfo.setUpdateBy(sysUser.getNickName());
+        xxpCardInfo.setUpdateTime(new Date());
+        return xxpCardInfoMapper.updateXxpCardInfo(xxpCardInfo);
     }
 
     /**
@@ -79,7 +91,8 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
      */
     @Override
     public int deleteXxpCardInfoByIds(Long[] ids) {
-        return xxpCardInfoService.deleteXxpCardInfoByIds(ids);
+
+        return xxpCardInfoMapper.deleteXxpCardInfoByIds(ids);
     }
 
     /**
@@ -90,6 +103,7 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
      */
     @Override
     public int deleteXxpCardInfoById(Long id) {
-        return xxpCardInfoService.deleteXxpCardInfoById(id);
+
+        return xxpCardInfoMapper.deleteXxpCardInfoById(id);
     }
 }

+ 63 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/XxpDutyServiceImpl.java

@@ -1,15 +1,22 @@
 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.DateUtils;
+import com.zd.common.core.utils.StringUtils;
 import com.zd.laboratory.domain.XxpDuty;
 import com.zd.laboratory.domain.XxpInspection;
+import com.zd.laboratory.domain.vo.XxpDutyVO;
 import com.zd.laboratory.mapper.XxpDutyMapper;
 import com.zd.laboratory.mapper.XxpInspectionMapper;
 import com.zd.laboratory.service.IXxpDutyService;
 import com.zd.laboratory.service.IXxpInspectionService;
+import com.zd.model.entity.SysUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -53,12 +60,42 @@ public class XxpDutyServiceImpl implements IXxpDutyService
     /**
      * 新增值班
      *
-     * @param xxpDuty 值班
+     * @param xxpDutyVO 值班
      * @return 结果
      */
     @Override
-    public int insertXxpDuty(XxpDuty xxpDuty) {
-        return xxpDutyMapper.insertXxpDuty(xxpDuty);
+    @Transactional(rollbackFor = Exception.class)
+    public int insertXxpDuty(XxpDutyVO xxpDutyVO) {
+        if(StringUtils.isNull(xxpDutyVO.getDateList()) ){
+            throw new ServiceException("值班时间为空");
+        }else if(StringUtils.isNull(xxpDutyVO.getSubjectList())){
+            throw new ServiceException("值班实验室为空");
+        }else if(StringUtils.isNull(xxpDutyVO.getSysUserList())){
+            throw new ServiceException("值班人员为空");
+        }
+
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+        for (int i=0;i<xxpDutyVO.getDateList().size();i++){
+            for (int o=0;o<xxpDutyVO.getSubjectList().size();o++){
+                for (int p=0;p<xxpDutyVO.getSysUserList().size();p++){
+                    //数据封装
+                    xxpDutyVO.setUserName(xxpDutyVO.getSysUserList().get(p).getNickName())
+                            .setUserPhone(xxpDutyVO.getSysUserList().get(p).getPhonenumber())
+                            .setUserImg(xxpDutyVO.getSysUserList().get(p).getAvatar())
+                            .setUserType(xxpDutyVO.getSysUserList().get(p).getUserType())
+                            .setSubjectId(xxpDutyVO.getSubjectList().get(o).getId())
+                            .setSubjectName(xxpDutyVO.getSubjectList().get(o).getName())
+                            .setDutyTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD,xxpDutyVO.getDateList().get(i)))
+                            .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());
+                    xxpDutyMapper.insertXxpDuty(xxpDutyVO);
+                }
+            }
+        }
+        return 1;
     }
 
     /**
@@ -93,4 +130,27 @@ public class XxpDutyServiceImpl implements IXxpDutyService
     public int deleteXxpDutyById(Long id) {
         return xxpDutyMapper.deleteXxpDutyById(id);
     }
+
+    /***
+     * 根据时间段查询有数据的时间列表
+     * @param xxpDuty
+     * @return
+     */
+    @Override
+    public List<XxpDutyVO> selectDutyYmdById(XxpDuty xxpDuty) {
+        if(StringUtils.isNull(xxpDuty.getBeginTime()) || StringUtils.isNull(xxpDuty.getEndTime())){
+            throw new ServiceException("必须指定开始时间和结束时间");
+        }
+        return xxpDutyMapper.selectDutyYmdById(xxpDuty);
+    }
+
+    /***
+     * 查询某个具体时间下的实验室和人员总数
+     * @param dutyTime
+     * @return
+     */
+    @Override
+    public XxpDutyVO selectSubAndUserSum(Date dutyTime) {
+        return xxpDutyMapper.selectSubAndUserSum(dutyTime);
+    }
 }

+ 15 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/XxpInspectionServiceImpl.java

@@ -1,6 +1,7 @@
 package com.zd.laboratory.service.impl;
 
 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.mapper.XxpClassifyMapper;
@@ -48,7 +49,20 @@ public class XxpInspectionServiceImpl implements IXxpInspectionService
      */
     @Override
     public List<XxpInspection> selectXxpInspectionList(XxpInspection xxpInspection) {
-        return xxpInspectionMapper.selectXxpInspectionList(xxpInspection);
+        List<XxpInspection> list = xxpInspectionMapper.selectXxpInspectionList(xxpInspection);
+        String timeStr=null;
+        for (XxpInspection ins:list) {
+            if(StringUtils.isNotEmpty(ins.getResidenceTime())){
+                String[] time =  ins.getResidenceTime().split(":");
+                for (int i=0; i<time.length;i++){
+                    timeStr=time[0]+"时";
+                    timeStr+=time[1]+"分";
+                    timeStr+=time[2]+"秒";
+                    ins.setResidenceTime(timeStr);
+                }
+            }
+        }
+        return list;
     }
 
     /**

+ 7 - 9
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/XxpCardInfoMapper.xml

@@ -9,15 +9,14 @@
         <result property="cardName" column="card_name"/>
         <result property="cardNum" column="card_num"/>
         <result property="college" column="college"/>
+        <result property="collegeId" column="college_id"/>
         <result property="location" column="location"/>
-        <result property="locationId" column="location_id"/>
         <result property="operate" column="operate"/>
         <result property="subjectId" column="subject_id"/>
         <result property="subjectName" column="subject_name"/>
         <result property="deptId" column="dept_id"/>
         <result property="deptName" column="dept_name"/>
         <result property="isStart" column="is_start"/>
-
         <result property="userId" column="user_id"/>
         <result property="createBy" column="create_by"/>
         <result property="createTime" column="create_time"/>
@@ -30,8 +29,8 @@
                card_name,
                card_num,
                college,
+               college_id
                location,
-               location_id,
                operate,
                subject_id,
                subject_name,
@@ -53,10 +52,10 @@
             <if test="cardName != null and cardName != null">and t.card_name = #{cardName}</if>
             <if test="cardNum != null and cardNum != ''">and t.card_num = #{cardNum}</if>
             <if test="college != null and college != null">and t.college = #{college}</if>
+            <if test="collegeId != null">and t.college_id = #{collegeId}</if>
             <if test="location != null and location != '' ">and t.location = #{location}</if>
-            <if test="locationId != null ">and t.location_id = #{locationId}</if>
             <if test="operate != null ">and t.operate = #{operate}</if>
-            <if test="subject_id != null ">and t.subject_id = #{subjectId}</if>
+            <if test="subjectId != null ">and t.subject_id = #{subjectId}</if>
             <if test="subjectName != null ">and t.subject_name = #{subjectName}</if>
             <if test="deptId != null ">and t.dept_id = #{deptId}</if>
             <if test="deptName != null ">and t.dept_name = #{deptName}</if>
@@ -80,8 +79,8 @@
             <if test="cardName != null">card_name,</if>
             <if test="cardNum != null">card_num,</if>
             <if test="college != null">college,</if>
+            <if test="collegeId != null">college_id,</if>
             <if test="location != null">location,</if>
-            <if test="locationId != null">location_id,</if>
             <if test="operate != null">operate,</if>
             <if test="subjectId != null">subject_id,</if>
             <if test="subjectName != null">subject_name,</if>
@@ -98,8 +97,8 @@
             <if test="cardName != null">#{cardName},</if>
             <if test="cardNum != null">#{cardNum},</if>
             <if test="college != null">#{college},</if>
+            <if test="collegeId != null">#{collegeId},</if>
             <if test="location != null">#{location},</if>
-            <if test="locationId != null">#{locationId},</if>
             <if test="operate != null">#{operate},</if>
             <if test="subjectId != null">#{subjectId},</if>
             <if test="subjectName != null">#{subjectName},</if>
@@ -120,8 +119,8 @@
             <if test="cardNum != null">card_name = #{cardNum},</if>
             <if test="cardNum != null">card_num = #{cardNum},</if>
             <if test="college != null">college = #{college},</if>
+            <if test="collegeId != null">college_id = #{collegeId},</if>
             <if test="location != null">location = #{location},</if>
-            <if test="locationId != null">location = #{locationId},</if>
             <if test="operate != null">operate = #{operate},</if>
             <if test="subjectId != null">subject_id = #{subjectId},</if>
             <if test="subjectName != null">subject_name = #{subjectName},</if>
@@ -129,7 +128,6 @@
             <if test="deptName != null">dept_name = #{deptName},</if>
             <if test="isStart != null">is_start = #{isStart},</if>
             <if test="userId != null">user_id = #{userId},</if>
-
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>

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

@@ -101,7 +101,7 @@
             <if test="deptId != null">#{deptId},</if>
             <if test="deptName != null">#{deptName},</if>
             <if test="college != null">#{college},</if>
-            <if test="dutyTime != null">#{duty_time},</if>
+            <if test="dutyTime != null">#{dutyTime},</if>
             <if test="createById != null">#{createById},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
@@ -141,4 +141,31 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="selectDutyYmdById" parameterType="com.zd.laboratory.domain.XxpDuty" resultType="com.zd.laboratory.domain.vo.XxpDutyVO">
+        select t1.duty_time
+        from (
+                 select t.duty_time
+                 from xxp_duty t
+                 where t.duty_time &gt;= str_to_date(#{beginTime}, '%Y-%m-%d')
+                   and t.duty_time &lt;= str_to_date(#{endTime}, '%Y-%m-%d')
+                 GROUP BY t.duty_time
+             ) t1
+    </select>
+
+    <select id="selectSubAndUserSum" resultType="com.zd.laboratory.domain.vo.XxpDutyVO" parameterType="java.util.Date">
+        select sum(subSum) subSum, sum(userSum) userSum
+        from (
+                 select count(1) subSum, 0 userSum
+                 from (
+                          select count(1) from xxp_duty d where d.duty_time = #{dutyTime} GROUP BY d.subject_id
+                      ) s
+                 UNION ALL
+                 select 0 subSum, count(1) userSum
+                 from (
+                          select count(1) from xxp_duty d where d.duty_time = #{dutyTime} GROUP BY d.user_id
+                      ) u
+             ) t
+    </select>
+
 </mapper>

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

@@ -28,7 +28,7 @@
                sign_out,
                dept_id,
                dept_name,
-               residence_time,
+               timediff(sign_out,sign_in) residence_time,
                create_time
         from xxp_inspection t
     </sql>