Explorar o código

测试

Signed-off-by: EDZ <1>
EDZ %!s(int64=3) %!d(string=hai) anos
pai
achega
61f3e4860a

+ 21 - 1
src/main/java/net/chenlin/dp/common/openapi4j/examples/voucher/VoucherAdd.java

@@ -9,6 +9,8 @@ import com.alibaba.fastjson.JSONObject;
 import net.chenlin.dp.common.openapi4j.exception.OpenAPIException;
 import net.chenlin.dp.common.openapi4j.service.VoucherService;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.util.*;
 
 /**
@@ -29,7 +31,7 @@ public class VoucherAdd {
      * @param biz_id  唯一来源id
      * @param type 数据源 1昆山,3潍坊
      */
-    public static void addVoucher(Map<String,Object> map,String biz_id,String type) {
+    public static String addVoucher(Map<String,Object> map,String biz_id,String type) {
 
         Map<String,Object> jsonBodyMap = new HashMap<>();
         Map<String,Object> voucher = new HashMap<>();//凭证数据详情
@@ -58,6 +60,12 @@ public class VoucherAdd {
         Map<String,Object> auxiliaryCredit = new HashMap<>();
         auxiliaryCredit.put("dept_id",map.get("dept_code"));
         auxiliaryCredit.put("personnel_id",map.get("job_number"));
+
+        if(auxiliaryCredit.containsKey("item_class")){
+            auxiliaryCredit.put("item_class","00");//项目大类
+            auxiliaryCredit.put("item_id","YFYYYY00001-99");//项目档案
+        }
+
 //        auxiliaryCredit.put("operator","CHK2019001");
         entryCreditMap.put("auxiliary",auxiliaryCredit);
 
@@ -90,6 +98,12 @@ public class VoucherAdd {
         Map<String,Object> auxiliaryDebit = new HashMap<>();
         auxiliaryDebit.put("dept_id",map.get("dept_code"));
         auxiliaryDebit.put("personnel_id",map.get("job_number"));
+
+        if(auxiliaryDebit.containsKey("item_class")){
+            auxiliaryDebit.put("item_class","00");//项目大类
+            auxiliaryDebit.put("item_id","YFYYYY00001-99");//项目档案
+        }
+
 //        auxiliaryDebit.put("operator","CHK2019001");
         entryDebitMap.put("auxiliary",auxiliaryDebit);
 
@@ -118,9 +132,15 @@ public class VoucherAdd {
         try {
             JSONObject record = voucherService.add(jsonBody, biz_id,type);
             logger.info(record.toString());
+            return record.toString();
         } catch (OpenAPIException e) {
             e.printStackTrace();
+            StringWriter sw = new StringWriter();
+            e.printStackTrace(new PrintWriter(sw, true));
+            String str = sw.toString();
+            return str;
         }
+
     }
 
 }

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

@@ -76,15 +76,15 @@ public class DingdingOpenInterface {
             OapiProcessinstanceListidsRequest req = new OapiProcessinstanceListidsRequest();
 
             req.setProcessCode(processCode);
-//            Calendar nowTime = Calendar.getInstance();
-//            nowTime.add(Calendar.DAY_OF_YEAR, -1);
-//            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());
+            Calendar nowTime = Calendar.getInstance();
+            nowTime.add(Calendar.DAY_OF_YEAR, -10);
+            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());
             String next_cursor = "1";
             req.setSize(20L);
             while (!StringUtils.isNullOrEmpty(next_cursor)){
@@ -249,8 +249,8 @@ public class DingdingOpenInterface {
 
 
     public static void main(String[] args) throws Exception {
-        getViewByUserId("2006265537678286");
-//        getOrderIdList("PROC-A561B73E-8282-4780-BB05-DCBA8125C45C");
+//        getViewByUserId("2006265537678286");
+        getOrderIdList("PROC-A561B73E-8282-4780-BB05-DCBA8125C45C");
 //            for (Map.Entry<String, Object> entry : JSONUtils.jsonToMap(rsp.getBody()).entrySet()) {
 //                System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
 //            }

+ 33 - 5
src/main/java/net/chenlin/dp/modules/api/service/PettyCashService.java

@@ -7,7 +7,10 @@ import net.chenlin.dp.common.openapi4j.exception.OpenAPIException;
 import net.chenlin.dp.common.openapi4j.service.PersonService;
 import net.chenlin.dp.common.openapi4j.util.PropUtil;
 import net.chenlin.dp.common.utils.JSONUtils;
+import net.chenlin.dp.common.utils.SpringContextUtils;
 import net.chenlin.dp.modules.api.controller.DingdingOpenInterface;
+import net.chenlin.dp.modules.sys.entity.SyViewEntity;
+import net.chenlin.dp.modules.sys.service.testU8Service;
 
 import java.util.HashMap;
 import java.util.List;
@@ -20,15 +23,26 @@ import java.util.Properties;
  */
 public class PettyCashService {
 
-    public static void autoUpdataPetty() throws Exception {
+    private testU8Service u8Service= SpringContextUtils.getBean("testU8Service",testU8Service.class);
+
+    public void autoUpdataPetty() throws Exception {
 
         DingdingOpenInterface dingdingOpenInterface = new DingdingOpenInterface();
         Properties prop = PropUtil.getProperties("/config.properties");
         String PROC = prop.getProperty("byj_process_code");
         List<String> list = dingdingOpenInterface.getOrderIdList(PROC);
 //
+        List<SyViewEntity> listId = u8Service.selectView("备用金");
         if(list.size() > 0){
-            for(String o:list){
+            outCycle:for(String o:list){
+
+                if(listId.size() > 0){
+                    for(SyViewEntity en:listId){
+                        if(!StringUtils.isNullOrEmpty(en.getOaId()) && en.getOaId().equals(o)){
+                            continue outCycle;
+                        }
+                    }
+                }
 
                 String job_number = "";//工号
                 String work_place = "";//办公地(潍坊对03账套 昆山对01账套)
@@ -68,8 +82,22 @@ public class PettyCashService {
                 map1.put("account_code","122102");//科目编码
                 map1.put("dept_code",dept_code);//部门编码
                 map1.put("job_number",job_number);//人员编码
-                VoucherAdd.addVoucher(map1,map.get("business_id").toString(),type);
-//                System.out.println(map1);
+                String mess = VoucherAdd.addVoucher(map1,map.get("business_id").toString(),type);
+
+                SyViewEntity entity = new SyViewEntity();
+                entity.setOaId(o);
+                entity.setAccountCode("122102");
+                entity.setParType("备用金");
+//                entity.setDeptName(map.get("originator_dept_name").toString());
+                entity.setDeptCode(dept_code);
+                entity.setJobNumber(job_number);
+                entity.setJobNumber("备用金");
+                entity.setSyMessage(mess);
+                try {
+                    u8Service.saveSyView(entity);
+                }catch (Exception e){
+                    System.out.println("异常备用金");
+                }
             }
 
         }
@@ -106,7 +134,7 @@ public class PettyCashService {
 
 
     public static void main(String[] args) throws Exception {
-        autoUpdataPetty();
+//        autoUpdataPetty();
 //        getPerson("CHK2021001",null);
     }
 

+ 81 - 12
src/main/java/net/chenlin/dp/modules/api/service/ReimbursementService.java

@@ -6,13 +6,20 @@ import net.chenlin.dp.common.openapi4j.examples.voucher.VoucherAdd;
 import net.chenlin.dp.common.openapi4j.exception.OpenAPIException;
 import net.chenlin.dp.common.openapi4j.service.PersonService;
 import net.chenlin.dp.common.openapi4j.util.PropUtil;
+import net.chenlin.dp.common.utils.SpringContextUtils;
 import net.chenlin.dp.modules.api.controller.DingdingOpenInterface;
+import net.chenlin.dp.modules.sys.entity.SyViewEntity;
+import net.chenlin.dp.modules.sys.service.SysUserService;
+import net.chenlin.dp.modules.sys.service.testU8Service;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.*;
 
 public class ReimbursementService {
 
-    public static void autoReimbursement() throws Exception {
+    private testU8Service u8Service= SpringContextUtils.getBean("testU8Service",testU8Service.class);
+
+    public void autoReimbursement() throws Exception {
 
         DingdingOpenInterface dingdingOpenInterface = new DingdingOpenInterface();
         Properties prop = PropUtil.getProperties("/config.properties");
@@ -24,14 +31,25 @@ public class ReimbursementService {
         String account_code = ""; //科目编码
         String type = ""; //数据源账套 1昆山,3潍坊
 
+        List<SyViewEntity> listId = u8Service.selectView("报销单");
+
         if(list.size() > 0){
-            for(String o:list){
+            outCycle:for(String o:list){
+
+                if(listId.size() > 0){
+                    for(SyViewEntity en:listId){
+                        if(!StringUtils.isNullOrEmpty(en.getOaId()) && en.getOaId().equals(o)){
+                            continue outCycle;
+                        }
+                    }
+                }
 
-//                Map<String,Object> map = dingdingOpenInterface.getOrderDetails("8ee5b37b-8702-4068-874f-eb74c5e78863");
+//                Map<String,Object> map = dingdingOpenInterface.getOrderDetails("90325515-a5a5-4af8-abf9-2d4ef1eb7c23");
                 Map<String,Object> map = dingdingOpenInterface.getOrderDetails(o);
                 if(StringUtils.isNullOrEmpty(map.get("result").toString()) || !map.get("result").toString().equals("agree")){
                     continue;
                 }
+//                System.out.println(map);
                 Map<String,Object> map1 = tableToMap2(map);
                 Map<String,Object> mapPerson = dingdingOpenInterface.getViewByUserId(map.get("originator_userid").toString());
 
@@ -60,41 +78,92 @@ public class ReimbursementService {
                 if(map.get("originator_dept_name") == null){
                     continue;
                 }
+                String mess = null;
+                SyViewEntity entity = new SyViewEntity();
 
-                if(map1.containsKey("差旅报销")){
+                if(map.get("originator_dept_name").toString().equals("营销设计中心-设计部") ||
+                        map.get("originator_dept_name").toString().equals("营销设计中心-项目部") ||
+                        map.get("originator_dept_name").toString().equals("营销设计中心-市场部")){
+                    map1.put("item_class","00");//项目大类  --研发项目
+                    map1.put("item_id","YFYYYY00001");//项目名称  --项目研发-公共
+                }
+
+                if(map1.containsKey("差旅报销") && map1.get("差旅报销")!=null && Double.valueOf(map1.get("差旅报销").toString()) > 0){
                     account_code = getDeptCode(map.get("originator_dept_name").toString(),"差旅报销");
+                    if(StringUtils.isNullOrEmpty(account_code) || account_code == null || account_code.equals("null")){
+                        continue;
+                    }
                     map1.put("abstract","差旅报销");
                     map1.put("naturalCurrency",map1.get("差旅报销"));
                     map1.put("account_code",account_code);//科目编码
                     map1.put("dept_code",dept_code);//部门编码
                     map1.put("job_number",job_number);//人员编码
-//                    System.out.println("============================");
+                    entity.setParType("差旅报销");
+//                    System.out.println("============================差旅报销"+account_code);
 //                    System.out.println(map1);
-                    VoucherAdd.addVoucher(map1,map.get("business_id").toString()+"差旅",type);
+                    try {
+                        mess = VoucherAdd.addVoucher(map1,map.get("business_id").toString()+"差旅",type);
+                    }catch (Exception e){
+                        mess = e.getMessage();
+                    }
+
                 }
-                if(map1.containsKey("私车公用报销")){
+                if(map1.containsKey("私车公用报销") && map1.get("私车公用报销")!=null && Double.valueOf(map1.get("私车公用报销").toString()) > 0){
                     account_code = getDeptCode(map.get("originator_dept_name").toString(),"私车公用报销");
+                    if(StringUtils.isNullOrEmpty(account_code) || account_code == null || account_code.equals("null")){
+                        continue;
+                    }
                     map1.put("abstract","私车公用报销");
                     map1.put("naturalCurrency",map1.get("私车公用报销"));
                     map1.put("account_code",account_code);//科目编码
                     map1.put("dept_code",dept_code);//部门编码
                     map1.put("job_number",job_number);//人员编码
+                    entity.setParType("私车公用报销");
 //                    System.out.println("============================");
 //                    System.out.println(map1);
-                    VoucherAdd.addVoucher(map1,map.get("business_id").toString()+"私车公用",type);
+//                    System.out.println("============================私车公用报销"+account_code);
+                    try {
+                        mess = VoucherAdd.addVoucher(map1,map.get("business_id").toString()+"私车公用",type);
+                    }catch (Exception e){
+                        mess = e.getMessage();
+                    }
                 }
-                if(map1.containsKey("其他报销科目")){
+                if(map1.containsKey("其他报销科目") && map1.get("其他报销科目")!=null && Double.valueOf(map1.get("其他报销科目").toString()) > 0){
                     account_code = getDeptCode(map.get("originator_dept_name").toString(),"其他报销科目");
+                    if(StringUtils.isNullOrEmpty(account_code) || account_code == null || account_code.equals("null")){
+                        continue;
+                    }
                     map1.put("abstract","其他报销科目");
                     map1.put("naturalCurrency",map1.get("其他报销科目"));
                     map1.put("account_code",account_code);//科目编码
                     map1.put("dept_code",dept_code);//部门编码
                     map1.put("job_number",job_number);//人员编码
+                    entity.setParType("其他报销科目");
+//                    System.out.println("============================其他报销科目"+account_code+"===="+map.get("originator_dept_name").toString());
 //                    System.out.println("============================");
 //                    System.out.println(map1);
-                    VoucherAdd.addVoucher(map1,map.get("business_id").toString()+"其他",type);
+
+                    try {
+                        mess = VoucherAdd.addVoucher(map1,map.get("business_id").toString()+"其他",type);
+                    }catch (Exception e){
+                        mess = e.getMessage();
+                    }
                 }
 
+                entity.setOaId(o);
+                entity.setDeptName(map.get("originator_dept_name").toString());
+                entity.setDeptCode(dept_code);
+                entity.setAccountCode(account_code);
+                entity.setJobNumber(job_number);
+                entity.setJobNumber("报销单");
+                entity.setSyMessage(mess);
+                try {
+                    u8Service.saveSyView(entity);
+                }catch (Exception e){
+                    System.out.println("异常1");
+                }
+
+
             }
 
         }
@@ -207,7 +276,7 @@ public class ReimbursementService {
                 JSONObject record1 = (JSONObject) record.get("person");
                 code = record1.get("cdept_num").toString();
             }
-            System.out.println(record);
+//            System.out.println(record);
 
         } catch (OpenAPIException e) {
             return code;
@@ -218,7 +287,7 @@ public class ReimbursementService {
 
 
     public static void main(String[] args) throws Exception {
-        autoReimbursement();
+//        autoReimbursement();
     }
 
 

+ 6 - 1
src/main/java/net/chenlin/dp/modules/sys/dao/TestU8Mapper.java

@@ -1,20 +1,25 @@
 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.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 
+import java.util.List;
+
 /**
  * 定时任务日志
  * @author zcl<yczclcn@163.com>
  */
 @Mapper
-public interface TestU8Mapper extends BaseMapper<QuartzJobLogEntity> {
+public interface TestU8Mapper extends BaseMapper<SyViewEntity> {
 
 	int testAll();
 
+	List<SyViewEntity> selectView(String tableType);
+
 	/**
 	 * 调用存储过程 获取下一个编码
 	 * @param StuNo

+ 128 - 0
src/main/java/net/chenlin/dp/modules/sys/entity/SyViewEntity.java

@@ -0,0 +1,128 @@
+package net.chenlin.dp.modules.sys.entity;
+
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.List;
+
+/**
+ * 同步消息表
+ */
+public class SyViewEntity implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+
+	/**
+	 * 钉钉中id
+	 */
+	private String oaId;
+
+	/**
+	 * 报销类型
+	 */
+	private String parType;
+
+	/**
+	 * 费用科目
+	 */
+	private String accountCode;
+
+	/**
+	 * 钉钉中部门名称
+	 */
+	private String deptName;
+	/**
+	 * 钉钉中部门名称
+	 */
+	private String deptCode;
+	/**
+	 * 钉钉中人员编码
+	 */
+	private String jobNumber;
+	/**
+	 * 同步返回消息
+	 */
+	private String syMessage;
+	/**
+	 * 创建时间
+	 */
+	private Timestamp createTime;
+
+	/**
+	 * 备用金、报销单
+	 */
+	private String tableType;
+
+	public String getTableType() {
+		return tableType;
+	}
+
+	public void setTableType(String tableType) {
+		this.tableType = tableType;
+	}
+
+	public String getOaId() {
+		return oaId;
+	}
+
+	public void setOaId(String oaId) {
+		this.oaId = oaId;
+	}
+
+	public String getParType() {
+		return parType;
+	}
+
+	public void setParType(String parType) {
+		this.parType = parType;
+	}
+
+	public String getAccountCode() {
+		return accountCode;
+	}
+
+	public void setAccountCode(String accountCode) {
+		this.accountCode = accountCode;
+	}
+
+	public String getDeptName() {
+		return deptName;
+	}
+
+	public void setDeptName(String deptName) {
+		this.deptName = deptName;
+	}
+
+	public String getDeptCode() {
+		return deptCode;
+	}
+
+	public void setDeptCode(String deptCode) {
+		this.deptCode = deptCode;
+	}
+
+	public String getJobNumber() {
+		return jobNumber;
+	}
+
+	public void setJobNumber(String jobNumber) {
+		this.jobNumber = jobNumber;
+	}
+
+	public String getSyMessage() {
+		return syMessage;
+	}
+
+	public void setSyMessage(String syMessage) {
+		this.syMessage = syMessage;
+	}
+
+	public Timestamp getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Timestamp createTime) {
+		this.createTime = createTime;
+	}
+}

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

@@ -56,4 +56,35 @@
 			}
 	</select>
 
+	<select id="selectView" 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(NOW(),'%Y-%m-%d')
+		and table_type = #{tableType}
+	</select>
+
+	<insert id="save">
+		INSERT INTO sy_view (
+			oa_id,
+			par_type,
+			account_code,
+			dept_name,
+			dept_code,
+			job_number,
+			create_time,
+			sy_message,
+			table_type
+		)
+		VALUES (
+			   #{oaId},
+			   #{parType},
+			   #{accountCode},
+			   #{deptName},
+			   #{deptCode},
+			   #{jobNumber},
+			   now(),
+			   #{syMessage},
+		        #{tableType}
+
+			   )
+	</insert>
 </mapper>

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

@@ -1,13 +1,19 @@
 package net.chenlin.dp.modules.sys.service.impl;
 
+import net.chenlin.dp.common.entity.R;
 import net.chenlin.dp.common.support.orm.db.DynamicDataSource;
+import net.chenlin.dp.common.utils.CommonUtils;
 import net.chenlin.dp.modules.sys.dao.TestU8Mapper;
+import net.chenlin.dp.modules.sys.entity.SyViewEntity;
+import net.chenlin.dp.modules.sys.entity.SysAreaEntity;
 import net.chenlin.dp.modules.sys.service.testU8Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.List;
+
 
 /**
  * 定时任务日志
@@ -24,6 +30,18 @@ public class testU8ServiceImpl implements testU8Service {
 		return testU8Mapper.testAll();
 	}
 
+	@Override
+	public List<SyViewEntity> selectView(String tableType) {
+		return testU8Mapper.selectView(tableType);
+	}
+
+	@Override
+	public R saveSyView(SyViewEntity area) {
+		int count = testU8Mapper.save(area);
+		return CommonUtils.msg(count);
+	}
+
+
 	/**
 	 * 调用存储过程 获取下一个编码
 	 * @param upTime

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

@@ -1,6 +1,11 @@
 package net.chenlin.dp.modules.sys.service;
 
+import net.chenlin.dp.common.entity.R;
 import net.chenlin.dp.common.support.orm.db.DynamicDataSource;
+import net.chenlin.dp.modules.sys.entity.SyViewEntity;
+import net.chenlin.dp.modules.sys.entity.SysUserEntity;
+
+import java.util.List;
 
 /**
  * 定时任务日志
@@ -9,6 +14,10 @@ import net.chenlin.dp.common.support.orm.db.DynamicDataSource;
 public interface testU8Service {
 	int testAll();
 
+	R saveSyView(SyViewEntity user);
+
+	public List<SyViewEntity> selectView(String tableType);
+
 	/**
 	 * 调用存储过程 获取下一个编码
 	 * @param StuNo