|
@@ -0,0 +1,314 @@
|
|
|
|
+package fi.ar.formplugin;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import kd.bos.dataentity.serialization.SerializationUtils;
|
|
|
|
+import kd.bos.dataentity.utils.ObjectUtils;
|
|
|
|
+import kd.bos.dataentity.utils.StringUtils;
|
|
|
|
+import kd.bos.entity.filter.FilterValue;
|
|
|
|
+import kd.bos.report.plugin.*;
|
|
|
|
+import kd.bos.context.*;
|
|
|
|
+import kd.fi.arapcommon.report.acctagev2.AcctageParam;
|
|
|
|
+import org.apache.commons.lang.*;
|
|
|
|
+import kd.bos.dataentity.resource.*;
|
|
|
|
+import kd.bos.entity.*;
|
|
|
|
+import kd.bos.form.field.*;
|
|
|
|
+import kd.bos.form.control.*;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.*;
|
|
|
|
+import kd.bplat.scmc.report.conf.*;
|
|
|
|
+import kd.bos.entity.datamodel.events.*;
|
|
|
|
+import kd.bplat.scmc.report.core.*;
|
|
|
|
+import kd.bos.dataentity.utils.*;
|
|
|
|
+import kd.bos.dataentity.entity.*;
|
|
|
|
+import kd.fi.arapcommon.report.acctage.*;
|
|
|
|
+import kd.bos.dataentity.serialization.*;
|
|
|
|
+import kd.bos.orm.query.*;
|
|
|
|
+import kd.bos.servicehelper.*;
|
|
|
|
+import com.alibaba.fastjson.*;
|
|
|
|
+import kd.fi.arapcommon.helper.*;
|
|
|
|
+import kd.fi.arapcommon.report.*;
|
|
|
|
+import kd.fi.arapcommon.util.*;
|
|
|
|
+import kd.bos.servicehelper.basedata.*;
|
|
|
|
+import kd.bos.bill.*;
|
|
|
|
+import kd.bos.report.*;
|
|
|
|
+import kd.bos.entity.report.*;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.function.*;
|
|
|
|
+import kd.bos.dataentity.metadata.*;
|
|
|
|
+import kd.bos.entity.property.*;
|
|
|
|
+import kd.bos.entity.filter.*;
|
|
|
|
+import kd.bos.report.filter.*;
|
|
|
|
+import kd.bos.dataentity.metadata.clr.*;
|
|
|
|
+import kd.bos.form.container.*;
|
|
|
|
+import kd.bos.form.*;
|
|
|
|
+import kd.bos.list.*;
|
|
|
|
+import kd.bos.form.events.*;
|
|
|
|
+import kd.bos.entity.datamodel.*;
|
|
|
|
+import kd.bos.form.field.events.*;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author cjz
|
|
|
|
+ * @date 2024/10/30 17:34
|
|
|
|
+ * @description:标准报表改造
|
|
|
|
+ */
|
|
|
|
+public class AcctageForm extends AbstractReportFormPlugin implements HyperLinkClickListener
|
|
|
|
+{
|
|
|
|
+ private List<Long> orgIds;
|
|
|
|
+ private ReportConf confCache;
|
|
|
|
+
|
|
|
|
+ public AcctageForm() {
|
|
|
|
+ this.orgIds = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void registerListener(final EventObject e) {
|
|
|
|
+ super.registerListener(e);
|
|
|
|
+ final ReportList list = (ReportList)this.getControl("reportlistap");
|
|
|
|
+ list.addHyperClickListener((HyperLinkClickListener)this);
|
|
|
|
+ final BasedataEdit orgCtrl = (BasedataEdit)this.getControl("orgs");
|
|
|
|
+ orgCtrl.addBeforeF7SelectListener(beforeF7SelectEvent -> {
|
|
|
|
+ final ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
|
|
|
|
+ showParameter.getListFilterParameter().setFilter(new QFilter("id", "in", (Object)this.getOrgIds()));
|
|
|
|
+ });
|
|
|
|
+ final BasedataEdit billTypeEdit = (BasedataEdit)this.getControl("billtypes");
|
|
|
|
+ billTypeEdit.addBeforeF7SelectListener(listener -> {
|
|
|
|
+ final ListShowParameter formShowParameter = (ListShowParameter)listener.getFormShowParameter();
|
|
|
|
+ final String billScope = (String)this.getModel().getValue("sourceentity");
|
|
|
|
+ final List<String> billScopes = new LinkedList<String>();
|
|
|
|
+ if ("ALL".equals(billScope)) {
|
|
|
|
+ if (this.isAr()) {
|
|
|
|
+ billScopes.add("ar_finarbill");
|
|
|
|
+ billScopes.add("ar_busbill");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ billScopes.add("ap_finapbill");
|
|
|
|
+ billScopes.add("ap_busbill");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (billScope.contains("fin")) {
|
|
|
|
+ if (this.isAr()) {
|
|
|
|
+ billScopes.add("ar_finarbill");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ billScopes.add("ap_finapbill");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (billScope.contains("bus")) {
|
|
|
|
+ if (this.isAr()) {
|
|
|
|
+ billScopes.add("ar_busbill");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ billScopes.add("ap_busbill");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ formShowParameter.getListFilterParameter().setFilter(new QFilter("billformid", "in", (Object)billScopes));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void initDefaultQueryParam(final ReportQueryParam queryParam) {
|
|
|
|
+ if (EmptyUtils.isEmpty(this.getModel().getValue("orgs"))) {
|
|
|
|
+ this.orgIds = this.getOrgIds();
|
|
|
|
+ if (this.orgIds != null && this.orgIds.size() > 0) {
|
|
|
|
+ long orgId = RequestContext.get().getOrgId();
|
|
|
|
+ if (!this.orgIds.contains(orgId)) {
|
|
|
|
+ orgId = this.orgIds.get(0);
|
|
|
|
+ }
|
|
|
|
+ this.getModel().setValue("orgs", (Object)new Object[] { orgId });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.setCompareDateComboItems();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<Long> getOrgIds() {
|
|
|
|
+ if (this.orgIds == null) {
|
|
|
|
+ final List<DynamicObject> orgs = OrgHelper.getAuthorizedInitializedOrgs(this.getView().getEntityId(), "47150e89000000ac", this.isAr());
|
|
|
|
+ this.orgIds = (List)orgs.stream().map((org) -> {
|
|
|
|
+ return org.getLong("id");
|
|
|
|
+ }).distinct().collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ return this.orgIds;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean isAr() {
|
|
|
|
+ return StringUtils.contains(this.getView().getEntityId(), "ar_");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void setCompareDateComboItems() {
|
|
|
|
+ final String sourceEntity = (String)this.getModel().getValue("sourceentity");
|
|
|
|
+ final List<ComboItem> comboItems = new ArrayList<ComboItem>(64);
|
|
|
|
+ List<ComboItem> combo = new ArrayList<ComboItem>(64);
|
|
|
|
+ if ("ALL".equals(sourceEntity) || "finpaidbill".equals(sourceEntity)) {
|
|
|
|
+ final ComboItem comboItem = new ComboItem(new LocaleString(ResManager.loadKDString("\u6309\u5355\u636e\u65e5\u671f", "AcctageForm_6", "fi-arapcommon", new Object[0])), "bizdate");
|
|
|
|
+ comboItems.add(comboItem);
|
|
|
|
+ this.setStandard(comboItems);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if ("paidbill".equals(sourceEntity)) {
|
|
|
|
+ final ComboItem bizDateItem = new ComboItem(new LocaleString(ResManager.loadKDString("\u6309\u4e1a\u52a1\u65e5\u671f", "AcctageForm_7", "fi-arapcommon", new Object[0])), "bizdate");
|
|
|
|
+ comboItems.add(bizDateItem);
|
|
|
|
+ final String recDate = ResManager.loadKDString("\u6536\u6b3e\u65e5\u671f", "AcctageForm_8", "fi-arapcommon", new Object[0]);
|
|
|
|
+ final String payDate = ResManager.loadKDString("\u4ed8\u6b3e\u65e5\u671f", "AcctageForm_9", "fi-arapcommon", new Object[0]);
|
|
|
|
+ final ComboItem payDateItem = new ComboItem(new LocaleString(ResManager.loadKDString("\u6309%s", "AcctageForm_10", "fi-arapcommon", new Object[] { this.isAr() ? recDate : payDate })), this.isAr() ? "payeedate" : "paydate");
|
|
|
|
+ comboItems.add(payDateItem);
|
|
|
|
+ this.setStandard(comboItems);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ final Set<String> allSourceEntityKeys = this.buildSourceEntityKeys(sourceEntity);
|
|
|
|
+ List<DateTimeProp> datePropIntersection = null;
|
|
|
|
+ for (final String entityKey : allSourceEntityKeys) {
|
|
|
|
+ final List<DateTimeProp> dateProps = EntityMetadataUtils.getDateProps(entityKey);
|
|
|
|
+ if (datePropIntersection == null) {
|
|
|
|
+ datePropIntersection = dateProps;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ final Iterator<DateTimeProp> iterator = datePropIntersection.iterator();
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ final DateTimeProp next = iterator.next();
|
|
|
|
+ boolean contains = false;
|
|
|
|
+ for (final DateTimeProp p : dateProps) {
|
|
|
|
+ if (p.getName().equals(next.getName())) {
|
|
|
|
+ contains = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!contains) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (datePropIntersection != null) {
|
|
|
|
+ for (final DateTimeProp prop : datePropIntersection) {
|
|
|
|
+ final String value = prop.getName();
|
|
|
|
+ if (!StringUtils.contains(value, "createtime") && !StringUtils.contains(value, "modifytime") && !StringUtils.contains(value, "updatetime") && !"auditdate".equals(value) && !"exratedate".equals(value)) {
|
|
|
|
+ if ("premduedate".equals(prop.getName())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ final IDataEntityType parent = prop.getParent();
|
|
|
|
+ final String displayName = prop.getDisplayName().getLocaleValue();
|
|
|
|
+ if (parent instanceof EntryType) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ final ComboItem comboItem2 = new ComboItem(new LocaleString(ResManager.loadKDString("\u6309%s", "AcctageForm_10", "fi-arapcommon", new Object[] { displayName })), value);
|
|
|
|
+ comboItems.add(comboItem2);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if ("ap_finapbill".equals(sourceEntity) || "ar_finarbill".equals(sourceEntity)) {
|
|
|
|
+ final ComboItem comboItem3 = new ComboItem(new LocaleString(ResManager.loadKDString("\u6309\u8ba1\u5212\u884c\u5230\u671f\u65e5", "AcctageForm_0", "fi-arapcommon", new Object[0])), "planduedate");
|
|
|
|
+ comboItems.add(comboItem3);
|
|
|
|
+ this.setStandard(comboItems);
|
|
|
|
+ }
|
|
|
|
+ combo=comboItems.subList(0,2);
|
|
|
|
+ this.setStandard(combo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Set<String> buildSourceEntityKeys(final String sourceEntity) {
|
|
|
|
+ final Set<String> allSourceEntityKeys = new HashSet<String>(4);
|
|
|
|
+ if (sourceEntity.contains("fin")) {
|
|
|
|
+ if (this.isAr()) {
|
|
|
|
+ allSourceEntityKeys.add("ar_finarbill");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ allSourceEntityKeys.add("ap_finapbill");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (sourceEntity.contains("bus")) {
|
|
|
|
+ if (this.isAr()) {
|
|
|
|
+ allSourceEntityKeys.add("ar_busbill");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ allSourceEntityKeys.add("ap_busbill");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ("finpaidbill".equals(sourceEntity) || "paidbill".equals(sourceEntity)) {
|
|
|
|
+ if (this.isAr()) {
|
|
|
|
+ allSourceEntityKeys.add("cas_recbill");
|
|
|
|
+ allSourceEntityKeys.add("ar_receivedbill");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ allSourceEntityKeys.add("cas_paybill");
|
|
|
|
+ allSourceEntityKeys.add("ap_paidbill");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ("ALL".equals(sourceEntity)) {
|
|
|
|
+ if (this.isAr()) {
|
|
|
|
+ allSourceEntityKeys.add("cas_recbill");
|
|
|
|
+ allSourceEntityKeys.add("ar_receivedbill");
|
|
|
|
+ allSourceEntityKeys.add("ar_busbill");
|
|
|
|
+ allSourceEntityKeys.add("ar_finarbill");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ allSourceEntityKeys.add("cas_paybill");
|
|
|
|
+ allSourceEntityKeys.add("ap_paidbill");
|
|
|
|
+ allSourceEntityKeys.add("ap_busbill");
|
|
|
|
+ allSourceEntityKeys.add("ap_finapbill");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return allSourceEntityKeys;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void setStandard(final List<ComboItem> comboItems) {
|
|
|
|
+ final ComboEdit comboEdit = (ComboEdit)this.getControl("standard");
|
|
|
|
+ comboEdit.setComboItems((List)comboItems);
|
|
|
|
+ this.getModel().setValue("standard", (Object)"duedate");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void hyperLinkClick(final HyperLinkClickEvent evt) {
|
|
|
|
+ final String fieldName = evt.getFieldName();
|
|
|
|
+ if ("billno".equals(fieldName)) {
|
|
|
|
+ final ReportList list = (ReportList)this.getControl("reportlistap");
|
|
|
|
+ final DynamicObject rowData = list.getReportModel().getRowData(evt.getRowIndex());
|
|
|
|
+ final BillShowParameter parameter = new BillShowParameter();
|
|
|
|
+ parameter.setFormId(rowData.getString("entitykey"));
|
|
|
|
+ parameter.setPkId((Object)rowData.getLong("id"));
|
|
|
|
+ parameter.setStatus(OperationStatus.VIEW);
|
|
|
|
+ parameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
|
|
|
|
+ parameter.setHasRight(true);
|
|
|
|
+ this.getView().showForm((FormShowParameter)parameter);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ final ReportShowParameter parameter2 = new ReportShowParameter();
|
|
|
|
+ final FormShowParameter reportParameter = this.getView().getFormShowParameter();
|
|
|
|
+ parameter2.setFormId(reportParameter.getFormId());
|
|
|
|
+ parameter2.getOpenStyle().setTargetKey(reportParameter.getOpenStyle().getTargetKey());
|
|
|
|
+ parameter2.getOpenStyle().setShowType(reportParameter.getFormConfig().getShowType());
|
|
|
|
+ final ReportList reportList = (ReportList)evt.getSource();
|
|
|
|
+ final IReportListModel reportModel = reportList.getReportModel();
|
|
|
|
+ final DynamicObject rowData2 = reportModel.getRowData(evt.getRowIndex());
|
|
|
|
+ final Map<String, Object> customParams = this.getCustomParams(rowData2);
|
|
|
|
+ customParams.put("hyperLinkClickLineName", fieldName);
|
|
|
|
+ parameter2.setCustomParams((Map)customParams);
|
|
|
|
+ this.getView().showForm((FormShowParameter)parameter2);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Map<String, Object> getCustomParams(final DynamicObject rowData) {
|
|
|
|
+ final Map<String, Object> customParams = new HashMap<String, Object>(2);
|
|
|
|
+ final Map<String, Object> dimensionData = new HashMap<String, Object>(4);
|
|
|
|
+ customParams.put("isopenbyhyperlink", Boolean.TRUE);
|
|
|
|
+ dimensionData.put("org", rowData.get("org"));
|
|
|
|
+ dimensionData.put("orgs", rowData.get("org"));
|
|
|
|
+ dimensionData.put("asstacttype", rowData.get("asstacttype"));
|
|
|
|
+ dimensionData.put("asstact", rowData.get("asstact"));
|
|
|
|
+ dimensionData.put("currency", rowData.get("currency"));
|
|
|
|
+ final List<String> sysDimensions = new ArrayList<String>(Arrays.asList("org", "asstacttype", "asstact", "currency"));
|
|
|
|
+ final String showKeyCols = (String)this.getModel().getValue("showkeycols");
|
|
|
|
+ final List<String> showKeyColList = Stream.of(showKeyCols.split(",")).filter(EmptyUtils::isNotEmpty).collect(Collectors.toList());
|
|
|
|
+ for (String s : showKeyColList) {
|
|
|
|
+ if (sysDimensions.contains(s)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Object value = rowData.get(s);
|
|
|
|
+ if (value instanceof DynamicObject) {
|
|
|
|
+ s += ".number";
|
|
|
|
+ value = ((DynamicObject)value).getString("number");
|
|
|
|
+ }
|
|
|
|
+ dimensionData.put(s, value);
|
|
|
|
+ }
|
|
|
|
+ customParams.put("rowData", dimensionData);
|
|
|
|
+ return customParams;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|