parent
3b1deed75c
commit
e751d21ba0
|
@ -0,0 +1,97 @@
|
|||
package shkd.sys.sys.plugin.task;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.kingdee.bos.qing.util.DateUtils;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.exception.KDException;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.schedule.executor.AbstractTask;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shkd.sys.sys.mservice.ApiService;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 后台任务插件
|
||||
*/
|
||||
public class PushTaskPlugin extends AbstractTask implements Plugin {
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
Object billMark = map.get("billMark");
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
|
||||
// 获取当前日期的前两天
|
||||
LocalDate twoDaysAgo = currentDate.minusDays(2);
|
||||
|
||||
// 格式化日期为 "yyyy-MM-dd"
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String formattedDate = twoDaysAgo.format(formatter);
|
||||
|
||||
Date date;
|
||||
try {
|
||||
date = DateUtils.stringToDate(formattedDate,"yyyy-MM-dd");
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
List<DynamicObject> dynamicObjects = new ArrayList<>();
|
||||
if (billMark != null) {
|
||||
switch (billMark.toString()) {
|
||||
// 付款处理
|
||||
case "cas_paybill":
|
||||
DynamicObject[] objects1 = BusinessDataServiceHelper.load("cas_paybill",
|
||||
"id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," +
|
||||
"payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," +
|
||||
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname"
|
||||
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
|
||||
dynamicObjects = Arrays.asList(objects1);
|
||||
break;
|
||||
// 收款处理
|
||||
case "cas_recbill":
|
||||
DynamicObject[] objects2 = BusinessDataServiceHelper.load("cas_recbill",
|
||||
"id,billno,entry,entry.e_expenseitem,settletype,entry.e_remark,receivingtype," +
|
||||
"payertype,org,bizdate,accountbank,payernumber,actrecamt,txt_description,shkd_pushstatus," +
|
||||
"shkd_businessnumber,shkd_businessid,shkd_businessname"
|
||||
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
|
||||
dynamicObjects = Arrays.asList(objects2);
|
||||
break;
|
||||
// 银企交易明细查询
|
||||
case "bei_transdetail_cas":
|
||||
DynamicObject[] objects3 = BusinessDataServiceHelper.load("bei_transdetail_cas",
|
||||
"id,bizdate,oppbank,oppunit,accountbank,description,company,oppbanknumber," +
|
||||
"bankdetailno,transbalance,description,debitamount,creditamount,shkd_pushstatus," +
|
||||
"shkd_businessnumber,shkd_businessid,shkd_businessname"
|
||||
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
|
||||
dynamicObjects = Arrays.asList(objects3);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
List<DynamicObject> objects = new ArrayList<>();
|
||||
dynamicObjects.forEach(dynamicObject -> {
|
||||
String responseBody = ApiService.paymentSlipsJson(dynamicObject, "BIP");
|
||||
JSONObject jsonObject = JSON.parseObject(responseBody);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String code = data.getString("code");
|
||||
String id = data.getString("id");
|
||||
dynamicObject.set("shkd_businessnumber", code);
|
||||
dynamicObject.set("shkd_businessid", id);
|
||||
dynamicObject.set("shkd_businessname", "BIP");
|
||||
dynamicObject.set("shkd_pushstatus", "已推送");
|
||||
objects.add(dynamicObject);
|
||||
});
|
||||
SaveServiceHelper.save(objects.toArray(new DynamicObject[0]));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue