parent
6b5e26b5c6
commit
1dc2e9e50a
|
@ -1,20 +1,25 @@
|
|||
package shkd.sys.sys.plugin.list;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.datamodel.ListSelectedRow;
|
||||
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||
import kd.bos.form.IPageCache;
|
||||
import kd.bos.form.control.events.BeforeItemClickEvent;
|
||||
import kd.bos.list.BillList;
|
||||
import kd.bos.list.IListView;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.bos.util.CollectionUtils;
|
||||
import kd.bos.util.StringUtils;
|
||||
import shkd.sys.sys.plugin.list.domain.OverTimeVarietyEnum;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class ElectronicPayDealListPlugin extends AbstractListPlugin {
|
||||
|
||||
|
@ -34,29 +39,45 @@ public class ElectronicPayDealListPlugin extends AbstractListPlugin {
|
|||
Map<String, List<String>> qtqyrz = OverTimeVarietyEnum.qtqyrz;
|
||||
List<String> list = qtqyrz.get(billFormId);
|
||||
if (list!=null&&list.contains(itemKey)){
|
||||
// 定义日期时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
IPageCache iPageCache =this.getPageCache();
|
||||
|
||||
String LastTime = iPageCache.get("LastTime");
|
||||
if(!StringUtils.isEmpty(LastTime)){
|
||||
// 获取当前时间
|
||||
LocalDateTime currentTime = LocalDateTime.now();
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(LastTime, formatter);
|
||||
// 计算当前时间与另一个时间的时间差
|
||||
Duration duration = Duration.between(localDateTime, currentTime);
|
||||
|
||||
// 判断时间差是否超过 10 秒
|
||||
if (duration.getSeconds() <= 10) {
|
||||
this.getView().showTipNotification("该按钮点击间隔需要超过十秒");
|
||||
try {
|
||||
// 获取勾选的单据ID
|
||||
BillList billList = (BillList)this.getControl("billlistap");
|
||||
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
|
||||
Set<Long> setIds = new HashSet<>();
|
||||
if (CollectionUtils.isNotEmpty(selectedRows)) {
|
||||
for (ListSelectedRow selectedRow : selectedRows) {
|
||||
setIds.add(toLong(selectedRow.getPrimaryKeyValue()));
|
||||
}
|
||||
}
|
||||
List<Long> longs = new ArrayList<>(setIds);
|
||||
for (int i = 0; i < longs.size(); i++) {
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(longs.get(i), "cdm_electronic_pay_deal");
|
||||
dynamicObject.set("shkd_lock",false);
|
||||
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
|
||||
}
|
||||
evt.setCancel(true);
|
||||
}else {
|
||||
iPageCache.put("LastTime",currentTime.format(formatter));
|
||||
this.getView().invokeOperation("refresh");
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
iPageCache.put("LastTime",LocalDateTime.now().format(formatter));
|
||||
}
|
||||
|
||||
public static Long toLong(Object o) {
|
||||
if (o == null) {
|
||||
return 0L;
|
||||
}
|
||||
String s = String.valueOf(o);
|
||||
if (StringUtils.isEmpty(s)) {
|
||||
return 0L;
|
||||
}
|
||||
try {
|
||||
int index = s.indexOf(".");
|
||||
index = index > -1 ? index : s.length();
|
||||
return Long.parseLong(s.substring(0, index));
|
||||
} catch (NumberFormatException e) {
|
||||
logger.error("数字转化错误", e);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.*;
|
|||
|
||||
public class OverTimeVarietyEnum {
|
||||
public static final Map<String, List<String>> qtqyrz = new HashMap() {{
|
||||
put("cdm_electronic_pay_deal", new ArrayList<>(Arrays.asList("querynotepayable")));
|
||||
put("cdm_electronic_pay_deal", new ArrayList<>(Arrays.asList("unlock")));
|
||||
put("银行借款合同", new ArrayList<>(Arrays.asList("其他权益融资")));
|
||||
}};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue