Преглед изворни кода

Merge branch 'master' of ssh://10.10.100.21/source/uas-office-integration

RaoMeng пре 6 година
родитељ
комит
72fcd40ff5

+ 44 - 0
uas-office-dingtalk/src/main/java/com/usoftchina/uas/office/dingtalk/listener/UasEmpTurnoverListener.java

@@ -0,0 +1,44 @@
+package com.usoftchina.uas.office.dingtalk.listener;
+
+import com.usoftchina.dingtalk.sdk.AddrBookSdk;
+import com.usoftchina.uas.office.dingtalk.entity.Employee;
+import com.usoftchina.uas.office.dingtalk.service.UasEmpTurnoverService;
+import com.usoftchina.uas.office.dingtalk.service.UasEmployeeService;
+import com.usoftchina.uas.office.dto.UasEvent;
+import com.usoftchina.uas.office.entity.DataCenter;
+import com.usoftchina.uas.office.listener.UasEventListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author yingp
+ * @date 2020/4/10
+ */
+@Component
+public class UasEmpTurnoverListener {
+    @Autowired
+    private AddrBookSdk addrBookSdk;
+
+    @Autowired
+    private UasEmpTurnoverService empTurnoverService;
+
+    @Autowired
+    private UasEmployeeService employeeService;
+
+    /**
+     * uas人员离职,删除企业微信通讯录人员
+     */
+    @UasEventListener(caller = "Turnover", operation = "AUDIT")
+    public void onEmployeeLeave(UasEvent event) {
+        if (!event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
+        String emCode = empTurnoverService.getEmCodeById(Integer.parseInt(event.getKey().toString()));
+        if (null != emCode) {
+            Employee employee = employeeService.getByCode(emCode);
+            if (null != employee && null != employee.getEm_ding()) {
+                addrBookSdk.deleteUser("Uas", employee.getEm_ding());
+            }
+        }
+    }
+}

+ 17 - 0
uas-office-dingtalk/src/main/java/com/usoftchina/uas/office/dingtalk/service/UasEmpTurnoverService.java

@@ -0,0 +1,17 @@
+package com.usoftchina.uas.office.dingtalk.service;
+
+import com.usoftchina.uas.office.dingtalk.entity.Employee;
+import com.usoftchina.uas.office.service.AbstractService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author yingp
+ * @date 2020/2/16
+ */
+@Service
+public class UasEmpTurnoverService extends AbstractService {
+
+    public String getEmCodeById(Integer id) {
+        return queryForObject("select to_applymancode from Turnover where to_id=?", String.class, id);
+    }
+}

+ 44 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/listener/UasEmpTurnoverListener.java

@@ -0,0 +1,44 @@
+package com.usoftchina.uas.office.qywx.listener;
+
+import com.usoftchina.qywx.sdk.AddrBookSdk;
+import com.usoftchina.uas.office.dto.UasEvent;
+import com.usoftchina.uas.office.entity.DataCenter;
+import com.usoftchina.uas.office.listener.UasEventListener;
+import com.usoftchina.uas.office.qywx.entity.Employee;
+import com.usoftchina.uas.office.qywx.service.UasEmpTurnoverService;
+import com.usoftchina.uas.office.qywx.service.UasEmployeeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author yingp
+ * @date 2020/4/10
+ */
+@Component
+public class UasEmpTurnoverListener {
+    @Autowired
+    private AddrBookSdk addrBookSdk;
+
+    @Autowired
+    private UasEmpTurnoverService empTurnoverService;
+
+    @Autowired
+    private UasEmployeeService employeeService;
+
+    /**
+     * uas人员离职,删除企业微信通讯录人员
+     */
+    @UasEventListener(caller = "Turnover", operation = "AUDIT")
+    public void onEmployeeLeave(UasEvent event) {
+        if (!addrBookSdk.enabled() || !event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
+        String emCode = empTurnoverService.getEmCodeById(Integer.parseInt(event.getKey().toString()));
+        if (null != emCode) {
+            Employee employee = employeeService.getByCode(emCode);
+            if (null != employee && null != employee.getEm_qywx() && !addrBookSdk.isReadonly()) {
+                addrBookSdk.deleteUser(employee.getEm_qywx());
+            }
+        }
+    }
+}

+ 16 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/service/UasEmpTurnoverService.java

@@ -0,0 +1,16 @@
+package com.usoftchina.uas.office.qywx.service;
+
+import com.usoftchina.uas.office.service.AbstractService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author yingp
+ * @date 2020/2/16
+ */
+@Service
+public class UasEmpTurnoverService extends AbstractService {
+
+    public String getEmCodeById(Integer id) {
+        return queryForObject("select to_applymancode from Turnover where to_id=?", String.class, id);
+    }
+}

+ 6 - 2
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/task/QywxCheckinTask.java

@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 
 import java.time.LocalDate;
 import java.time.ZoneId;
@@ -96,14 +97,17 @@ public class QywxCheckinTask {
 
     private void saveCheckinData(Map<String, Employee> employeeMap, List<GetCheckinDataResp.CheckinData> dataList) {
         dataList.forEach(data -> {
-            if(!data.getException_type().equals("未打卡")){
+            if (!data.getException_type().equals("未打卡")) {
                 Employee employee = employeeMap.get(data.getUserid());
                 logger.debug("get checkin data, user {}, type {}", employee.getEm_name(), data.getCheckin_type());
                 if ("外出打卡".equals(data.getCheckin_type())) {
                     // 外勤签到 插入外勤打卡记录
                     outSignService.save(new OutSign(employee, data));
                 } else {
-                    cardLogService.save(new CardLog(employee, data));
+                    // 在企业微信设置了考勤打卡规则的,才同步到uas
+                    if (!StringUtils.isEmpty(data.getGroupname())) {
+                        cardLogService.save(new CardLog(employee, data));
+                    }
                 }
             }
         });

+ 3 - 3
uas-office-web/wxuasapproval/src/pages/approval/Approval.jsx

@@ -23,6 +23,7 @@ import {
   isObjEmpty,
   isObjNull,
   MapToJson,
+  strMapToObj,
   strContain,
 } from '@/utils/common'
 // import FileViewer from 'react-file-viewer'
@@ -2049,9 +2050,8 @@ class Approval extends Component {
       this.approvalAgreeRequest()
       return
     }
-
-    let formStoreJson = MapToJson(mFormStore)
-    let paramsJson = MapToJson(mParams)
+    let formStoreJson = MapToJson(mFormStore);
+    let paramsJson = strMapToObj(mParams)
     fetchGet(mBaseUrl + '/common/processUpdate.action', {
       'caller': mApprovalRecord.caller,
       'master': mMaster,

+ 26 - 0
uas-office-web/wxuasapproval/src/utils/common.js

@@ -156,6 +156,32 @@ export function MapToJson (m) {
   return str
 }
 
+export  function strMapToObj(m) {
+  if (isObjEmpty(m)) {
+    return ''
+  }
+  var str = '['
+  if (isObjEmpty(m)) {
+    return ''
+  }
+  m.forEach(function (item, key) {
+    var obj = JSON.stringify(_strMapToObj(item));
+    str+=obj+','
+  })
+  str = str.slice(0,str.length-1)
+  str += ']'
+  return str;
+}
+
+export function _strMapToObj(item) {
+  let obj = Object.create(null);
+  for (let [k,v] of item) {
+    obj[k] = v;
+  }
+  return obj;
+}
+
+
 /**
  * require.context(directory, useSubdirectories = false, regExp = /^\.\//);
  * 获取目标目录下符合条件的所有文件