Browse Source

车间系统同步企业微信人员时,部门不存在的情况下有bug. 已修复

QuYueTing 7 months ago
parent
commit
eac848e350

+ 0 - 6
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/UserController.java

@@ -194,12 +194,6 @@ public class UserController {
         return userService.switchPermission(id, request);
     }
 
-    @RequestMapping("/getUserSalaryList")
-    public HttpRespMsg getUserSalaryList(String id) {
-        return userService.getUserSalaryList(id);
-    }
-
-
     @RequestMapping("/setActive")
     public HttpRespMsg setActive(String id, int isActive) {
         return userService.setActive(id, isActive);

+ 0 - 21
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/UserSalaryController.java

@@ -1,21 +0,0 @@
-package com.management.platform.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- *  前端控制器
- * </p>
- *
- * @author Seyason
- * @since 2021-05-19
- */
-@RestController
-@RequestMapping("/user-salary")
-public class UserSalaryController {
-
-}
-

+ 16 - 6
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/WeiXinCorpController.java

@@ -1950,18 +1950,25 @@ public class WeiXinCorpController {
         if (id == 0) {
             cascade.append("0");
         } else {
-            cascade.append(id);
-            id = findById(id, allDeptList).getSuperiorId();
-            while (id != null) {
-                cascade.append(",").append(id);
-                id = findById(id, allDeptList).getSuperiorId();
+
+            Department dept = findById(id, allDeptList);
+            if (dept == null) {
+                cascade.append("0");
+            } else {
+                cascade.append(id);
+                id = dept.getSuperiorId();
+                while (id != null) {
+                    cascade.append(",").append(id);
+                    id = findById(id, allDeptList).getSuperiorId();
+                }
             }
         }
         return cascade.toString();
     }
 
     private Department findById(int id, List<Department> allList) {
-        return allList.stream().filter(all->all.getDepartmentId().intValue() == id).findFirst().get();
+        Optional<Department> first = allList.stream().filter(all -> all.getDepartmentId().intValue() == id).findFirst();
+        return first.isPresent()?first.get():null;
     }
 
     private boolean judgeIsLeader(String userId) {
@@ -2283,6 +2290,9 @@ public class WeiXinCorpController {
                                 .setPassword(MD5Util.getPassword("000000"))
                                 .setJobNumber(corpWxuserid);
                             boolean b = oldUserList.stream().anyMatch(ul -> ul.getCorpwxRealUserid().equals(user.getCorpwxRealUserid()));
+                            if ("黄家雨".equals(userName)) {
+                                System.out.println("黄家雨"+(b?"存在":"不存在"));
+                            }
                             if(!b){
                                 userList.add(user);
                             }

+ 0 - 94
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/entity/UserSalary.java

@@ -1,94 +0,0 @@
-package com.management.platform.entity;
-
-import java.math.BigDecimal;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
-import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * <p>
- * 
- * </p>
- *
- * @author Seyason
- * @since 2022-10-19
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class UserSalary extends Model<UserSalary> {
-
-    private static final long serialVersionUID=1L;
-
-    @TableId(value = "id", type = IdType.AUTO)
-    private Integer id;
-
-    /**
-     * 用户id
-     */
-    @TableField("user_id")
-    private String userId;
-
-    /**
-     * 用户姓名
-     */
-    @TableField("user_name")
-    private String userName;
-
-    /**
-     * 月薪
-     */
-    @TableField("month_cost")
-    private BigDecimal monthCost;
-
-    /**
-     * 时薪
-     */
-    @TableField("cost")
-    private BigDecimal cost;
-
-    /**
-     * 薪资类型
-     */
-    @TableField("salary_type")
-    private Integer salaryType;
-
-
-    /**
-     * 更新时间
-     */
-    @TableField("indate")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
-    private LocalDateTime indate;
-
-
-    /**
-     * 所属月份
-     */
-    @TableField("ymonth")
-    private String ymonth;
-
-    public static UserSalary copyFromUser(User user) {
-        UserSalary userSalary = new UserSalary();
-        userSalary.setUserId(user.getId());
-        userSalary.setSalaryType(user.getSalaryType());
-        userSalary.setMonthCost(user.getMonthCost());
-        userSalary.setCost(user.getCost());
-        userSalary.setUserName(user.getName());
-        return  userSalary;
-    }
-
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
-
-}

+ 0 - 16
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/mapper/UserSalaryMapper.java

@@ -1,16 +0,0 @@
-package com.management.platform.mapper;
-
-import com.management.platform.entity.UserSalary;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author Seyason
- * @since 2021-05-19
- */
-public interface UserSalaryMapper extends BaseMapper<UserSalary> {
-
-}

+ 0 - 16
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/UserSalaryService.java

@@ -1,16 +0,0 @@
-package com.management.platform.service;
-
-import com.management.platform.entity.UserSalary;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author Seyason
- * @since 2021-05-19
- */
-public interface UserSalaryService extends IService<UserSalary> {
-
-}

+ 0 - 2
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/UserService.java

@@ -46,8 +46,6 @@ public interface UserService extends IService<User> {
 
     HttpRespMsg resetPwd(String userId);
 
-    HttpRespMsg getUserSalaryList(String id);
-
     HttpRespMsg setActive(String id, int isActive);
 
     HttpRespMsg bindWeiXin(String code, String userId);

+ 0 - 20
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/UserSalaryServiceImpl.java

@@ -1,20 +0,0 @@
-package com.management.platform.service.impl;
-
-import com.management.platform.entity.UserSalary;
-import com.management.platform.mapper.UserSalaryMapper;
-import com.management.platform.service.UserSalaryService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author Seyason
- * @since 2021-05-19
- */
-@Service
-public class UserSalaryServiceImpl extends ServiceImpl<UserSalaryMapper, UserSalary> implements UserSalaryService {
-
-}

+ 1 - 40
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -128,10 +128,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     @Resource
     private ProjectMapper projectMapper;
     @Resource
-    private UserSalaryMapper userSalaryMapper;
-    @Resource
-    private UserSalaryService userSalaryService;
-    @Resource
     private UserVcodeMapper userVcodeMapper;
     @Resource
     private TaskMapper taskMapper;
@@ -431,14 +427,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             if (updateUserList.size() > 0) {
                 //有人员薪资更新
                 updateBatchById(updateUserList);
-                //记录薪资变动
-                List<UserSalary> salaryChangeList = new ArrayList<>();
-                for (User u : updateUserList) {
-                    UserSalary salary = UserSalary.copyFromUser(u);
-                    salary.setYmonth(yearMonth);
-                    salaryChangeList.add(salary);
-                }
-                userSalaryService.saveBatch(salaryChangeList);
             }
             //更新该月份的日报相关的成本
             if (!StringUtils.isEmpty(yearMonth)) {
@@ -908,7 +896,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                                 httpRespMsg.setError(MessageUtils.message("staff.deleteErrorByProject"));
                             } else {
                                 userMapper.deleteById(userId);
-                                userSalaryMapper.delete(new QueryWrapper<UserSalary>().eq("user_id", userId));
                                 //项目参与人可以直接删除
                                 participationMapper.delete(new QueryWrapper<Participation>().eq("user_id", userId));
                             }
@@ -1165,9 +1152,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                             //httpRespMsg.setError("操作失败");
                             httpRespMsg.setError(MessageUtils.message("other.operationFail"));
                         } else {
-                            //插入人员历史成本表
-                            UserSalary userSalary = UserSalary.copyFromUser(user);
-                            userSalaryMapper.insert(userSalary);
                             //插入人员专业证书表
                             if (!StringUtils.isEmpty(certJson)) {
                                 List<UserCert> certList = JSONArray.parseArray(certJson, UserCert.class);
@@ -1193,18 +1177,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                     return httpRespMsg;
                 }
                 User oldUser = userMapper.selectById(targetId);
-                boolean salaryChange = false;
-
-                if (oldUser.getCost() == null) {
-                    if (costValue.intValue() != 0) {
-                        salaryChange = true;
-                    }
-                } else {
-                    if (oldUser.getCost().compareTo(costValue) != 0) {
-                        salaryChange = true;
-                    }
-                }
-
                 String oldCostApplyDate = oldUser.getCostApplyDate();
                 if(!StringUtils.isEmpty(inductionDate)){
                     oldUser.setInductionDate(LocalDate.parse(inductionDate,dtf));
@@ -1246,10 +1218,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                     userMapper.setSuperiorNull(oldUser.getId());
                 }
 
-                if (salaryChange) {
-                    UserSalary userSalary = UserSalary.copyFromUser(oldUser);
-                    userSalaryMapper.insert(userSalary);
-                }
                 if (superiorChange) {
                     //检查是否有审核中的日报
                     if (timeTypeMapper.selectById(oldUser.getCompanyId()).getReportAuditType() == 5) {
@@ -1298,7 +1266,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                     if (cnt > 0) {
                         shouldChangeOldReport = true;
                     }
-                }  else if (salaryChange && costApplyDate != null) {
+                }  else if (costApplyDate != null) {
                     //成本发生改变
                     int cnt = reportMapper.selectCount(reportQueryWrapper);
                     if (cnt > 0) {
@@ -1605,13 +1573,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         return new HttpRespMsg();
     }
 
-    @Override
-    public HttpRespMsg getUserSalaryList(String id) {
-        List<UserSalary> userSalaries = userSalaryMapper.selectList(new QueryWrapper<UserSalary>().eq("user_id", id).orderByDesc("id"));
-        HttpRespMsg msg = new HttpRespMsg();
-        msg.data = userSalaries;
-        return msg;
-    }
 
     @Override
     public HttpRespMsg setActive(String id, int isActive) {

+ 0 - 22
fhKeeper/formulahousekeeper/management-workshop/src/main/resources/mapper/UserSalaryMapper.xml

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.management.platform.mapper.UserSalaryMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.management.platform.entity.UserSalary">
-        <id column="id" property="id" />
-        <result column="user_id" property="userId" />
-        <result column="user_name" property="userName" />
-        <result column="month_cost" property="monthCost" />
-        <result column="cost" property="cost" />
-        <result column="salary_type" property="salaryType" />
-        <result column="indate" property="indate" />
-        <result column="ymonth" property="ymonth" />
-    </resultMap>
-
-    <!-- 通用查询结果列 -->
-    <sql id="Base_Column_List">
-        id, user_id, user_name, month_cost, cost, salary_type, indate, ymonth
-    </sql>
-
-</mapper>