ソースを参照

运维绑定员工

changhaoning 1 年間 前
コミット
b203f6547f

+ 21 - 0
src/main/java/com/dk/mdm/controller/mst/StaffController.java

@@ -247,4 +247,25 @@ public class StaffController {
         return staffService.logout(param);
     }
 
+    /**
+     * @desc   : 生成幽灵标识的数据
+     * @author : 常皓宁
+     * @date   : 2024/6/19 10:53
+     */
+    @ApiOperation(value = "生成幽灵标识的数据", notes = "生成幽灵标识的数据")
+    @PostMapping({"insert_flg_ghost_staff"})
+    public ResponseResultVO<?> insertGhostStaff(@RequestBody StaffVO staffVO) {
+        return staffService.insertGhostStaff(staffVO);
+    }
+
+    /**
+     * @desc   : 删除幽灵标识数据
+     * @author : 常皓宁
+     * @date   : 2024/6/20 8:51
+     */
+    @ApiOperation(value = "删除幽灵标识数据", notes = "删除幽灵标识数据")
+    @PostMapping({"delete_flg_ghost_staff"})
+    public ResponseResultVO<?> deleteGhostStaff(@RequestBody StaffVO staffVO) {
+        return staffService.deleteGhostStaff(staffVO);
+    }
 }

+ 7 - 0
src/main/java/com/dk/mdm/mapper/mst/StaffMapper.java

@@ -60,5 +60,12 @@ public interface StaffMapper extends BaseMapper<Staff>{
      */
     StaffResponse selectByUuId(StaffQuery staffQuery);
 
+    /**
+     * @desc   : 删除幽灵标识数据
+     * @author : 常皓宁
+     * @date   : 2024/6/20 8:55
+     */
+    int deleteGhostStaff(StaffQuery staffQuery);
+
 }
 

+ 10 - 0
src/main/java/com/dk/mdm/mapper/mst/StaffMapper.xml

@@ -247,4 +247,14 @@
             AND staff_code = #{staffCode}
         </if>
     </select>
+
+    <!-- 删除幽灵标识数据-->
+    <delete id="deleteGhostStaff">
+        DELETE
+        FROM dkic_b.t_mst_staff
+        where staff_name = #{staffName}
+          and staff_phone = #{staffPhone}
+          and cp_id = #{cpId}
+          and flg_ghost = true
+    </delete>
 </mapper>

+ 65 - 0
src/main/java/com/dk/mdm/service/mst/StaffService.java

@@ -864,4 +864,69 @@ public class StaffService extends BaseService<Staff> {
 //        this.updateByUuid(new Staff().setStaffId(param.get("staffId").toString()).setFlgCanLogin(false));
         return ResponseResultUtil.success(true);
     }
+
+
+    /**
+     * @desc   : 生成幽灵标识的数据
+     * @author : 常皓宁
+     * @date   : 2024/6/19 10:53
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public ResponseResultVO<?> insertGhostStaff(StaffVO staffVO) {
+        // 转化实体
+        Staff staff = staffConvert.convertToPo(staffVO);
+        StaffQuery staffQuery = new StaffQuery();
+        staffQuery.setStaffCode(staff.getStaffCode());
+        staffQuery.setCpId(staff.getCpId());
+        List<StaffResponse> staffResponses = staffMapper.selectByCond(staffQuery);
+        if (staffResponses == null || staffResponses.size() == 0) {
+            return ResponseResultUtil.error("绑定员工不存在");
+        }else {
+            for (StaffResponse staffResponse:staffResponses){
+                // 获取编码和主键UuId
+                Map<String, Object> codeMap = commonService.getUniqueNoteCode(
+                        Constant.docNameConstant.STAFF.getName(), staff.getCpId(), true);
+                staff.setStaffId(codeMap.get("outId").toString());
+                staff.setStaffCode(codeMap.get("outNote").toString());
+                staff.setStaffName(staff.getStaffName());
+                staff.setStaffPhone(staff.getStaffPhone());
+                staff.setOrgId(staffResponse.getOrgId());
+                staff.setRoleIds(staffResponse.getRoleIds());
+                staff.setHrStatus(staffResponse.getHrStatus());
+                staff.setFlgCanLogin(staffResponse.getFlgCanLogin());
+                staff.setWxUserId(staff.getWxUserId());
+                staff.setLoginType(staffResponse.getLoginType());
+                staff.setFlgInit(false);
+                staff.setFlgGhost(true);
+                super.insert(staff);
+            }
+            return ResponseResultUtil.success();
+        }
+    }
+
+    /**
+     * @desc   : 删除幽灵标识数据
+     * @author : 常皓宁
+     * @date   : 2024/6/19 10:53
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public ResponseResultVO<?> deleteGhostStaff(StaffVO staffVO) {
+        // 转化实体
+        Staff staff = staffConvert.convertToPo(staffVO);
+        StaffQuery staffQuery = new StaffQuery();
+        staffQuery.setStaffName(staff.getStaffName());
+        staffQuery.setStaffPhone(staff.getStaffPhone());
+        staffQuery.setCpId(staff.getCpId());
+        int a = staffMapper.deleteGhostStaff(staffQuery);
+        if (a > 0){
+            return ResponseResultUtil.success();
+        }
+        else{
+            return ResponseResultUtil.error("绑定员工不存在");
+        }
+    }
 }