浏览代码

换班修改

yejian016332 3 年之前
父节点
当前提交
8fc7643b87

+ 13 - 7
imcs-admin-boot/imcs-authority-controller/src/main/java/com/github/zuihou/authority/controller/auth/UserController.java

@@ -34,7 +34,9 @@ import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.log.annotation.SysLog;
 import com.github.zuihou.model.RemoteData;
+import com.github.zuihou.security.annotation.LoginUser;
 import com.github.zuihou.security.annotation.PreAuth;
+import com.github.zuihou.security.model.SysUser;
 import com.github.zuihou.utils.MapHelper;
 import com.github.zuihou.utils.StrPool;
 import io.swagger.annotations.Api;
@@ -53,13 +55,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.MessageSource;
 import org.springframework.context.i18n.LocaleContextHolder;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
@@ -404,4 +400,14 @@ public class UserController extends SuperCacheController<UserService, Long, User
                 .eq(User::getStatus, userPage.getStatus());
         baseService.findPage(page, wrapper);
     }
+
+    /**
+     * 查找当前登录用户信息
+     * @return
+     */
+    @PostMapping("/getCurrUser")
+    @SysLog("'重置密码:' + #data.id")
+    public R<SysUser> getCurrUser(@LoginUser SysUser sysUser) {
+        return success(sysUser);
+    }
 }

+ 5 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/service/ScheduleUserChangeService.java

@@ -6,6 +6,9 @@ import com.github.zuihou.business.classSchedule.dto.ScheduleUserChangeSaveDTO;
 import com.github.zuihou.business.classSchedule.dto.ScheduleUserChangeUpdateDTO;
 import com.github.zuihou.business.classSchedule.entity.ScheduleUserChange;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.security.model.SysUser;
+
+import java.util.List;
 
 /**
  * <p>
@@ -39,7 +42,7 @@ public interface ScheduleUserChangeService extends SuperService<ScheduleUserChan
     /**
      * 审核
      */
-    ScheduleUserChange updateStatus(ScheduleUserChangeUpdateDTO data);
+    ScheduleUserChange updateStatus(ScheduleUserChangeUpdateDTO data, SysUser sysUser);
 
     /**
      * 删除
@@ -47,6 +50,6 @@ public interface ScheduleUserChangeService extends SuperService<ScheduleUserChan
      * @param
      * @return
      */
-    Boolean delete(ScheduleUserChange model);
+    Boolean delete(List<Long> ids);
 
 }

+ 44 - 5
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/service/impl/ScheduleUserChangeServiceImpl.java

@@ -7,9 +7,11 @@ import com.github.zuihou.business.classSchedule.dao.ScheduleUserChangeMapper;
 import com.github.zuihou.business.classSchedule.dto.ScheduleUserChangePageDTO;
 import com.github.zuihou.business.classSchedule.dto.ScheduleUserChangeSaveDTO;
 import com.github.zuihou.business.classSchedule.dto.ScheduleUserChangeUpdateDTO;
+import com.github.zuihou.business.classSchedule.entity.ScheduleFrequency;
 import com.github.zuihou.business.classSchedule.entity.ScheduleUserChange;
 import com.github.zuihou.business.classSchedule.entity.ScheduleUserChangeDate;
 import com.github.zuihou.business.classSchedule.entity.ScheduleUserDate;
+import com.github.zuihou.business.classSchedule.service.ScheduleFrequencyService;
 import com.github.zuihou.business.classSchedule.service.ScheduleUserChangeDateService;
 import com.github.zuihou.business.classSchedule.service.ScheduleUserChangeService;
 import com.github.zuihou.base.service.SuperServiceImpl;
@@ -18,6 +20,7 @@ import com.github.zuihou.business.classSchedule.service.ScheduleUserDateService;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionResult;
+import com.github.zuihou.security.model.SysUser;
 import com.github.zuihou.utils.BeanPlusUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,7 +28,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.sql.Wrapper;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -46,6 +53,10 @@ public class ScheduleUserChangeServiceImpl extends SuperServiceImpl<ScheduleUser
 
     @Autowired
     ScheduleUserChangeDateService scheduleUserChangeDateService;
+    @Autowired
+    ScheduleUserDateService scheduleUserDateService;
+    @Autowired
+    ScheduleFrequencyService scheduleFrequencyService;
 
     @Override
     // 启用属性自动注入
@@ -57,6 +68,24 @@ public class ScheduleUserChangeServiceImpl extends SuperServiceImpl<ScheduleUser
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ScheduleUserChange save(ScheduleUserChangeSaveDTO data) {
+
+        // 判断换班信息是否合理,
+        // 1.换班人和被让换班人不能是同一天同一班次 2.换班人其他班次不能和被换班人的日期,班次一致
+        for(long applyFrequency : data.getApplyList()){
+            ScheduleUserChange existUserSchedule = this.baseMapper.selectOne(Wraps.<ScheduleUserChange>lbQ().eq(ScheduleUserChange::getApplyTime,data.getApplyTime()).eq(ScheduleUserChange::getApplyUserId,data.getApplyUserId()));
+            if(null != existUserSchedule){
+                ScheduleUserChangeDate exsitScheduleUserChangeDate =  scheduleUserChangeDateService.getOne(Wraps.<ScheduleUserChangeDate>lbQ().eq(ScheduleUserChangeDate::getChangeId,existUserSchedule.getId()).eq(ScheduleUserChangeDate::getFrequencyId,applyFrequency));
+                if(null != exsitScheduleUserChangeDate){
+                    ScheduleFrequency scheduleFrequency = scheduleFrequencyService.getById(exsitScheduleUserChangeDate.getFrequencyId());
+                    isFalse(null != exsitScheduleUserChangeDate,"当前选择的换班["+data.getChangeTime() + "-" + scheduleFrequency.getName().getKey() +"]申请已存在,请重新选择");
+                }
+            }
+        }
+        for(long changeFrequency : data.getChangeList()){
+            List<ScheduleUserDate> userScheduleUserDate = scheduleUserDateService.list(Wraps.<ScheduleUserDate>lbQ().eq(ScheduleUserDate::getDate,data.getChangeTime()).eq(ScheduleUserDate::getUserId,data.getApplyUserId()).eq(ScheduleUserDate::getFrequencyId,changeFrequency));
+            isFalse(userScheduleUserDate.size() > 0,"更换班表不能选择自己排班的班次");
+        }
+
         ScheduleUserChange bean = BeanPlusUtil.toBean(data, ScheduleUserChange.class);
         save(bean);
 
@@ -108,7 +137,7 @@ public class ScheduleUserChangeServiceImpl extends SuperServiceImpl<ScheduleUser
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public ScheduleUserChange updateStatus(ScheduleUserChangeUpdateDTO data) {
+    public ScheduleUserChange updateStatus(ScheduleUserChangeUpdateDTO data, SysUser sysUser) {
         ScheduleUserChange oriScheduleUserChange = this.getById(data.getId());
         String auditStatus = data.getAuditStatus();
         String oriStatus = oriScheduleUserChange.getAuditStatus();
@@ -136,17 +165,27 @@ public class ScheduleUserChangeServiceImpl extends SuperServiceImpl<ScheduleUser
             }
         }
         ScheduleUserChange bean = BeanPlusUtil.toBean(data, ScheduleUserChange.class);
+        if("2".equals(auditStatus)||"3".equals(auditStatus)){
+            bean.setAuditUser(sysUser.getId());
+            bean.setAuditTime(LocalDateTime.now());
+        }
         updateById(bean);
         return bean;
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean delete(ScheduleUserChange model) {
+    public Boolean delete(List<Long> ids) {
+        for(long changeId : ids){
+            ScheduleUserChange oriScheduleUserChange = this.getById(changeId);
+            String oriStatus = oriScheduleUserChange.getAuditStatus();
+            isFalse("2".equals(oriStatus),"该换班申请已经审核通过,不能删除");
 
-        //删除换班明细班次表
-        scheduleUserChangeDateService.remove(Wraps.<ScheduleUserChangeDate>lbQ().eq(ScheduleUserChangeDate::getChangeId,model.getId()));
+            //删除换班明细班次表
+            scheduleUserChangeDateService.remove(Wraps.<ScheduleUserChangeDate>lbQ().eq(ScheduleUserChangeDate::getChangeId,changeId));
 
-        return removeById(model.getId());
+            return removeById(changeId);
+        }
+        return true;
     }
 }

+ 2 - 2
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/classSchedule/ScheduleUserChangeMapper.xml

@@ -15,13 +15,13 @@
         <result column="change_time" jdbcType="TIMESTAMP" property="changeTime"/>
         <result column="audit_status" jdbcType="VARCHAR" property="auditStatus"/>
         <result column="audit_user" jdbcType="BIGINT" property="auditUser"/>
-        <result column="audit_user_name" jdbcType="VARCHAR" property="auditUserName"/>
+        <result column="audit_time" jdbcType="VARCHAR" property="auditTime"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id,create_time,create_user,update_time,update_user,
-        apply_user_id, apply_time, change_user_id, change_time, audit_status, audit_user, audit_user_name,applyDesc,applyDictionary,changeDesc,changeDictionary
+        apply_user_id, apply_time, change_user_id, change_time, audit_status, audit_user, audit_time,applyDesc,applyDictionary,changeDesc,changeDictionary
     </sql>
 
     <!-- 分页 -->

+ 2 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/classSchedule/ScheduleFrequencyController.java

@@ -21,6 +21,8 @@ import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.injection.core.InjectionCore;
 import com.github.zuihou.log.annotation.SysLog;
+import com.github.zuihou.security.annotation.LoginUser;
+import com.github.zuihou.security.model.SysUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;

+ 8 - 4
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/classSchedule/ScheduleUserChangeController.java

@@ -16,6 +16,8 @@ import com.github.zuihou.base.R;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.log.annotation.SysLog;
+import com.github.zuihou.security.annotation.LoginUser;
+import com.github.zuihou.security.model.SysUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -74,6 +76,7 @@ public class ScheduleUserChangeController extends SuperController<ScheduleUserCh
 
     @ApiOperation(value = "修改换班", notes = "修改换班")
     @PostMapping("/update")
+    @Override
     public R<ScheduleUserChange> update(@RequestBody ScheduleUserChangeUpdateDTO model) {
         ScheduleUserChange bean = baseService.update(model);
         return success(bean);
@@ -81,16 +84,17 @@ public class ScheduleUserChangeController extends SuperController<ScheduleUserCh
 
     @ApiOperation(value = "审核状态", notes = "审核状态")
     @PostMapping("/updateStatus")
-    public R<ScheduleUserChange> updateStatus(@RequestBody ScheduleUserChangeUpdateDTO model) {
-        ScheduleUserChange bean = baseService.updateStatus(model);
+    public R<ScheduleUserChange> updateStatus(@RequestBody ScheduleUserChangeUpdateDTO model, @LoginUser SysUser sysUser) {
+        ScheduleUserChange bean = baseService.updateStatus(model,sysUser);
         return success(bean);
     }
 
     @ApiOperation(value = "删除换班", notes = "删除换班")
     @PostMapping("/delete")
-    public R<Boolean> delete(ScheduleUserChange model) {
+    public R<Boolean> delete(@RequestBody Map<String,List<Long>> data) {
+        List<Long> ids = (List<Long>) data.get("ids");
         // 这个操作相当的危险,请谨慎操作!!!
-        return success(baseService.delete(model));
+        return success(baseService.delete(ids));
     }
 
 }

+ 2 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/dto/ScheduleUserDatePageDTO.java

@@ -60,4 +60,6 @@ public class ScheduleUserDatePageDTO implements Serializable {
     @Length(max = 10, message = "日期(yyyy-mm-dd格式)长度不能超过10")
     private String date;
 
+    private boolean searchSelfFlag;
+
 }

+ 15 - 14
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/classSchedule/entity/ScheduleUserChange.java

@@ -4,6 +4,8 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
 import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.IdType;
+
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.github.zuihou.base.entity.Entity;
@@ -23,9 +25,9 @@ import lombok.NoArgsConstructor;
 import lombok.ToString;
 import lombok.experimental.Accessors;
 import com.github.zuihou.common.constant.DictionaryType;
-import static com.github.zuihou.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
 
 import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+import static com.github.zuihou.utils.DateUtils.*;
 
 /**
  * <p>
@@ -61,8 +63,8 @@ public class ScheduleUserChange extends Entity<Long> {
      */
     @ApiModelProperty(value = "申请时间")
     @TableField("apply_time")
-    @Excel(name = "申请时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
-    private LocalDateTime applyTime;
+    @Excel(name = "申请时间", format = DEFAULT_DATE_FORMAT, width = 20)
+    private String applyTime;
 
     /**
      * 用户id
@@ -77,8 +79,8 @@ public class ScheduleUserChange extends Entity<Long> {
      */
     @ApiModelProperty(value = "申请时间")
     @TableField("change_time")
-    @Excel(name = "申请时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
-    private LocalDateTime changeTime;
+    @Excel(name = "申请时间", format = DEFAULT_DATE_FORMAT, width = 20)
+    private String changeTime;
 
     /**
      * 审核状态(0-新增1-待审核2-审核通过3-审核不通过)
@@ -100,11 +102,10 @@ public class ScheduleUserChange extends Entity<Long> {
     /**
      * 审核人姓名
      */
-    @ApiModelProperty(value = "审核人姓名")
-    @Length(max = 32, message = "审核人姓名长度不能超过32")
-    @TableField(value = "audit_user_name", condition = LIKE)
-    @Excel(name = "审核人姓名")
-    private String auditUserName;
+    @ApiModelProperty(value = "审核时间")
+    @TableField(value = "audit_time", condition = LIKE)
+    @Excel(name = "审核时间")
+    private LocalDateTime auditTime;
 
     @ApiModelProperty(value = "申请人姓名")
     @TableField(exist = false)
@@ -123,9 +124,9 @@ public class ScheduleUserChange extends Entity<Long> {
     private String changeDictionary;
 
     @Builder
-    public ScheduleUserChange(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, 
-                    Long applyUserId, LocalDateTime applyTime, Long changeUserId, LocalDateTime changeTime, String auditStatus,
-                    Long auditUser, String auditUserName) {
+    public ScheduleUserChange(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
+                    Long applyUserId, String applyTime, Long changeUserId, String changeTime, String auditStatus,
+                    Long auditUser, LocalDateTime auditTime) {
         this.id = id;
         this.createTime = createTime;
         this.createUser = createUser;
@@ -137,7 +138,7 @@ public class ScheduleUserChange extends Entity<Long> {
         this.changeTime = changeTime;
         this.auditStatus = auditStatus;
         this.auditUser = auditUser;
-        this.auditUserName = auditUserName;
+        this.auditTime = auditTime;
     }
 
 }