feat:信保未回款预警task
This commit is contained in:
parent
e599288765
commit
871005c558
@ -0,0 +1,114 @@
|
|||||||
|
package com.yem.wm.es.exportpresent.task;
|
||||||
|
|
||||||
|
import com.yem.rf.utils.RFUtils;
|
||||||
|
import com.yem.tws.common1.DateUtils;
|
||||||
|
import com.yem.wm.utils.DynamicObjectUtil;
|
||||||
|
import com.yem.wm.utils.YEM;
|
||||||
|
import kd.bos.context.RequestContext;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.exception.KDException;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.schedule.executor.AbstractTask;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import org.apache.commons.compress.utils.Lists;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 寄单放单申请收汇方式,增加销售员(根据携带当前行合同上的销售员)、应回款日期(提单日+收款天数),应回款日期不为空时,每10天给销售员发送一次消息提醒:合同:***,寄单放单单号:***,应回款日期为:***,请知悉!
|
||||||
|
* @Date: 2024/12/19 10:24
|
||||||
|
* @Created: by ZZSLL
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ExportPresentWarningTask extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||||
|
|
||||||
|
boolean isSendMessage = isTenDaysAfter();
|
||||||
|
|
||||||
|
QFilter qFilter = RFUtils.getBaseQFilter();
|
||||||
|
String selectfields = DynamicObjectUtil.getSelectfields("yem_es_exportpresent");
|
||||||
|
selectfields = DynamicObjectUtil.getEntrySelectfields(selectfields, "yem_es_exportpresent", "yem_es_exportpre_erw");
|
||||||
|
DynamicObject[] load = BusinessDataServiceHelper.load("yem_es_exportpresent", selectfields, qFilter.toArray());
|
||||||
|
// 订舱单号-提单日期
|
||||||
|
Map<String, Date> ladingDateMap = new HashMap<>();
|
||||||
|
for (DynamicObject d : load) {
|
||||||
|
DynamicObjectCollection c = d.getDynamicObjectCollection("yem_es_exportpre_erw");
|
||||||
|
for (DynamicObject subD : c) {
|
||||||
|
String shipmentnum = subD.getString("yem_shipmentnum_c");
|
||||||
|
ladingDateMap.put(shipmentnum, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询提单日期
|
||||||
|
Map<Object, DynamicObject> st = BusinessDataServiceHelper.loadFromCache("yem_es_storagetrans", "id, billno, yem_tddate", new QFilter[]{new QFilter("billno", "in", ladingDateMap.keySet())});
|
||||||
|
for (DynamicObject value : st.values()) {
|
||||||
|
String billno = value.getString("billno");
|
||||||
|
Date tddate = value.getDate("yem_tddate");
|
||||||
|
ladingDateMap.put(billno, tddate);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, List<String>> message = new HashMap<>();
|
||||||
|
for (DynamicObject d : load) {
|
||||||
|
DynamicObjectCollection c = d.getDynamicObjectCollection("yem_es_exportpre_erw");
|
||||||
|
for (DynamicObject subD : c) {
|
||||||
|
String stno = subD.getString("yem_shipmentnum_c");
|
||||||
|
if (ladingDateMap.containsKey(stno)) {
|
||||||
|
Date date = ladingDateMap.get(stno);
|
||||||
|
if (YEM.isEmpty(date)) continue;
|
||||||
|
// 计算应回款日期 = 天数 + 提单日期
|
||||||
|
int forward = subD.getInt("yem_forward");
|
||||||
|
Date added = DateUtils.addDays(date, forward);
|
||||||
|
subD.set("yem_shdreceivedate", added);
|
||||||
|
String contractnum = subD.getString("yem_contractnum_c");
|
||||||
|
if (isSendMessage) {
|
||||||
|
DynamicObject operator = subD.getDynamicObject("yem_operator_e");
|
||||||
|
if (operator == null) continue;
|
||||||
|
long sendUser = operator.getLong("id");
|
||||||
|
List<String> list;
|
||||||
|
if (message.containsKey(sendUser)) {
|
||||||
|
list = message.get(sendUser);
|
||||||
|
} else {
|
||||||
|
list = new ArrayList<>();
|
||||||
|
}
|
||||||
|
list.add(String.format("合同:%s,寄单放单单号:%s,应回款日期为:%s,请知悉!\n\r", contractnum, d.getString("billno"), DateUtils.getData(added, "yyyy-MM-dd")));
|
||||||
|
message.put(sendUser, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> phone = new HashSet<>();
|
||||||
|
phone.add("15771670073");
|
||||||
|
ArrayList<Long> devUserIds = Lists.newArrayList();
|
||||||
|
// 发给开发测试
|
||||||
|
DynamicObject[] users = BusinessDataServiceHelper.load("bos_user", "id, name, phone", new QFilter[]{new QFilter("phone", "in", phone)});
|
||||||
|
for (DynamicObject user : users) {
|
||||||
|
devUserIds.add(user.getLong("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<Long, List<String>> sendMsg : message.entrySet()) {
|
||||||
|
Long userid = sendMsg.getKey();
|
||||||
|
List<String> messageContent = sendMsg.getValue();
|
||||||
|
ArrayList<Long> sendUserId = Lists.newArrayList();
|
||||||
|
sendUserId.add(userid);
|
||||||
|
sendUserId.addAll(devUserIds);
|
||||||
|
|
||||||
|
YEM.sendMessage(sendUserId, "预警消息", "应回款日期预警", String.join("", messageContent), "预警消息");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前日期是否是给定日期的十天后
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
public static boolean isTenDaysAfter() {
|
||||||
|
// 起始日期
|
||||||
|
LocalDate startDate = LocalDate.of(2024, 12, 1);
|
||||||
|
long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(startDate, LocalDate.now());
|
||||||
|
// 是否是起始日期10天后或,10*n天后
|
||||||
|
return daysBetween >= 0 && daysBetween % 10 == 0;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user