出差单获取发送OA
This commit is contained in:
parent
01943abab5
commit
bddab72790
|
@ -62,6 +62,138 @@ public class BusinessServiceImpl extends BaseService<BusinessEntity, String> imp
|
|||
this.dao = dao;
|
||||
}
|
||||
|
||||
//@Override
|
||||
//public JsonResultEntity getBusinessData(JSONObject requestJson) {
|
||||
//
|
||||
// //1、调用token
|
||||
// String access_token = getToken();
|
||||
// if (access_token == null) {
|
||||
// return BaseResult.getFailureMessageEntity("token获取失败");
|
||||
// }
|
||||
// Date date = new Date();
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// String times = sdf.format(date);
|
||||
//times = "2025-02-08";//
|
||||
// //2、调用接口获取数据
|
||||
// String queryCursor = null;
|
||||
// String startDate = times+" 00:00:00";
|
||||
// String endDate = times+" 23:59:59";
|
||||
// JSONArray datalist = new JSONArray();
|
||||
// sendBusinessData(datalist, access_token, queryCursor, startDate, endDate);
|
||||
//
|
||||
// if(datalist != null && datalist.size() > 0){
|
||||
// for (int i = 0; i < datalist.size(); i++) {
|
||||
// JSONObject saveData = new JSONObject();
|
||||
// //3、对照数据
|
||||
// JSONObject jsonObject = datalist.getJSONObject(i);
|
||||
// //field0011 申请单号
|
||||
// String field0011 = jsonObject.getString("serialNumber");
|
||||
// if(field0011 == null || "".equals(field0011) ){
|
||||
// continue;
|
||||
// }
|
||||
// saveData.put("field0011",field0011);
|
||||
// //判断是否有这个数据
|
||||
// List<JSONObject> checkData = businessDao.queryData(saveData);
|
||||
// if(checkData != null && checkData.size() > 0){
|
||||
// continue;
|
||||
// }
|
||||
// saveData.put("id", String.valueOf(UUIDLong.longUUID()));
|
||||
// saveData.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
// saveData.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
// saveData.put("org_id", "0");
|
||||
// saveData.put("create_time", new Date());
|
||||
// saveData.put("modify_time", new Date());
|
||||
// saveData.put("sts", "Y");
|
||||
// saveData.put("data_status", "Y");//新增状态
|
||||
// saveData.put("add_status", "0");//新增状态
|
||||
// saveData.put("update_status", "1");//修改状态
|
||||
// saveData.put("delete_status", "1");//删除状态
|
||||
// ComparisonEntity comparisonEntityRule = new ComparisonEntity();
|
||||
// comparisonEntityRule.setRulePrefix("CCD");
|
||||
// comparisonEntityRule.setRuleMiddle("%Y-%m-%d");
|
||||
// comparisonEntityRule.setRuleSuffix(5);
|
||||
// comparisonEntityRule.setDbName("mdm_ccd");
|
||||
// ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
|
||||
// saveData.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
|
||||
// saveData.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
|
||||
// saveData.put("field0001",jsonObject.getString("applyUser"));//申请人
|
||||
// saveData.put("field0002",jsonObject.getString("jobNumber"));//申请人工号
|
||||
// String oaToken = getOAToken("");
|
||||
// JSONObject user = getUser(jsonObject.getString("jobNumber"),oaToken);
|
||||
// saveData.put("field0012",user.getString("orgPostName"));
|
||||
// saveData.put("field0013",user.getString("orgDepartmentName"));
|
||||
// saveData.put("field0014",user.getString("telNumber"));
|
||||
// saveData.put("field0003",jsonObject.getString("startDateTime"));// 出差时间
|
||||
// saveData.put("field0015",jsonObject.getString("documentType"));
|
||||
// saveData.put("field0017",jsonObject.getString("dayValOfDuration"));// 出差时长(天)
|
||||
// saveData.put("field0018",jsonObject.getString("extshifouzhanhuichucha_109372_807255447"));// 是否境外出差
|
||||
// saveData.put("field0019",jsonObject.getString("extshifouxuyaoapecka_109372_294746269"));// 是否需要APEC卡
|
||||
// saveData.put("field0020",jsonObject.getString("extshifoujingwaichucha_109372_295886206"));// 是否展会出差
|
||||
// saveData.put("field0021",jsonObject.getString("reason"));// 出差事由
|
||||
//
|
||||
// JSONArray detaildata = jsonObject.getJSONArray("businessDetailsSync");
|
||||
// if(detaildata != null && detaildata.size() > 0){
|
||||
// for (int i1 = 0; i1 < detaildata.size(); i1++) {
|
||||
// JSONObject saveDetailData = new JSONObject();
|
||||
// saveDetailData.put("field0004",detaildata.getJSONObject(i1).getString("startDateTime"));//明细表-出发时间
|
||||
// saveDetailData.put("field0005",detaildata.getJSONObject(i1).getString("stopDateTime"));//明细表-结束时间
|
||||
// saveDetailData.put("field0022",detaildata.getJSONObject(i1).getString("businessDuration"));//明细表-出差时长
|
||||
//
|
||||
// if(detaildata.getJSONObject(i1).getString("businessVehicle") != null){// 明细表-交通工具
|
||||
// if("0".equals(detaildata.getJSONObject(i1).getString("businessVehicle"))){
|
||||
// saveDetailData.put("field0008","飞机");
|
||||
// }
|
||||
// if("1".equals(detaildata.getJSONObject(i1).getString("businessVehicle"))){
|
||||
// saveDetailData.put("field0008","火车");
|
||||
// }
|
||||
// if("2".equals(detaildata.getJSONObject(i1).getString("businessVehicle"))){
|
||||
// saveDetailData.put("field0008","汽车");
|
||||
// }
|
||||
// if("3".equals(detaildata.getJSONObject(i1).getString("businessVehicle"))){
|
||||
// saveDetailData.put("field0008","轮船");
|
||||
// }
|
||||
// }
|
||||
// saveDetailData.put("field0006",detaildata.getJSONObject(i1).getString("departurePlace"));//明细表-出发地
|
||||
// saveDetailData.put("field0007",detaildata.getJSONObject(i1).getString("destination"));//明细表-目的地
|
||||
// saveDetailData.put("field0009",detaildata.getJSONObject(i1).getString("expectedCost"));//明细表-预计费用
|
||||
// saveData.put("field0016",detaildata.getJSONObject(i1).getString("destination"));// 出差城市
|
||||
//
|
||||
//
|
||||
// saveDetailData.put("id", String.valueOf(UUIDLong.longUUID()));
|
||||
// saveDetailData.put("formmain_id", saveData.getString("id"));
|
||||
// saveDetailData.put("data_status", "Y");//新增状态
|
||||
//
|
||||
// saveDetailData.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
// saveDetailData.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
// saveDetailData.put("org_id", "0");
|
||||
// saveDetailData.put("create_time", new Date());
|
||||
// saveDetailData.put("modify_time", new Date());
|
||||
// saveDetailData.put("sts", "Y");
|
||||
// businessDao.saveDetailData(saveDetailData);
|
||||
// }
|
||||
// }
|
||||
// businessDao.saveData(saveData);
|
||||
//
|
||||
// //5、保存写入日志
|
||||
// ControlsLogEntity controlsLogEntity=new ControlsLogEntity();
|
||||
// controlsLogEntity.setId(UUIDUtils.getUUID());
|
||||
// controlsLogEntity.setFormmainId(saveData.getString("id"));
|
||||
// controlsLogEntity.setSourceName("数智中台");
|
||||
// controlsLogEntity.setCode("800004");
|
||||
// controlsLogEntity.setSourceData(jsonObject.toString());
|
||||
// controlsLogEntity.setOptionType("接口新增");
|
||||
// controlsLogEntity.setOptionName("数智中台");
|
||||
// controlsLogEntity.setDbName("mdm_ccd_option_log");
|
||||
// controlsLogEntity.setDataType("1");
|
||||
// controlsLogEntity.setCreate_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
// controlsLogEntity.setModify_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
// controlsLogEntity.setOrg_id("0");
|
||||
// controlsLogEntity.setRemark("插件新增");
|
||||
// controlsLogDaoimpl.saveControlsLog(saveData.getString("id"), "数智中台", "800004", jsonObject.toJSONString(), "接口新增", "数智中台", "mdm_ccd_option_log", "1","插件新增");
|
||||
// }
|
||||
// }
|
||||
// return BaseResult.getSuccessMessageEntity("处理成功");
|
||||
//}
|
||||
@Override
|
||||
public JsonResultEntity getBusinessData(JSONObject requestJson) {
|
||||
|
||||
|
@ -73,9 +205,8 @@ public class BusinessServiceImpl extends BaseService<BusinessEntity, String> imp
|
|||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String times = sdf.format(date);
|
||||
times = "2025-02-08";//todo
|
||||
//2、调用接口获取数据
|
||||
String queryCursor = null;
|
||||
Integer queryCursor = 1;
|
||||
String startDate = times+" 00:00:00";
|
||||
String endDate = times+" 23:59:59";
|
||||
JSONArray datalist = new JSONArray();
|
||||
|
@ -83,11 +214,11 @@ public class BusinessServiceImpl extends BaseService<BusinessEntity, String> imp
|
|||
|
||||
if(datalist != null && datalist.size() > 0){
|
||||
for (int i = 0; i < datalist.size(); i++) {
|
||||
JSONObject saveData = new JSONObject();
|
||||
JSONObject saveData = new JSONObject();
|
||||
//3、对照数据
|
||||
JSONObject jsonObject = datalist.getJSONObject(i);
|
||||
//field0011 申请单号
|
||||
String field0011 = jsonObject.getString("serialNumber");
|
||||
String field0011 = jsonObject.getString("SerialNumber");
|
||||
if(field0011 == null || "".equals(field0011) ){
|
||||
continue;
|
||||
}
|
||||
|
@ -116,47 +247,64 @@ public class BusinessServiceImpl extends BaseService<BusinessEntity, String> imp
|
|||
ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
|
||||
saveData.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
|
||||
saveData.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
|
||||
saveData.put("field0001",jsonObject.getString("applyUser"));//申请人
|
||||
saveData.put("field0002",jsonObject.getString("jobNumber"));//申请人工号
|
||||
saveData.put("field0001",jsonObject.getString("ApplyUser"));//申请人
|
||||
saveData.put("field0002",jsonObject.getString("JobNumber"));//申请人工号
|
||||
String oaToken = getOAToken("");
|
||||
JSONObject user = getUser(jsonObject.getString("jobNumber"),oaToken);
|
||||
JSONObject user = getUser(jsonObject.getString("JobNumber"),oaToken);
|
||||
if(jsonObject.getString("ApplyUser") != null && !"".equals(jsonObject.getString("ApplyUser"))){
|
||||
saveData.put("field0001",jsonObject.getString("ApplyUser"));//申请人
|
||||
}else {
|
||||
saveData.put("field0001",user.getString("name"));//申请人
|
||||
}
|
||||
saveData.put("field0012",user.getString("orgPostName"));
|
||||
saveData.put("field0013",user.getString("orgDepartmentName"));
|
||||
saveData.put("field0014",user.getString("telNumber"));
|
||||
saveData.put("field0003",jsonObject.getString("startDateTime"));// 出差时间
|
||||
saveData.put("field0015",jsonObject.getString("documentType"));
|
||||
saveData.put("field0017",jsonObject.getString("dayValOfDuration"));// 出差时长(天)
|
||||
saveData.put("field0018",jsonObject.getString("extshifouzhanhuichucha_109372_807255447"));// todo 是否境外出差
|
||||
saveData.put("field0019",jsonObject.getString("extshifouxuyaoapecka_109372_294746269"));// todo 是否需要APEC卡
|
||||
saveData.put("field0020",jsonObject.getString("extshifoujingwaichucha_109372_295886206"));// todo 是否展会出差
|
||||
saveData.put("field0021",jsonObject.getString("reason"));// 出差事由
|
||||
saveData.put("field0003",jsonObject.getString("StartDateTime"));// 出差时间
|
||||
saveData.put("field0015",jsonObject.getString("DocumentType"));
|
||||
saveData.put("field0017",jsonObject.getString("DayValOfDuration"));// 出差时长(天)
|
||||
if(jsonObject.getString("extshifouzhanhuichucha_109372_807255447") != null && "true".equals(jsonObject.getString("extshifouzhanhuichucha_109372_807255447"))){
|
||||
saveData.put("field0018","是");// 是否境外出差
|
||||
}else {
|
||||
saveData.put("field0018","否");// 是否境外出差
|
||||
}
|
||||
if(jsonObject.getString("extshifouxuyaoapecka_109372_294746269") != null && "true".equals(jsonObject.getString("extshifouxuyaoapecka_109372_294746269"))){
|
||||
saveData.put("field0019","是");// 是否需要APEC卡
|
||||
}else {
|
||||
saveData.put("field0019","否");// 是否需要APEC卡
|
||||
}
|
||||
if(jsonObject.getString("extshifoujingwaichucha_109372_295886206") != null && "true".equals(jsonObject.getString("extshifoujingwaichucha_109372_295886206"))){
|
||||
saveData.put("field0020","是");// 是否展会出差
|
||||
}else {
|
||||
saveData.put("field0020","否");// 是否展会出差
|
||||
}
|
||||
saveData.put("field0021",jsonObject.getString("Reason"));// 出差事由
|
||||
|
||||
JSONArray detaildata = jsonObject.getJSONArray("businessDetailsSync");
|
||||
JSONArray detaildata = jsonObject.getJSONArray("BusinessDetailsSync");
|
||||
if(detaildata != null && detaildata.size() > 0){
|
||||
for (int i1 = 0; i1 < detaildata.size(); i1++) {
|
||||
JSONObject saveDetailData = new JSONObject();
|
||||
saveDetailData.put("field0004",detaildata.getJSONObject(i1).getString("startDateTime"));//明细表-出发时间
|
||||
saveDetailData.put("field0005",detaildata.getJSONObject(i1).getString("stopDateTime"));//明细表-结束时间
|
||||
saveDetailData.put("field0022",detaildata.getJSONObject(i1).getString("businessDuration"));//明细表-出差时长
|
||||
saveDetailData.put("field0004",detaildata.getJSONObject(i1).getString("StartDateTime"));//明细表-出发时间
|
||||
saveDetailData.put("field0005",detaildata.getJSONObject(i1).getString("StopDateTime"));//明细表-结束时间
|
||||
saveDetailData.put("field0022",detaildata.getJSONObject(i1).getString("BusinessDuration"));//明细表-出差时长
|
||||
|
||||
if(detaildata.getJSONObject(i1).getString("businessVehicle") != null){// 明细表-交通工具
|
||||
if("0".equals(detaildata.getJSONObject(i1).getString("businessVehicle"))){
|
||||
if(detaildata.getJSONObject(i1).getString("BusinessVehicle") != null){// 明细表-交通工具
|
||||
if("0".equals(detaildata.getJSONObject(i1).getString("BusinessVehicle"))){
|
||||
saveDetailData.put("field0008","飞机");
|
||||
}
|
||||
if("1".equals(detaildata.getJSONObject(i1).getString("businessVehicle"))){
|
||||
if("1".equals(detaildata.getJSONObject(i1).getString("BusinessVehicle"))){
|
||||
saveDetailData.put("field0008","火车");
|
||||
}
|
||||
if("2".equals(detaildata.getJSONObject(i1).getString("businessVehicle"))){
|
||||
if("2".equals(detaildata.getJSONObject(i1).getString("BusinessVehicle"))){
|
||||
saveDetailData.put("field0008","汽车");
|
||||
}
|
||||
if("3".equals(detaildata.getJSONObject(i1).getString("businessVehicle"))){
|
||||
if("3".equals(detaildata.getJSONObject(i1).getString("BusinessVehicle"))){
|
||||
saveDetailData.put("field0008","轮船");
|
||||
}
|
||||
}
|
||||
saveDetailData.put("field0006",detaildata.getJSONObject(i1).getString("departurePlace"));//明细表-出发地
|
||||
saveDetailData.put("field0007",detaildata.getJSONObject(i1).getString("destination"));//明细表-目的地
|
||||
saveDetailData.put("field0009",detaildata.getJSONObject(i1).getString("expectedCost"));//明细表-预计费用
|
||||
saveData.put("field0016",detaildata.getJSONObject(i1).getString("destination"));// 出差城市
|
||||
saveDetailData.put("field0006",detaildata.getJSONObject(i1).getString("DeparturePlace"));//明细表-出发地
|
||||
saveDetailData.put("field0007",detaildata.getJSONObject(i1).getString("Destination"));//明细表-目的地
|
||||
saveDetailData.put("field0009",detaildata.getJSONObject(i1).getString("ExpectedCost"));//明细表-预计费用
|
||||
saveData.put("field0016",detaildata.getJSONObject(i1).getString("Destination"));// 出差城市
|
||||
|
||||
|
||||
saveDetailData.put("id", String.valueOf(UUIDLong.longUUID()));
|
||||
|
@ -195,27 +343,57 @@ public class BusinessServiceImpl extends BaseService<BusinessEntity, String> imp
|
|||
return BaseResult.getSuccessMessageEntity("处理成功");
|
||||
}
|
||||
|
||||
private void sendBusinessData(JSONArray datalist, String access_token, String queryCursor, String startDate, String endDate) {
|
||||
String url = "https://openapi.italent.cn/AttendanceOpen/api/v1/Business/GetApprovalCompletedBusinessListByDate";
|
||||
//private void sendBusinessData(JSONArray datalist, String access_token, String queryCursor, String startDate, String endDate) {
|
||||
// String url = "https://openapi.italent.cn/AttendanceOpen/api/v1/Business/GetApprovalCompletedBusinessListByDate";
|
||||
// Map<String, String> headers = new HashMap<>();
|
||||
// headers.put("Authorization", "Bearer " + access_token);
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("startDate", startDate);
|
||||
// jsonObject.put("endDate", endDate);
|
||||
// jsonObject.put("pageSize", 100);
|
||||
// if (queryCursor != null) {
|
||||
// jsonObject.put("queryCursor", queryCursor);
|
||||
// }
|
||||
// String returndata = sendPost(url, headers, jsonObject.toString());
|
||||
//
|
||||
// if (returndata != null && JSONObject.isValidObject(returndata)) {
|
||||
// JSONObject dataJson = JSONObject.parseObject(returndata);
|
||||
// if(dataJson != null && dataJson.getString("code") != null && "200".equals( dataJson.getString("code"))){
|
||||
// JSONObject data = dataJson.getJSONObject("data");
|
||||
// if(data != null ){
|
||||
// JSONArray businessList = data.getJSONArray("businessList");
|
||||
// if(!data.getBoolean("isLastPage")){
|
||||
// queryCursor = data.getString("sortCursor");
|
||||
// sendBusinessData(datalist, access_token, queryCursor, startDate, endDate);
|
||||
// }
|
||||
// if(businessList != null && businessList.size() > 0){
|
||||
// datalist.addAll(businessList);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
private void sendBusinessData(JSONArray datalist, String access_token, Integer queryCursor, String startDate, String endDate) {
|
||||
String url = "https://openapi.italent.cn/AttendanceOpen/api/v1/Business/GetApprovalCompletedBusinessList";
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", "Bearer " + access_token);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("startDate", startDate);
|
||||
jsonObject.put("endDate", endDate);
|
||||
jsonObject.put("pageSize", 100);
|
||||
if (queryCursor != null) {
|
||||
jsonObject.put("queryCursor", queryCursor);
|
||||
}
|
||||
jsonObject.put("StartDate", startDate);
|
||||
jsonObject.put("EndDate", endDate);
|
||||
jsonObject.put("PageIndex", queryCursor);
|
||||
jsonObject.put("PageSize", 100);
|
||||
|
||||
String returndata = sendPost(url, headers, jsonObject.toString());
|
||||
|
||||
if (returndata != null && JSONObject.isValidObject(returndata)) {
|
||||
JSONObject dataJson = JSONObject.parseObject(returndata);
|
||||
if(dataJson != null && dataJson.getString("code") != null && "200".equals( dataJson.getString("code"))){
|
||||
JSONObject data = dataJson.getJSONObject("data");
|
||||
if(dataJson != null && dataJson.getString("Code") != null && "200".equals( dataJson.getString("Code"))){
|
||||
JSONObject data = dataJson.getJSONObject("Data");
|
||||
if(data != null ){
|
||||
JSONArray businessList = data.getJSONArray("businessList");
|
||||
if(!data.getBoolean("isLastPage")){
|
||||
queryCursor = data.getString("sortCursor");
|
||||
JSONArray businessList = data.getJSONArray("BusinessList");
|
||||
if(data.getInteger("Total") > queryCursor*100){
|
||||
queryCursor = queryCursor+1;
|
||||
sendBusinessData(datalist, access_token, queryCursor, startDate, endDate);
|
||||
}
|
||||
if(businessList != null && businessList.size() > 0){
|
||||
|
@ -224,7 +402,6 @@ public class BusinessServiceImpl extends BaseService<BusinessEntity, String> imp
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private JSONObject getUser(String usercode,String access_token) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
@ -242,6 +419,7 @@ public class BusinessServiceImpl extends BaseService<BusinessEntity, String> imp
|
|||
jsonObject.put("telNumber",dataJson.getJSONObject(i).getString("telNumber"));
|
||||
jsonObject.put("orgDepartmentName",dataJson.getJSONObject(i).getString("orgDepartmentName"));
|
||||
jsonObject.put("orgPostName",dataJson.getJSONObject(i).getString("orgPostName"));
|
||||
jsonObject.put("name",dataJson.getJSONObject(i).getString("name"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue