提交人:陈绍鑫

日期:2025/7/02 17:00
内容:取消锁定
This commit is contained in:
陈绍鑫 2025-07-02 17:42:18 +08:00
parent 6b5e26b5c6
commit 1dc2e9e50a
2 changed files with 47 additions and 26 deletions

View File

@ -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("该按钮点击间隔需要超过十秒");
evt.setCancel(true);
}else {
iPageCache.put("LastTime",currentTime.format(formatter));
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()));
}
}
}else {
iPageCache.put("LastTime",LocalDateTime.now().format(formatter));
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);
this.getView().invokeOperation("refresh");
} catch (Exception e) {
logger.error(e.getMessage());
}
}
}
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;
}
}

View File

@ -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("其他权益融资")));
}};
}