Ver Fonte

业务处理单改造

徐昊 há 10 meses atrás
pai
commit
318c2c15d5
1 ficheiros alterados com 168 adições e 0 exclusões
  1. 168 0
      src/main/java/fi/rim/fromPlugin/FpzsMainEXPlugin.java

+ 168 - 0
src/main/java/fi/rim/fromPlugin/FpzsMainEXPlugin.java

@@ -0,0 +1,168 @@
+package fi.rim.fromPlugin;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.form.control.Button;
+import kd.bos.form.control.Control;
+import kd.bos.form.control.EntryGrid;
+import kd.bos.form.control.events.RowClickEventListener;
+import kd.bos.form.control.events.TabSelectEvent;
+import kd.bos.form.control.events.TabSelectListener;
+import kd.bos.form.control.events.UploadListener;
+import kd.bos.msgjet.MsgSendFactory;
+import kd.bos.orm.util.CollectionUtils;
+import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
+import kd.imc.rim.common.helper.ExcelHelper;
+import kd.imc.rim.common.invoice.fpzs.FpzsMainService;
+import kd.imc.rim.common.invoice.query.AttachQueryService;
+import kd.imc.rim.common.invoice.verify.VerifyStatisticsService;
+import kd.imc.rim.common.invoice.verify.VerifyUtil;
+import kd.imc.rim.common.license.LicenseFormPlugin;
+import kd.imc.rim.common.service.InvoiceAutoFillBillService;
+import kd.imc.rim.common.service.InvoiceLog;
+import kd.imc.rim.common.utils.BigDecimalUtil;
+import kd.imc.rim.common.utils.CacheHelper;
+
+import java.util.EventObject;
+import java.util.Iterator;
+import java.util.Map;
+
+public class FpzsMainEXPlugin extends LicenseFormPlugin implements RowClickEventListener, UploadListener, TabSelectListener {
+    private static final String BTN_IMPORT = "btn_import";
+    @Override
+    public void tabSelected(TabSelectEvent tabSelectEvent) {}
+    public void initialize() {
+        EntryGrid entryGrid = (EntryGrid)this.getView().getControl("operate_entry");
+        entryGrid.addRowClickListener(this);
+        EntryGrid entryGridAttach = (EntryGrid)this.getView().getControl("operate_entry_attach");
+        entryGridAttach.addRowClickListener(this);
+        Button excelDownload = (Button)this.getView().getControl("excel_download");
+        excelDownload.addClickListener(this);
+        Button importButton = (Button)this.getView().getControl("btn_import");
+        importButton.addClickListener(this);
+        Button uploadFile = (Button)this.getView().getControl("upload_file");
+        uploadFile.addUploadListener(this);
+        Button uploadInvoiceAttach = (Button)this.getView().getControl("upload_invoice_attach");
+        uploadInvoiceAttach.addUploadListener(this);
+        Button uploadInvoiceAttachUnimport = (Button)this.getView().getControl("upload_invoice_attach2");
+        uploadInvoiceAttachUnimport.addUploadListener(this);
+    }
+
+    public void click(EventObject evt) {
+        Control properties = (Control)evt.getSource();
+        String clickKey = properties.getKey();
+        if ("excel_download".equals(clickKey)) {
+            ExcelHelper.downloadTemplate(this, "templates", "发票查验模板.xlsx");
+        } else if ("btn_import".equals(clickKey)) {
+            Map<String, Object> param = FpzsMainService.getCustomParam(this);
+            Object linkKey = param.get("linkKey");
+            int attachTotal = this.getModel().getEntryRowCount("attach_grid_entry");
+            JSONObject returnData = new JSONObject();
+            JSONArray attachData = new JSONArray();
+            String billId = "billId";
+            if (!CollectionUtils.isEmpty(param)) {
+                billId = (String)param.get("billId");
+            }
+
+            AttachQueryService attachQueryService = new AttachQueryService();
+            String entityId = (String)param.get("entityId");
+            String resource = (String)param.get("resource");
+            JSONArray attachCacheArray = new JSONArray();
+
+            String key;
+            for(int i = 0; i < attachTotal; ++i) {
+                String serialNo = (String)this.getModel().getValue("serial_no3", i);
+                String attachId = (String)this.getModel().getValue("attachid", i);
+                JSONObject attach = new JSONObject(true);
+                attach.put("serialNo", serialNo);
+                attach.put("attachId", attachId);
+                attach.put("attachType", (String)this.getModel().getValue("attach_type", i));
+                key = (String)this.getModel().getValue("attach_name", i);
+                attach.put("attachName", key);
+                String fileExtension = (String)this.getModel().getValue("file_extension", i);
+                attach.put("fileExtension", fileExtension);
+                attach.put("originalFileName", key + '.' + fileExtension);
+                attach.put("attachNo", (String)this.getModel().getValue("attach_no", i));
+                attach.put("attachUrl", (String)this.getModel().getValue("attach_path", i));
+                attach.put("remark", (String)this.getModel().getValue("attach_remark", i));
+                attach.put("attachIcon", (String)this.getModel().getValue("attach_icon", i));
+                attach.put("uploadDate", this.getModel().getValue("upload_date", i));
+                Object pkValue = this.getModel().getValue("attach_category_grid");
+                Object pkValue2 = this.getModel().getValue("attach_categoryid");
+                attach.put("expenseId", billId);
+                DynamicObject attachCategory = (DynamicObject)this.getModel().getValue("attach_category_grid", i);
+                if (attachCategory != null) {
+                    attach.put("attachCategory", attachCategory.getLong("id"));
+                }
+
+                attachCacheArray.add(attach);
+                JSONObject dataJson = new JSONObject();
+                dataJson.put("serialNo", serialNo);
+                dataJson.put("attachId", attachId);
+                dataJson.put("attachUrl", (String)this.getModel().getValue("attach_path", i));
+                dataJson.put("attachType", (String)this.getModel().getValue("attach_type", i));
+                dataJson.put("attachNo", (String)this.getModel().getValue("attach_no", i));
+                dataJson.put("attachName", (String)this.getModel().getValue("attach_name", i));
+                dataJson.put("remark", (String)this.getModel().getValue("attach_remark", i));
+                dataJson.put("attachSize", this.getModel().getValue("attach_size", i));
+                dataJson.put("attachIcon", this.getModel().getValue("attach_icon", i));
+                dataJson.put("uploadDate", this.getModel().getValue("upload_date", i));
+                attachData.add(dataJson);
+            }
+
+            attachQueryService.addFpzsAttach(billId, entityId, resource, attachCacheArray);
+            returnData.put("attachData", attachData);
+            JSONObject dataJson = FpzsMainService.getInvoiceDataCache(this.getView().getPageId());
+            JSONArray invoiceData = new JSONArray();
+            JSONArray invoiceVerifyData = new JSONArray();
+            Iterator<String> iterator = dataJson.keySet().iterator();
+
+            while(iterator.hasNext()) {
+                key = (String)iterator.next();
+                JSONObject invoice = dataJson.getJSONObject(key);
+                invoiceVerifyData.add(invoice);
+                String errorLevel = invoice.getString("errorLevel");
+                String invoiceType = invoice.getString("invoiceType");
+                String serialNo = invoice.getString("serialNo");
+                VerifyUtil.updateDataStatus(errorLevel, serialNo, InputInvoiceTypeEnum.getInvoiceTypeByAwsType(invoiceType), Boolean.TRUE);
+                if (!FpzsMainService.isFilter(invoice) && !invoice.isEmpty()) {
+                    if (!"expense_pc".equals(param.get("resource"))) {
+                        invoice.remove("validateMessage_html");
+                    }
+
+                    invoiceData.add(invoice);
+                }
+            }
+
+            this.saveVerifyResult(invoiceVerifyData);
+            if (attachTotal < 1 && invoiceData.isEmpty()) {
+                this.getView().showTipNotification("不存在符合导入单据的发票,请检查是否已采集发票或采集的发票是否合规", 3000);
+                return;
+            }
+
+            returnData.put("invoiceData", invoiceData);//发票助手导入单据的数据
+            Object pushType = param.get("pushType");
+            InvoiceLog.insertExpenseLog("发票助手导入单据", String.valueOf(param.get("billId")), String.valueOf(param.get("billNo")), returnData.toJSONString());
+            if (pushType != null) {
+                if ("socket".equals(pushType.toString())) {
+                    MsgSendFactory.getSender().send(linkKey.toString(), returnData.toJSONString());
+                } else if ("poll".equals(pushType.toString())) {
+                    CacheHelper.put("rim_push:" + linkKey, returnData.toJSONString(), 120);
+                }
+            } else {
+                InvoiceAutoFillBillService iafbs = new InvoiceAutoFillBillService();
+                iafbs.autoFill(this.getView(), returnData);
+                this.getView().returnDataToParent(returnData);
+                this.getView().close();
+            }
+        }
+
+    }
+    private void saveVerifyResult(JSONArray invoices) {
+        if (!CollectionUtils.isEmpty(invoices)) {
+            Map<String, Object> param = FpzsMainService.getCustomParam(this);
+            VerifyStatisticsService.asyncSaveVerifyStatistics(invoices, BigDecimalUtil.transDecimal(param.get("orgId")).longValue(), (String)param.get("userId"));
+        }
+    }
+}