|
@@ -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();
|
|
|
}
|
|
|
|
|
|
|