|
|
@@ -1,8 +1,10 @@
|
|
|
package com.usoftchina.uas.office.dingtalk.service;
|
|
|
|
|
|
import com.dingtalk.api.response.OapiAlitripBtripApplySearchResponse;
|
|
|
+import com.dingtalk.api.response.OapiAttendanceGetleavestatusResponse;
|
|
|
import com.dingtalk.api.response.OapiSmartworkHrmEmployeeListdimissionResponse;
|
|
|
import com.usoftchina.dingtalk.sdk.OaSdk;
|
|
|
+import com.usoftchina.uas.office.dingtalk.core.DateUtil;
|
|
|
import com.usoftchina.uas.office.dingtalk.util.BaseDao;
|
|
|
import com.usoftchina.uas.office.dingtalk.util.SqlRowList;
|
|
|
import com.usoftchina.uas.office.service.AbstractService;
|
|
|
@@ -11,6 +13,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
@@ -31,7 +35,7 @@ public class UasOaService extends AbstractService {
|
|
|
if ("出差申请单".equals(odKind)){
|
|
|
saveAlitripList(agentCode, startdate, enddate);
|
|
|
} else if ("请假申请单".equals(odKind)) {
|
|
|
-
|
|
|
+ saveLeaves(agentCode,DateUtil.parse(startdate,"yyyy-MM-dd HH:mm:ss").getTime(),DateUtil.parse(enddate,"yyyy-MM-dd HH:mm:ss").getTime());
|
|
|
} else if ("加班申请单".equals(odKind)) {
|
|
|
|
|
|
}else if ("补卡申请单".equals(odKind)) {
|
|
|
@@ -47,13 +51,12 @@ public class UasOaService extends AbstractService {
|
|
|
public void saveAlitripList(String agentCode, String startTime, String endTime) {
|
|
|
List<OapiAlitripBtripApplySearchResponse.OpenApplyRs> alitripList = oaSdk.getAllAlitrip(agentCode,startTime,endTime);
|
|
|
if (!CollectionUtils.isEmpty(alitripList)) {
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
for (OapiAlitripBtripApplySearchResponse.OpenApplyRs openApplyRs:alitripList) {
|
|
|
- String inDate = format.format(openApplyRs.getGmtCreate());
|
|
|
+ String inDate = DateUtil.format(openApplyRs.getGmtCreate(),"yyyy-MM-dd HH:mm:ss");
|
|
|
List<OapiAlitripBtripApplySearchResponse.OpenItineraryInfo> itineraryList = openApplyRs.getItineraryList();
|
|
|
OapiAlitripBtripApplySearchResponse.OpenItineraryInfo openItineraryInfo = itineraryList.get(0);
|
|
|
- String startDate = format.format(openItineraryInfo.getDepDate());
|
|
|
- String endDate = format.format(openItineraryInfo.getArrDate());
|
|
|
+ String startDate = DateUtil.format(openItineraryInfo.getDepDate(),"yyyy-MM-dd HH:mm:ss");
|
|
|
+ String endDate = DateUtil.format(openItineraryInfo.getArrDate(),"yyyy-MM-dd HH:mm:ss");
|
|
|
Long rsId = openApplyRs.getId();
|
|
|
String projectTitle = openItineraryInfo.getProjectTitle();
|
|
|
String projectCode = openItineraryInfo.getProjectCode();
|
|
|
@@ -77,13 +80,12 @@ public class UasOaService extends AbstractService {
|
|
|
public void saveEmpLeaveRecords(String agentCode) {
|
|
|
List<OapiSmartworkHrmEmployeeListdimissionResponse.EmpDimissionInfoVo> empLeave = oaSdk.getAllEmpLeaveRecords(agentCode);
|
|
|
if (!CollectionUtils.isEmpty(empLeave)){
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
for (int i = 0; i < empLeave.size(); i++) {
|
|
|
OapiSmartworkHrmEmployeeListdimissionResponse.EmpDimissionInfoVo empDimissionInfoVo = empLeave.get(i);
|
|
|
String deptName = empDimissionInfoVo.getMainDeptName();
|
|
|
String reasonMemo = empDimissionInfoVo.getReasonMemo();
|
|
|
Long lastWorkDay = empDimissionInfoVo.getLastWorkDay();
|
|
|
- String leaves = format.format(lastWorkDay);
|
|
|
+ String leaves = DateUtil.format(new Date(lastWorkDay), "yyyy-MM-dd HH:mm:ss");
|
|
|
String userid = empDimissionInfoVo.getUserid();
|
|
|
int count = baseDao.getCountByCondition("Turnover", "to_dingtalkid='" + userid + "'");
|
|
|
int count1 = baseDao.getCountByCondition("employee", "em_ding='" + userid + "'");
|
|
|
@@ -97,6 +99,42 @@ public class UasOaService extends AbstractService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 请假申请
|
|
|
+ */
|
|
|
+ public void saveLeaves(String agentCode, long startTime, long endTime){
|
|
|
+ int count = baseDao.getCountByCondition("employee", "nvl(em_class,' ')<>'离职' and nvl(em_ding,' ')<>' '");
|
|
|
+ if (count>0){
|
|
|
+ int size=100;
|
|
|
+ for (int i = 0; i < count/size; i++) {
|
|
|
+ int min=i*size,max=(i+1)*size;
|
|
|
+ List<String> strings = new ArrayList<>();
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select em_ding from (select em_ding,rownum rn from employee where nvl(em_class,' ')<>'离职' and nvl(em_ding,' ')<>' ') where rn>"+min+" and rn<="+max);
|
|
|
+ while (rs.next()){
|
|
|
+ strings.add(rs.getGeneralString("em_ding"));
|
|
|
+ }
|
|
|
+ List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> leaveStatusVOS = oaSdk.getAllLeaves(agentCode, strings, startTime, endTime);
|
|
|
+ if (!CollectionUtils.isEmpty(leaveStatusVOS)) {
|
|
|
+ for (int j = 0; j < leaveStatusVOS.size(); j++) {
|
|
|
+ OapiAttendanceGetleavestatusResponse.LeaveStatusVO leaveStatusVO = leaveStatusVOS.get(j);
|
|
|
+ Long durationPercent = leaveStatusVO.getDurationPercent()/100;
|
|
|
+ String durationUnit = leaveStatusVO.getDurationUnit();
|
|
|
+ Long startDate = leaveStatusVO.getStartTime();
|
|
|
+ Long endDate = leaveStatusVO.getEndTime();
|
|
|
+ String userid = leaveStatusVO.getUserid();
|
|
|
+ String startformat = DateUtil.format(new Date(startDate), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String endformat = DateUtil.format(new Date(endDate), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ int count1 = baseDao.getCountByCondition("Vacation", "va_dingtalkid='" + userid + "' and to_char(va_startime,'yyyy-MM-dd HH24:mi:ss')='" + startformat + "' and to_char(va_endtime,'yyyy-MM-dd HH24:mi:ss')='" + endformat + "'");
|
|
|
+ if (count1<=0) {
|
|
|
+ int id = baseDao.getSeqId("VACATION_SEQ");
|
|
|
+ String code = baseDao.callProcedure("Sp_GetMaxNumber", new Object[]{"Ask4Leave", 2});
|
|
|
+ baseDao.execute("insert into Vacation (va_id,va_code,va_statuscode,va_status,va_emcode,va_emname,va_date,va_department,va_position,va_recordor,va_recordorid,va_days,va_alltimes,va_startime,va_endtime,va_remark,va_dingtalkid) " +
|
|
|
+ "select " + id + ",'" + code + "','AUDITED','已审核',em_code,em_name,sysdate,em_depart,em_position,em_name,em_id,case when '" + durationUnit + "'='percent_day' then " + durationPercent + " else 0 end,case when '" + durationUnit + "'='percent_hour' then " + durationPercent + " else 0 end,to_date('" + startformat + "','yyyy-MM-dd hh24:mi:ss'),to_date('" + endformat + "','yyyy-MM-dd hh24:mi:ss'),'钉钉同步','" + userid + "' from employee where em_ding='" + userid + "'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|