123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- package kd.imc.rim;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import kd.bos.context.RequestContext;
- import kd.bos.dataentity.serialization.SerializationUtils;
- import kd.bos.ext.form.control.CustomControl;
- import kd.bos.form.IPageCache;
- import kd.bos.form.control.events.UploadEvent;
- import kd.bos.logging.Log;
- import kd.bos.logging.LogFactory;
- import kd.bos.orm.util.CollectionUtils;
- import kd.bos.threads.ThreadPools;
- import kd.bos.util.StringUtils;
- import kd.imc.rim.common.constant.CollectTypeEnum;
- import kd.imc.rim.common.invoice.collector.InvoiceCollectTaskNew;
- import kd.imc.rim.common.service.DialogService;
- import kd.imc.rim.common.utils.BigDecimalUtil;
- import kd.imc.rim.common.utils.PermissionUtils;
- import kd.imc.rim.common.utils.RimConfigUtils;
- import kd.imc.rim.formplugin.collector.InvoiceCollectPlugin;
- import java.util.*;
- public class InvoiceCollectPluginEx extends InvoiceCollectPlugin {
- private static Log logger = LogFactory.getLog(InvoiceCollectPluginEx.class);
- @Override
- public void afterUpload(UploadEvent evt) {
- {
- String itemKey = evt.getCallbackKey();
- Object[] urls = evt.getUrls();
- logger.info("上传文件:{}-{}", itemKey, urls);
- if (urls.length > 0) {
- StringJoiner taskUrls = new StringJoiner(",");
- List<Map<String, String>> fileUrls = new ArrayList(urls.length);
- String mapSeqStr = this.getPageCache().get("upload_seq");
- Map<String, Object> nameSeq = new HashMap(urls.length);
- if (StringUtils.isNotEmpty(mapSeqStr)) {
- nameSeq = (Map) SerializationUtils.fromJsonString(mapSeqStr, nameSeq.getClass());
- }
- int i = 0;
- for(int size = urls.length; i < size; ++i) {
- String url = urls[i].toString();
- String fileName = url.substring(url.lastIndexOf(47) + 1);
- Map<String, String> map = new HashMap(2);
- map.put("url", url);
- map.put("name", fileName);
- if (!CollectionUtils.isEmpty((Map)nameSeq)) {
- String seq = String.valueOf(((Map)nameSeq).get(fileName));
- if (StringUtils.isNotEmpty(seq)) {
- map.put("seq", seq);
- }
- }
- fileUrls.add(map);
- }
- Collections.sort(fileUrls, (o1, o2) -> {
- Long uploadSeq1 = BigDecimalUtil.transDecimal(o1.get("seq")).longValue();
- Long uploadSeq2 = BigDecimalUtil.transDecimal(o2.get("seq")).longValue();
- return uploadSeq1.compareTo(uploadSeq2);
- });
- Iterator var14 = fileUrls.iterator();
- while(var14.hasNext()) {
- Map<String, String> fileUrl = (Map)var14.next();
- taskUrls.add((CharSequence)fileUrl.get("url"));
- }
- this.getPageCache().put("upload_itemKey", itemKey);
- this.getPageCache().remove("upload_seq");
- this.getPageCache().put("taskUrls", taskUrls.toString());
- this.progressBarVisible(Boolean.TRUE, new String[]{"进行中..."});
- this.getPageCache().put("startprogress", "true");
- JSONObject businessParam = this.getBusinessParam(CollectTypeEnum.PC_UPLOAD.getCode());
- businessParam.put("itemKey", itemKey);
- InvoiceCollectTaskNew collectTask = new InvoiceCollectTaskNew(RequestContext.get(), this.getView().getPageId(), fileUrls, businessParam);
- ThreadPools.executeOnce("CollectorProgressPool", collectTask);
- }
- }
- }
- private JSONObject getBusinessParam(String collectType) {
- JSONObject businessParam = new JSONObject();
- IPageCache pageCache = this.getView().getPageCache();
- String businessParamCache = pageCache.get("businessParam");
- if (businessParamCache != null) {
- businessParam = JSON.parseObject(businessParamCache);
- } else {
- RequestContext request = RequestContext.get();
- businessParam.put("collect_type", collectType);
- businessParam.put("resource", "收票管理");
- businessParam.put("isAdmin", PermissionUtils.checkPermission(request.getUserId(), request.getOrgId(), this.getView(), "1PAFGP5MO1NU"));
- String state = RimConfigUtils.getConfig("original_state");
- if ("1".equals(state)) {
- businessParam.put("originalState", "1");
- }
- Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
- if (!CollectionUtils.isEmpty(customParams)) {
- businessParam.putAll(customParams);
- }
- businessParam.put("billType", "fpqs");
- pageCache.put("businessParam", businessParam.toJSONString());
- }
- logger.info("发票签收采集参数:" + businessParam);
- return businessParam;
- }
- private void progressBarVisible(Boolean visibleFlag, String[] descriptionArray) {
- CustomControl customcontrol = (CustomControl)this.getControl("progressBar_customcontrol");
- DialogService service = new DialogService(customcontrol);
- if (visibleFlag) {
- if (null != descriptionArray) {
- service.show("1", descriptionArray, 500);
- } else {
- service.show("1", new String[]{"进行中..."}, 500);
- }
- } else {
- service.hide();
- }
- }
- }
|