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

获取离职申请单增加日志

koul пре 1 година
родитељ
комит
11d73039a2

+ 71 - 61
uas-office-dingtalk/src/main/java/com/usoftchina/uas/office/dingtalk/service/UasOaService.java

@@ -85,39 +85,44 @@ public class UasOaService extends AbstractService {
         logger.info("离职申请单count=="+count);
         if (count>0) {
             int size=50;
-            for (int j = 0; j < count/size; j++) {
-                int min = j * size, max = (j + 1) * size;
-                List<String> strings = new ArrayList<>();
-                SqlRowSet rs = jdbcTemplate.queryForRowSet("select em_ding from (select em_ding,rownum rn from employee where nvl(em_ding,' ')<>' ') where rn>" + min + " and rn<=" + max);
-                while (rs.next()) {
-                    strings.add(rs.getString("em_ding"));
-                }
-                logger.info("离职申请单emdings=="+strings.size());
-                List<OapiSmartworkHrmEmployeeListdimissionResponse.EmpDimissionInfoVo> empLeave = oaSdk.getEmpLeave(agentCode,strings);
-                logger.info("离职申请单empLeavesize=="+empLeave.size());
-                if (!CollectionUtils.isEmpty(empLeave)) {
-                    logger.info("离职申请单empLeave=="+empLeave.toString());
-                    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=null;
-                        if (lastWorkDay>0) {
-                            leaves= DateUtil.format(new Date(lastWorkDay), "yyyy-MM-dd HH:mm:ss");
-                        }
-                        String userid = empDimissionInfoVo.getUserid();
-                        int count1 = queryForObject("select count(1) from Turnover where to_dingtalkid='" + userid + "'", Integer.class);
-                        logger.info("离职申请单count1=="+count1);
-                        if (count1 <= 0) {
-                            int id = generateId("TURNOVER_SEQ");
-                            String code = generateCode("Turnover", 2);
-                            if (leaves!=null) {
-                                jdbcTemplate.execute("insert into Turnover (to_id,to_code,to_applymancode,to_applyman,to_leavedate,to_recordor,to_date,to_statuscode,to_status,to_otherreason,to_dingtalkid) " +
-                                        "select " + id + ",'" + code + "',em_code,em_name,to_date('" + leaves + "','yyyy-MM-dd HH24:mi:ss'),em_name,sysdate,'AUDITED','已审核','" + reasonMemo + "','" + userid + "' employee where em_ding='" + userid + "'");
-                            }else {
-                                jdbcTemplate.execute("insert into Turnover (to_id,to_code,to_applymancode,to_applyman,to_recordor,to_date,to_statuscode,to_status,to_otherreason,to_dingtalkid) " +
-                                        "select " + id + ",'" + code + "',em_code,em_name,em_name,sysdate,'AUDITED','已审核','" + reasonMemo + "','" + userid + "' employee where em_ding='" + userid + "'");
+            int con = (int) Math.ceil(count / size);
+            logger.info("离职申请单con=="+con);
+            if (con>0) {
+                for (int j = 0; j < con; j++) {
+                    int min = j * size, max = (j + 1) * size;
+                    logger.info("离职申请单min==" + min);
+                    logger.info("离职申请单max==" + max);
+                    List<String> strings = new ArrayList<>();
+                    SqlRowSet rs = jdbcTemplate.queryForRowSet("select em_ding from (select em_ding,rownum rn from employee where nvl(em_ding,' ')<>' ') where rn>" + min + " and rn<=" + max);
+                    while (rs.next()) {
+                        strings.add(rs.getString("em_ding"));
+                    }
+                    logger.info("离职申请单emdings==" + strings.size());
+                    List<OapiSmartworkHrmEmployeeListdimissionResponse.EmpDimissionInfoVo> empLeave = oaSdk.getEmpLeave(agentCode, strings);
+                    logger.info("离职申请单empLeavesize==" + empLeave.size());
+                    if (!CollectionUtils.isEmpty(empLeave)) {
+                        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 = null;
+                            if (lastWorkDay!=null&&lastWorkDay > 0) {
+                                leaves = DateUtil.format(new Date(lastWorkDay), "yyyy-MM-dd HH:mm:ss");
+                            }
+                            String userid = empDimissionInfoVo.getUserid();
+                            int count1 = queryForObject("select count(1) from Turnover where to_dingtalkid='" + userid + "'", Integer.class);
+                            logger.info("离职申请单count1==" + count1);
+                            if (count1 <= 0) {
+                                int id = generateId("TURNOVER_SEQ");
+                                String code = generateCode("Turnover", 2);
+                                if (leaves != null) {
+                                    jdbcTemplate.execute("insert into Turnover (to_id,to_code,to_applymancode,to_applyman,to_leavedate,to_recordor,to_date,to_statuscode,to_status,to_otherreason,to_dingtalkid) " +
+                                            "select " + id + ",'" + code + "',em_code,em_name,to_date('" + leaves + "','yyyy-MM-dd HH24:mi:ss'),em_name,sysdate,'AUDITED','已审核','" + reasonMemo + "','" + userid + "' employee where em_ding='" + userid + "'");
+                                } else {
+                                    jdbcTemplate.execute("insert into Turnover (to_id,to_code,to_applymancode,to_applyman,to_recordor,to_date,to_statuscode,to_status,to_otherreason,to_dingtalkid) " +
+                                            "select " + id + ",'" + code + "',em_code,em_name,em_name,sysdate,'AUDITED','已审核','" + reasonMemo + "','" + userid + "' employee where em_ding='" + userid + "'");
+                                }
                             }
                         }
                     }
@@ -135,34 +140,39 @@ public class UasOaService extends AbstractService {
         logger.info("请假申请单count=="+count);
         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<>();
-                SqlRowSet rs = jdbcTemplate.queryForRowSet("select em_ding from (select em_ding,rownum rn from employee where nvl(em_ding,' ')<>' ') where rn>" + min + " and rn<=" + max);
-                while (rs.next()){
-                    strings.add(rs.getString("em_ding"));
-                }
-                logger.info("请假申请单emdings=="+strings.size());
-                List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> leaveStatusVOS = oaSdk.getAllLeaves(agentCode, strings, startTime, endTime);
-                logger.info("请假申请单leaveStatusVOS.size=="+leaveStatusVOS.size());
-                if (!CollectionUtils.isEmpty(leaveStatusVOS)) {
-                    logger.info("请假申请单leaveStatusVOS=="+leaveStatusVOS.toString());
-                    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 = queryForObject("select count(1) from Vacation where 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 + "'",Integer.class);
-                        logger.info("请假申请单count1=="+count1);
-                        if (count1<=0) {
-                            int id = generateId("VACATION_SEQ");
-                            String code = generateCode("Ask4Leave", 2);
-                            jdbcTemplate.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 + "'");
+            int con = (int) Math.ceil(count / size);
+            logger.info("请假申请单con=="+con);
+            if (con>0) {
+                for (int i = 0; i < con; i++) {
+                    int min = i * size, max = (i + 1) * size;
+                    logger.info("请假申请单min==" + min);
+                    logger.info("请假申请单max==" + max);
+                    List<String> strings = new ArrayList<>();
+                    SqlRowSet rs = jdbcTemplate.queryForRowSet("select em_ding from (select em_ding,rownum rn from employee where nvl(em_ding,' ')<>' ') where rn>" + min + " and rn<=" + max);
+                    while (rs.next()) {
+                        strings.add(rs.getString("em_ding"));
+                    }
+                    logger.info("请假申请单emdings==" + strings.size());
+                    List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> leaveStatusVOS = oaSdk.getAllLeaves(agentCode, strings, startTime, endTime);
+                    logger.info("请假申请单leaveStatusVOS.size==" + leaveStatusVOS.size());
+                    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 = queryForObject("select count(1) from Vacation where 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 + "'", Integer.class);
+                            logger.info("请假申请单count1==" + count1);
+                            if (count1 <= 0) {
+                                int id = generateId("VACATION_SEQ");
+                                String code = generateCode("Ask4Leave", 2);
+                                jdbcTemplate.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 + "'");
+                            }
                         }
                     }
                 }