123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package net.chenlin.dp.modules.api.service;
- import com.alibaba.fastjson.JSONObject;
- import com.mysql.cj.util.StringUtils;
- 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.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;
- import java.util.Map;
- import java.util.Properties;
- public class PettyCashService {
- 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){
- 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 = "";
- String dept_code = "";
- String type = "";
- Map<String,Object> map = dingdingOpenInterface.getOrderDetails(o);
- if(StringUtils.isNullOrEmpty(map.get("result").toString()) || !map.get("result").toString().equals("agree")){
- continue;
- }
- Map<String,Object> map1 = dingdingOpenInterface.tableToMap(map);
- Map<String,Object> mapPerson = dingdingOpenInterface.getViewByUserId(map.get("originator_userid").toString());
- if(mapPerson !=null ){
- job_number = mapPerson.get("job_number").toString();
- work_place = mapPerson.get("work_place").toString();
- if(StringUtils.isNullOrEmpty(work_place)){
- continue;
- }
- if (work_place.equals("昆山")){
- dept_code = getPerson(job_number,"1");
- type = "1";
- }else if(work_place.equals("潍坊")){
- dept_code = getPerson(job_number,"3");
- type = "3";
- }else{
- continue;
- }
- }else{
- continue;
- }
- map1.put("abstract",map1.get("申请事由"));
- map1.put("naturalCurrency",map1.get("申请金额(元)"));
- map1.put("account_code","122102");
- map1.put("dept_code",dept_code);
- map1.put("job_number",job_number);
- String mess = VoucherAdd.addVoucher(map1,map.get("business_id").toString(),type);
- SyViewEntity entity = new SyViewEntity();
- entity.setOaId(o);
- entity.setAccountCode("122102");
- entity.setParType("备用金");
- entity.setDeptCode(dept_code);
- entity.setJobNumber(job_number);
- entity.setJobNumber("备用金");
- entity.setSyMessage(mess);
- try {
- u8Service.saveSyView(entity);
- }catch (Exception e){
- System.out.println("异常备用金");
- }
- }
- }
- }
-
- public static String getPerson(String id,String ds){
- Properties prop = PropUtil.getProperties("/config.properties");
- String to_account = prop.getProperty("to_account");
- PersonService par = new PersonService();
- String code = "";
- try {
- JSONObject record = par.get(id, to_account,ds);
- if(record.get("errcode").equals("0")){
- JSONObject record1 = (JSONObject) record.get("person");
- code = record1.get("cdept_num").toString();
- }
- System.out.println(record);
- } catch (OpenAPIException e) {
- return code;
- }
- return code;
- }
- public static void main(String[] args) throws Exception {
- }
- }
|