WIP:信保未回款预警task
This commit is contained in:
parent
3abdb3bb3f
commit
f47b4a70a7
@ -2,6 +2,7 @@ package com.yem.wm.es.exportpresent.task;
|
|||||||
|
|
||||||
import com.yem.rf.utils.RFUtils;
|
import com.yem.rf.utils.RFUtils;
|
||||||
import com.yem.tws.common1.DateUtils;
|
import com.yem.tws.common1.DateUtils;
|
||||||
|
import com.yem.wm.es.shippingdetails.util.PaymentControlUtil;
|
||||||
import com.yem.wm.utils.DynamicObjectUtil;
|
import com.yem.wm.utils.DynamicObjectUtil;
|
||||||
import com.yem.wm.utils.YEM;
|
import com.yem.wm.utils.YEM;
|
||||||
import kd.bos.context.RequestContext;
|
import kd.bos.context.RequestContext;
|
||||||
@ -11,8 +12,10 @@ import kd.bos.exception.KDException;
|
|||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.schedule.executor.AbstractTask;
|
import kd.bos.schedule.executor.AbstractTask;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
import org.apache.commons.compress.utils.Lists;
|
import org.apache.commons.compress.utils.Lists;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -26,7 +29,7 @@ public class ExportPresentWarningTask extends AbstractTask {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||||
|
|
||||||
boolean isSendMessage = isTenDaysAfter();
|
// boolean isSendMessage = isTenDaysAfter();
|
||||||
|
|
||||||
QFilter qFilter = RFUtils.getBaseQFilter();
|
QFilter qFilter = RFUtils.getBaseQFilter();
|
||||||
String selectfields = DynamicObjectUtil.getSelectfields("yem_es_exportpresent");
|
String selectfields = DynamicObjectUtil.getSelectfields("yem_es_exportpresent");
|
||||||
@ -34,11 +37,52 @@ public class ExportPresentWarningTask extends AbstractTask {
|
|||||||
DynamicObject[] load = BusinessDataServiceHelper.load("yem_es_exportpresent", selectfields, qFilter.toArray());
|
DynamicObject[] load = BusinessDataServiceHelper.load("yem_es_exportpresent", selectfields, qFilter.toArray());
|
||||||
// 订舱单号-提单日期
|
// 订舱单号-提单日期
|
||||||
Map<String, Date> ladingDateMap = new HashMap<>();
|
Map<String, Date> ladingDateMap = new HashMap<>();
|
||||||
|
// 合同号-是否合同回款完成
|
||||||
|
Map<String, Boolean> isClaimFinishedMap = new HashMap<>();
|
||||||
for (DynamicObject d : load) {
|
for (DynamicObject d : load) {
|
||||||
DynamicObjectCollection c = d.getDynamicObjectCollection("yem_es_exportpre_erw");
|
DynamicObjectCollection c = d.getDynamicObjectCollection("yem_es_exportpre_erw");
|
||||||
for (DynamicObject subD : c) {
|
for (DynamicObject subD : c) {
|
||||||
String shipmentnum = subD.getString("yem_shipmentnum_c");
|
String shipmentnum = subD.getString("yem_shipmentnum_c");
|
||||||
ladingDateMap.put(shipmentnum, null);
|
ladingDateMap.put(shipmentnum, null);
|
||||||
|
String contractnum = subD.getString("yem_contractnum_c");
|
||||||
|
isClaimFinishedMap.put(contractnum, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Object, DynamicObject> salesorders = BusinessDataServiceHelper.loadFromCache("yem_es_salesorder", "id, billno", new QFilter[]{new QFilter("billno", "in", isClaimFinishedMap.keySet())});
|
||||||
|
Map<String, Long> salesorderNo = new HashMap<>();
|
||||||
|
for (Map.Entry<Object, DynamicObject> salesorderEntry : salesorders.entrySet()) {
|
||||||
|
Long orderId = (Long) salesorderEntry.getKey();
|
||||||
|
DynamicObject order = salesorderEntry.getValue();
|
||||||
|
salesorderNo.put(order.getString("billno"), orderId);
|
||||||
|
}
|
||||||
|
Map<Object, DynamicObject> stOrder = BusinessDataServiceHelper.loadFromCache("yem_es_storagetrans", "id, billno, yem_es_salescontrac_s.yem_rapamt, yem_es_salescontrac_s.yem_contractnumbers_p", new QFilter[]{new QFilter("yem_es_salescontrac_s.yem_contractnumbers_p", "in", salesorderNo.keySet())});
|
||||||
|
// 合同号-收汇金额合计
|
||||||
|
Map<String, BigDecimal> receiveAmt = new HashMap<>();
|
||||||
|
for (DynamicObject stBill : stOrder.values()) {
|
||||||
|
DynamicObjectCollection collection = stBill.getDynamicObjectCollection("yem_es_salescontrac_s");
|
||||||
|
for (DynamicObject d : collection) {
|
||||||
|
BigDecimal rapamt = d.getBigDecimal("yem_rapamt");
|
||||||
|
String contractnumbers = d.getString("yem_contractnumbers_p");
|
||||||
|
BigDecimal calc;
|
||||||
|
if (receiveAmt.containsKey(contractnumbers)) {
|
||||||
|
calc = receiveAmt.get(contractnumbers).add(rapamt);
|
||||||
|
} else {
|
||||||
|
calc = rapamt;
|
||||||
|
}
|
||||||
|
receiveAmt.put(contractnumbers, calc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, Long> salesorderEntry : salesorderNo.entrySet()) {
|
||||||
|
String billno = salesorderEntry.getKey();
|
||||||
|
DynamicObject salesorder = salesorders.get(salesorderEntry.getValue());
|
||||||
|
if (salesorder == null) continue;
|
||||||
|
BigDecimal climeAmt = PaymentControlUtil.getContractClimeAmt(salesorder, "F");
|
||||||
|
if (receiveAmt.containsKey(billno)) {
|
||||||
|
BigDecimal receive = receiveAmt.get(billno);
|
||||||
|
if (receive.compareTo(climeAmt) < 0 && isClaimFinishedMap.containsKey(billno)) {
|
||||||
|
isClaimFinishedMap.put(billno, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +107,11 @@ public class ExportPresentWarningTask extends AbstractTask {
|
|||||||
Date added = DateUtils.addDays(date, forward);
|
Date added = DateUtils.addDays(date, forward);
|
||||||
subD.set("yem_shdreceivedate", added);
|
subD.set("yem_shdreceivedate", added);
|
||||||
String contractnum = subD.getString("yem_contractnum_c");
|
String contractnum = subD.getString("yem_contractnum_c");
|
||||||
if (isSendMessage) {
|
// if (isSendMessage) {
|
||||||
|
// 以认领完成
|
||||||
|
if (isClaimFinishedMap.containsKey(contractnum) && isClaimFinishedMap.get(contractnum)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
DynamicObject operator = subD.getDynamicObject("yem_operator_e");
|
DynamicObject operator = subD.getDynamicObject("yem_operator_e");
|
||||||
if (operator == null) continue;
|
if (operator == null) continue;
|
||||||
long sendUser = operator.getLong("id");
|
long sendUser = operator.getLong("id");
|
||||||
@ -75,7 +123,7 @@ public class ExportPresentWarningTask extends AbstractTask {
|
|||||||
}
|
}
|
||||||
list.add(String.format("合同:%s,寄单放单单号:%s,应回款日期为:%s,请知悉!\n\r", contractnum, d.getString("billno"), DateUtils.getData(added, "yyyy-MM-dd")));
|
list.add(String.format("合同:%s,寄单放单单号:%s,应回款日期为:%s,请知悉!\n\r", contractnum, d.getString("billno"), DateUtils.getData(added, "yyyy-MM-dd")));
|
||||||
message.put(sendUser, list);
|
message.put(sendUser, list);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,15 +141,18 @@ public class ExportPresentWarningTask extends AbstractTask {
|
|||||||
Long userid = sendMsg.getKey();
|
Long userid = sendMsg.getKey();
|
||||||
List<String> messageContent = sendMsg.getValue();
|
List<String> messageContent = sendMsg.getValue();
|
||||||
ArrayList<Long> sendUserId = Lists.newArrayList();
|
ArrayList<Long> sendUserId = Lists.newArrayList();
|
||||||
sendUserId.add(userid);
|
// sendUserId.add(userid);//销售员
|
||||||
sendUserId.addAll(devUserIds);
|
sendUserId.addAll(devUserIds);
|
||||||
|
|
||||||
YEM.sendMessage(sendUserId, "预警消息", "应回款日期预警", String.join("", messageContent), "预警消息");
|
YEM.sendMessage(sendUserId, "预警消息", "应回款日期预警", String.join("", messageContent), "预警消息");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SaveServiceHelper.save(load);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前日期是否是给定日期的十天后
|
* 当前日期是否是给定日期的十天后
|
||||||
|
*
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public static boolean isTenDaysAfter() {
|
public static boolean isTenDaysAfter() {
|
||||||
|
Loading…
Reference in New Issue
Block a user