Browse Source

完善凭证

ysh 3 years ago
parent
commit
81d779ae9f

+ 50 - 15
src/main/java/net/chenlin/dp/common/openapi4j/examples/voucher/VoucherAdd.java

@@ -178,6 +178,7 @@ public class VoucherAdd {
         List<Map<String,Object>> entryDebit = new ArrayList<>();        //voucher > debit > entryDebit
 
         String bm = map.get("申请人所属部门").toString();
+
         String sqr = map.get("申请人").toString();
         String[] a = sqr.split("提交的");
         if(a.length > 1){
@@ -295,7 +296,7 @@ public class VoucherAdd {
                     BigDecimal jinE = new BigDecimal(object.get("未税金额").toString());
                     BigDecimal sl = new BigDecimal(object.get("次数").toString());
 
-                    if(object.get("税额") != null){
+                    if(object.get("税额") != null && Double.valueOf(object.get("税额").toString()) > 0){
                         BigDecimal se = new BigDecimal(object.get("税额").toString());
                         Map<String,Object> entryDebitMap = new HashMap<>();             //voucher > debit > entryDebit > entryDebitMap
 
@@ -399,7 +400,7 @@ public class VoucherAdd {
                     BigDecimal jinE = new BigDecimal(object.get("未税金额").toString());
                     BigDecimal sl = new BigDecimal(object.get("次数").toString());
 
-                    if(object.get("税额") != null){
+                    if(object.get("税额") != null && Double.valueOf(object.get("税额").toString()) > 0){
                         BigDecimal se = new BigDecimal(object.get("税额").toString());
                         Map<String,Object> entryDebitMap = new HashMap<>();             //voucher > debit > entryDebit > entryDebitMap
 
@@ -538,7 +539,7 @@ public class VoucherAdd {
         try {
             JSONObject record = voucherService.add(jsonBody, biz_id,type);
             logger.info(record.toString());
-            return record.toString();
+            return "正常:"+record.toString();
         } catch (OpenAPIException e) {
             e.printStackTrace();
             StringWriter sw = new StringWriter();
@@ -547,7 +548,7 @@ public class VoucherAdd {
             if(StringUtils.isNullOrEmpty(str)){
                 str = "数据异常,未进行同步";
             }
-            return str;
+            return "数据异常:"+str;
         }
     }
 
@@ -575,7 +576,7 @@ public class VoucherAdd {
      */
     public static String getCode(String dept,String type){
 
-          if(dept.equals("营销设计中心-销售部")){
+          if(dept.contains("营销设计中心-销售部")){
             //OA差旅报销
             if("飞机、火车、出租车、轮渡".contains(type)){
                 return "6601070101";
@@ -595,12 +596,24 @@ public class VoucherAdd {
                 return "6601070102";
             }
             //OA其他报销科目
-            else if("零星采买、文件打印费".contains(type)){
+            else if("办公费".contains(type)){
                 return "660110";
-            }else if("展会宣传、展位布置".contains(type)){
+            }else if("广告宣传费".contains(type)){
                 return "66011802";
+            }else if("广告物料费".contains(type)){
+                return "66011803";
             }else if("邮寄/物流".contains(type)){
                 return "66012003";
+            }else if("交际应酬费".contains(type)){
+                return "660106";
+            }else if("样品费".contains(type)){
+                return "660116";
+            }else if("市场拓展费".contains(type)){
+                return "660118";
+            }else if("公出打车费".contains(type)){
+                return "6601070102";
+            }else if("设计费".contains(type)){
+                return "66010903";
             }else if("全员聚餐费".contains(type)){
                 return "66010205";
             }else if("其他费用".contains(type)){
@@ -613,7 +626,7 @@ public class VoucherAdd {
             else{
                 return "66010208";
             }
-        }else if(dept.equals("营销设计中心-设计部")){
+        }else if(dept.contains("营销设计中心-设计部")){
             //OA差旅报销
             if("飞机、火车、出租车、轮渡".contains(type)){
                 return "66040701";
@@ -635,23 +648,31 @@ public class VoucherAdd {
             //OA其他报销科目
             else if("零星采买、文件打印费".contains(type)){
                 return "660423";
+            }else if("办公费".contains(type)){
+                return "660423";
             }else if("展会宣传、展位布置".contains(type)){
                 return "66041801";
             }else if("邮寄/物流".contains(type)){
                 return "66042003";
             }else if("全员聚餐费".contains(type)){
                 return "66040205";
+            }else if("交际应酬费".contains(type)){
+                return "660406";
             }else if("其他费用".contains(type)){
                 return "66040113";
             }else if("公出打车费".contains(type)){
                 return "66040701";
             }else if("移动开发费".contains(type)){
                 return "66042001";
+            }else if("样品费".contains(type)){
+                return "660416";
+            }else if("市场拓展费".contains(type)){
+                return "66041801";
             }
             else{//OA差旅报销-其他
                 return "66040113";
             }
-        }else if(dept.equals("营销设计中心-项目部") || dept.equals("营销设计中心-市场部")){
+        }else if(dept.contains("营销设计中心-项目部") || dept.contains("营销设计中心-市场部")){
             //OA差旅报销
             if("飞机、火车、出租车、轮渡".contains(type)){
                 return "6601070101";
@@ -661,9 +682,9 @@ public class VoucherAdd {
                 return "6601070104";
             }else if("餐饮费".contains(type)){
                 return "66010201";
-            }else if("宴客费".contains(type)){
+            }else if("宴客费、交际应酬费".contains(type)){
                 return "660106";
-            }else if("误餐补贴".contains(type)){
+            }else if("误餐补贴、出差补助".contains(type)){
                 return "6601070105";
             }
             //OA私车公用报销
@@ -671,20 +692,28 @@ public class VoucherAdd {
                 return "6601070102";
             }
             //OA其他报销科目
-            else if("零星采买、文件打印费".contains(type)){
+            else if("零星采买、文件打印费、办公费".contains(type)){
                 return "660110";
-            }else if("展会宣传、展位布置".contains(type)){
+            }else if("展会宣传、展位布置、广告宣传费".contains(type)){
                 return "66011802";
+            }else if("广告物料费".contains(type)){
+                return "66011803";
             }else if("邮寄/物流".contains(type)){
                 return "66012003";
             }else if("全员聚餐费".contains(type)){
                 return "66010205";
+            }else if("交际应酬费".contains(type)){
+                return "660106";
             }else if("其他费用".contains(type)){
                 return "660124";
             }else if("公出打车费".contains(type)){
                 return "6601070102";
             }else if("移动开发费".contains(type)){
                 return "66012001";
+            }else if("样品费".contains(type)){
+                return "660116";
+            }else if("市场拓展费".contains(type)){
+                return "660118";
             }
             else{//OA差旅报销-其他
                 return "66010208";
@@ -717,12 +746,18 @@ public class VoucherAdd {
                 return "66022003";
             }else if("全员聚餐费".contains(type)){
                 return "66020205";
+            }else if("交际应酬费".contains(type)){
+                return "660206";
             }else if("其他费用".contains(type)){
                 return "66020208";
             }else if("公出打车费".contains(type)){
                 return "66020701";
+            }else if("新品开发费".contains(type)){
+                return "660217";
             }else if("移动开发费".contains(type)){
                 return "66021801";
+            }else if("样品费".contains(type)){
+                return "660216";
             }
             else{//OA差旅报销-其他
                 return "66020706";
@@ -738,8 +773,8 @@ public class VoucherAdd {
      */
     public static String getCodeSD(String dept,String type){
 
-        if(dept.equals("营销设计中心-总经理室") || dept.equals("营销设计中心-采购部") || dept.equals("共享中心-财务部")
-                || dept.equals("共享中心-人事行政部")){
+        if(dept.contains("营销设计中心-总经理室") || dept.contains("营销设计中心-采购部") || dept.contains("共享中心-财务部")
+                || dept.contains("共享中心-人事行政部")){
 
             //OA差旅报销
             if("飞机、火车、出租车、租车费、轮渡".contains(type)){

+ 95 - 8
src/main/java/net/chenlin/dp/modules/api/controller/DingdingOpenInterface.java

@@ -170,6 +170,65 @@ public class DingdingOpenInterface {
 
     }
 
+    public static List<String> getOrderIdList3(String processCode,String useTime){
+        getToken();//获取token
+
+        Map<String,Object> map = new HashMap<>();
+        List<String> list = new ArrayList<>();
+
+        try {
+            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/processinstance/listids");
+            OapiProcessinstanceListidsRequest req = new OapiProcessinstanceListidsRequest();
+
+            req.setProcessCode(processCode);
+//            Calendar nowTime = Calendar.getInstance();
+//            nowTime.add(Calendar.DAY_OF_YEAR, 31);
+//            Date date = nowTime.getTime();
+//            req.setStartTime(Long.valueOf(date.getTime()));//时间戳:例1586448000000
+//            Date now = new Date();
+//            long time = 30*60*1000;//30分钟
+//            Date beforeDate = new Date(now .getTime() - time);//30分钟前的时间
+//            req.setStartTime(beforeDate.getTime());
+//            req.setEndTime(now.getTime());
+            if(StringUtils.isNullOrEmpty(useTime)){
+                Calendar nowTime = Calendar.getInstance();
+                nowTime.add(Calendar.DAY_OF_YEAR, 31);
+                Date date = nowTime.getTime();
+                req.setStartTime(Long.valueOf(date.getTime()));//时间戳:例1586448000000
+            }else{
+                String a = DateUtils.date3TimeStamp(useTime,DateUtils.DATE_PATTERN);
+                req.setStartTime(Long.valueOf(a));//时间戳:例1586448000000
+            }
+
+            String next_cursor = "1";
+            req.setSize(20L);
+            while (!StringUtils.isNullOrEmpty(next_cursor)){
+
+                OapiProcessinstanceListidsResponse rsp = client.execute(req, gettoken);//access_token
+                map = JSONUtils.jsonToMap(rsp.getBody());
+                if(map.get("errcode").equals(0)){
+                    Map<String,Object> mapList = (Map<String, Object>) map.get("result");
+                    if(mapList.get("next_cursor") != null){
+                        next_cursor = mapList.get("next_cursor").toString();
+                        req.setCursor(Long.valueOf(next_cursor));
+                    }else{
+                        next_cursor = "";
+                    }
+
+                    list.addAll((List<String>) mapList.get("list"));
+                }
+            }
+//            System.out.println(list);
+        } catch (ApiException e) {
+            e.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return list;
+
+    }
+
     /**
      * 获取审批实例详
      */
@@ -311,8 +370,21 @@ public class DingdingOpenInterface {
 
 
     public static void main(String[] args) throws Exception {
+
+//        Calendar nowTime = Calendar.getInstance();
+//        nowTime.add(Calendar.DAY_OF_YEAR, 1);
+//        Date date = nowTime.getTime();
+//        System.out.println(Long.valueOf(date.getTime()));//时间戳:例1586448000000
+//        String a = DateUtils.date3TimeStamp("2022-03-07",DateUtils.DATE_PATTERN);
+//        System.out.println(a);
+//
+//        String b = DateUtils.timeStamp2Date(a,"yyyy-MM-dd HH:mm:ss:SSS");
+//        String c = DateUtils.timeStamp2Date(Long.valueOf(date.getTime()).toString(),"yyyy-MM-dd HH:mm:ss:sss");
+//        System.out.println(b);
+//        System.out.println(c);
 //        getViewByUserId("2006265537678286");
-        List<String> list = getOrderIdList2("PROC-A561B73E-8282-4780-BB05-DCBA8125C45C",-30);
+//        List<String> list = getOrderIdList2("PROC-A561B73E-8282-4780-BB05-DCBA8125C45C",-30);
+//        List<String> list = getOrderIdList3("PROC-A561B73E-8282-4780-BB05-DCBA8125C45C","2022-01-01");
 //        getOrderIdList("PROC-DD8FF68E-B90E-4885-8C17-F69E53BE5C81");
 //            for (Map.Entry<String, Object> entry : JSONUtils.jsonToMap(rsp.getBody()).entrySet()) {
 //                System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
@@ -323,16 +395,31 @@ public class DingdingOpenInterface {
 //        Date date = nowTime.getTime();
 //        System.out.println(date.getTime());
 //        System.out.println(nowTime.getTime());
-        for(String o:list){
-            Map<String,Object> map = getOrderDetails(o);
-            if(StringUtils.isNullOrEmpty(map.get("result").toString()) || !map.get("result").toString().equals("agree")){
-                System.out.println("sssss");
+//        for(String o:list){
+//            Map<String,Object> map = getOrderDetails(o);
+//            if(StringUtils.isNullOrEmpty(map.get("result").toString()) || !map.get("result").toString().equals("agree")){
+//                System.out.println("未审批通过");
+//            }else{
+//                System.out.println("===================");
+////                System.out.println(map);
+////                System.out.println(map);
+//            }
+//        }
+
+        //use list
+        long startTime = System.nanoTime();
+        int a = 0;
+        for (int i = 0; i < 1000100110; i++) {
+            if( "1".equals("1")){
+                a++;
             }else{
-                System.out.println(o);
-//                System.out.println(map);
+                a++;
             }
         }
-
+        System.out.println(a);
+        long endTime = System.nanoTime();
+        long duration = endTime - startTime;
+        System.out.println("useList:  " + duration / 1000000);
 
     }
 

+ 10 - 9
src/main/java/net/chenlin/dp/modules/api/service/PettyCashService.java

@@ -129,9 +129,10 @@ public class PettyCashService {
         String userid = prop.getProperty("userid");
         String agentid = prop.getProperty("agentid");
         String deptid = prop.getProperty("deptid");
-        List<String> list = dingdingOpenInterface.getOrderIdList2(PROC,-22);
+//        List<String> list = dingdingOpenInterface.getOrderIdList2(PROC,-22);
+        List<String> list = dingdingOpenInterface.getOrderIdList3(PROC,"2022-03-01");
         System.out.println("备用金:"+list);
-        List<SyViewEntity> listIdError = u8Service.selectViewByError("备用金至银行凭证");
+//        List<SyViewEntity> listIdError = u8Service.selectViewByError("备用金至银行凭证");
         List<SyViewEntity> listIdTrue = u8Service.selectViewByTrue("备用金至银行凭证");
 
         if(list.size() > 0){
@@ -140,13 +141,13 @@ public class PettyCashService {
             outCycle:for(String o:list){
 
                 //获取当日同步失败的单据,控制当日不再同步
-                if(listIdError.size() > 0){
-                    for(SyViewEntity en:listIdError){
-                        if(!StringUtils.isNullOrEmpty(en.getOaId()) && en.getOaId().equals(o)){
-                            continue outCycle;
-                        }
-                    }
-                }
+//                if(listIdError.size() > 0){
+//                    for(SyViewEntity en:listIdError){
+//                        if(!StringUtils.isNullOrEmpty(en.getOaId()) && en.getOaId().equals(o)){
+//                            continue outCycle;
+//                        }
+//                    }
+//                }
                 //获取10天内同步成功的数据,控制不再同步
                 if(listIdTrue.size() > 0){
                     for(SyViewEntity en:listIdTrue){

+ 17 - 16
src/main/java/net/chenlin/dp/modules/api/service/ReimbursementService.java

@@ -235,11 +235,11 @@ public class ReimbursementService {
 
                 if(mapPerson !=null ){
                     job_number = mapPerson.get("job_number").toString();//"CHK2019002";
-                    work_place = mapPerson.get("work_place").toString();
-                    if(StringUtils.isNullOrEmpty(work_place)){
+
+                    if(mapPerson.get("work_place") == null && StringUtils.isNullOrEmpty(mapPerson.get("work_place").toString())){
                         continue;
                     }
-
+                    work_place = mapPerson.get("work_place").toString();
                     if (work_place.equals("昆山")){
                         dept_code = getPerson(job_number,"1");
                         type = "1";
@@ -310,7 +310,7 @@ public class ReimbursementService {
                 }else{
                     continue ;
                 }
-                if(mess.length() > 1000){
+                if(!StringUtils.isNullOrEmpty(mess) && mess.length() > 1000){
                     entity.setSyMessage(mess.substring(0,1000));
                 }else{
                     entity.setSyMessage(mess);
@@ -331,7 +331,7 @@ public class ReimbursementService {
 
 
     /**
-     * 同步报销单至银行凭证
+     * 同步报销单至银行回单
      * @throws Exception
      */
     public void autoOABankReceipt() throws Exception {
@@ -344,24 +344,25 @@ public class ReimbursementService {
         String agentid = prop.getProperty("agentid");
         String deptid = prop.getProperty("deptid");
         String userid = prop.getProperty("userid");
-        List<String> list = dingdingOpenInterface.getOrderIdList2(PROC,-22);
+        List<String> list = dingdingOpenInterface.getOrderIdList3(PROC,"2022-03-01");
+//        List<String> list = dingdingOpenInterface.getOrderIdList2(PROC,-22);
 //        List<String> list = dingdingOpenInterface.getOrderIdList("PROC-DD8FF68E-B90E-4885-8C17-F69E53BE5C81");
         System.out.println("报销申请:"+list);
-        List<SyViewEntity> listIdError = u8Service.selectViewByError("报销单至银行凭证");
-        List<SyViewEntity> listIdTrue = u8Service.selectViewByTrue("报销单至银行凭证");
+//        List<SyViewEntity> listIdError = u8Service.selectViewByError("报销单至银行凭证");
+        List<SyViewEntity> listIdTrue = u8Service.selectViewByTrue2("报销单至银行凭证","2022-03-01");
 
         if(list.size() > 0){
             getToken();
             outCycle:for(String o:list){
             //获取当日同步失败的单据,控制当日不再同步
-               if(listIdError.size() > 0){
-                    for(SyViewEntity en:listIdError){
-                        if(!StringUtils.isNullOrEmpty(en.getOaId()) && en.getOaId().equals(o)){
-                            continue outCycle;
-                        }
-                    }
-                }
-               //获取10天内同步成功的数据,控制不再同步
+//               if(listIdError.size() > 0){
+//                    for(SyViewEntity en:listIdError){
+//                        if(!StringUtils.isNullOrEmpty(en.getOaId()) && en.getOaId().equals(o)){
+//                            continue outCycle;
+//                        }
+//                    }
+//                }
+               //获取指定时间内同步成功的数据,控制不再同步·
                if(listIdTrue.size() > 0){
                     for(SyViewEntity en:listIdTrue){
                         if(!StringUtils.isNullOrEmpty(en.getOaId()) && en.getOaId().equals(o)){

+ 3 - 0
src/main/java/net/chenlin/dp/modules/sys/dao/TestU8Mapper.java

@@ -3,6 +3,7 @@ package net.chenlin.dp.modules.sys.dao;
 import net.chenlin.dp.modules.sys.entity.QuartzJobLogEntity;
 import net.chenlin.dp.modules.sys.entity.SyViewEntity;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Bean;
@@ -24,6 +25,8 @@ public interface TestU8Mapper extends BaseMapper<SyViewEntity> {
 
 	List<SyViewEntity> selectViewByTrue(String tableType);
 
+	List<SyViewEntity> selectViewByTrue2(@Param("tableType") String tableType, @Param("useTime")String useTime);
+
 	List<SyViewEntity> selectViewBy31(String tableType);
 
 	/**

+ 5 - 0
src/main/java/net/chenlin/dp/modules/sys/mapper/testU8.xml

@@ -73,6 +73,11 @@
 		where DATE_FORMAT(create_time,'%Y-%m-%d') >= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 22 DAY),'%Y-%m-%d')
 		and sy_state = "true" and table_type = #{tableType}
 	</select>
+	<select id="selectViewByTrue2" resultType="net.chenlin.dp.modules.sys.entity.SyViewEntity">
+		select oa_Id as oaId from sy_view
+		where DATE_FORMAT(create_time,'%Y-%m-%d') >= DATE_FORMAT(#{useTime},'%Y-%m-%d')
+		and sy_state = "true" and table_type = #{tableType}
+	</select>
 
 	<select id="selectViewBy31" resultType="net.chenlin.dp.modules.sys.entity.SyViewEntity">
 		select oa_Id as oaId from sy_view

+ 5 - 0
src/main/java/net/chenlin/dp/modules/sys/service/impl/testU8ServiceImpl.java

@@ -44,6 +44,11 @@ public class testU8ServiceImpl implements testU8Service {
 	public List<SyViewEntity> selectViewByTrue(String tableType) {
 		return testU8Mapper.selectViewByTrue(tableType);
 	}
+
+	@Override
+	public List<SyViewEntity> selectViewByTrue2(String tableType,String useTime) {
+		return testU8Mapper.selectViewByTrue2(tableType,useTime);
+	}
 	@Override
 	public List<SyViewEntity> selectViewBy31(String tableType) {
 		return testU8Mapper.selectViewBy31(tableType);

+ 2 - 0
src/main/java/net/chenlin/dp/modules/sys/service/testU8Service.java

@@ -22,6 +22,8 @@ public interface testU8Service {
 
 	public List<SyViewEntity> selectViewByTrue(String tableType);
 
+	public List<SyViewEntity> selectViewByTrue2(String tableType,String useTime);
+
 	public List<SyViewEntity> selectViewBy31(String tableType);
 
 	/**