parent
e751d21ba0
commit
8d7f58194d
|
@ -6,6 +6,8 @@ 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.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.schedule.executor.AbstractTask;
|
||||
|
@ -13,6 +15,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shkd.sys.sys.mservice.ApiService;
|
||||
import shkd.sys.sys.plugin.form.ApiMappingBillPlugin;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
|
@ -23,6 +26,7 @@ import java.util.*;
|
|||
* 后台任务插件
|
||||
*/
|
||||
public class PushTaskPlugin extends AbstractTask implements Plugin {
|
||||
private static final Log logger = LogFactory.getLog(PushTaskPlugin.class);
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
|
@ -39,11 +43,13 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
|
|||
|
||||
Date date;
|
||||
try {
|
||||
date = DateUtils.stringToDate(formattedDate,"yyyy-MM-dd");
|
||||
date = DateUtils.stringToDate(formattedDate, "yyyy-MM-dd");
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
String billName = null;
|
||||
|
||||
List<DynamicObject> dynamicObjects = new ArrayList<>();
|
||||
if (billMark != null) {
|
||||
switch (billMark.toString()) {
|
||||
|
@ -55,6 +61,7 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
|
|||
"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);
|
||||
billName = "付款处理";
|
||||
break;
|
||||
// 收款处理
|
||||
case "cas_recbill":
|
||||
|
@ -64,8 +71,9 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
|
|||
"shkd_businessnumber,shkd_businessid,shkd_businessname"
|
||||
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
|
||||
dynamicObjects = Arrays.asList(objects2);
|
||||
billName = "收款处理";
|
||||
break;
|
||||
// 银企交易明细查询
|
||||
// 银行收付处理
|
||||
case "bei_transdetail_cas":
|
||||
DynamicObject[] objects3 = BusinessDataServiceHelper.load("bei_transdetail_cas",
|
||||
"id,bizdate,oppbank,oppunit,accountbank,description,company,oppbanknumber," +
|
||||
|
@ -73,6 +81,7 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
|
|||
"shkd_businessnumber,shkd_businessid,shkd_businessname"
|
||||
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
|
||||
dynamicObjects = Arrays.asList(objects3);
|
||||
billName = "银行收付处理";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
@ -80,17 +89,22 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
|
|||
}
|
||||
|
||||
List<DynamicObject> objects = new ArrayList<>();
|
||||
String finalBillName = billName;
|
||||
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);
|
||||
if (!responseBody.contains("失败")) {
|
||||
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);
|
||||
} else {
|
||||
logger.info("推送 → {} → 失败,失败单据编号:{}", finalBillName, dynamicObject.getString("billno"));
|
||||
}
|
||||
});
|
||||
SaveServiceHelper.save(objects.toArray(new DynamicObject[0]));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue