|
@@ -1,37 +1,87 @@
|
|
package fi.rim.fromPlugin;
|
|
package fi.rim.fromPlugin;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
|
+import kd.bos.cache.CacheFactory;
|
|
|
|
+import kd.bos.cache.TempFileCache;
|
|
|
|
+import kd.bos.context.RequestContext;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
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.dataentity.entity.DynamicObjectCollection;
|
|
|
|
+import kd.bos.dataentity.entity.LocaleString;
|
|
|
|
+import kd.bos.dataentity.serialization.SerializationUtils;
|
|
|
|
+import kd.bos.dataentity.utils.ObjectUtils;
|
|
|
|
+import kd.bos.dlock.DLock;
|
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
|
+import kd.bos.entity.MainEntityType;
|
|
|
|
+import kd.bos.ext.form.control.CustomControl;
|
|
|
|
+import kd.bos.fileservice.FileService;
|
|
|
|
+import kd.bos.fileservice.FileServiceFactory;
|
|
|
|
+import kd.bos.form.*;
|
|
|
|
+import kd.bos.form.cardentry.CardEntry;
|
|
|
|
+import kd.bos.form.container.Tab;
|
|
|
|
+import kd.bos.form.control.*;
|
|
|
|
+import kd.bos.form.control.events.*;
|
|
|
|
+import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
|
|
+import kd.bos.form.events.CustomEventArgs;
|
|
|
|
+import kd.bos.logging.Log;
|
|
|
|
+import kd.bos.logging.LogFactory;
|
|
import kd.bos.msgjet.MsgSendFactory;
|
|
import kd.bos.msgjet.MsgSendFactory;
|
|
|
|
+import kd.bos.mvc.cache.PageCache;
|
|
|
|
+import kd.bos.mvc.form.ClientViewProxy;
|
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
import kd.bos.orm.util.CollectionUtils;
|
|
import kd.bos.orm.util.CollectionUtils;
|
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.operation.DeleteServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
+import kd.bos.url.UrlService;
|
|
|
|
+import kd.imc.rim.common.constant.AttachConstant;
|
|
|
|
+import kd.imc.rim.common.constant.CollectTypeEnum;
|
|
import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
|
|
import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
|
|
import kd.imc.rim.common.helper.ExcelHelper;
|
|
import kd.imc.rim.common.helper.ExcelHelper;
|
|
|
|
+import kd.imc.rim.common.invoice.collector.ScannerService;
|
|
|
|
+import kd.imc.rim.common.invoice.fpzs.FpzsAwsService;
|
|
import kd.imc.rim.common.invoice.fpzs.FpzsMainService;
|
|
import kd.imc.rim.common.invoice.fpzs.FpzsMainService;
|
|
import kd.imc.rim.common.invoice.query.AttachQueryService;
|
|
import kd.imc.rim.common.invoice.query.AttachQueryService;
|
|
|
|
+import kd.imc.rim.common.invoice.query.InvoiceQueryService;
|
|
|
|
+import kd.imc.rim.common.invoice.query.convert.impl.AirConvertService;
|
|
|
|
+import kd.imc.rim.common.invoice.recognition.impl.RecognitionCheckTask;
|
|
|
|
+import kd.imc.rim.common.invoice.save.InvoiceSaveResult;
|
|
|
|
+import kd.imc.rim.common.invoice.save.InvoiceSaveService;
|
|
|
|
+import kd.imc.rim.common.invoice.verify.VerifyService;
|
|
import kd.imc.rim.common.invoice.verify.VerifyStatisticsService;
|
|
import kd.imc.rim.common.invoice.verify.VerifyStatisticsService;
|
|
import kd.imc.rim.common.invoice.verify.VerifyUtil;
|
|
import kd.imc.rim.common.invoice.verify.VerifyUtil;
|
|
import kd.imc.rim.common.license.LicenseFormPlugin;
|
|
import kd.imc.rim.common.license.LicenseFormPlugin;
|
|
|
|
+import kd.imc.rim.common.service.DialogService;
|
|
import kd.imc.rim.common.service.InvoiceAutoFillBillService;
|
|
import kd.imc.rim.common.service.InvoiceAutoFillBillService;
|
|
import kd.imc.rim.common.service.InvoiceLog;
|
|
import kd.imc.rim.common.service.InvoiceLog;
|
|
-import kd.imc.rim.common.utils.BigDecimalUtil;
|
|
|
|
-import kd.imc.rim.common.utils.CacheHelper;
|
|
|
|
|
|
+import kd.imc.rim.common.utils.*;
|
|
|
|
+import kd.imc.rim.common.utils.UUID;
|
|
|
|
+import kd.imc.rim.common.utils.itextpdf.UrlServiceUtils;
|
|
|
|
+import kd.imc.rim.file.utils.FileConvertUtils;
|
|
|
|
+import kd.imc.rim.formplugin.fpzs.FpzsMainPlugin;
|
|
|
|
+import kd.imc.rim.formplugin.fpzs.operate.FpzsOperateService;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
|
|
-import java.util.EventObject;
|
|
|
|
-import java.util.Iterator;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class FpzsMainEXPlugin extends LicenseFormPlugin implements RowClickEventListener, UploadListener, TabSelectListener {
|
|
public class FpzsMainEXPlugin extends LicenseFormPlugin implements RowClickEventListener, UploadListener, TabSelectListener {
|
|
private static final String BTN_IMPORT = "btn_import";
|
|
private static final String BTN_IMPORT = "btn_import";
|
|
|
|
+ private static Log logger = LogFactory.getLog(FpzsMainPlugin.class);
|
|
|
|
+ private static final List<String> ERROR_MSG_LIST = new ArrayList(Arrays.asList("error_filter_msg", "error_red_msg", "error_yellow_msg"));
|
|
|
|
+ private static final List<String> IMPORT_MSG_LIST = new ArrayList(Arrays.asList("import_filter_msg", "import_red_msg", "import_yellow_msg"));
|
|
|
|
+ private Map<String, String> traceMap;
|
|
@Override
|
|
@Override
|
|
public void tabSelected(TabSelectEvent tabSelectEvent) {}
|
|
public void tabSelected(TabSelectEvent tabSelectEvent) {}
|
|
|
|
+ //初始化
|
|
public void initialize() {
|
|
public void initialize() {
|
|
EntryGrid entryGrid = (EntryGrid)this.getView().getControl("operate_entry");
|
|
EntryGrid entryGrid = (EntryGrid)this.getView().getControl("operate_entry");
|
|
entryGrid.addRowClickListener(this);
|
|
entryGrid.addRowClickListener(this);
|
|
@@ -52,7 +102,7 @@ public class FpzsMainEXPlugin extends LicenseFormPlugin implements RowClickEvent
|
|
public void click(EventObject evt) {
|
|
public void click(EventObject evt) {
|
|
Control properties = (Control)evt.getSource();
|
|
Control properties = (Control)evt.getSource();
|
|
String clickKey = properties.getKey();
|
|
String clickKey = properties.getKey();
|
|
- if ("excel_download".equals(clickKey)) {//111111
|
|
|
|
|
|
+ if ("excel_download".equals(clickKey)) {
|
|
ExcelHelper.downloadTemplate(this, "templates", "发票查验模板.xlsx");
|
|
ExcelHelper.downloadTemplate(this, "templates", "发票查验模板.xlsx");
|
|
} else if ("btn_import".equals(clickKey)) {
|
|
} else if ("btn_import".equals(clickKey)) {
|
|
Map<String, Object> param = FpzsMainService.getCustomParam(this);
|
|
Map<String, Object> param = FpzsMainService.getCustomParam(this);
|
|
@@ -159,10 +209,1756 @@ public class FpzsMainEXPlugin extends LicenseFormPlugin implements RowClickEvent
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
private void saveVerifyResult(JSONArray invoices) {
|
|
private void saveVerifyResult(JSONArray invoices) {
|
|
if (!CollectionUtils.isEmpty(invoices)) {
|
|
if (!CollectionUtils.isEmpty(invoices)) {
|
|
Map<String, Object> param = FpzsMainService.getCustomParam(this);
|
|
Map<String, Object> param = FpzsMainService.getCustomParam(this);
|
|
VerifyStatisticsService.asyncSaveVerifyStatistics(invoices, BigDecimalUtil.transDecimal(param.get("orgId")).longValue(), (String)param.get("userId"));
|
|
VerifyStatisticsService.asyncSaveVerifyStatistics(invoices, BigDecimalUtil.transDecimal(param.get("orgId")).longValue(), (String)param.get("userId"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void registerListener(EventObject e) {
|
|
|
|
+ Tab tab = (Tab)this.getControl("tabap");
|
|
|
|
+ tab.addTabSelectListener(this);
|
|
|
|
+ this.addItemClickListeners(new String[]{"toolbarap_import", "toolbarap_error", "toolbarap_attach"});
|
|
|
|
+ this.addClickListeners(new String[]{"list_attach_button", "pic_attach_button", "list_invoice_button", "card_invoice_button"});
|
|
|
|
+ Toolbar attachLabel = (Toolbar)this.getControl("toolbarap_attach");
|
|
|
|
+ if (attachLabel != null) {
|
|
|
|
+ attachLabel.addUploadListener(this);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void scannerProcess(String type) {
|
|
|
|
+ String pageId = this.getView().getPageId();
|
|
|
|
+ logger.info("scannerProcess-{}-{} coming", pageId, type);
|
|
|
|
+ DLock lock = DLock.create("scannerProcess" + pageId, "刷新卡片锁");
|
|
|
|
+ Throwable var4 = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ int times = 0;
|
|
|
|
+ String dialogId = "scanner";
|
|
|
|
+
|
|
|
|
+ while(times < 30) {
|
|
|
|
+ ++times;
|
|
|
|
+ if (lock.tryLock(500L)) {
|
|
|
|
+ times = 100;
|
|
|
|
+ JSONObject result = RecognitionCheckTask.queryCacheFile(pageId);
|
|
|
|
+ logger.info("scannerProcess-{}:{}", pageId, result);
|
|
|
|
+ boolean var41 = false;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ var41 = true;
|
|
|
|
+ CustomControl customcontrol = (CustomControl)this.getControl("progressBar_customcontrol");
|
|
|
|
+ DialogService service = new DialogService(customcontrol);
|
|
|
|
+ Set<String> urlSet = result.keySet();
|
|
|
|
+ Iterator<String> it = urlSet.iterator();
|
|
|
|
+ int waiting = 0;
|
|
|
|
+ int fail = 0;
|
|
|
|
+
|
|
|
|
+ String repeatFlag;
|
|
|
|
+ while(it.hasNext()) {
|
|
|
|
+ String url = (String)it.next();
|
|
|
|
+ repeatFlag = result.getString(url);
|
|
|
|
+ if ("waiting".equals(repeatFlag)) {
|
|
|
|
+ ++waiting;
|
|
|
|
+ } else if ("fail".equals(repeatFlag)) {
|
|
|
|
+ ++fail;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int total = result.size();
|
|
|
|
+ logger.info("scannerProcess-{} waiting:{},fail:{},total:{}", new Object[]{pageId, waiting, fail, total});
|
|
|
|
+ JSONArray retryArray;
|
|
|
|
+ JSONObject attachJson;
|
|
|
|
+ JSONObject invoiceInfo;
|
|
|
|
+ if ("dialog".equals(type) && (total == 0 || waiting == 0)) {
|
|
|
|
+ if (total > 0) {
|
|
|
|
+ RecognitionCheckTask.clearCacheFile(pageId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (fail > 0) {
|
|
|
|
+ Set<String> urlSet2 = result.keySet();
|
|
|
|
+ Iterator<String> it2 = urlSet2.iterator();
|
|
|
|
+ retryArray = new JSONArray();
|
|
|
|
+
|
|
|
|
+ label537:
|
|
|
|
+ while(true) {
|
|
|
|
+ String url;
|
|
|
|
+ String status;
|
|
|
|
+ do {
|
|
|
|
+ if (!it2.hasNext()) {
|
|
|
|
+ if (!retryArray.isEmpty()) {
|
|
|
|
+ Map<String, Object> customParams = new HashMap(4);
|
|
|
|
+ customParams.put("retryArray", retryArray);
|
|
|
|
+ invoiceInfo = FpzsMainService.getBusinessParam(pageId, CollectTypeEnum.PC_UPLOAD.getCode());
|
|
|
|
+ customParams.put("businessParam", invoiceInfo);
|
|
|
|
+ FormShowParameter showParameter = this.newPage("rim_inv_recognition_retry", customParams, "retryCallback");
|
|
|
|
+ showParameter.setCaption("识别失败重试列表");
|
|
|
|
+ this.getView().showForm(showParameter);
|
|
|
|
+ }
|
|
|
|
+ break label537;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ url = (String)it2.next();
|
|
|
|
+ status = result.getString(url);
|
|
|
|
+ } while(!"fail".equals(status));
|
|
|
|
+
|
|
|
|
+ attachJson = new JSONObject();
|
|
|
|
+ attachJson.put("fileUrl", url);
|
|
|
|
+ attachJson.put("fileName", url.substring(url.lastIndexOf(47) + 1, url.length()));
|
|
|
|
+ JSONObject cause = RecognitionCheckTask.queryCacheCause(pageId);
|
|
|
|
+ if (cause != null && StringUtils.isNotEmpty(cause.getString(url))) {
|
|
|
|
+ attachJson.put("failDescription", cause.getString(url));
|
|
|
|
+ } else {
|
|
|
|
+ attachJson.put("failDescription", "处理失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ retryArray.add(attachJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (total > 0 && fail > 0) {
|
|
|
|
+ this.getView().showTipNotification(String.format("上传%s个文件,处理失败%s个", total, fail), 10000);
|
|
|
|
+ } else if (total > 0) {
|
|
|
|
+ this.getView().showSuccessNotification(String.format("上传%s个文件,处理成功%s个", total, total, 10000));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ service.hide();
|
|
|
|
+ repeatFlag = this.getView().getPageId() + "scannerProcessRepeat";
|
|
|
|
+ String scannerProcessRepeat = CacheHelper.get(repeatFlag);
|
|
|
|
+ if (StringUtils.isNotEmpty(scannerProcessRepeat) && "true".equals(scannerProcessRepeat)) {
|
|
|
|
+ this.getView().showSuccessNotification("发票已存在列表");
|
|
|
|
+ CacheHelper.remove(repeatFlag);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String[] content = new String[]{"待处理文件剩余" + waiting + "个", "正在处理中(" + (total - waiting) + "/" + total + ")"};
|
|
|
|
+ service.show(dialogId, content, 1000);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+ JSONObject data = FpzsMainService.getInvoiceDataCache(pageId);
|
|
|
|
+ FpzsMainService.updateInvoiceGrid(this, data);
|
|
|
|
+ this.updateInvoiceCard(data);
|
|
|
|
+ Map<String, String> attIdSerialMap = Maps.newLinkedHashMap();
|
|
|
|
+ Iterator var54 = data.entrySet().iterator();
|
|
|
|
+
|
|
|
|
+ label569:
|
|
|
|
+ while(true) {
|
|
|
|
+ List attachList;
|
|
|
|
+ do {
|
|
|
|
+ do {
|
|
|
|
+ if (!var54.hasNext()) {
|
|
|
|
+ retryArray = FpzsMainService.getAttachDataCache(pageId);
|
|
|
|
+ if (retryArray.size() != 0) {
|
|
|
|
+ this.getModel().deleteEntryData("attach_grid_entry");
|
|
|
|
+ this.getModel().deleteEntryData("attach_card_entry");
|
|
|
|
+ Iterator var57 = retryArray.iterator();
|
|
|
|
+
|
|
|
|
+ while(var57.hasNext()) {
|
|
|
|
+ Object attach = var57.next();
|
|
|
|
+ attachJson = (JSONObject)attach;
|
|
|
|
+ String id = attachJson.getString("id");
|
|
|
|
+ this.handleAttachCategory(attachJson);
|
|
|
|
+ Iterator var64 = attIdSerialMap.entrySet().iterator();
|
|
|
|
+
|
|
|
|
+ while(var64.hasNext()) {
|
|
|
|
+ Map.Entry<String, String> entry = (Map.Entry)var64.next();
|
|
|
|
+ if (id.equals(entry.getKey())) {
|
|
|
|
+ attachJson.put("serial_no", entry.getValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int row = this.getModel().createNewEntryRow("attach_grid_entry");
|
|
|
|
+ this.getModel().setValue("attachid", attachJson.get("id"), row);
|
|
|
|
+ this.getModel().setValue("attach_category_grid", attachJson.get("attach_category"), row);
|
|
|
|
+ this.getModel().setValue("attach_name", attachJson.get("attach_name"), row);
|
|
|
|
+ this.getModel().setValue("serial_no3", attachJson.get("serial_no"), row);
|
|
|
|
+ this.getModel().setValue("attach_type", attachJson.get("attach_type"), row);
|
|
|
|
+ this.getModel().setValue("upload_date", attachJson.getDate("create_time"), row);
|
|
|
|
+ this.getModel().setValue("attach_remark", attachJson.get("remark"), row);
|
|
|
|
+ this.getModel().setValue("attach_path", attachJson.get("attach_url"), row);
|
|
|
|
+ this.getModel().setValue("file_extension", attachJson.get("file_extension"), row);
|
|
|
|
+ this.getModel().setValue("attach_no", attachJson.get("attach_no"), row);
|
|
|
|
+ int attachGridIndex = this.getModel().createNewEntryRow("attach_card_entry");
|
|
|
|
+ String simplify_name = attachJson.getString("simplify_name");
|
|
|
|
+ DynamicObject attachObject;
|
|
|
|
+ if (StringUtils.isEmpty(simplify_name)) {
|
|
|
|
+ attachObject = BusinessDataServiceHelper.loadSingle(attachJson.getLong("attach_category"), "bdm_attach_type");
|
|
|
|
+ simplify_name = attachObject.getString("simplify_name");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.getModel().setValue("attach_category", simplify_name, attachGridIndex);
|
|
|
|
+ this.getModel().setValue("attach_name_grid", attachJson.get("attach_name"), attachGridIndex);
|
|
|
|
+ attachObject = BusinessDataServiceHelper.newDynamicObject("rim_attach");
|
|
|
|
+ attachObject = DynamicObjectUtil.jsonToDynamicObject(attachJson, attachObject);
|
|
|
|
+ String imageUrl = this.getAttachSnapshotUrl(attachObject);
|
|
|
|
+ this.getModel().setValue("attach_image_grid", imageUrl, attachGridIndex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.showFlex();
|
|
|
|
+ var41 = false;
|
|
|
|
+ break label569;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map.Entry<String, Object> entry = (Map.Entry)var54.next();
|
|
|
|
+ invoiceInfo = (JSONObject)entry.getValue();
|
|
|
|
+ attachList = (List)invoiceInfo.get("attachList");
|
|
|
|
+ } while(attachList == null);
|
|
|
|
+ } while(attachList.size() == 0);
|
|
|
|
+
|
|
|
|
+ Iterator var62 = attachList.iterator();
|
|
|
|
+
|
|
|
|
+ while(var62.hasNext()) {
|
|
|
|
+ Map<String, Object> attachInfo = (Map)var62.next();
|
|
|
|
+ String id = (String)attachInfo.get("id");
|
|
|
|
+ attIdSerialMap.put(id, invoiceInfo.getString("serialNo"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } finally {
|
|
|
|
+ if (var41) {
|
|
|
|
+ String failResultDataStr = CacheHelper.get(this.getView().getPageId().concat("failResult"));
|
|
|
|
+ if (StringUtils.isNotBlank(failResultDataStr)) {
|
|
|
|
+ FormShowParameter failedListForm = new FormShowParameter();
|
|
|
|
+ failedListForm.setFormId("rim_inv_import_fail");
|
|
|
|
+ failedListForm.setCustomParam("invoiceFailedList", failResultDataStr);
|
|
|
|
+ failedListForm.getOpenStyle().setShowType(ShowType.Modal);
|
|
|
|
+ this.getView().showForm(failedListForm);
|
|
|
|
+ CacheHelper.remove(this.getView().getPageId().concat("failResult"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ lock.unlock();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String failResultDataStr = CacheHelper.get(this.getView().getPageId().concat("failResult"));
|
|
|
|
+ if (StringUtils.isNotBlank(failResultDataStr)) {
|
|
|
|
+ FormShowParameter failedListForm = new FormShowParameter();
|
|
|
|
+ failedListForm.setFormId("rim_inv_import_fail");
|
|
|
|
+ failedListForm.setCustomParam("invoiceFailedList", failResultDataStr);
|
|
|
|
+ failedListForm.getOpenStyle().setShowType(ShowType.Modal);
|
|
|
|
+ this.getView().showForm(failedListForm);
|
|
|
|
+ CacheHelper.remove(this.getView().getPageId().concat("failResult"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ lock.unlock();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Throwable var44) {
|
|
|
|
+ var4 = var44;
|
|
|
|
+ throw var44;
|
|
|
|
+ } finally {
|
|
|
|
+ if (lock != null) {
|
|
|
|
+ if (var4 != null) {
|
|
|
|
+ try {
|
|
|
|
+ lock.close();
|
|
|
|
+ } catch (Throwable var42) {
|
|
|
|
+ var4.addSuppressed(var42);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ lock.close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ public void customEvent(CustomEventArgs e) {
|
|
|
|
+ String eventName = e.getEventName();
|
|
|
|
+ String eventArgs = e.getEventArgs();
|
|
|
|
+ if ("pushData".equals(eventName) || "onMessage".equals(eventName)) {
|
|
|
|
+ this.dealWebSoceketMsag(eventArgs);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ("onError".equals(eventName)) {
|
|
|
|
+ this.getView().getPageCache().remove("linkkey");
|
|
|
|
+ this.getView().showTipNotification(eventArgs, 10000);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ("scanner_fail".equals(eventName)) {
|
|
|
|
+ if (ScannerService.scannerFail(this, eventArgs)) {
|
|
|
|
+ this.scannerProcess("uploadFinish");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ JSONObject json;
|
|
|
|
+ String name;
|
|
|
|
+ String cache;
|
|
|
|
+ String description;
|
|
|
|
+ String url;
|
|
|
|
+ JSONObject businessParam;
|
|
|
|
+ String traceId;
|
|
|
|
+ if ("scanner_success".equals(eventName)) {
|
|
|
|
+ if (!StringUtils.isEmpty(eventArgs)) {
|
|
|
|
+ json = JSON.parseObject(eventArgs);
|
|
|
|
+ JSONObject data = json.getJSONObject("data");
|
|
|
|
+ name = data.getString("url");
|
|
|
|
+ cache = data.getString("name");
|
|
|
|
+ description = this.getView().getPageCache().get("operate_type");
|
|
|
|
+ logger.info("扫描仪上传成功:" + description + "," + name + "," + cache);
|
|
|
|
+ if (!"operate_attach_scanner".equals(description)) {
|
|
|
|
+ url = this.getView().getPageId();
|
|
|
|
+ businessParam = FpzsMainService.getBusinessParam(url, CollectTypeEnum.PC_SCANNER.getCode());
|
|
|
|
+ businessParam.put("uploadIndex", ScannerService.getUploadIndex(data));
|
|
|
|
+ ScannerService.recognitionInvoice("fpzs", this.getView().getPageId(), name, cache, businessParam, FpzsMainService.getCustomParam(this));
|
|
|
|
+ } else {
|
|
|
|
+ url = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ JSONArray upload = new JSONArray();
|
|
|
|
+ businessParam = new JSONObject();
|
|
|
|
+ businessParam.put("url", name);
|
|
|
|
+ businessParam.put("name", cache);
|
|
|
|
+ businessParam.put("resource", "scanner");
|
|
|
|
+ upload.add(businessParam);
|
|
|
|
+ traceId = this.getView().getPageId();
|
|
|
|
+ Boolean lockFlag = Boolean.FALSE;
|
|
|
|
+ DLock lock = DLock.create("updateAttachView" + traceId, "更新附件页面锁");
|
|
|
|
+ Throwable var15 = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ int times = 0;
|
|
|
|
+
|
|
|
|
+ while(times < 30) {
|
|
|
|
+ ++times;
|
|
|
|
+ if (lock.tryLock(500L)) {
|
|
|
|
+ try {
|
|
|
|
+// int times = true;
|
|
|
|
+ this.updateAttachView(upload);
|
|
|
|
+ lockFlag = Boolean.TRUE;
|
|
|
|
+ break;
|
|
|
|
+ } finally {
|
|
|
|
+ lock.unlock();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Throwable var33) {
|
|
|
|
+ var15 = var33;
|
|
|
|
+ throw var33;
|
|
|
|
+ } finally {
|
|
|
|
+ if (lock != null) {
|
|
|
|
+ if (var15 != null) {
|
|
|
|
+ try {
|
|
|
|
+ lock.close();
|
|
|
|
+ } catch (Throwable var31) {
|
|
|
|
+ var15.addSuppressed(var31);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ lock.close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!lockFlag) {
|
|
|
|
+ this.getView().showErrorNotification("附件上传失败:" + cache);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception var35) {
|
|
|
|
+ logger.error("扫描仪上传附件失败", var35);
|
|
|
|
+ this.getView().showErrorNotification("附件上传失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if ("scanner_uploadFinish".equals(e.getEventName())) {
|
|
|
|
+ if (!ScannerService.uploadFinish(eventArgs)) {
|
|
|
|
+ String operateType = this.getView().getPageCache().get("operate_type");
|
|
|
|
+ logger.info("扫描仪上传结束:" + operateType);
|
|
|
|
+ if (!"operate_attach_scanner".equals(operateType)) {
|
|
|
|
+ this.scannerProcess("uploadFinish");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if ("datagrid_deleteRow".equals(e.getEventName())) {
|
|
|
|
+ this.deleteInvoiceRow(eventArgs);
|
|
|
|
+ } else if ("datagrid_clearTable".equals(eventName)) {
|
|
|
|
+ this.clearInvoiceTable(eventArgs);
|
|
|
|
+ } else {
|
|
|
|
+ String type;
|
|
|
|
+ if ("datagrid_click".equals(eventName)) {
|
|
|
|
+ json = JSON.parseObject(eventArgs);
|
|
|
|
+ type = json.getString("clickkey");
|
|
|
|
+ name = json.getString("rowkey");
|
|
|
|
+ if ("viewInvoice".equals(type)) {
|
|
|
|
+ this.showInvoiceEdit(name);
|
|
|
|
+ } else if ("addAttach".equals(type)) {
|
|
|
|
+ this.getPageCache().put("add_attach", name);
|
|
|
|
+ this.showAttachUpload();
|
|
|
|
+ }
|
|
|
|
+ } else if ("dialog".equals(eventName)) {
|
|
|
|
+ this.scannerProcess("dialog");
|
|
|
|
+ } else if ("uploadfile_upload".equals(eventName)) {
|
|
|
|
+ json = JSON.parseObject(eventArgs);
|
|
|
|
+ type = json.getString("status");
|
|
|
|
+ name = json.getString("name");
|
|
|
|
+ cache = json.getString("errcode");
|
|
|
|
+ description = json.getString("description");
|
|
|
|
+ if ("success".equals(type) && !"40002".equals(cache)) {
|
|
|
|
+ url = json.getString("url");
|
|
|
|
+ String pageId = this.getView().getPageId();
|
|
|
|
+ logger.info("uploadfile_upload{},{}", pageId, RequestContext.get().getTraceId());
|
|
|
|
+ businessParam = FpzsMainService.getBusinessParam(pageId, CollectTypeEnum.PC_UPLOAD.getCode());
|
|
|
|
+ businessParam.put("uploadIndex", ScannerService.getUploadIndex(json));
|
|
|
|
+ ScannerService.recognitionInvoice("fpzs", this.getView().getPageId(), url, name, businessParam, FpzsMainService.getCustomParam(this));
|
|
|
|
+ traceId = RequestContext.get().getTraceId();
|
|
|
|
+ if (this.traceMap == null || this.traceMap.get(traceId) == null) {
|
|
|
|
+ this.scannerProcess("upload");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.traceMap == null) {
|
|
|
|
+ this.traceMap = new HashMap(16);
|
|
|
|
+ } else if (this.traceMap.size() > 1) {
|
|
|
|
+ this.traceMap.clear();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.traceMap.put(traceId, "1");
|
|
|
|
+ } else if ("40002".equals(cache)) {
|
|
|
|
+ this.getView().showErrorNotification("文件:" + name + "上传失败,不支持的文件类型");
|
|
|
|
+ } else if (StringUtils.isEmpty(description)) {
|
|
|
|
+ this.getView().showErrorNotification("文件:" + name + "上传失败");
|
|
|
|
+ } else {
|
|
|
|
+ this.getView().showErrorNotification("文件:" + name + "上传失败:" + description);
|
|
|
|
+ }
|
|
|
|
+ } else if ("interval".equals(eventName)) {
|
|
|
|
+ json = JSON.parseObject(eventArgs);
|
|
|
|
+ type = json.getString("eventName");
|
|
|
|
+ name = json.getString("linkKey");
|
|
|
|
+ if (!StringUtils.isEmpty(name) && "pooling".equals(type)) {
|
|
|
|
+ cache = CacheHelper.get(name);
|
|
|
|
+ if (!StringUtils.isEmpty(cache)) {
|
|
|
|
+ this.dealWebSoceketMsag(cache);
|
|
|
|
+ CacheHelper.remove(name);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void dealWebSoceketMsag(String eventArgs) {
|
|
|
|
+ logger.info("onMessage:{}", eventArgs);
|
|
|
|
+ JSONObject result = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ result = JSON.parseObject(eventArgs);
|
|
|
|
+ } catch (Exception var17) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != result) {
|
|
|
|
+ String resource = result.getString("resource");
|
|
|
|
+ JSONObject data = result.getJSONObject("data");
|
|
|
|
+ if (null != data) {
|
|
|
|
+ JSONArray invoiceData = data.getJSONArray("invoiceData");
|
|
|
|
+ JSONArray attachIds = data.getJSONArray("attachIds");
|
|
|
|
+ if (!StringUtils.isEmpty(resource) && (!CollectionUtils.isEmpty(attachIds) || !CollectionUtils.isEmpty(invoiceData))) {
|
|
|
|
+ List<Long> invoiceIds = new ArrayList(16);
|
|
|
|
+ if (!CollectionUtils.isEmpty(invoiceData)) {
|
|
|
|
+ for(int i = 0; i < invoiceData.size(); ++i) {
|
|
|
|
+ invoiceIds.add(invoiceData.getLong(i));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.showSelectInvoice(invoiceIds, (List)null, (JSONArray)null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.updateAttachList(attachIds, invoiceIds);
|
|
|
|
+ } else {
|
|
|
|
+ JSONArray fids;
|
|
|
|
+ ArrayList invoiceIds;
|
|
|
|
+ int i;
|
|
|
|
+ JSONObject businessParam;
|
|
|
|
+ if (!CollectionUtils.isEmpty(invoiceData)) {
|
|
|
|
+ String pageId = this.getView().getPageId();
|
|
|
|
+ businessParam = FpzsMainService.getBusinessParam(pageId, CollectTypeEnum.WEIXIN.getCode());
|
|
|
|
+ invoiceIds = new ArrayList(16);
|
|
|
|
+
|
|
|
|
+ for(i = 0; i < invoiceData.size(); ++i) {
|
|
|
|
+ businessParam = invoiceData.getJSONObject(i);
|
|
|
|
+ InvoiceSaveService service = InvoiceSaveService.newInstance(businessParam.getString("invoiceType"));
|
|
|
|
+ if (service != null) {
|
|
|
|
+ Long invoiceType = service.getInvoiceType();
|
|
|
|
+ businessParam.putAll(businessParam);
|
|
|
|
+ if (InputInvoiceTypeEnum.AIR_INVOICE.getCode().equals(invoiceType)) {
|
|
|
|
+ businessParam.put("seatGradeName", AirConvertService.convertSeatName(businessParam.getString("seatGrade")));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ InvoiceSaveResult saveResult = service.save(businessParam);
|
|
|
|
+ invoiceIds.add((Long)saveResult.getMainId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.showSelectInvoice(invoiceIds, (List)null, (JSONArray)null);
|
|
|
|
+ } else {
|
|
|
|
+ fids = data.getJSONArray("fids");
|
|
|
|
+ if (!CollectionUtils.isEmpty(fids)) {
|
|
|
|
+ List<String> awsSerialList = new ArrayList(fids.size());
|
|
|
|
+ invoiceIds = new ArrayList(fids.size());
|
|
|
|
+
|
|
|
|
+ for(i = 0; i < fids.size(); ++i) {
|
|
|
|
+ String seri = fids.getString(i);
|
|
|
|
+ awsSerialList.add(seri);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String pageId = this.getView().getPageId();
|
|
|
|
+ businessParam = FpzsMainService.getBusinessParam(pageId, CollectTypeEnum.WEIXIN.getCode());
|
|
|
|
+ FpzsAwsService awsService = new FpzsAwsService();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Map<String, InvoiceSaveResult> syncResult = awsService.syncInvoiceFromAws(businessParam.getLong("org_id"), awsSerialList, businessParam);
|
|
|
|
+ if (syncResult != null) {
|
|
|
|
+ Iterator var14 = syncResult.entrySet().iterator();
|
|
|
|
+
|
|
|
|
+ while(var14.hasNext()) {
|
|
|
|
+ Map.Entry<String, InvoiceSaveResult> entry = (Map.Entry)var14.next();
|
|
|
|
+ InvoiceSaveResult result1 = (InvoiceSaveResult)entry.getValue();
|
|
|
|
+ invoiceIds.add((Long)result1.getMainId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.showSelectInvoice(invoiceIds, (List)null, (JSONArray)null);
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException var18) {
|
|
|
|
+ this.getView().showErrorNotification("同步发票失败" + var18.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fids = data.getJSONArray("attachmentData");
|
|
|
|
+ JSONArray newAttachIds = this.saveAwsAttach(fids);
|
|
|
|
+ this.updateAttachList(newAttachIds, (List)null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.getView().getPageCache().remove("qrCodePage");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void updateAttachView(JSONArray uploadUrls) {
|
|
|
|
+ if (!CollectionUtils.isEmpty(uploadUrls)) {
|
|
|
|
+ logger.info("附件上传请求参数:{}", uploadUrls);
|
|
|
|
+ IPageCache pageCache = new PageCache(this.getView().getPageId());
|
|
|
|
+ String serialNo = pageCache.get("add_attach");
|
|
|
|
+ if (!StringUtils.isEmpty(serialNo)) {
|
|
|
|
+ this.getPageCache().remove("add_attach");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Object> customParam = FpzsMainService.getCustomParam(this);
|
|
|
|
+ TempFileCache tempFileCache = CacheFactory.getCommonCacheFactory().getTempFileCache();
|
|
|
|
+ Long userId = Long.valueOf(RequestContext.get().getUserId());
|
|
|
|
+
|
|
|
|
+ int attachCount;
|
|
|
|
+ for(attachCount = 0; attachCount < uploadUrls.size(); ++attachCount) {
|
|
|
|
+ Map<String, Object> urlObj = (Map)uploadUrls.get(attachCount);
|
|
|
|
+ if (!CollectionUtils.isEmpty(urlObj)) {
|
|
|
|
+ Object resource = urlObj.get("resource");
|
|
|
|
+ DynamicObject attachObject = null;
|
|
|
|
+ String strUrl = urlObj.get("url").toString();
|
|
|
|
+ String originalName = urlObj.get("name").toString();
|
|
|
|
+ String fileName = originalName.substring(0, originalName.lastIndexOf(46));
|
|
|
|
+ if (StringUtils.isEmpty(fileName)) {
|
|
|
|
+ this.getView().showErrorNotification("请注意,文件名称不能为空");
|
|
|
|
+ } else {
|
|
|
|
+ String fileExtension = originalName.substring(originalName.lastIndexOf(46) + 1);
|
|
|
|
+ if (StringUtils.isEmpty(fileExtension)) {
|
|
|
|
+ this.getView().showErrorNotification("无法识别文件格式,请确认文件是否正常");
|
|
|
|
+ } else {
|
|
|
|
+ String fileFormat = FileUtils.getFileType(originalName);
|
|
|
|
+ String attachHash = null;
|
|
|
|
+ boolean isTempFile = false;
|
|
|
|
+ if (!ObjectUtils.isEmpty(resource) && "scanner".equals(resource.toString())) {
|
|
|
|
+ attachObject = this.newAttachDynamicObj();
|
|
|
|
+ attachHash = FileUploadUtils.getSHA256FromAttach(strUrl);
|
|
|
|
+ logger.info("【发票助手上传附件】-url地址:{}hash值:{},文件名:{}", new Object[]{strUrl, attachHash, originalName});
|
|
|
|
+ } else {
|
|
|
|
+ try {
|
|
|
|
+ isTempFile = strUrl.startsWith("http");
|
|
|
|
+ } catch (Exception var31) {
|
|
|
|
+ logger.error("临时文件判断异常:", var31);
|
|
|
|
+ isTempFile = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isTempFile) {
|
|
|
|
+ attachHash = FileUploadUtils.getSHA256FromCache(strUrl);
|
|
|
|
+ } else {
|
|
|
|
+ attachHash = FileUploadUtils.getSHA256FromAttach(strUrl);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ attachObject = this.newAttachDynamicObj();
|
|
|
|
+ logger.info("上传附件临时文件,isTempFlie:{},url:{}", isTempFile, strUrl);
|
|
|
|
+ if (isTempFile) {
|
|
|
|
+ InputStream inputStream = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ inputStream = tempFileCache.getInputStream(strUrl);
|
|
|
|
+ strUrl = FileUploadUtils.upload(FileUploadUtils.getInvoiceDir("attach") + attachHash + '.' + fileFormat, originalName, inputStream);
|
|
|
|
+ if (StringUtils.isEmpty(strUrl)) {
|
|
|
|
+ this.getView().showTipNotification(originalName + "文件上传失败,请重试", 2000);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception var32) {
|
|
|
|
+ logger.error("临时文件上传异常:", var32);
|
|
|
|
+ this.getView().showTipNotification(originalName + "文件上传超时,请重试", 2000);
|
|
|
|
+ continue;
|
|
|
|
+ } finally {
|
|
|
|
+ if (inputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ inputStream.close();
|
|
|
|
+ } catch (IOException var30) {
|
|
|
|
+ logger.error("附件文件流关闭失败:", var30);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ attachObject.set("update_time", new Date());
|
|
|
|
+ attachObject.set("attach_hash_value", attachHash);
|
|
|
|
+ attachObject.set("attach_url", strUrl);
|
|
|
|
+ if (ObjectUtils.isEmpty(attachObject.get("attach_category")) && ObjectUtils.isEmpty(attachObject.get("attach_category.id"))) {
|
|
|
|
+ attachObject.set("attach_category", AttachConstant.ATTACH_OTHER_CATEGORY_ID);
|
|
|
|
+ } else if (!ObjectUtils.isEmpty(attachObject.get("attach_category.id"))) {
|
|
|
|
+ attachObject.set("attach_category", attachObject.getLong("attach_category.id"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String iconImage = "";
|
|
|
|
+ if (!"pdf".equalsIgnoreCase(fileFormat) && !"ofd".equalsIgnoreCase(fileFormat)) {
|
|
|
|
+ if (!"doc".equalsIgnoreCase(fileFormat) && !"docx".equalsIgnoreCase(fileFormat)) {
|
|
|
|
+ if (!"xls".equalsIgnoreCase(fileFormat) && !"xlsx".equalsIgnoreCase(fileFormat)) {
|
|
|
|
+ if ("pptx".equalsIgnoreCase(fileFormat)) {
|
|
|
|
+ attachObject.set("attach_type", "7");
|
|
|
|
+ } else if ("txt".equalsIgnoreCase(fileFormat)) {
|
|
|
|
+ attachObject.set("attach_type", "8");
|
|
|
|
+ } else {
|
|
|
|
+ attachObject.set("attach_type", "2");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ attachObject.set("attach_type", "6");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ attachObject.set("attach_type", "5");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ iconImage = this.getAttachIconUrl(strUrl);
|
|
|
|
+ attachObject.set("icon_url", iconImage);
|
|
|
|
+ attachObject.set("snapshot_url", iconImage);
|
|
|
|
+ if ("pdf".equalsIgnoreCase(fileFormat)) {
|
|
|
|
+ attachObject.set("attach_type", "1");
|
|
|
|
+ } else {
|
|
|
|
+ attachObject.set("attach_type", "4");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ attachObject.set("file_extension", fileExtension);
|
|
|
|
+ attachObject.set("attach_name", fileName);
|
|
|
|
+ attachObject.set("remark", urlObj.get("description"));
|
|
|
|
+ attachObject.set("original_name", originalName);
|
|
|
|
+ DynamicObject attachSaveObject = (DynamicObject)SaveServiceHelper.save(new DynamicObject[]{attachObject})[0];
|
|
|
|
+ JSONObject attachInfo = new JSONObject(DynamicObjectUtil.dynamicObject2Map(attachSaveObject));
|
|
|
|
+ JSONArray attachArray = new JSONArray();
|
|
|
|
+ attachArray.add(attachInfo);
|
|
|
|
+ if (!StringUtils.isEmpty(serialNo)) {
|
|
|
|
+ this.saveAttachRelation(serialNo, attachObject.getPkValue().toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String pageId = this.getView().getPageId();
|
|
|
|
+ FpzsMainService.cacheAttachList(pageId, SerializationUtils.toJsonString(attachArray));
|
|
|
|
+ this.updateAttachModel(attachObject, serialNo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ attachCount = this.getModel().getEntryRowCount("attach_grid_entry");
|
|
|
|
+ this.showAttachFlex(attachCount);
|
|
|
|
+ this.calculationSum();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private JSONArray saveAwsAttach(JSONArray attachmentDatas) {
|
|
|
|
+ JSONArray newAttachIds = new JSONArray();
|
|
|
|
+ if (!CollectionUtils.isEmpty(attachmentDatas)) {
|
|
|
|
+ for(int i = 0; i < attachmentDatas.size(); ++i) {
|
|
|
|
+ JSONObject attachmentData = (JSONObject)attachmentDatas.get(i);
|
|
|
|
+ if (!ObjectUtils.isEmpty(attachmentData)) {
|
|
|
|
+ QFilter attachNoFilter = new QFilter("attach_no", "=", attachmentData.getString("serialNo"));
|
|
|
|
+ DynamicObject attachObj = QueryServiceHelper.queryOne("rim_attach", "id", attachNoFilter.toArray());
|
|
|
|
+ if (!ObjectUtils.isEmpty(attachObj)) {
|
|
|
|
+ newAttachIds.add(attachObj.getLong("id"));
|
|
|
|
+ } else {
|
|
|
|
+ attachObj = BusinessDataServiceHelper.newDynamicObject("rim_attach");
|
|
|
|
+ attachObj.set("attach_no", attachmentData.getString("serialNo"));
|
|
|
|
+ attachObj.set("attach_type", attachmentData.getString("attachmentType"));
|
|
|
|
+ attachObj.set("create_time", attachmentData.getDate("gatherTime"));
|
|
|
|
+ attachObj.set("attach_name", attachmentData.getString("attachmentName"));
|
|
|
|
+ String originalFileName = null;
|
|
|
|
+ String awsLocalUrl = attachmentData.getString("localUrl");
|
|
|
|
+ String awsSnapshotUrl = attachmentData.getString("snapshotUrl");
|
|
|
|
+ String url = null;
|
|
|
|
+ String fileExtension = "";
|
|
|
|
+ String localUrl = FileUtils.downLoadAndUpload(awsLocalUrl);
|
|
|
|
+ String snapshotUrl = FileUtils.downLoadAndUpload(awsSnapshotUrl);
|
|
|
|
+ if (StringUtils.isNotBlank(attachmentData.getString("originalFileName"))) {
|
|
|
|
+ originalFileName = attachmentData.getString("originalFileName");
|
|
|
|
+ } else {
|
|
|
|
+ originalFileName = attachmentData.getString("attachmentName");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!StringUtils.isEmpty(awsLocalUrl)) {
|
|
|
|
+ fileExtension = awsLocalUrl.substring(awsLocalUrl.lastIndexOf(46) + 1);
|
|
|
|
+ originalFileName = originalFileName.concat(".").concat(fileExtension);
|
|
|
|
+ url = awsLocalUrl;
|
|
|
|
+ } else if (!StringUtils.isEmpty(awsSnapshotUrl)) {
|
|
|
|
+ fileExtension = awsSnapshotUrl.substring(awsSnapshotUrl.lastIndexOf(46) + 1);
|
|
|
|
+ originalFileName = originalFileName.concat(fileExtension);
|
|
|
|
+ url = snapshotUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String fileHash = null;
|
|
|
|
+ if (StringUtils.isNotBlank(url)) {
|
|
|
|
+ InputStream inputStream = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ inputStream = FileUtils.getInputStreamByGet(url);
|
|
|
|
+ fileHash = FileUtils.getSHA256(inputStream);
|
|
|
|
+ } catch (Exception var26) {
|
|
|
|
+ logger.error("读取附件失败", var26);
|
|
|
|
+ } finally {
|
|
|
|
+ if (inputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ inputStream.close();
|
|
|
|
+ } catch (IOException var25) {
|
|
|
|
+ logger.error("获取aws文件的hash值失败", var25);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ attachObj.set("attach_hash_value", fileHash);
|
|
|
|
+ attachObj.set("original_name", originalFileName);
|
|
|
|
+ attachObj.set("update_time", new Date());
|
|
|
|
+ attachObj.set("snapshot_url", snapshotUrl);
|
|
|
|
+ attachObj.set("attach_url", localUrl);
|
|
|
|
+ attachObj.set("user", RequestContext.get().getUserId());
|
|
|
|
+ attachObj.set("rim_user", FpzsMainService.getCustomParam(this).get("rim_user"));
|
|
|
|
+ DynamicObject saveObj = (DynamicObject) SaveServiceHelper.save(new DynamicObject[]{attachObj})[0];
|
|
|
|
+ if (!ObjectUtils.isEmpty(saveObj)) {
|
|
|
|
+ newAttachIds.add(saveObj.getLong("id"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return newAttachIds;
|
|
|
|
+ }
|
|
|
|
+ private void updateAttachList(JSONArray attachIds, List<Long> invoiceIds) {
|
|
|
|
+ String pageId = this.getView().getPageId();
|
|
|
|
+ Set<String> attachSet = new HashSet(16);
|
|
|
|
+ Set<Long> attachLongSet = new HashSet(16);
|
|
|
|
+ if (!CollectionUtils.isEmpty(attachIds)) {
|
|
|
|
+ for(int i = 0; i < attachIds.size(); ++i) {
|
|
|
|
+ attachSet.add(attachIds.getString(i));
|
|
|
|
+ attachLongSet.add(attachIds.getLong(i));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject cache = FpzsMainService.getInvoiceDataCache(pageId);
|
|
|
|
+ QFilter serialFilter = new QFilter("relation_id", "in", cache.keySet());
|
|
|
|
+ QFilter typeFilter = new QFilter("relation_type", "=", "2");
|
|
|
|
+ DynamicObjectCollection attachCollection = QueryServiceHelper.query("rim_attach_relation", "attach_id,relation_id", new QFilter[]{serialFilter, typeFilter});
|
|
|
|
+ Map<String, String> attachRelaion = new HashMap(16);
|
|
|
|
+ Iterator var11 = attachCollection.iterator();
|
|
|
|
+
|
|
|
|
+ while(var11.hasNext()) {
|
|
|
|
+ DynamicObject obj = (DynamicObject)var11.next();
|
|
|
|
+ String attaId = obj.getString("attach_id");
|
|
|
|
+ attachSet.add(attaId);
|
|
|
|
+ attachRelaion.put(attaId, obj.getString("relation_id"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DynamicObject obj;
|
|
|
|
+ if (!CollectionUtils.isEmpty(invoiceIds)) {
|
|
|
|
+ QFilter relationFilter = new QFilter("attach_id", "in", attachSet);
|
|
|
|
+ QFilter type3Filter = new QFilter("relation_type", "=", "3");
|
|
|
|
+ DynamicObjectCollection attach3Collection = QueryServiceHelper.query("rim_attach_relation", "attach_id,relation_id", new QFilter[]{relationFilter, type3Filter});
|
|
|
|
+ if (!CollectionUtils.isEmpty(attach3Collection)) {
|
|
|
|
+ QFilter idFilter = new QFilter("id", "in", invoiceIds);
|
|
|
|
+ DynamicObjectCollection collection = QueryServiceHelper.query("rim_invoice", "id,serial_no", new QFilter[]{idFilter});
|
|
|
|
+ if (!CollectionUtils.isEmpty(collection)) {
|
|
|
|
+ Map<String, Long> serialMap = new HashMap(collection.size());
|
|
|
|
+ Iterator var17 = collection.iterator();
|
|
|
|
+
|
|
|
|
+ while(var17.hasNext()) {
|
|
|
|
+ obj = (DynamicObject)var17.next();
|
|
|
|
+ serialMap.put(obj.getString("serial_no"), obj.getLong("id"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var17 = attach3Collection.iterator();
|
|
|
|
+
|
|
|
|
+ while(var17.hasNext()) {
|
|
|
|
+ obj = (DynamicObject)var17.next();
|
|
|
|
+ String serialNo = obj.getString("relation_id");
|
|
|
|
+ Long invoiceId = (Long)serialMap.get(serialNo);
|
|
|
|
+ if (invoiceId != null && invoiceIds.contains(invoiceId)) {
|
|
|
|
+ String attaId = obj.getString("attach_id");
|
|
|
|
+ attachRelaion.put(attaId, serialNo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(attachSet)) {
|
|
|
|
+ int count = this.getModel().getEntryRowCount("attach_grid_entry");
|
|
|
|
+ Set<String> existsAttach = new HashSet(16);
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < count; ++i) {
|
|
|
|
+ String attachId = String.valueOf(this.getModel().getValue("attachid", i));
|
|
|
|
+ existsAttach.add(attachId);
|
|
|
|
+ attachSet.remove(attachId);
|
|
|
|
+ String serialNo = (String)attachRelaion.get(attachId);
|
|
|
|
+ if (!StringUtils.isEmpty(serialNo)) {
|
|
|
|
+ this.getModel().setValue("serial_no3", serialNo, i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MainEntityType mainEntityType = EntityMetadataCache.getDataEntityType("rim_attach");
|
|
|
|
+ DynamicObject[] dynamicObject = BusinessDataServiceHelper.load(attachLongSet.toArray(), mainEntityType);
|
|
|
|
+ DynamicObject[] var33 = dynamicObject;
|
|
|
|
+ int var34 = dynamicObject.length;
|
|
|
|
+
|
|
|
|
+ for(int var35 = 0; var35 < var34; ++var35) {
|
|
|
|
+ obj = var33[var35];
|
|
|
|
+ Long attachId = obj.getLong("id");
|
|
|
|
+ if (existsAttach.add(String.valueOf(attachId))) {
|
|
|
|
+ if (obj.get("attach_category") != null && obj.get("attach_category.id") != null) {
|
|
|
|
+ obj.set("attach_category", obj.get("attach_category.id"));
|
|
|
|
+ } else {
|
|
|
|
+ obj.set("attach_category", AttachConstant.ATTACH_OTHER_CATEGORY_ID);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.updateAttachModel(obj, (String)attachRelaion.get(String.valueOf(attachId)));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.showFlex();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void updateAttachModel(DynamicObject attachObject, String serialNo) {
|
|
|
|
+ Object categoryId = DynamicObjectUtil.getDynamicObjectLongValue(attachObject.get("attach_category"));
|
|
|
|
+ QFilter categoryFilter = new QFilter("id", "=", categoryId);
|
|
|
|
+ DynamicObject attachCategory = QueryServiceHelper.queryOne("bdm_attach_type", "name,simplify_name", categoryFilter.toArray());
|
|
|
|
+ if (attachCategory == null) {
|
|
|
|
+ this.getView().showTipNotification("找不到附件分类");
|
|
|
|
+ } else {
|
|
|
|
+ String categorySimplifyName = attachCategory.getString("simplify_name");
|
|
|
|
+ String categoryName = attachCategory.getString("name");
|
|
|
|
+ if (StringUtils.isEmpty(categorySimplifyName)) {
|
|
|
|
+ categorySimplifyName = "其他";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isEmpty(categoryName)) {
|
|
|
|
+ categoryName = "其他附件";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int attachIndex = this.getModel().createNewEntryRow("attach_grid_entry");
|
|
|
|
+ String attachType = attachObject.getString("attach_type");
|
|
|
|
+ String fileExtension = attachObject.getString("file_extension");
|
|
|
|
+ this.getModel().setValue("attach_no", attachObject.get("attach_no"), attachIndex);
|
|
|
|
+ this.getModel().setValue("attach_type", attachType, attachIndex);
|
|
|
|
+ this.getModel().setValue("attach_name", attachObject.get("attach_name"), attachIndex);
|
|
|
|
+ Date uploadDate = attachObject.getDate("create_time");
|
|
|
|
+ uploadDate = (Date)Optional.ofNullable(uploadDate).orElseGet(() -> {
|
|
|
|
+ return new Date();
|
|
|
|
+ });
|
|
|
|
+ this.getModel().setValue("upload_date", uploadDate, attachIndex);
|
|
|
|
+ this.getModel().setValue("attach_path", attachObject.get("attach_url"), attachIndex);
|
|
|
|
+ this.getModel().setValue("original_name", attachObject.get("original_name"), attachIndex);
|
|
|
|
+ this.getModel().setValue("attach_icon", attachObject.get("icon_url"), attachIndex);
|
|
|
|
+ this.getModel().setValue("attach_no", attachObject.getString("attach_no"), attachIndex);
|
|
|
|
+ this.getModel().setValue("attach_category_grid", categoryId, attachIndex);
|
|
|
|
+ this.getModel().setValue("attach_categoryid", categoryId, attachIndex);
|
|
|
|
+ this.getModel().setValue("file_extension", fileExtension, attachIndex);
|
|
|
|
+ if (!StringUtils.isEmpty(serialNo)) {
|
|
|
|
+ this.getModel().setValue("serial_no3", serialNo, attachIndex);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.getModel().setValue("attachid", attachObject.getPkValue(), attachIndex);
|
|
|
|
+ this.getModel().setValue("attach_remark", attachObject.getString("remark"), attachIndex);
|
|
|
|
+ int attachCardIndex = this.getModel().createNewEntryRow("attach_card_entry");
|
|
|
|
+ this.getModel().setValue("attach_category", categorySimplifyName, attachCardIndex);
|
|
|
|
+ this.getModel().setValue("attach_name_grid", attachObject.get("attach_name"), attachCardIndex);
|
|
|
|
+ String imageUrl = this.getAttachSnapshotUrl(attachObject);
|
|
|
|
+ this.getModel().setValue("attach_image_grid", imageUrl, attachCardIndex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private Boolean showSelectInvoice(List<Long> invoiceIds, List<Long> unchekInvoiceIds, JSONArray invoiceArray) {
|
|
|
|
+ JSONArray showArray = new JSONArray();
|
|
|
|
+ Iterator var5;
|
|
|
|
+ Long id;
|
|
|
|
+ JSONObject obj;
|
|
|
|
+ if (!CollectionUtils.isEmpty(invoiceIds)) {
|
|
|
|
+ var5 = invoiceIds.iterator();
|
|
|
|
+
|
|
|
|
+ while(var5.hasNext()) {
|
|
|
|
+ id = (Long)var5.next();
|
|
|
|
+ obj = new JSONObject();
|
|
|
|
+ obj.put("mainId", id);
|
|
|
|
+ showArray.add(obj);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(unchekInvoiceIds)) {
|
|
|
|
+ var5 = unchekInvoiceIds.iterator();
|
|
|
|
+
|
|
|
|
+ while(var5.hasNext()) {
|
|
|
|
+ id = (Long)var5.next();
|
|
|
|
+ obj = new JSONObject();
|
|
|
|
+ obj.put("unCheckId", id);
|
|
|
|
+ showArray.add(obj);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(invoiceArray)) {
|
|
|
|
+ showArray.addAll(invoiceArray);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.refreshInvoiceList(showArray);
|
|
|
|
+ return Boolean.TRUE;
|
|
|
|
+ }
|
|
|
|
+ private void refreshInvoiceList(JSONArray invoiceArray) {
|
|
|
|
+ JSONArray attachArray = (JSONArray)invoiceArray.stream().filter((f) -> {
|
|
|
|
+ JSONObject info = (JSONObject)f;
|
|
|
|
+ String attach_no = info.getString("attach_no");
|
|
|
|
+ return StringUtils.isNotEmpty(attach_no);
|
|
|
|
+ }).collect(Collectors.toCollection(JSONArray::new));
|
|
|
|
+ invoiceArray.removeAll(attachArray);
|
|
|
|
+ Pair<JSONObject, Boolean> cachePair = FpzsMainService.cacheInvoiceList(this.getView().getPageId(), FpzsMainService.getCustomParam(this), invoiceArray, attachArray);
|
|
|
|
+ JSONObject invoiceJson = (JSONObject)cachePair.getLeft();
|
|
|
|
+ if (!ObjectUtils.isEmpty(invoiceJson)) {
|
|
|
|
+ FpzsMainService.updateInvoiceGrid(this, invoiceJson);
|
|
|
|
+ this.updateInvoiceCard(invoiceJson);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject data = FpzsMainService.getInvoiceDataCache(this.getView().getPageId());
|
|
|
|
+ Map<String, String> attIdSerialMap = Maps.newLinkedHashMap();
|
|
|
|
+ Iterator var7 = data.entrySet().iterator();
|
|
|
|
+
|
|
|
|
+ while(true) {
|
|
|
|
+ JSONObject invoiceInfo;
|
|
|
|
+ List attachList;
|
|
|
|
+ do {
|
|
|
|
+ do {
|
|
|
|
+ if (!var7.hasNext()) {
|
|
|
|
+ JSONArray attachCache = FpzsMainService.getAttachDataCache(this.getView().getPageId());
|
|
|
|
+ if (attachCache.size() != 0) {
|
|
|
|
+ this.getModel().deleteEntryData("attach_grid_entry");
|
|
|
|
+ this.getModel().deleteEntryData("attach_card_entry");
|
|
|
|
+ Iterator var18 = attachCache.iterator();
|
|
|
|
+
|
|
|
|
+ while(var18.hasNext()) {
|
|
|
|
+ Object attach = var18.next();
|
|
|
|
+ JSONObject attachJson = (JSONObject)attach;
|
|
|
|
+ String id = attachJson.getString("id");
|
|
|
|
+ Iterator var22 = attIdSerialMap.entrySet().iterator();
|
|
|
|
+
|
|
|
|
+ while(var22.hasNext()) {
|
|
|
|
+ Map.Entry<String, String> entry = (Map.Entry)var22.next();
|
|
|
|
+ if (id.equals(entry.getKey())) {
|
|
|
|
+ attachJson.put("serial_no", entry.getValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.handleAttachCategory(attachJson);
|
|
|
|
+ int row = this.getModel().createNewEntryRow("attach_grid_entry");
|
|
|
|
+ this.getModel().setValue("attachid", attachJson.get("id"), row);
|
|
|
|
+ this.getModel().setValue("attach_category_grid", attachJson.get("attach_category"), row);
|
|
|
|
+ this.getModel().setValue("attach_name", attachJson.get("attach_name"), row);
|
|
|
|
+ this.getModel().setValue("serial_no3", attachJson.get("serial_no"), row);
|
|
|
|
+ this.getModel().setValue("attach_type", attachJson.get("attach_type"), row);
|
|
|
|
+ this.getModel().setValue("upload_date", attachJson.getDate("create_time"), row);
|
|
|
|
+ this.getModel().setValue("attach_remark", attachJson.get("remark"), row);
|
|
|
|
+ this.getModel().setValue("attach_path", attachJson.get("attach_url"), row);
|
|
|
|
+ this.getModel().setValue("file_extension", attachJson.get("file_extension"), row);
|
|
|
|
+ this.getModel().setValue("attach_no", attachJson.get("attach_no"), row);
|
|
|
|
+ int attachGridIndex = this.getModel().createNewEntryRow("attach_card_entry");
|
|
|
|
+ String simplify_name = attachJson.getString("simplify_name");
|
|
|
|
+ if (StringUtils.isEmpty(simplify_name)) {
|
|
|
|
+ Long attachCategoryId = DynamicObjectUtil.getDynamicObjectLongValue(attachJson.get("attach_category"));
|
|
|
|
+ DynamicObject attachTypeObj = BusinessDataServiceHelper.loadSingle(attachCategoryId, "bdm_attach_type");
|
|
|
|
+ simplify_name = attachTypeObj.getString("simplify_name");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.getModel().setValue("attach_category", simplify_name, attachGridIndex);
|
|
|
|
+ this.getModel().setValue("attach_name_grid", attachJson.get("attach_name"), attachGridIndex);
|
|
|
|
+ DynamicObject attachObj = BusinessDataServiceHelper.newDynamicObject("rim_attach");
|
|
|
|
+ attachObj = DynamicObjectUtil.jsonToDynamicObject(attachJson, attachObj);
|
|
|
|
+ String imageUrl = this.getAttachSnapshotUrl(attachObj);
|
|
|
|
+ this.getModel().setValue("attach_image_grid", imageUrl, attachGridIndex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.showFlex();
|
|
|
|
+ if ((Boolean)cachePair.getRight()) {
|
|
|
|
+ this.getView().showSuccessNotification("发票已存在列表");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map.Entry<String, Object> entry = (Map.Entry)var7.next();
|
|
|
|
+ invoiceInfo = (JSONObject)entry.getValue();
|
|
|
|
+ attachList = (List)invoiceInfo.get("attachList");
|
|
|
|
+ } while(attachList == null);
|
|
|
|
+ } while(attachList.size() == 0);
|
|
|
|
+
|
|
|
|
+ Iterator var11 = attachList.iterator();
|
|
|
|
+
|
|
|
|
+ while(var11.hasNext()) {
|
|
|
|
+ Map<String, Object> attachInfo = (Map)var11.next();
|
|
|
|
+ String id = (String)attachInfo.get("id");
|
|
|
|
+ attIdSerialMap.put(id, invoiceInfo.getString("serialNo"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private FormShowParameter newPage(String formId, Map<String, Object> customParams, String callBackId) {
|
|
|
|
+ FormShowParameter showParameter = new FormShowParameter();
|
|
|
|
+ showParameter.setShowTitle(true);
|
|
|
|
+ showParameter.setCustomParams(customParams);
|
|
|
|
+ showParameter.setFormId(formId);
|
|
|
|
+ showParameter.getOpenStyle().setShowType(ShowType.Modal);
|
|
|
|
+ if (StringUtils.isNotEmpty(callBackId)) {
|
|
|
|
+ CloseCallBack closeCallBack = new CloseCallBack(this, callBackId);
|
|
|
|
+ showParameter.setCloseCallBack(closeCallBack);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return showParameter;
|
|
|
|
+ }
|
|
|
|
+ private void updateInvoiceCard(JSONObject invoiceArray) {
|
|
|
|
+ this.getModel().deleteEntryData("invoice_card_entry");
|
|
|
|
+ this.getModel().deleteEntryData("error_invoice_card_entry");
|
|
|
|
+ JSONObject obj;
|
|
|
|
+ Boolean isFilter;
|
|
|
|
+ int cardIndex;
|
|
|
|
+ if (!ObjectUtils.isEmpty(invoiceArray)) {
|
|
|
|
+ for(Iterator var2 = invoiceArray.entrySet().iterator(); var2.hasNext(); this.showWarningAndEdit(isFilter, obj, cardIndex)) {
|
|
|
|
+ Map.Entry<String, Object> entry = (Map.Entry)var2.next();
|
|
|
|
+ obj = (JSONObject)entry.getValue();
|
|
|
|
+ String invoiceType = obj.getString("invoiceType");
|
|
|
|
+ String level = (String)obj.get("errorLevel");
|
|
|
|
+ String snapshotUrl = obj.getString("snapshotUrl");
|
|
|
|
+ String imageUrl = UrlServiceUtils.getDownloadUrl(snapshotUrl);
|
|
|
|
+ String serialNo = obj.getString("serialNo");
|
|
|
|
+ isFilter = FpzsMainService.isFilter(obj);
|
|
|
|
+ if (isFilter) {
|
|
|
|
+ cardIndex = this.getModel().createNewEntryRow("error_invoice_card_entry");
|
|
|
|
+ this.getModel().setValue("error_invoice_card_image", imageUrl, cardIndex);
|
|
|
|
+ this.getModel().setValue("error_serial_no", serialNo, cardIndex);
|
|
|
|
+ } else {
|
|
|
|
+ cardIndex = this.getModel().createNewEntryRow("invoice_card_entry");
|
|
|
|
+ this.getModel().setValue("invoice_card_image", imageUrl, cardIndex);
|
|
|
|
+ this.getModel().setValue("import_serial_no", serialNo, cardIndex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void showFlex() {
|
|
|
|
+ int attachCount = this.getModel().getEntryRowCount("attach_grid_entry");
|
|
|
|
+ String tab = "tab_invoice";
|
|
|
|
+ if (null != this.getPageCache().get("tabSelect")) {
|
|
|
|
+ tab = this.getPageCache().get("tabSelect");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!tab.equalsIgnoreCase("tab_invoice") && !tab.equalsIgnoreCase("tab_oversea")) {
|
|
|
|
+ if (tab.equalsIgnoreCase("tab_attach")) {
|
|
|
|
+ this.showAttachFlex(attachCount);
|
|
|
|
+ } else if (tab.equalsIgnoreCase("tab_oversea")) {
|
|
|
|
+ this.showInvoiceFlex(tab);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.showInvoiceFlex(tab);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.calculationSum();
|
|
|
|
+ }
|
|
|
|
+ private void showAttachFlex(int attachCount) {
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"flexpanelap1"});
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"flexpanelap11"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"all_invoice"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"advconap_import"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"advconap_error"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"radio_flex"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"flexpanelap131"});
|
|
|
|
+ if (attachCount > 0) {
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"attach_panel"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String flex_init_description = "请从左侧选择导入附件的方式。";
|
|
|
|
+ if (attachCount == 0) {
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"flex_init"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"attach_panel"});
|
|
|
|
+ this.getModel().setValue("flex_init_description", flex_init_description);
|
|
|
|
+ } else {
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"flex_init"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.showAttachModel();
|
|
|
|
+ }
|
|
|
|
+ private void showInvoiceFlex(String tab) {
|
|
|
|
+ int importCount = 0;
|
|
|
|
+ int errorCount = 0;
|
|
|
|
+ JSONObject dataJson = FpzsMainService.getInvoiceDataCache(this.getView().getPageId());
|
|
|
|
+ logger.info("scannerProcess showFlex dataJson : " + dataJson);
|
|
|
|
+ if (dataJson == null) {
|
|
|
|
+ importCount = 0;
|
|
|
|
+ errorCount = 0;
|
|
|
|
+ } else {
|
|
|
|
+ Set<String> keySet = dataJson.keySet();
|
|
|
|
+ Iterator<String> iterator = keySet.iterator();
|
|
|
|
+
|
|
|
|
+ while(iterator.hasNext()) {
|
|
|
|
+ String key = (String)iterator.next();
|
|
|
|
+ JSONObject obj = dataJson.getJSONObject(key);
|
|
|
|
+ if (FpzsMainService.isFilter(obj)) {
|
|
|
|
+ ++errorCount;
|
|
|
|
+ } else {
|
|
|
|
+ ++importCount;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String flex_init_description = "请从左侧选择导入发票的方式。";
|
|
|
|
+ String radioGroup = (String)this.getModel().getValue("radiogroup");
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"flexpanelap11"});
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"flexpanelap1"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"attach_panel"});
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"radio_flex"});
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"flexpanelap131"});
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"all_invoice"});
|
|
|
|
+ if (importCount <= 0 || !"1".equals(radioGroup) && !"2".equals(radioGroup)) {
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"advconap_import"});
|
|
|
|
+ } else {
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"advconap_import"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (errorCount <= 0 || !"1".equals(radioGroup) && !"3".equals(radioGroup)) {
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"advconap_error"});
|
|
|
|
+ } else {
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"advconap_error"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (importCount == 0 && errorCount == 0) {
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"flex_init"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"all_invoice"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"advconap_import"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"advconap_error"});
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"attach_panel"});
|
|
|
|
+ this.getModel().setValue("flex_init_description", flex_init_description);
|
|
|
|
+ } else {
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"flex_init"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.showInvoiceModel();
|
|
|
|
+ }
|
|
|
|
+ private void showInvoiceModel() {
|
|
|
|
+ String invoiceModel = this.getView().getPageCache().get("invoice_list_model");
|
|
|
|
+ Map<String, Object> falseCtrl = new HashMap(1);
|
|
|
|
+ falseCtrl.put("vi", 0);
|
|
|
|
+ Map<String, Object> trueCtrl = new HashMap(1);
|
|
|
|
+ trueCtrl.put("vi", 1);
|
|
|
|
+ if (StringUtils.isEmpty(invoiceModel)) {
|
|
|
|
+ this.getView().updateControlMetadata("list_invoice_flex", trueCtrl);
|
|
|
|
+ this.getView().updateControlMetadata("error_list_invoice_flex", trueCtrl);
|
|
|
|
+ this.getView().updateControlMetadata("error_card_invoice_flex", falseCtrl);
|
|
|
|
+ this.getView().updateControlMetadata("card_invoice_flex", falseCtrl);
|
|
|
|
+ } else {
|
|
|
|
+ this.getView().updateControlMetadata("list_invoice_flex", falseCtrl);
|
|
|
|
+ this.getView().updateControlMetadata("error_list_invoice_flex", falseCtrl);
|
|
|
|
+ this.getView().updateControlMetadata("error_card_invoice_flex", trueCtrl);
|
|
|
|
+ this.getView().updateControlMetadata("card_invoice_flex", trueCtrl);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void calculationSum() {
|
|
|
|
+ JSONObject cacheJson = FpzsMainService.getInvoiceDataCache(this.getView().getPageId());
|
|
|
|
+ BigDecimal importAmount = BigDecimal.ZERO;
|
|
|
|
+ BigDecimal importTaxAmount = BigDecimal.ZERO;
|
|
|
|
+ BigDecimal errorAmount = BigDecimal.ZERO;
|
|
|
|
+ BigDecimal errorTaxAmount = BigDecimal.ZERO;
|
|
|
|
+ int errorTotal = 0;
|
|
|
|
+ int importTotal = 0;
|
|
|
|
+ if (cacheJson != null) {
|
|
|
|
+ Iterator<String> iterator = cacheJson.keySet().iterator();
|
|
|
|
+
|
|
|
|
+ while(iterator.hasNext()) {
|
|
|
|
+ String key = (String)iterator.next();
|
|
|
|
+ JSONObject obj = cacheJson.getJSONObject(key);
|
|
|
|
+ BigDecimal objTotalAmount = BigDecimal.ZERO;
|
|
|
|
+ BigDecimal objTotalTaxAmount = BigDecimal.ZERO;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ objTotalAmount = BigDecimalUtil.transDecimal(obj.getBigDecimal("totalAmount"));
|
|
|
|
+ objTotalTaxAmount = BigDecimalUtil.transDecimal(obj.getBigDecimal("totalTaxAmount"));
|
|
|
|
+ } catch (Exception var16) {
|
|
|
|
+ logger.info("合计金额计算失败,格式不正确:" + obj.get("totalAmount") + "," + obj.get("totalTaxAmount"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (FpzsMainService.isFilter(obj)) {
|
|
|
|
+ ++errorTotal;
|
|
|
|
+ errorAmount = errorAmount.add(objTotalAmount);
|
|
|
|
+ errorTaxAmount = errorTaxAmount.add(objTotalTaxAmount);
|
|
|
|
+ } else {
|
|
|
|
+ ++importTotal;
|
|
|
|
+ importAmount = importAmount.add(objTotalAmount);
|
|
|
|
+ importTaxAmount = importTaxAmount.add(objTotalTaxAmount);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int attachTotal = this.getModel().getEntryRowCount("attach_grid_entry");
|
|
|
|
+ Label labelapImportMsgCount = (Label)this.getView().getControl("labelap_import_msg_count");
|
|
|
|
+ Label labelapErrorMsgCount = (Label)this.getView().getControl("labelap_error_msg_count");
|
|
|
|
+ Label labelapAttachMsgCount = (Label)this.getView().getControl("labelap_attach_msg_count");
|
|
|
|
+ labelapImportMsgCount.setText(String.format("共%s张,价税合计:%s元 税额:%s元", importTotal, BigDecimalUtil.format(importAmount, "###,##0.00"), BigDecimalUtil.format(importTaxAmount, "###,##0.00")));
|
|
|
|
+ labelapErrorMsgCount.setText(String.format("共%s张,价税合计:%s元 税额:%s元", errorTotal, BigDecimalUtil.format(errorAmount, "###,##0.00"), BigDecimalUtil.format(errorTaxAmount, "###,##0.00")));
|
|
|
|
+ labelapAttachMsgCount.setText(String.format("共%s份", attachTotal));
|
|
|
|
+ Label labelapInvTotal = (Label)this.getView().getControl("labelap_inv_total");
|
|
|
|
+ Label labelapInvamountTotal = (Label)this.getView().getControl("labelap_invamount_total");
|
|
|
|
+ Label labelapInvtaxTotal = (Label)this.getView().getControl("labelap_invtax_total");
|
|
|
|
+ Label labelapAttachTotal = (Label)this.getView().getControl("labelap_attach_total");
|
|
|
|
+ labelapInvTotal.setText(importTotal + errorTotal + "");
|
|
|
|
+ labelapInvamountTotal.setText(BigDecimalUtil.format(importAmount.add(errorAmount), "###,##0.00"));
|
|
|
|
+ labelapInvtaxTotal.setText(BigDecimalUtil.format(errorTaxAmount.add(importTaxAmount), "###,##0.00"));
|
|
|
|
+ labelapAttachTotal.setText(attachTotal + "");
|
|
|
|
+ }
|
|
|
|
+ private void showAttachModel() {
|
|
|
|
+ String attachModel = this.getView().getPageCache().get("attach_list_model");
|
|
|
|
+ if (StringUtils.isEmpty(attachModel)) {
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"picture_attach"});
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"list_attach"});
|
|
|
|
+ } else {
|
|
|
|
+ this.getView().setVisible(Boolean.FALSE, new String[]{"list_attach"});
|
|
|
|
+ this.getView().setVisible(Boolean.TRUE, new String[]{"picture_attach"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private String getAttachSnapshotUrl(DynamicObject attachObject) {
|
|
|
|
+ String attachType = attachObject.getString("attach_type");
|
|
|
|
+ String imageUrl = "";
|
|
|
|
+ String domain = UrlService.getDomainContextUrl();
|
|
|
|
+ if (!"1".equals(attachType) && !"4".equals(attachType)) {
|
|
|
|
+ if ("8".equals(attachType)) {
|
|
|
|
+ imageUrl = domain.concat("/icons/pc/label/fpy_txt.png");
|
|
|
|
+ } else if ("5".equals(attachType)) {
|
|
|
|
+ imageUrl = domain.concat("/icons/pc/label/fpy_word_doc.png");
|
|
|
|
+ } else if ("6".equals(attachType)) {
|
|
|
|
+ imageUrl = domain.concat("/icons/pc/label/fpy_excel_xls.png");
|
|
|
|
+ } else if ("7".equals(attachType)) {
|
|
|
|
+ imageUrl = domain.concat("/icons/pc/label/fpy_ppt.png");
|
|
|
|
+ } else if (!"3".equals(attachType)) {
|
|
|
|
+ imageUrl = UrlServiceUtils.getDownloadUrl(attachObject.get("attach_url").toString());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ imageUrl = UrlServiceUtils.getDownloadUrl(attachObject.get("icon_url").toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return imageUrl;
|
|
|
|
+ }
|
|
|
|
+ private void handleAttachCategory(JSONObject attachJson) {
|
|
|
|
+ if (ObjectUtils.isEmpty(attachJson.get("attach_category")) && ObjectUtils.isEmpty(attachJson.get("attach_category.id")) && ObjectUtils.isEmpty(attachJson.get("attach_category_id"))) {
|
|
|
|
+ attachJson.put("attach_category", AttachConstant.ATTACH_OTHER_CATEGORY_ID);
|
|
|
|
+ } else if (!ObjectUtils.isEmpty(attachJson.get("attach_category_id"))) {
|
|
|
|
+ attachJson.put("attach_category", attachJson.getLong("attach_category_id"));
|
|
|
|
+ } else if (!ObjectUtils.isEmpty(attachJson.get("attach_category.id"))) {
|
|
|
|
+ attachJson.put("attach_category", attachJson.getLong("attach_category.id"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void showWarningAndEdit(Boolean isFilter, JSONObject invoiceObj, int index) {
|
|
|
|
+ String entry = "invoice_card_entry";
|
|
|
|
+ if (isFilter) {
|
|
|
|
+ entry = "error_invoice_card_entry";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CardEntry cardEntry = (CardEntry)this.getControl(entry);
|
|
|
|
+ String level = (String)invoiceObj.get("errorLevel");
|
|
|
|
+ String verifyResultHtml = invoiceObj.getString("validateMessage_html");
|
|
|
|
+ String verifyMessage = invoiceObj.getString("validateMessage");
|
|
|
|
+ JSONArray verifyResultArray = invoiceObj.getJSONArray("verifyResult");
|
|
|
|
+ String filterMsg = "";
|
|
|
|
+ String redMsg = "";
|
|
|
|
+ String yellowMsg = "";
|
|
|
|
+ String showAttachUpload;
|
|
|
|
+ if (verifyResultArray != null && verifyResultArray.size() > 0) {
|
|
|
|
+ for(int i = 0; i < verifyResultArray.size(); ++i) {
|
|
|
|
+ JSONObject verifyResult = verifyResultArray.getJSONObject(i);
|
|
|
|
+ if (verifyResult != null) {
|
|
|
|
+ showAttachUpload = verifyResult.getString("config");
|
|
|
|
+ String msg = verifyResult.getString("msg");
|
|
|
|
+ if ("0".equals(showAttachUpload)) {
|
|
|
|
+ if (StringUtils.isEmpty(filterMsg) && !StringUtils.isEmpty(msg)) {
|
|
|
|
+ filterMsg = "严重警示:\r\n\t".concat(msg).concat("\r\n\t");
|
|
|
|
+ } else if (!StringUtils.isEmpty(filterMsg) && !StringUtils.isEmpty(msg)) {
|
|
|
|
+ filterMsg = filterMsg.concat(msg).concat("\r\n\t");
|
|
|
|
+ }
|
|
|
|
+ } else if ("1".equals(showAttachUpload)) {
|
|
|
|
+ if (StringUtils.isEmpty(redMsg) && !StringUtils.isEmpty(msg)) {
|
|
|
|
+ redMsg = "中度警示:\r\n\t".concat(msg).concat("\r\n\t");
|
|
|
|
+ } else if (!StringUtils.isEmpty(redMsg) && !StringUtils.isEmpty(msg)) {
|
|
|
|
+ redMsg = redMsg.concat(msg).concat("\r\n\t");
|
|
|
|
+ }
|
|
|
|
+ } else if ("2".equals(showAttachUpload)) {
|
|
|
|
+ if (StringUtils.isEmpty(yellowMsg) && !StringUtils.isEmpty(msg)) {
|
|
|
|
+ yellowMsg = "轻度提醒:\r\n\t".concat(msg).concat("\r\n\t");
|
|
|
|
+ } else if (!StringUtils.isEmpty(yellowMsg) && !StringUtils.isEmpty(msg)) {
|
|
|
|
+ yellowMsg = yellowMsg.concat(msg).concat("\r\n\t");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String allMsg = "";
|
|
|
|
+ if (!StringUtils.isEmpty(filterMsg)) {
|
|
|
|
+ allMsg = allMsg.concat(filterMsg);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!StringUtils.isEmpty(redMsg)) {
|
|
|
|
+ allMsg = allMsg.concat(redMsg);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!StringUtils.isEmpty(yellowMsg)) {
|
|
|
|
+ allMsg = allMsg.concat(yellowMsg);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ("0".equals(level)) {
|
|
|
|
+ if (isFilter) {
|
|
|
|
+ if (StringUtils.isEmpty(allMsg) && !StringUtils.isEmpty(verifyResultHtml) && verifyResultHtml.contains("发票必要字段缺失")) {
|
|
|
|
+ allMsg = "严重警示:\r\n\t".concat("发票必要字段缺失,请编辑补全").concat("\r\n\t");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.createTips(entry, allMsg, index, "error_filter_msg");
|
|
|
|
+ this.showTipsTag(isFilter, "error_filter_msg", index);
|
|
|
|
+ } else {
|
|
|
|
+ this.createTips(entry, allMsg, index, "import_filter_msg");
|
|
|
|
+ this.showTipsTag(isFilter, "import_filter_msg", index);
|
|
|
|
+ }
|
|
|
|
+ } else if ("1".equals(level)) {
|
|
|
|
+ if (isFilter) {
|
|
|
|
+ this.createTips(entry, allMsg, index, "error_red_msg");
|
|
|
|
+ this.showTipsTag(isFilter, "error_red_msg", index);
|
|
|
|
+ } else {
|
|
|
|
+ this.createTips(entry, allMsg, index, "import_red_msg");
|
|
|
|
+ this.showTipsTag(isFilter, "import_red_msg", index);
|
|
|
|
+ }
|
|
|
|
+ } else if ("2".equals(level)) {
|
|
|
|
+ if (isFilter) {
|
|
|
|
+ this.createTips(entry, allMsg, index, "error_yellow_msg");
|
|
|
|
+ this.showTipsTag(isFilter, "error_yellow_msg", index);
|
|
|
|
+ } else {
|
|
|
|
+ this.createTips(entry, allMsg, index, "import_yellow_msg");
|
|
|
|
+ this.showTipsTag(isFilter, "import_yellow_msg", index);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.showTipsTag(isFilter, "null", index);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Boolean canEdit = FpzsMainService.canEdit(invoiceObj);
|
|
|
|
+ showAttachUpload = this.getPageCache().get("showAttachUpload");
|
|
|
|
+ boolean allowAttachUpload = StringUtils.isEmpty(showAttachUpload) || !"false".equals(showAttachUpload);
|
|
|
|
+ if (isFilter) {
|
|
|
|
+ if (canEdit) {
|
|
|
|
+ cardEntry.setChildVisible(true, index, new String[]{"error_edit_button"});
|
|
|
|
+ cardEntry.setChildVisible(false, index, new String[]{"error_view_button"});
|
|
|
|
+ } else {
|
|
|
|
+ cardEntry.setChildVisible(false, index, new String[]{"error_edit_button"});
|
|
|
|
+ cardEntry.setChildVisible(true, index, new String[]{"error_view_button"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (allowAttachUpload) {
|
|
|
|
+ cardEntry.setChildVisible(true, index, new String[]{"error_upload_attach"});
|
|
|
|
+ } else {
|
|
|
|
+ cardEntry.setChildVisible(false, index, new String[]{"error_upload_attach"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ if (canEdit) {
|
|
|
|
+ cardEntry.setChildVisible(true, index, new String[]{"import_edit_button"});
|
|
|
|
+ cardEntry.setChildVisible(false, index, new String[]{"import_view_button"});
|
|
|
|
+ } else {
|
|
|
|
+ cardEntry.setChildVisible(false, index, new String[]{"import_edit_button"});
|
|
|
|
+ cardEntry.setChildVisible(true, index, new String[]{"import_view_button"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (allowAttachUpload) {
|
|
|
|
+ cardEntry.setChildVisible(true, index, new String[]{"import_upload_attach"});
|
|
|
|
+ } else {
|
|
|
|
+ cardEntry.setChildVisible(false, index, new String[]{"import_upload_attach"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void createTips(String entry, String verifyMessage, int index, String key) {
|
|
|
|
+ ClientViewProxy client = (ClientViewProxy)this.getView().getService(IClientViewProxy.class);
|
|
|
|
+ Map<String, Object> pmap = new HashMap(2);
|
|
|
|
+ Map<String, Object> operateHoverPropMap = new HashMap(4);
|
|
|
|
+ Map<String, Object> tips = new HashMap(2);
|
|
|
|
+ tips.put("type", "text");
|
|
|
|
+ if (verifyMessage != null && verifyMessage.length() > 3) {
|
|
|
|
+ verifyMessage = verifyMessage.substring(0, verifyMessage.length() - 3);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ tips.put("content", new LocaleString(verifyMessage));
|
|
|
|
+ tips.put("showIcon", Boolean.TRUE);
|
|
|
|
+ operateHoverPropMap.put("tips", tips);
|
|
|
|
+ operateHoverPropMap.put("text", "");
|
|
|
|
+ pmap.put(key, operateHoverPropMap);
|
|
|
|
+ client.invokeControlMethod(entry, "setCustomProperties", new Object[]{index, pmap});
|
|
|
|
+ }
|
|
|
|
+ private void showTipsTag(Boolean isFilter, String tagKey, int index) {
|
|
|
|
+ String entry = "invoice_card_entry";
|
|
|
|
+ CardEntry cardEntry;
|
|
|
|
+ Iterator var6;
|
|
|
|
+ String msgKey;
|
|
|
|
+ if (isFilter) {
|
|
|
|
+ entry = "error_invoice_card_entry";
|
|
|
|
+ cardEntry = (CardEntry)this.getControl(entry);
|
|
|
|
+ var6 = ERROR_MSG_LIST.iterator();
|
|
|
|
+
|
|
|
|
+ while(var6.hasNext()) {
|
|
|
|
+ msgKey = (String)var6.next();
|
|
|
|
+ if (msgKey.equals(tagKey)) {
|
|
|
|
+ cardEntry.setChildVisible(true, index, new String[]{msgKey});
|
|
|
|
+ } else {
|
|
|
|
+ cardEntry.setChildVisible(false, index, new String[]{msgKey});
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ cardEntry = (CardEntry)this.getControl(entry);
|
|
|
|
+ var6 = IMPORT_MSG_LIST.iterator();
|
|
|
|
+
|
|
|
|
+ while(var6.hasNext()) {
|
|
|
|
+ msgKey = (String)var6.next();
|
|
|
|
+ if (msgKey.equals(tagKey)) {
|
|
|
|
+ cardEntry.setChildVisible(true, index, new String[]{msgKey});
|
|
|
|
+ } else {
|
|
|
|
+ cardEntry.setChildVisible(false, index, new String[]{msgKey});
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void deleteInvoiceRow(String eventArgs) {
|
|
|
|
+ JSONObject json = JSON.parseObject(eventArgs);
|
|
|
|
+ String tableId = json.getString("tableId");
|
|
|
|
+ new JSONArray();
|
|
|
|
+ JSONArray array = json.getJSONArray("rows");
|
|
|
|
+ if (CollectionUtils.isEmpty(array)) {
|
|
|
|
+ this.getView().showTipNotification("请先选择需要删除的发票", 2000);
|
|
|
|
+ } else {
|
|
|
|
+ this.updateInvoiceCache(array);
|
|
|
|
+ this.deleteCardInvoiceRow(tableId, array);
|
|
|
|
+ this.showFlex();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void clearInvoiceTable(String eventArgs) {
|
|
|
|
+ JSONObject json = JSON.parseObject(eventArgs);
|
|
|
|
+ String tableId = json.getString("tableId");
|
|
|
|
+ String tableType = tableId.indexOf("error") >= 0 ? "error" : "import";
|
|
|
|
+ JSONObject dataJson = FpzsMainService.getInvoiceDataCache(this.getView().getPageId());
|
|
|
|
+ JSONArray invoiceVerifyData2 = new JSONArray();
|
|
|
|
+ if (dataJson != null) {
|
|
|
|
+ Iterator<Map.Entry<String, Object>> iterator = dataJson.entrySet().iterator();
|
|
|
|
+
|
|
|
|
+ while(iterator.hasNext()) {
|
|
|
|
+ Map.Entry<String, Object> entry = (Map.Entry)iterator.next();
|
|
|
|
+ String key = (String)entry.getKey();
|
|
|
|
+ JSONObject obj = dataJson.getJSONObject(key);
|
|
|
|
+ Boolean filterFlag = FpzsMainService.isFilter(obj);
|
|
|
|
+ String serialNo = obj.getString("serialNo");
|
|
|
|
+ if ("error".equals(tableType) && filterFlag) {
|
|
|
|
+ invoiceVerifyData2.add(obj);
|
|
|
|
+ iterator.remove();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ("import".equals(tableType) && !filterFlag) {
|
|
|
|
+ invoiceVerifyData2.add(obj);
|
|
|
|
+ iterator.remove();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.saveInvoiceDataCache(dataJson.toJSONString());
|
|
|
|
+ this.saveVerifyResult(invoiceVerifyData2);
|
|
|
|
+ this.showFlex();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void showInvoiceEdit(String serialNo) {
|
|
|
|
+ FormShowParameter param = new FormShowParameter();
|
|
|
|
+ param.setCaption("发票预览");
|
|
|
|
+ Map<String, Object> customParams = new HashMap(8);
|
|
|
|
+ JSONObject cacheJson = FpzsMainService.getInvoiceDataCache(this.getView().getPageId());
|
|
|
|
+ JSONObject invoiceJson = cacheJson.getJSONObject(serialNo);
|
|
|
|
+ if (ObjectUtils.isEmpty(invoiceJson)) {
|
|
|
|
+ Map<String, DynamicObject> mainDetailMap = VerifyUtil.queryInvoiceDynamicObjectBySerialNo(serialNo);
|
|
|
|
+ DynamicObject detail = (DynamicObject)mainDetailMap.get("detail");
|
|
|
|
+ invoiceJson = JSON.parseObject(JSON.toJSONString(detail));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ObjectUtils.isEmpty(invoiceJson)) {
|
|
|
|
+ this.getView().showTipNotification("页面数据已过期,请重新采集!", 5000);
|
|
|
|
+ } else {
|
|
|
|
+ this.setInvoiceFiled(invoiceJson);
|
|
|
|
+ int invoiceIndex = 0;
|
|
|
|
+ customParams.put("invoice", invoiceJson);
|
|
|
|
+ customParams.put("row", Integer.valueOf(invoiceIndex));
|
|
|
|
+ if (FpzsMainService.canEdit(invoiceJson)) {
|
|
|
|
+ customParams.put("editAllow", Boolean.TRUE);
|
|
|
|
+ param.setCaption("发票编辑");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String pageId = this.getView().getPageId();
|
|
|
|
+ JSONObject businessParam = FpzsMainService.getBusinessParam(pageId, CollectTypeEnum.PC_UPLOAD.getCode());
|
|
|
|
+ invoiceJson.put("org_id", businessParam.getString("org_id"));
|
|
|
|
+ param.setCustomParams(customParams);
|
|
|
|
+ param.getOpenStyle().setShowType(ShowType.Modal);
|
|
|
|
+ param.setFormId("rim_inv_collect_edit");
|
|
|
|
+ CloseCallBack closeCallBack = new CloseCallBack(this, "rim_inv_collect_edit");
|
|
|
|
+ param.setCloseCallBack(closeCallBack);
|
|
|
|
+ this.getView().showForm(param);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void showAttachUpload() {
|
|
|
|
+ FormShowParameter showParameter = new FormShowParameter();
|
|
|
|
+ showParameter.setShowTitle(true);
|
|
|
|
+ showParameter.setFormId("rim_attach_upload");
|
|
|
|
+ showParameter.getOpenStyle().setShowType(ShowType.Modal);
|
|
|
|
+ CloseCallBack closeCallBack = new CloseCallBack(this, "rim_attach_upload");
|
|
|
|
+ showParameter.setCloseCallBack(closeCallBack);
|
|
|
|
+ this.getView().showForm(showParameter);
|
|
|
|
+ }
|
|
|
|
+ private DynamicObject newAttachDynamicObj() {
|
|
|
|
+ Long userId = Long.valueOf(RequestContext.get().getUserId());
|
|
|
|
+ Map<String, Object> customParam = FpzsMainService.getCustomParam(this);
|
|
|
|
+ DynamicObject attachObject = BusinessDataServiceHelper.newDynamicObject("rim_attach");
|
|
|
|
+ attachObject.set("create_time", new Date());
|
|
|
|
+ attachObject.set("update_time", new Date());
|
|
|
|
+ attachObject.set("user", userId);
|
|
|
|
+ attachObject.set("rim_user", customParam.get("rim_user"));
|
|
|
|
+ String attachNo = UUID.randomUUID();
|
|
|
|
+ attachObject.set("attach_no", attachNo);
|
|
|
|
+ attachObject.set("attach_category", AttachConstant.ATTACH_OTHER_CATEGORY_ID);
|
|
|
|
+ return attachObject;
|
|
|
|
+ }
|
|
|
|
+ private String getAttachIconUrl(String attachUrl) {
|
|
|
|
+ InputStream fileInputStream = null;
|
|
|
|
+ String iconImage = "";
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ fileInputStream = FileServiceFactory.getAttachmentFileService().getInputStream(attachUrl);
|
|
|
|
+ byte[] streamByte = FileUtils.getByte(fileInputStream);
|
|
|
|
+ iconImage = FileConvertUtils.pdf2image(streamByte, "jpg");
|
|
|
|
+ } catch (Exception var33) {
|
|
|
|
+ logger.error("pdf附件生成快照信息错误,使用本地icon", var33);
|
|
|
|
+ } finally {
|
|
|
|
+ if (fileInputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ fileInputStream.close();
|
|
|
|
+ } catch (IOException var29) {
|
|
|
|
+ logger.error("关闭附件流失败", var29);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isEmpty(iconImage)) {
|
|
|
|
+ FileService service = FileServiceFactory.getAttachmentFileService();
|
|
|
|
+ boolean fileExist = service.exists("/rim/attach/fpy_icon_pdf.png");
|
|
|
|
+ if (fileExist) {
|
|
|
|
+ iconImage = "/rim/attach/fpy_icon_pdf.png";
|
|
|
|
+ } else {
|
|
|
|
+ InputStream in = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
|
|
|
+ in = classLoader.getResourceAsStream("templates".concat("/").concat("fpy_icon_pdf.png"));
|
|
|
|
+ String fileName = "fpy_icon_pdf.png";
|
|
|
|
+ iconImage = FileUploadUtils.upload("/rim/attach/" + fileName, fileName, in);
|
|
|
|
+ } catch (Exception var31) {
|
|
|
|
+ logger.error("上传本地附件icon失败", var31);
|
|
|
|
+ } finally {
|
|
|
|
+ try {
|
|
|
|
+ if (in != null) {
|
|
|
|
+ in.close();
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException var30) {
|
|
|
|
+ logger.error("关闭附件pdf_icon错误", var30);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return iconImage;
|
|
|
|
+ }
|
|
|
|
+ private void saveAttachRelation(String serialNo, String attachPkValue) {
|
|
|
|
+ if (!StringUtils.isEmpty(serialNo)) {
|
|
|
|
+ QFilter attachRelationFilter = (new QFilter("attach_id", "=", attachPkValue)).and("relation_type", "=", "3").and("relation_id", "=", serialNo);
|
|
|
|
+ DynamicObjectCollection relations = QueryServiceHelper.query("rim_attach_relation", "id", attachRelationFilter.toArray());
|
|
|
|
+ if (relations == null || relations.size() == 0) {
|
|
|
|
+ DynamicObject relationObject = BusinessDataServiceHelper.newDynamicObject("rim_attach_relation");
|
|
|
|
+ relationObject.set("attach_id", attachPkValue);
|
|
|
|
+ relationObject.set("relation_type", "3");
|
|
|
|
+ relationObject.set("relation_id", serialNo);
|
|
|
|
+ SaveServiceHelper.save(new DynamicObject[]{relationObject});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void updateInvoiceCache(JSONArray array) {
|
|
|
|
+ JSONObject dataJson = FpzsMainService.getInvoiceDataCache(this.getView().getPageId());
|
|
|
|
+ JSONArray invoiceVerifyData = new JSONArray();
|
|
|
|
+ if (dataJson != null) {
|
|
|
|
+ for(int i = 0; i < array.size(); ++i) {
|
|
|
|
+ invoiceVerifyData.add(dataJson.getJSONObject(array.getString(i)));
|
|
|
|
+ dataJson.remove(array.getString(i));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!dataJson.isEmpty()) {
|
|
|
|
+ String pageId = this.getView().getPageId();
|
|
|
|
+ Map<String, Object> customParam = FpzsMainService.getCustomParam(this);
|
|
|
|
+ VerifyService.verifySequenceNo(customParam, dataJson);
|
|
|
|
+ FpzsMainService.updateInvoiceGrid(this, dataJson);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.saveInvoiceDataCache(dataJson.toJSONString());
|
|
|
|
+ this.saveVerifyResult(invoiceVerifyData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void deleteCardInvoiceRow(String tableId, JSONArray array) {
|
|
|
|
+ if (array == null || array.size() == 0) {
|
|
|
|
+ array = this.getSelectedCardInvoice(tableId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DynamicObjectCollection invoiceCardDatas = this.getModel().getEntryEntity("invoice_card_entry");
|
|
|
|
+ DynamicObjectCollection errorInvoiceCardDatas = this.getModel().getEntryEntity("error_invoice_card_entry");
|
|
|
|
+ ArrayList errorIndexList;
|
|
|
|
+ int i;
|
|
|
|
+ Iterator var7;
|
|
|
|
+ DynamicObject errorInvoiceCardData;
|
|
|
|
+ int[] errorIndex;
|
|
|
|
+ int m;
|
|
|
|
+ if (!CollectionUtils.isEmpty(invoiceCardDatas) && StringUtils.isNotEmpty(tableId) && tableId.endsWith("import")) {
|
|
|
|
+ errorIndexList = new ArrayList(invoiceCardDatas.size());
|
|
|
|
+ i = 0;
|
|
|
|
+ var7 = invoiceCardDatas.iterator();
|
|
|
|
+
|
|
|
|
+ while(var7.hasNext()) {
|
|
|
|
+ errorInvoiceCardData = (DynamicObject)var7.next();
|
|
|
|
+ if (errorInvoiceCardData != null) {
|
|
|
|
+ String importSerialNo = errorInvoiceCardData.getString("import_serial_no");
|
|
|
|
+ if (array.size() > 0 && array.contains(importSerialNo)) {
|
|
|
|
+ errorIndexList.add(i);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ++i;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(errorIndexList)) {
|
|
|
|
+ errorIndex = new int[errorIndexList.size()];
|
|
|
|
+
|
|
|
|
+ for(m = 0; m < errorIndex.length; ++m) {
|
|
|
|
+ errorIndex[m] = (Integer)errorIndexList.get(m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.getView().getModel().deleteEntryRows("invoice_card_entry", errorIndex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(errorInvoiceCardDatas) && StringUtils.isNotEmpty(tableId) && tableId.endsWith("error")) {
|
|
|
|
+ errorIndexList = new ArrayList(errorInvoiceCardDatas.size());
|
|
|
|
+ i = 0;
|
|
|
|
+ var7 = errorInvoiceCardDatas.iterator();
|
|
|
|
+
|
|
|
|
+ while(var7.hasNext()) {
|
|
|
|
+ errorInvoiceCardData = (DynamicObject)var7.next();
|
|
|
|
+ if (errorInvoiceCardData != null) {
|
|
|
|
+ if (array.contains(errorInvoiceCardData.getString("error_serial_no"))) {
|
|
|
|
+ errorIndexList.add(i);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ++i;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(errorIndexList)) {
|
|
|
|
+ errorIndex = new int[errorIndexList.size()];
|
|
|
|
+
|
|
|
|
+ for(m = 0; m < errorIndex.length; ++m) {
|
|
|
|
+ errorIndex[m] = (Integer)errorIndexList.get(m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.getView().getModel().deleteEntryRows("error_invoice_card_entry", errorIndex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void saveInvoiceDataCache(String cache) {
|
|
|
|
+ FpzsMainService.setInvoiceDataCache(this.getView().getPageId(), cache);
|
|
|
|
+ }
|
|
|
|
+ private void setInvoiceFiled(JSONObject invoiceJson) {
|
|
|
|
+ String serialNo = invoiceJson.getString("serialNo");
|
|
|
|
+ if (!StringUtils.isBlank(serialNo)) {
|
|
|
|
+ QFilter qFilter = new QFilter("serial_no", "=", serialNo);
|
|
|
|
+ InvoiceQueryService invoiceQueryService = new InvoiceQueryService();
|
|
|
|
+ DynamicObjectCollection collection = invoiceQueryService.findByFilter("collect_type", qFilter);
|
|
|
|
+ if (!CollectionUtils.isEmpty(collection)) {
|
|
|
|
+ invoiceJson.put("collect_type", ((DynamicObject)collection.get(0)).getString("collect_type"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private JSONArray getSelectedCardInvoice(String tableId) {
|
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
|
+ CardEntry errorCardEntry;
|
|
|
|
+ int[] errorSelectedRows;
|
|
|
|
+ int i;
|
|
|
|
+ String serialNo;
|
|
|
|
+ if (StringUtils.isNotEmpty(tableId) && tableId.endsWith("import")) {
|
|
|
|
+ errorCardEntry = (CardEntry)this.getControl("invoice_card_entry");
|
|
|
|
+ errorSelectedRows = errorCardEntry.getSelectRows();
|
|
|
|
+ if (errorSelectedRows == null || errorSelectedRows.length == 0) {
|
|
|
|
+ this.getView().showTipNotification("请先选择需要删除的发票", 2000);
|
|
|
|
+ return array;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(i = 0; i < errorSelectedRows.length; ++i) {
|
|
|
|
+ serialNo = this.getModel().getValue("import_serial_no", errorSelectedRows[i]).toString();
|
|
|
|
+ array.add(serialNo);
|
|
|
|
+ }
|
|
|
|
+ } else if (StringUtils.isNotEmpty(tableId) && tableId.endsWith("error")) {
|
|
|
|
+ errorCardEntry = (CardEntry)this.getControl("error_invoice_card_entry");
|
|
|
|
+ errorSelectedRows = errorCardEntry.getSelectRows();
|
|
|
|
+ if (errorSelectedRows == null || errorSelectedRows.length == 0) {
|
|
|
|
+ this.getView().showTipNotification("请先选择需要删除的发票", 2000);
|
|
|
|
+ return array;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(i = 0; i < errorSelectedRows.length; ++i) {
|
|
|
|
+ serialNo = this.getModel().getValue("error_serial_no", errorSelectedRows[i]).toString();
|
|
|
|
+ array.add(serialNo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return array;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|