|
@@ -0,0 +1,1012 @@
|
|
|
+//
|
|
|
+// Source code recreated from a .class file by IntelliJ IDEA
|
|
|
+// (powered by FernFlower decompiler)
|
|
|
+//
|
|
|
+
|
|
|
+package fi.fa.formPlugin;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.EventObject;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.ListIterator;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import fi.fa.opplugin.utils.ChangeDataUtils;
|
|
|
+import kd.bos.algo.DataSet;
|
|
|
+import kd.bos.algo.Row;
|
|
|
+import kd.bos.context.RequestContext;
|
|
|
+import kd.bos.dataentity.entity.CloneUtils;
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.dataentity.entity.LocaleString;
|
|
|
+import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
|
|
+import kd.bos.dataentity.resource.ResManager;
|
|
|
+import kd.bos.dataentity.serialization.SerializationUtils;
|
|
|
+import kd.bos.db.tx.TX;
|
|
|
+import kd.bos.db.tx.TXHandle;
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
+import kd.bos.entity.MainEntityType;
|
|
|
+import kd.bos.entity.cache.AppCache;
|
|
|
+import kd.bos.entity.cache.IAppCache;
|
|
|
+import kd.bos.entity.datamodel.ListSelectedRow;
|
|
|
+import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
|
|
+import kd.bos.entity.datamodel.events.PackageDataEvent;
|
|
|
+import kd.bos.entity.list.column.ColumnDesc;
|
|
|
+import kd.bos.entity.property.MulBasedataProp;
|
|
|
+import kd.bos.entity.validate.BillStatus;
|
|
|
+import kd.bos.exception.KDBizException;
|
|
|
+import kd.bos.filter.CommonFilterColumn;
|
|
|
+import kd.bos.filter.FilterColumn;
|
|
|
+import kd.bos.form.CloseCallBack;
|
|
|
+import kd.bos.form.ConfirmCallBackListener;
|
|
|
+import kd.bos.form.ConfirmTypes;
|
|
|
+import kd.bos.form.FormShowParameter;
|
|
|
+import kd.bos.form.MessageBoxOptions;
|
|
|
+import kd.bos.form.MessageBoxResult;
|
|
|
+import kd.bos.form.ShowFormHelper;
|
|
|
+import kd.bos.form.ShowType;
|
|
|
+import kd.bos.form.control.Control;
|
|
|
+import kd.bos.form.control.events.ItemClickEvent;
|
|
|
+import kd.bos.form.events.BeforeCreateListColumnsArgs;
|
|
|
+import kd.bos.form.events.BeforeCreateListDataProviderArgs;
|
|
|
+import kd.bos.form.events.ClosedCallBackEvent;
|
|
|
+import kd.bos.form.events.FilterContainerInitArgs;
|
|
|
+import kd.bos.form.events.HyperLinkClickArgs;
|
|
|
+import kd.bos.form.events.HyperLinkClickEvent;
|
|
|
+import kd.bos.form.events.MessageBoxClosedEvent;
|
|
|
+import kd.bos.form.events.PreOpenFormEventArgs;
|
|
|
+import kd.bos.form.events.SetFilterEvent;
|
|
|
+import kd.bos.form.field.ComboItem;
|
|
|
+import kd.bos.fs.util.StringUtils;
|
|
|
+import kd.bos.license.api.LicenseCheckResult;
|
|
|
+import kd.bos.list.BillList;
|
|
|
+import kd.bos.list.IListColumn;
|
|
|
+import kd.bos.list.IListView;
|
|
|
+import kd.bos.list.ListShowParameter;
|
|
|
+import kd.bos.list.plugin.AbstractListPlugin;
|
|
|
+import kd.bos.logging.Log;
|
|
|
+import kd.bos.logging.LogFactory;
|
|
|
+import kd.bos.mvc.list.ListDataProvider;
|
|
|
+import kd.bos.orm.datamanager.DataManagerUtils;
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.orm.util.CollectionUtils;
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
+import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
+import kd.bos.servicehelper.license.LicenseServiceHelper;
|
|
|
+import kd.bos.servicehelper.operation.DeleteServiceHelper;
|
|
|
+import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
+import kd.bos.servicehelper.workflow.MessageCenterServiceHelper;
|
|
|
+import kd.bos.url.UrlService;
|
|
|
+import kd.bos.util.JSONUtils;
|
|
|
+import kd.bos.workflow.engine.msg.info.MessageInfo;
|
|
|
+import kd.fi.fa.business.BizStatusEnum;
|
|
|
+import kd.fi.fa.business.utils.FaOperateLogUtil;
|
|
|
+import kd.fi.fa.business.utils.FaUtils;
|
|
|
+import kd.fi.fa.common.util.ContextUtil;
|
|
|
+import kd.fi.fa.common.util.Fa;
|
|
|
+import kd.fi.fa.utils.FaAssetTypeUtils;
|
|
|
+import kd.fi.fa.utils.FaInventoryUtils;
|
|
|
+
|
|
|
+public class FaInventoryTaskListNew extends AbstractListPlugin {
|
|
|
+ private static final Log log = LogFactory.getLog(FaInventoryTaskListNew.class);
|
|
|
+ public static final String ALGOKEY = "kd.fi.fa.formplugin.FaInventoryTaskListNew";
|
|
|
+ private static final int DATA_SIZE = DataManagerUtils.getBatchSize();
|
|
|
+ private static final String ASSIGNINVENTORY = "assigninventory";
|
|
|
+ private Map<Long, Map<String, Set<Long>>> idAndBaseDataMap = new HashMap(16);
|
|
|
+ private Map<String, Map<Long, String>> resultMap = new HashMap(16);
|
|
|
+ private Map<String, Map<String, Object>> baseEntityIdMap = FaInventoryUtils.getBaseEntityIdMap();
|
|
|
+ private Map<String, String> baseNameMap;
|
|
|
+ private Set<String> columnNames;
|
|
|
+ private Map<Long, Map<String, Integer>> map;
|
|
|
+ private Set<String> splitFields;
|
|
|
+
|
|
|
+ public FaInventoryTaskListNew() {
|
|
|
+ this.baseNameMap = new HashMap(this.baseEntityIdMap.size(), 1.0F);
|
|
|
+ this.columnNames = new HashSet(16);
|
|
|
+ this.map = null;
|
|
|
+ this.splitFields = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void preOpenForm(PreOpenFormEventArgs e) {
|
|
|
+ LicenseCheckResult result = LicenseServiceHelper.checkByAppAndBizObj("83bfebc800001aac", "fa_inventscheme_new", Long.valueOf(RequestContext.get().getUserId()));
|
|
|
+ if (!result.getHasLicense()) {
|
|
|
+ boolean isConstellation = LicenseServiceHelper.getModeType() == 3;
|
|
|
+ String version = LicenseServiceHelper.getProductVersion();
|
|
|
+ String msg = ResManager.loadKDString("没有财务+供应链+制造分组固定资产许可,请联系管理员。", "FaInventoryTaskList_0", "fi-fa-formplugin", new Object[0]);
|
|
|
+ if (isConstellation) {
|
|
|
+ switch (version) {
|
|
|
+ case "1.0":
|
|
|
+ case "2.0":
|
|
|
+ case "3.0":
|
|
|
+ msg = ResManager.loadKDString("没有财务会计专业分组许可,请联系管理员。", "FaInventoryTaskList_1", "fi-fa-formplugin", new Object[0]);
|
|
|
+ case "4.0":
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ e.setCancel(true);
|
|
|
+ e.setCancelMessage(msg);
|
|
|
+ } else {
|
|
|
+ super.preOpenForm(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void filterContainerInit(FilterContainerInitArgs args) {
|
|
|
+ super.filterContainerInit(args);
|
|
|
+ this.setDefaultQuerySelect(args);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setFilter(SetFilterEvent e) {
|
|
|
+ Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
|
|
|
+ Object schemeId = customParams.get("schemeId");
|
|
|
+ e.getQFilters().add(new QFilter("status", "!=", "Z"));
|
|
|
+ if (schemeId == null) {
|
|
|
+ e.getQFilters().add(new QFilter("status", "!=", "A"));
|
|
|
+ Long userId = ContextUtil.getUserId();
|
|
|
+ QFilter qfInventory = new QFilter("inventperson", "=", userId);
|
|
|
+ qfInventory.or(new QFilter("inventorychecker.fbasedataid", "=", userId));
|
|
|
+ e.getQFilters().add(qfInventory);
|
|
|
+ this.getView().setVisible(false, new String[]{"inventoryassign"});
|
|
|
+ this.getView().setVisible(false, new String[]{"inventorywithdrawal"});
|
|
|
+ LicenseCheckResult result = LicenseServiceHelper.checkByAppAndBizObj("/OSOW2CPH91+", "fap_apphome", userId);
|
|
|
+ if (result != null && !result.getHasLicense()) {
|
|
|
+ this.getView().setVisible(false, new String[]{"inventorynotice"});
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ e.getQFilters().add(new QFilter("inventsscopeid.inventschemeentry", "=", schemeId));
|
|
|
+ this.getView().setVisible(false, new String[]{"inventorycreaterecord"});
|
|
|
+ this.getView().setVisible(false, new String[]{"inventorynotice"});
|
|
|
+ this.getView().setVisible(false, new String[]{"inventorydelete"});
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<QFilter> filters = new ArrayList(e.getQFilters());
|
|
|
+ String selectFields = Fa.comma(new String[]{"id", "inventschemeid", "splitfieldvalue", Fa.dot(new String[]{"inventsscopeid", "assetunit", "id"}), "status"});
|
|
|
+ DynamicObjectCollection inventoryTasks = QueryServiceHelper.query("fa_inventory_task", selectFields, (QFilter[])filters.toArray(filters.toArray(new QFilter[0])));
|
|
|
+ this.map = FaInventoryUtils.updateProgress(inventoryTasks);
|
|
|
+ this.splitFields = FaInventoryUtils.getSplitFields(inventoryTasks);
|
|
|
+ this.initbaseNameMap(this.splitFields);
|
|
|
+ this.setColumnVisible(this.splitFields);
|
|
|
+ this.setColumnName();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void click(EventObject evt) {
|
|
|
+ Control c = (Control)evt.getSource();
|
|
|
+ String key = c.getKey();
|
|
|
+ if ("name".equalsIgnoreCase(key)) {
|
|
|
+ Object rowPk = ((IListView)this.getView()).getCurrentSelectedRowInfo().getPrimaryKeyValue();
|
|
|
+ this.viewInventoryRecord(rowPk);
|
|
|
+ }
|
|
|
+
|
|
|
+ super.click(evt);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void billListHyperLinkClick(HyperLinkClickArgs args) {
|
|
|
+ if (!FaUtils.isF7(this.getView())) {
|
|
|
+ BillList billList = (BillList)this.getControl("BillListAp");
|
|
|
+ HyperLinkClickEvent hyperClick = args.getHyperLinkClickEvent();
|
|
|
+ if ("inventsscopeid_assetunit_name".equals(hyperClick.getFieldName())) {
|
|
|
+ Object rowPk = billList.getCurrentSelectedRowInfo().getPrimaryKeyValue();
|
|
|
+ args.setCancel(true);
|
|
|
+ this.viewInventoryRecord(rowPk);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void viewInventoryRecord(Object rowPk) {
|
|
|
+ String selectFields = "inventschemeid, inventsscopeid.assetunit";
|
|
|
+ QFilter[] filters = new QFilter[]{new QFilter("id", "=", rowPk)};
|
|
|
+ DynamicObject inventTask = QueryServiceHelper.queryOne("fa_inventory_task", selectFields, filters);
|
|
|
+ ListShowParameter parameter = new ListShowParameter();
|
|
|
+ parameter.setFormId("bos_list");
|
|
|
+ parameter.setCaption(ResManager.loadKDString("盘点记录", "FaInventoryTaskList_2", "fi-fa-formplugin", new Object[0]));
|
|
|
+ parameter.setCustomParam("inventorytaskid", rowPk);
|
|
|
+ parameter.setCustomParam("inventschemaid", String.valueOf(inventTask.getLong("inventschemeid")));
|
|
|
+ parameter.setCustomParam("inventassetunitid", String.valueOf(inventTask.getLong("inventsscopeid.assetunit")));
|
|
|
+ Object schemeId = this.getView().getFormShowParameter().getCustomParam("schemeId");
|
|
|
+ parameter.setCustomParam("showAuditBar", schemeId == null);
|
|
|
+ parameter.setBillFormId("fa_inventory_record");
|
|
|
+ parameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
|
|
|
+ this.getView().showForm(parameter);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {
|
|
|
+ super.beforeCreateListDataProvider(args);
|
|
|
+ args.setListDataProvider(new FaInventoryTaskListProvide());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void packageData(PackageDataEvent e) {
|
|
|
+ if (e.getSource() instanceof ColumnDesc) {
|
|
|
+ ColumnDesc columnDesc = (ColumnDesc)e.getSource();
|
|
|
+ String columnName = columnDesc.getKey();
|
|
|
+ long rowId = e.getRowData().getLong("id");
|
|
|
+ if (this.baseNameMap.containsKey(columnName)) {
|
|
|
+ Map<String, Set<Long>> baseDataMap = (Map)this.idAndBaseDataMap.get(rowId);
|
|
|
+ if (baseDataMap.size() == 0 || null == baseDataMap.get(this.baseNameMap.get(columnName)) || ((Set)baseDataMap.get(this.baseNameMap.get(columnName))).size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Long> ids = (Set)baseDataMap.get(this.baseNameMap.get(columnName));
|
|
|
+ List<String> names = new ArrayList(ids.size());
|
|
|
+ Map<Long, String> idAndNamesMap = (Map)this.resultMap.get(this.baseNameMap.get(columnName));
|
|
|
+ Iterator var10 = ids.iterator();
|
|
|
+
|
|
|
+ while(var10.hasNext()) {
|
|
|
+ Long id = (Long)var10.next();
|
|
|
+ names.add(idAndNamesMap.get(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ e.setFormatValue(FaInventoryUtils.getAllNamesString(names));
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("inventprogress".equals(columnName) && !this.map.isEmpty() && this.map.get(rowId) != null) {
|
|
|
+ e.setFormatValue(((Map)this.map.get(rowId)).get("inventRate"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("auditprogress".equals(columnName) && !this.map.isEmpty() && this.map.get(rowId) != null) {
|
|
|
+ e.setFormatValue(((Map)this.map.get(rowId)).get("auditRate"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ super.packageData(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void itemClick(ItemClickEvent evt) {
|
|
|
+ super.itemClick(evt);
|
|
|
+ String key = evt.getItemKey();
|
|
|
+ IListView view = (IListView)this.getView();
|
|
|
+ String opMsg = ResManager.loadKDString("成功", "FaInventoryTaskList_3", "fi-fa-formplugin", new Object[0]);
|
|
|
+ ListSelectedRowCollection selectedRows = view.getSelectedRows();
|
|
|
+ if (selectedRows.size() < 1 && !key.equals("tblrefresh") && !key.equals("tblclose")) {
|
|
|
+ this.getView().showTipNotification(ResManager.loadKDString("请选择一行操作。", "FaInventoryTaskList_4", "fi-fa-formplugin", new Object[0]));
|
|
|
+ } else {
|
|
|
+ int rowNum;
|
|
|
+ Iterator var8;
|
|
|
+ ListSelectedRow selectedRow;
|
|
|
+ DynamicObject inventoryTask;
|
|
|
+ String assetUnitName;
|
|
|
+ if ("inventorynotice".equals(key)) {
|
|
|
+ rowNum = this.isSchemeClose(selectedRows);
|
|
|
+ if (rowNum != -1) {
|
|
|
+ this.getView().showTipNotification(String.format(ResManager.loadKDString("任务第%s行:盘点方案已关闭,不能进行盘点通知。", "FaInventoryTaskList_5", "fi-fa-formplugin", new Object[0]), rowNum));
|
|
|
+ } else {
|
|
|
+ List<Long> inventoryTaskPks = new ArrayList();
|
|
|
+ var8 = selectedRows.iterator();
|
|
|
+
|
|
|
+ while(var8.hasNext()) {
|
|
|
+ selectedRow = (ListSelectedRow)var8.next();
|
|
|
+ inventoryTask = BusinessDataServiceHelper.loadSingle(String.valueOf(selectedRow), "fa_inventory_task");
|
|
|
+ assetUnitName = (String)inventoryTask.get("status");
|
|
|
+ if (!BillStatus.C.toString().equals(assetUnitName)) {
|
|
|
+ throw new KDBizException(ResManager.loadKDString("请先生成盘点记录。", "FaInventoryTaskList_6", "fi-fa-formplugin", new Object[0]));
|
|
|
+ }
|
|
|
+
|
|
|
+ inventoryTaskPks.add((Long)selectedRow.getPrimaryKeyValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ this.getPageCache().put("inventoryTaskPks", JSONUtils.toString(inventoryTaskPks));
|
|
|
+ } catch (IOException var31) {
|
|
|
+ throw new KDBizException(ResManager.loadKDString("盘点通知有误", "FaInventoryTaskList_7", "fi-fa-formplugin", new Object[0]));
|
|
|
+ }
|
|
|
+
|
|
|
+ FormShowParameter para = new FormShowParameter();
|
|
|
+ para.setFormId("fa_countingreport_message");
|
|
|
+ para.getOpenStyle().setShowType(ShowType.Modal);
|
|
|
+ para.setCloseCallBack(new CloseCallBack(this, "getmessage"));
|
|
|
+ this.getView().showForm(para);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ StringBuilder notRightStatus;
|
|
|
+ String unitName;
|
|
|
+ long assetUnitId;
|
|
|
+ if ("inventoryassign".equals(key)) {
|
|
|
+ rowNum = this.isSchemeClose(selectedRows);
|
|
|
+ if (rowNum != -1) {
|
|
|
+ this.getView().showTipNotification(String.format(ResManager.loadKDString("任务第%s行:盘点方案已关闭,不能下达任务。", "FaInventoryTaskList_8", "fi-fa-formplugin", new Object[0]), rowNum));
|
|
|
+ } else {
|
|
|
+ notRightStatus = new StringBuilder();
|
|
|
+ var8 = selectedRows.iterator();
|
|
|
+
|
|
|
+ while(var8.hasNext()) {
|
|
|
+ selectedRow = (ListSelectedRow)var8.next();
|
|
|
+ inventoryTask = BusinessDataServiceHelper.loadSingle(String.valueOf(selectedRow), "fa_inventory_task");
|
|
|
+ assetUnitName = inventoryTask.getDynamicObject("inventsscopeid").getDynamicObject("assetunit").getString("name");
|
|
|
+ assetUnitId = inventoryTask.getDynamicObject("inventsscopeid").getDynamicObject("assetunit").getLong("id");
|
|
|
+ unitName = inventoryTask.getString("status");
|
|
|
+ if (!BillStatus.A.toString().equals(unitName)) {
|
|
|
+ notRightStatus.append(assetUnitName).append(' ');
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", assetUnitId, ResManager.loadKDString("下达任务", "FaInventoryTaskList_9", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%s下达失败,任务状态不是未下达。", "FaInventoryTaskList_10", "fi-fa-formplugin", new Object[0]), assetUnitName));
|
|
|
+ } else {
|
|
|
+ inventoryTask.set("status", BillStatus.B.toString());
|
|
|
+ SaveServiceHelper.save(inventoryTask.getDataEntityType(), new DynamicObject[]{inventoryTask});
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", assetUnitId, ResManager.loadKDString("下达任务", "FaInventoryTaskList_9", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%s下达任务成功。", "FaInventoryTaskList_11", "fi-fa-formplugin", new Object[0]), assetUnitName));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (notRightStatus.length() > 0) {
|
|
|
+ opMsg = String.format(ResManager.loadKDString("%s下达失败,任务状态不是未下达。", "FaInventoryTaskList_10", "fi-fa-formplugin", new Object[0]), notRightStatus);
|
|
|
+ this.getView().showTipNotification(opMsg);
|
|
|
+ } else {
|
|
|
+ opMsg = ResManager.loadKDString("任务下达成功。", "FaInventoryTaskList_12", "fi-fa-formplugin", new Object[0]);
|
|
|
+ this.getView().showSuccessNotification(opMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getView().invokeOperation("refresh");
|
|
|
+ }
|
|
|
+ } else if ("inventorywithdrawal".equals(key)) {
|
|
|
+ rowNum = this.isSchemeClose(selectedRows);
|
|
|
+ if (rowNum != -1) {
|
|
|
+ this.getView().showTipNotification(String.format(ResManager.loadKDString("任务第%s行:盘点方案已关闭,不能撤销任务。", "FaInventoryTaskList_13", "fi-fa-formplugin", new Object[0]), rowNum));
|
|
|
+ } else {
|
|
|
+ notRightStatus = new StringBuilder();
|
|
|
+ var8 = selectedRows.iterator();
|
|
|
+
|
|
|
+ while(var8.hasNext()) {
|
|
|
+ selectedRow = (ListSelectedRow)var8.next();
|
|
|
+ inventoryTask = BusinessDataServiceHelper.loadSingle(String.valueOf(selectedRow), "fa_inventory_task");
|
|
|
+ assetUnitName = inventoryTask.getDynamicObject("inventsscopeid").getDynamicObject("assetunit").getString("name");
|
|
|
+ assetUnitId = inventoryTask.getDynamicObject("inventsscopeid").getDynamicObject("assetunit").getLong("id");
|
|
|
+ unitName = inventoryTask.getString("status");
|
|
|
+ if (!BillStatus.B.toString().equals(unitName)) {
|
|
|
+ notRightStatus.append(assetUnitName).append(' ');
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", assetUnitId, ResManager.loadKDString("撤销任务", "FaInventoryTaskList_14", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%s撤销失败,任务状态不是已下达。", "FaInventoryTaskList_15", "fi-fa-formplugin", new Object[0]), assetUnitName));
|
|
|
+ } else {
|
|
|
+ inventoryTask.set("status", "A");
|
|
|
+ inventoryTask.set("inventorychecker", (Object)null);
|
|
|
+ SaveServiceHelper.save(inventoryTask.getDataEntityType(), new DynamicObject[]{inventoryTask});
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", assetUnitId, ResManager.loadKDString("撤销任务", "FaInventoryTaskList_14", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%s撤销任务成功。", "FaInventoryTaskList_16", "fi-fa-formplugin", new Object[0]), assetUnitName));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (notRightStatus.length() > 0) {
|
|
|
+ opMsg = String.format(ResManager.loadKDString("%s撤销失败,任务状态不是已下达。", "FaInventoryTaskList_15", "fi-fa-formplugin", new Object[0]), notRightStatus);
|
|
|
+ this.getView().showTipNotification(opMsg);
|
|
|
+ } else {
|
|
|
+ opMsg = ResManager.loadKDString("任务撤销成功。", "FaInventoryTaskList_17", "fi-fa-formplugin", new Object[0]);
|
|
|
+ this.getView().showSuccessNotification(opMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getView().invokeOperation("refresh");
|
|
|
+ }
|
|
|
+ } else if (!"inventorycreaterecord".equals(key)) {
|
|
|
+ if ("inventorydelete".equals(key)) {
|
|
|
+ rowNum = this.isSchemeClose(selectedRows);
|
|
|
+ if (rowNum != -1) {
|
|
|
+ this.getView().showTipNotification(String.format(ResManager.loadKDString("任务第%s行:盘点方案已关闭,不能清除盘点记录。", "FaInventoryTaskList_25", "fi-fa-formplugin", new Object[0]), rowNum));
|
|
|
+ } else {
|
|
|
+ this.getView().showConfirm(ResManager.loadKDString("此操作将清除任务下所有的盘点记录,是否继续。", "FaInventoryTaskList_26", "fi-fa-formplugin", new Object[0]), "", MessageBoxOptions.YesNo, ConfirmTypes.Delete, new ConfirmCallBackListener("inventorydelete", this));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("assigninventory".equals(key)) {
|
|
|
+ rowNum = this.isSchemeClose(selectedRows);
|
|
|
+ if (rowNum != -1) {
|
|
|
+ this.getView().showTipNotification(String.format(ResManager.loadKDString("任务第%s行:盘点方案已关闭,不能指定盘点人。", "FaInventoryTaskList_27", "fi-fa-formplugin", new Object[0]), rowNum));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.assignInventory();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ rowNum = this.isSchemeClose(selectedRows);
|
|
|
+ if (rowNum != -1) {
|
|
|
+ this.getView().showTipNotification(String.format(ResManager.loadKDString("任务第%s行:盘点方案已关闭,不能生成盘点记录。", "FaInventoryTaskList_18", "fi-fa-formplugin", new Object[0]), rowNum));
|
|
|
+ } else {
|
|
|
+ notRightStatus = new StringBuilder();
|
|
|
+ var8 = selectedRows.iterator();
|
|
|
+
|
|
|
+ while(true) {
|
|
|
+ while(var8.hasNext()) {
|
|
|
+ selectedRow = (ListSelectedRow)var8.next();
|
|
|
+ inventoryTask = BusinessDataServiceHelper.loadSingle(selectedRow.getPrimaryKeyValue(), "fa_inventory_task");
|
|
|
+ DynamicObject inventorySope = inventoryTask.getDynamicObject("inventsscopeid");
|
|
|
+ if (inventorySope == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String status = inventoryTask.getString("status");
|
|
|
+ assetUnitId = (long) inventorySope.get("assetunit_id");
|
|
|
+ unitName = inventoryTask.getDynamicObject("inventsscopeid").getDynamicObject("assetunit").getString("name");
|
|
|
+ if (!BillStatus.B.toString().equals(status)) {
|
|
|
+ notRightStatus.append(unitName).append(' ');
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", (Long)assetUnitId, ResManager.loadKDString("生成盘点记录", "FaInventoryTaskList_19", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%s生成失败,任务状态不是已下达。", "FaInventoryTaskList_20", "fi-fa-formplugin", new Object[0]), unitName));
|
|
|
+ } else {
|
|
|
+ MainEntityType inventoryRecordType = EntityMetadataCache.getDataEntityType("fa_inventory_record");
|
|
|
+ Date finaccountdate = inventorySope.getDate("finaccountdate");
|
|
|
+ QFilter timeLimitCond = new QFilter("realaccountdate", "<=", finaccountdate);
|
|
|
+ QFilter billstatusCond = new QFilter("billstatus", "=", BillStatus.C.toString());
|
|
|
+ QFilter assetunitCond = new QFilter("assetunit_id", "=", assetUnitId);
|
|
|
+ QFilter bizstatusDeleteCond = new QFilter("bizstatus", "!=", BizStatusEnum.DELETE);
|
|
|
+ QFilter notIsBackAndOther = new QFilter("isbak", "=", false);
|
|
|
+ String splitfieldvalue = inventoryTask.getString("splitfieldvalue");
|
|
|
+ if (!StringUtils.isBlank(splitfieldvalue)) {
|
|
|
+ Map<String, Object> maps = (Map)JSON.parse(splitfieldvalue);
|
|
|
+ Iterator<Map.Entry<String, Object>> it = maps.entrySet().iterator();
|
|
|
+
|
|
|
+ while(it.hasNext()) {
|
|
|
+ Map.Entry<String, Object> entry = (Map.Entry)it.next();
|
|
|
+ String keySet = (String)entry.getKey();
|
|
|
+ Object valueSet = entry.getValue();
|
|
|
+ if (valueSet != null) {
|
|
|
+ List<Long> idList = null;
|
|
|
+ String assetcatIds = (String)valueSet;
|
|
|
+ if (!StringUtils.isBlank(assetcatIds)) {
|
|
|
+ Set<Long> idSet = (Set)Arrays.asList(assetcatIds.split(",")).stream().map((s) -> {
|
|
|
+ return Long.parseLong(StringUtils.isBlank(s) ? "0" : s.trim());
|
|
|
+ }).collect(Collectors.toSet());
|
|
|
+ idList = new ArrayList(idSet);
|
|
|
+ if (idList.size() == 1 && ((Long)idList.get(0)).equals(0L)) {
|
|
|
+ idList = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QFilter assetIds = null;
|
|
|
+ if (idList != null) {
|
|
|
+ if ("assetcat".equals(keySet)) {
|
|
|
+ assetIds = new QFilter("assetcat_id", "in", FaAssetTypeUtils.getAllSubAssetTypes(idList));
|
|
|
+ } else {
|
|
|
+ assetIds = new QFilter(keySet + "_id", "in", idList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (assetIds != null) {
|
|
|
+ notIsBackAndOther.and(assetIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String sicOnlyId = Fa.join(",", new String[]{"id"});
|
|
|
+ String sic = Fa.join(",", new String[]{"id,number,barcode,assetname,model,assetamount,unit,headuseperson,nckd_storeplace"});
|
|
|
+ DynamicObjectCollection realCards = QueryServiceHelper.query("fa_card_real", sicOnlyId, new QFilter[]{assetunitCond, timeLimitCond, billstatusCond, bizstatusDeleteCond, notIsBackAndOther});
|
|
|
+ Set<Long> cardIds = new HashSet();
|
|
|
+ Iterator var43 = realCards.iterator();
|
|
|
+
|
|
|
+ while(var43.hasNext()) {
|
|
|
+ DynamicObject realCard = (DynamicObject)var43.next();
|
|
|
+ cardIds.add(realCard.getLong("id"));
|
|
|
+ }
|
|
|
+
|
|
|
+ int i = 0;
|
|
|
+ Set<Long> cardId = new HashSet();
|
|
|
+
|
|
|
+ try {
|
|
|
+ Iterator<Long> ite = cardIds.iterator();
|
|
|
+
|
|
|
+ while(ite.hasNext()) {
|
|
|
+ if (i == DATA_SIZE) {
|
|
|
+ this.createInventoryRedords(inventoryRecordType, inventoryTask, sic, cardId);
|
|
|
+ cardId = new HashSet();
|
|
|
+ i = 0;
|
|
|
+ } else {
|
|
|
+ cardId.add(ite.next());
|
|
|
+ ++i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!cardId.isEmpty()) {
|
|
|
+ this.createInventoryRedords(inventoryRecordType, inventoryTask, sic, cardId);
|
|
|
+ }
|
|
|
+
|
|
|
+ inventoryTask.set("status", "C");
|
|
|
+ SaveServiceHelper.save(inventoryTask.getDataEntityType(), new DynamicObject[]{inventoryTask});
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", (Long)assetUnitId, ResManager.loadKDString("生成盘点记录", "FaInventoryTaskList_19", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%s生成盘点记录成功。", "FaInventoryTaskList_21", "fi-fa-formplugin", new Object[0]), unitName));
|
|
|
+ } catch (Exception var32) {
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", (Long)assetUnitId, ResManager.loadKDString("生成盘点记录", "FaInventoryTaskList_19", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%1$s生成盘点记录事务失败,联系管理员查看日志:%2$s。", "FaInventoryTaskList_22", "fi-fa-formplugin", new Object[0]), unitName, var32.getMessage()));
|
|
|
+ throw new KDBizException(String.format(ResManager.loadKDString("%1$s生成盘点记录事务失败,联系管理员查看日志:%2$s。", "FaInventoryTaskList_22", "fi-fa-formplugin", new Object[0]), unitName, var32.getMessage()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (notRightStatus.length() > 0) {
|
|
|
+ int unSuccess = notRightStatus.toString().split(" ").length;
|
|
|
+ int success = selectedRows.size() - unSuccess;
|
|
|
+ this.getView().showTipNotification(String.format(ResManager.loadKDString("成功%1$d条,失败%2$d条,其中[%3$s]生成失败,任务状态不是已下达。", "FaInventoryTaskList_23", "fi-fa-formplugin", new Object[0]), success, unSuccess, notRightStatus));
|
|
|
+ } else {
|
|
|
+ this.getView().showSuccessNotification(ResManager.loadKDString("生成盘点记录成功。", "FaInventoryTaskList_24", "fi-fa-formplugin", new Object[0]));
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getView().invokeOperation("refresh");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int isSchemeClose(ListSelectedRowCollection selectedRows) {
|
|
|
+ DynamicObject[] selectDynamicObject = this.getSelectDynamicObjcet();
|
|
|
+ DynamicObject[] var3 = selectDynamicObject;
|
|
|
+ int var4 = selectDynamicObject.length;
|
|
|
+
|
|
|
+ for(int var5 = 0; var5 < var4; ++var5) {
|
|
|
+ DynamicObject selectDO = var3[var5];
|
|
|
+ if ("C".equals(selectDO.getString("inventschemeid.billstate"))) {
|
|
|
+ Iterator var7 = selectedRows.iterator();
|
|
|
+
|
|
|
+ while(var7.hasNext()) {
|
|
|
+ ListSelectedRow selectRow = (ListSelectedRow)var7.next();
|
|
|
+ if (selectDO.getLong("id") == (Long)selectRow.getPrimaryKeyValue()) {
|
|
|
+ return selectRow.getRowKey() + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void assignInventory() {
|
|
|
+ DynamicObject[] selectDys = this.getSelectDynamicObjcet();
|
|
|
+ if (selectDys != null) {
|
|
|
+ long userId = ContextUtil.getUserId();
|
|
|
+ DynamicObject[] var4 = selectDys;
|
|
|
+ int var5 = selectDys.length;
|
|
|
+
|
|
|
+ for(int var6 = 0; var6 < var5; ++var6) {
|
|
|
+ DynamicObject dy = var4[var6];
|
|
|
+ if (userId != dy.getLong("inventperson_id") && userId != dy.getDynamicObject("inventschemeid").getDynamicObject("creator").getLong("id")) {
|
|
|
+ this.getView().showTipNotification(ResManager.loadKDString("只允许盘点负责人和方案创建人指定盘点人。", "FaInventoryTaskList_28", "fi-fa-formplugin", new Object[0]));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.showUserForm();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showUserForm() {
|
|
|
+ ListShowParameter param = ShowFormHelper.createShowListForm("bos_user", true);
|
|
|
+ param.setCloseCallBack(new CloseCallBack(this, "assigninventory"));
|
|
|
+ param.setCustomParam("skipCheckSelectRows", true);
|
|
|
+ DynamicObject[] selectDys = this.getSelectDynamicObjcet();
|
|
|
+ List<Long> selectids = new ArrayList(10);
|
|
|
+ Arrays.asList(selectDys).stream().forEach((v) -> {
|
|
|
+ List<Long> collect = (List)v.getDynamicObjectCollection("inventorychecker").stream().map((t) -> {
|
|
|
+ return t.getLong("fbasedataid_id");
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ selectids.addAll(collect);
|
|
|
+ });
|
|
|
+ param.setSelectedRows(selectids.toArray());
|
|
|
+ this.getView().showForm(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createInventoryRedords(MainEntityType inventoryRecordType, DynamicObject inventoryTask, String sic, Set<Long> cardId) {
|
|
|
+ TXHandle h = TX.requiresNew();
|
|
|
+ Throwable var6 = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ try {
|
|
|
+ DynamicObjectCollection realCards = QueryServiceHelper.query("fa_card_real", sic, new QFilter[]{new QFilter("id", "in", cardId)});
|
|
|
+ DynamicObject inventoryRecordEntity = (DynamicObject)inventoryRecordType.createInstance();
|
|
|
+ List<DynamicObject> inventoryRecordList = new ArrayList();
|
|
|
+ Iterator var10 = realCards.iterator();
|
|
|
+
|
|
|
+ while(var10.hasNext()) {
|
|
|
+ DynamicObject realCard = (DynamicObject)var10.next();
|
|
|
+ DynamicObject fin = ChangeDataUtils.queryFinCard(realCard.getLong("id"));
|
|
|
+ DynamicObject inventoryRecordInstance = (DynamicObject)(new CloneUtils(false, true)).clone(inventoryRecordType, inventoryRecordEntity);
|
|
|
+ inventoryRecordInstance.set("realCard_id", realCard.get("id"));
|
|
|
+ inventoryRecordInstance.set("number", realCard.getString("number"));
|
|
|
+ inventoryRecordInstance.set("barcode", realCard.getString("barcode"));
|
|
|
+ inventoryRecordInstance.set("name", realCard.getString("assetname"));
|
|
|
+ inventoryRecordInstance.set("model", realCard.getString("model"));
|
|
|
+ inventoryRecordInstance.set("bookquantity", realCard.getBigDecimal("assetamount"));
|
|
|
+ inventoryRecordInstance.set("unit_id", realCard.get("unit"));
|
|
|
+ inventoryRecordInstance.set("inventoryquantity", BigDecimal.ZERO);
|
|
|
+ inventoryRecordInstance.set("difference", BigDecimal.ZERO);
|
|
|
+ inventoryRecordInstance.set("inventorystate", BillStatus.B.toString());
|
|
|
+ inventoryRecordInstance.set("reason", " ");
|
|
|
+ inventoryRecordInstance.set("inventorytask_id", inventoryTask.getPkValue());
|
|
|
+ inventoryRecordInstance.set("inventschemeentry_id", inventoryTask.getDynamicObject("inventsscopeid").getDynamicObject("inventschemeentry").getPkValue());
|
|
|
+ inventoryRecordInstance.set("billstatus", "C");
|
|
|
+ inventoryRecordInstance.set("billstate", "A");
|
|
|
+ inventoryRecordInstance.set("nckd_storeplace", realCard.getString("nckd_storeplace"));
|
|
|
+ inventoryRecordInstance.set("nckd_fincard", fin);
|
|
|
+ inventoryRecordList.add(inventoryRecordInstance);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (inventoryRecordList.size() > 0) {
|
|
|
+ SaveServiceHelper.save(inventoryRecordType, inventoryRecordList.toArray(new DynamicObject[0]));
|
|
|
+ }
|
|
|
+ } catch (Throwable var21) {
|
|
|
+ h.markRollback();
|
|
|
+ throw var21;
|
|
|
+ }
|
|
|
+ } catch (Throwable var22) {
|
|
|
+ var6 = var22;
|
|
|
+ throw var22;
|
|
|
+ } finally {
|
|
|
+ if (h != null) {
|
|
|
+ if (var6 != null) {
|
|
|
+ try {
|
|
|
+ h.close();
|
|
|
+ } catch (Throwable var20) {
|
|
|
+ var6.addSuppressed(var20);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ h.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
|
|
|
+ super.confirmCallBack(messageBoxClosedEvent);
|
|
|
+ IListView view = (IListView)this.getView();
|
|
|
+ ListSelectedRowCollection selectedRows = view.getSelectedRows();
|
|
|
+ String callBackId = messageBoxClosedEvent.getCallBackId();
|
|
|
+ if ("inventorydelete".equals(callBackId) && MessageBoxResult.Yes.equals(messageBoxClosedEvent.getResult())) {
|
|
|
+ StringBuilder notRightStatus = new StringBuilder();
|
|
|
+ StringBuilder notBillStatus = new StringBuilder();
|
|
|
+ Iterator var7 = selectedRows.iterator();
|
|
|
+
|
|
|
+ while(var7.hasNext()) {
|
|
|
+ ListSelectedRow selectedRow = (ListSelectedRow)var7.next();
|
|
|
+ DynamicObject inventoryTask = BusinessDataServiceHelper.loadSingle(String.valueOf(selectedRow), "fa_inventory_task");
|
|
|
+ DynamicObject inventorySope = inventoryTask.getDynamicObject("inventsscopeid");
|
|
|
+ if (inventorySope == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Object assetunitId = inventorySope.get("assetunit_id");
|
|
|
+ String assetUnitName = inventorySope.getDynamicObject("assetunit").getString("name");
|
|
|
+ String status = inventoryTask.getString("status");
|
|
|
+ if (!BillStatus.C.toString().equals(status)) {
|
|
|
+ notRightStatus.append(assetUnitName).append(' ');
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", (Long)assetunitId, ResManager.loadKDString("清除盘点记录", "FaInventoryTaskList_29", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%s删除盘点记录失败,任务状态不是已生成。", "FaInventoryTaskList_30", "fi-fa-formplugin", new Object[0]), assetUnitName));
|
|
|
+ } else {
|
|
|
+ QFilter qfBillStatus = new QFilter("billstate", "=", "C");
|
|
|
+ QFilter qfInventoryTask = new QFilter("inventorytask", "=", inventoryTask.getPkValue());
|
|
|
+ boolean exists = QueryServiceHelper.exists("fa_inventory_record", new QFilter[]{qfInventoryTask, qfBillStatus});
|
|
|
+ if (exists) {
|
|
|
+ notBillStatus.append(assetUnitName).append(' ');
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", (Long)assetunitId, ResManager.loadKDString("清除盘点记录", "FaInventoryTaskList_29", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%s删除盘点记录失败,存在已审核的盘点记录。", "FaInventoryTaskList_31", "fi-fa-formplugin", new Object[0]), assetUnitName));
|
|
|
+ } else {
|
|
|
+ Object inventoryTaskPk = selectedRow.getPrimaryKeyValue();
|
|
|
+ QFilter inventoryTaskPkCond = new QFilter("inventorytask_id", "=", inventoryTaskPk);
|
|
|
+ DeleteServiceHelper.delete("fa_inventory_record", new QFilter[]{inventoryTaskPkCond});
|
|
|
+ QFilter qInventoryTaskPk = new QFilter("inventorytask_id", "=", inventoryTaskPk);
|
|
|
+ DeleteServiceHelper.delete("fa_inventory_entrust", new QFilter[]{qInventoryTaskPk});
|
|
|
+ inventoryTask.set("status", BillStatus.B.toString());
|
|
|
+ SaveServiceHelper.save(inventoryTask.getDataEntityType(), new DynamicObject[]{inventoryTask});
|
|
|
+ FaOperateLogUtil.addLog("fa_inventory_task", (Long)assetunitId, ResManager.loadKDString("清除盘点记录", "FaInventoryTaskList_29", "fi-fa-formplugin", new Object[0]), String.format(ResManager.loadKDString("%s删除盘点记录成功。", "FaInventoryTaskList_32", "fi-fa-formplugin", new Object[0]), assetUnitName));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (notBillStatus.length() > 0) {
|
|
|
+ this.getView().showTipNotification(String.format(ResManager.loadKDString("%s删除盘点记录失败,存在已审核的盘点记录。", "FaInventoryTaskList_31", "fi-fa-formplugin", new Object[0]), notRightStatus));
|
|
|
+ } else if (notRightStatus.length() > 0) {
|
|
|
+ this.getView().showTipNotification(String.format(ResManager.loadKDString("%s删除盘点记录失败,任务状态不是已生成。", "FaInventoryTaskList_33", "fi-fa-formplugin", new Object[0]), notRightStatus));
|
|
|
+ } else {
|
|
|
+ this.getView().showSuccessNotification(String.format(ResManager.loadKDString("%s删除盘点记录成功。", "FaInventoryTaskList_32", "fi-fa-formplugin", new Object[0]), ""));
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getView().invokeOperation("refresh");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
|
|
+ super.closedCallBack(closedCallBackEvent);
|
|
|
+ Object returnData = closedCallBackEvent.getReturnData();
|
|
|
+ if (returnData != null) {
|
|
|
+ if (!"assigninventory".equals(closedCallBackEvent.getActionId())) {
|
|
|
+ if ("getmessage".equals(closedCallBackEvent.getActionId())) {
|
|
|
+ IAppCache cacheDepreCheck = AppCache.get("fa");
|
|
|
+ String title = (String)cacheDepreCheck.get("countingreport_message_title", String.class);
|
|
|
+ this.sendMessage(returnData.toString(), title);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ DynamicObjectCollection proto = this.buildMulBasedata((ListSelectedRowCollection)returnData);
|
|
|
+ DynamicObject[] selectDys = this.getSelectDynamicObjcet();
|
|
|
+ CloneUtils c = new CloneUtils(true, true);
|
|
|
+ DynamicObject[] var7 = selectDys;
|
|
|
+ int var8 = selectDys.length;
|
|
|
+
|
|
|
+ for(int var9 = 0; var9 < var8; ++var9) {
|
|
|
+ DynamicObject dy = var7[var9];
|
|
|
+ List<DynamicObject> collection = new ArrayList(10);
|
|
|
+ Iterator var11 = proto.iterator();
|
|
|
+
|
|
|
+ while(var11.hasNext()) {
|
|
|
+ DynamicObject protoDy = (DynamicObject)var11.next();
|
|
|
+ collection.add((DynamicObject)c.clone(((DynamicObject)proto.get(0)).getDataEntityType(), protoDy));
|
|
|
+ }
|
|
|
+
|
|
|
+ dy.set("inventorychecker", collection);
|
|
|
+ }
|
|
|
+
|
|
|
+ SaveServiceHelper.save(selectDys);
|
|
|
+ this.getView().updateView();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private DynamicObjectCollection buildMulBasedata(ListSelectedRowCollection selectedRows) {
|
|
|
+ DynamicObjectCollection collection = new DynamicObjectCollection();
|
|
|
+ MainEntityType mainInventory = EntityMetadataCache.getDataEntityType("fa_inventory_task");
|
|
|
+ MulBasedataProp mulBasedataProp = (MulBasedataProp)mainInventory.findProperty("inventorychecker");
|
|
|
+ DynamicObjectType dynamicCollectionItemPropertyType = mulBasedataProp.getDynamicCollectionItemPropertyType();
|
|
|
+ Iterator var6 = selectedRows.iterator();
|
|
|
+
|
|
|
+ while(var6.hasNext()) {
|
|
|
+ ListSelectedRow row = (ListSelectedRow)var6.next();
|
|
|
+ DynamicObject dy = new DynamicObject(dynamicCollectionItemPropertyType);
|
|
|
+ dy.set("fbasedataid", row.getPrimaryKeyValue());
|
|
|
+ dy.set("fbasedataid_id", row.getPrimaryKeyValue());
|
|
|
+ collection.add(dy);
|
|
|
+ }
|
|
|
+
|
|
|
+ return collection;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void inventoryAssign(Object[] pkArray) {
|
|
|
+ QFilter filtersPk = new QFilter("id", "in", pkArray);
|
|
|
+ DynamicObject[] inventoryTasks = BusinessDataServiceHelper.load("fa_inventory_task", "status", new QFilter[]{filtersPk});
|
|
|
+ List<DynamicObject> inventoryTasksNeedChange = new ArrayList(inventoryTasks.length);
|
|
|
+ DynamicObject[] var4 = inventoryTasks;
|
|
|
+ int var5 = inventoryTasks.length;
|
|
|
+
|
|
|
+ for(int var6 = 0; var6 < var5; ++var6) {
|
|
|
+ DynamicObject inventoryTask = var4[var6];
|
|
|
+ inventoryTask.set("status", BillStatus.B.toString());
|
|
|
+ inventoryTasksNeedChange.add(inventoryTask);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (inventoryTasksNeedChange.size() > 0) {
|
|
|
+ SaveServiceHelper.save(((DynamicObject)inventoryTasksNeedChange.get(0)).getDataEntityType(), inventoryTasksNeedChange.toArray());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendMessage(String content, String title) {
|
|
|
+ MessageInfo message = new MessageInfo();
|
|
|
+ message.setType("message");
|
|
|
+ if (StringUtils.isNotEmpty(title)) {
|
|
|
+ message.setTitle(title);
|
|
|
+ } else {
|
|
|
+ message.setTitle(ResManager.loadKDString("人人资产-盘点", "FaInventoryTaskList_34", "fi-fa-formplugin", new Object[0]));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> inventoryTaskPks = (List)SerializationUtils.fromJsonString(String.valueOf(this.getPageCache().get("inventoryTaskPks")), List.class);
|
|
|
+ Iterator var5 = inventoryTaskPks.iterator();
|
|
|
+
|
|
|
+ while(var5.hasNext()) {
|
|
|
+ Long inventoryTaskPk = (Long)var5.next();
|
|
|
+ List<Long> assetInventors = this.getAssetInventors(inventoryTaskPk);
|
|
|
+ message.setUserIds(assetInventors);
|
|
|
+ message.setSenderId(ContextUtil.getUserId());
|
|
|
+ message.setSendTime(new Date(System.currentTimeMillis()));
|
|
|
+ message.setEntityNumber("fa_inventory_task");
|
|
|
+ message.setBizDataId(inventoryTaskPk);
|
|
|
+ message.setTag(ResManager.loadKDString("人人资产", "FaInventoryTaskList_35", "fi-fa-formplugin", new Object[0]));
|
|
|
+ String clientUrl = UrlService.getDomainContextUrl();
|
|
|
+ StringBuilder urlWithEncodedParams = new StringBuilder(clientUrl);
|
|
|
+ if (!clientUrl.trim().endsWith("/")) {
|
|
|
+ urlWithEncodedParams.append("/");
|
|
|
+ }
|
|
|
+
|
|
|
+ String strMobContentUrl = "%sintegration/yzjShareOpen.do?mb_formId=fa_mobile_inventpage&pkId=%s&device=mob&accountId=%s";
|
|
|
+ message.setMobContentUrl(String.format(strMobContentUrl, urlWithEncodedParams.toString(), inventoryTaskPk, RequestContext.get().getAccountId()));
|
|
|
+ log.info("FaInventoryTaskList-message-MobContentUrl-is " + message.getMobContentUrl());
|
|
|
+ String strContentUrl = "%sindex.html?formId=fa_inventory_task&pkId=%s";
|
|
|
+ message.setContentUrl(String.format(strContentUrl, urlWithEncodedParams.toString(), inventoryTaskPk));
|
|
|
+ log.info("FaInventoryTaskList-message-ContentUrl-is " + message.getContentUrl());
|
|
|
+ message.setContent(content);
|
|
|
+ log.info("FaInventoryTaskList-message-Content-is " + message.getContent());
|
|
|
+ message.setPubaccNumber("systempubacc");
|
|
|
+ MessageCenterServiceHelper.sendMessage(message);
|
|
|
+ this.getView().showMessage(ResManager.loadKDString("发送普通消息给“系统级消息助手”成功。", "FaInventoryTaskList_36", "fi-fa-formplugin", new Object[0]));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Long> getAssetInventors(Long inventoryTaskPk) {
|
|
|
+ Set<Long> assetInventors = new HashSet();
|
|
|
+ String sic = Fa.join(",", new String[]{"realcard.headuseperson.id"});
|
|
|
+ QFilter filters1 = new QFilter("inventorytask", "=", inventoryTaskPk);
|
|
|
+ filters1.and("inventorystate", "=", BillStatus.B);
|
|
|
+ DataSet dataSet = QueryServiceHelper.queryDataSet(FaInventoryTaskListNew.class.getName(), "fa_inventory_record", sic, new QFilter[]{filters1}, (String)null);
|
|
|
+ Iterator var6 = dataSet.iterator();
|
|
|
+
|
|
|
+ while(var6.hasNext()) {
|
|
|
+ Row row = (Row)var6.next();
|
|
|
+ assetInventors.add(row.getLong("realcard.headuseperson.id"));
|
|
|
+ }
|
|
|
+
|
|
|
+ return new ArrayList(assetInventors);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void beforeBindData(EventObject e) {
|
|
|
+ super.beforeBindData(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setDefaultQuerySelect(FilterContainerInitArgs filtercontainerinitargs) {
|
|
|
+ List<FilterColumn> listFilterColumns = filtercontainerinitargs.getFilterContainerInitEvent().getCommonFilterColumns();
|
|
|
+ Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
|
|
|
+ Object schemeId = customParams.get("schemeId");
|
|
|
+ Long userId = ContextUtil.getUserId();
|
|
|
+ List<ComboItem> comboItemsStatus = new ArrayList();
|
|
|
+ ComboItem a = new ComboItem(new LocaleString(ResManager.loadKDString("未下达", "FaInventoryTaskList_37", "fi-fa-formplugin", new Object[0])), BillStatus.A.toString());
|
|
|
+ ComboItem b = new ComboItem(new LocaleString(ResManager.loadKDString("已下达", "FaInventoryTaskList_38", "fi-fa-formplugin", new Object[0])), BillStatus.B.toString());
|
|
|
+ ComboItem c = new ComboItem(new LocaleString(ResManager.loadKDString("已生成", "FaInventoryTaskList_39", "fi-fa-formplugin", new Object[0])), "C");
|
|
|
+ if (schemeId != null) {
|
|
|
+ this.getPageCache().put("schemeIds", SerializationUtils.serializeToBase64(schemeId));
|
|
|
+ ListIterator<FilterColumn> deleteListFilterColumns = listFilterColumns.listIterator();
|
|
|
+
|
|
|
+ while(deleteListFilterColumns.hasNext()) {
|
|
|
+ String fieldName = ((FilterColumn)deleteListFilterColumns.next()).getFieldName();
|
|
|
+ if ("inventsscopeid.inventschemeentry.name".equals(fieldName)) {
|
|
|
+ deleteListFilterColumns.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Iterator var29 = listFilterColumns.iterator();
|
|
|
+
|
|
|
+ while(true) {
|
|
|
+ while(var29.hasNext()) {
|
|
|
+ FilterColumn listFilter = (FilterColumn)var29.next();
|
|
|
+ CommonFilterColumn commFilter = (CommonFilterColumn)listFilter;
|
|
|
+ String fieldName = commFilter.getFieldName();
|
|
|
+ if ("inventsscopeid.inventschemeentry.name".equals(fieldName)) {
|
|
|
+ Set<ComboItem> comboItemsTrys = new HashSet();
|
|
|
+ QFilter filtersUserid = new QFilter("inventperson", "=", userId);
|
|
|
+ filtersUserid.or(new QFilter("inventorychecker.fbasedataid", "=", userId));
|
|
|
+ QFilter filterStatus = new QFilter("status", "!=", "A");
|
|
|
+ QFilter filterStatusZ = new QFilter("status", "!=", "Z");
|
|
|
+ DynamicObjectCollection invenTasks = QueryServiceHelper.query("fa_inventory_task", "inventsscopeid", new QFilter[]{filtersUserid, filterStatus, filterStatusZ});
|
|
|
+ Set<Long> scopeIds = (Set)invenTasks.stream().map((s) -> {
|
|
|
+ return s.getLong("inventsscopeid");
|
|
|
+ }).collect(Collectors.toSet());
|
|
|
+ QFilter scopeIdsQ = new QFilter("id", "in", scopeIds);
|
|
|
+ DynamicObjectCollection invenschemeetry = QueryServiceHelper.query("fa_inventory_sope", "inventschemeentry", new QFilter[]{scopeIdsQ}, "createtime desc");
|
|
|
+ Set<Long> schemeIds = (Set)invenschemeetry.stream().map((s) -> {
|
|
|
+ return s.getLong("inventschemeentry");
|
|
|
+ }).collect(Collectors.toSet());
|
|
|
+ this.getPageCache().put("schemeIds", SerializationUtils.serializeToBase64(schemeIds));
|
|
|
+ QFilter schemeIdsQ = new QFilter("id", "in", schemeIds);
|
|
|
+ DynamicObjectCollection inventschemes = QueryServiceHelper.query("fa_inventscheme_new", "id,name,entryentity.splitfieldentity.splitfield splitfield", new QFilter[]{schemeIdsQ}, "createtime desc");
|
|
|
+ Iterator var25 = inventschemes.iterator();
|
|
|
+
|
|
|
+ while(var25.hasNext()) {
|
|
|
+ DynamicObject inventscheme = (DynamicObject)var25.next();
|
|
|
+ ComboItem item = new ComboItem(new LocaleString(inventscheme.getString("name")), inventscheme.getString("id"));
|
|
|
+ comboItemsTrys.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(inventschemes)) {
|
|
|
+ commFilter.setDefaultValue(((DynamicObject)inventschemes.get(0)).getString("id"));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ComboItem> allInventoryName = new ArrayList(comboItemsTrys);
|
|
|
+ commFilter.setComboItems(allInventoryName);
|
|
|
+ commFilter.setMustInput(true);
|
|
|
+ } else if ("status".equals(fieldName)) {
|
|
|
+ comboItemsStatus.add(a);
|
|
|
+ comboItemsStatus.add(b);
|
|
|
+ comboItemsStatus.add(c);
|
|
|
+ commFilter.setComboItems(comboItemsStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private DynamicObject[] getSelectDynamicObjcet() {
|
|
|
+ QFilter qfIds = new QFilter("id", "in", this.getSelectedRows().getPrimaryKeyValues());
|
|
|
+ return BusinessDataServiceHelper.load("fa_inventory_task", "inventorychecker,inventperson,inventschemeid", new QFilter[]{qfIds});
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initbaseNameMap(Set<String> splitfields) {
|
|
|
+ int k = 0;
|
|
|
+ Iterator var3 = splitfields.iterator();
|
|
|
+
|
|
|
+ while(var3.hasNext()) {
|
|
|
+ String splitfield = (String)var3.next();
|
|
|
+ String columnName = "entrytext" + k++;
|
|
|
+ this.baseNameMap.put(columnName, splitfield);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setColumnVisible(Set<String> splitfields) {
|
|
|
+ Iterator var2 = splitfields.iterator();
|
|
|
+
|
|
|
+ while(var2.hasNext()) {
|
|
|
+ String splitfield = (String)var2.next();
|
|
|
+ Iterator var4 = this.baseNameMap.entrySet().iterator();
|
|
|
+
|
|
|
+ while(var4.hasNext()) {
|
|
|
+ Map.Entry<String, String> entry = (Map.Entry)var4.next();
|
|
|
+ if (splitfield.equals(entry.getValue())) {
|
|
|
+ this.columnNames.add(entry.getKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BillList list = (BillList)this.getControl("billlistap");
|
|
|
+ FaInventoryUtils.setColumnVisible(list.getView(), this.columnNames);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setColumnName() {
|
|
|
+ BillList billList = (BillList)this.getView().getControl("billlistap");
|
|
|
+ BeforeCreateListColumnsArgs args = billList.getBeforeCreateListColumnsArgs();
|
|
|
+ if (null != args) {
|
|
|
+ Iterator var3 = this.columnNames.iterator();
|
|
|
+
|
|
|
+ while(var3.hasNext()) {
|
|
|
+ String columnName = (String)var3.next();
|
|
|
+ String entityId = (String)this.baseNameMap.get(columnName);
|
|
|
+ Map<String, Object> map = (Map)this.baseEntityIdMap.get(entityId);
|
|
|
+ IListColumn listColumn = billList.getBeforeCreateListColumnsArgs().getListColumn(columnName);
|
|
|
+ if (null != listColumn && null != map.get("displayName")) {
|
|
|
+ listColumn.setCaption((LocaleString)map.get("displayName"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class FaInventoryTaskListProvide extends ListDataProvider {
|
|
|
+ private FaInventoryTaskListProvide() {
|
|
|
+ }
|
|
|
+
|
|
|
+ public DynamicObjectCollection getData(int start, int limit) {
|
|
|
+ DynamicObjectCollection rows = super.getData(start, limit);
|
|
|
+ Map<String, Set<Long>> queryMap = new HashMap(FaInventoryTaskListNew.this.baseEntityIdMap.size(), 1.0F);
|
|
|
+ Iterator var5 = FaInventoryTaskListNew.this.baseEntityIdMap.keySet().iterator();
|
|
|
+
|
|
|
+ while(var5.hasNext()) {
|
|
|
+ String s = (String)var5.next();
|
|
|
+ queryMap.put(s, new HashSet());
|
|
|
+ }
|
|
|
+
|
|
|
+ var5 = rows.iterator();
|
|
|
+
|
|
|
+ while(var5.hasNext()) {
|
|
|
+ DynamicObject row = (DynamicObject)var5.next();
|
|
|
+ Map<String, Set<Long>> baseDataMap = new HashMap(16);
|
|
|
+ String splitFieldObj = row.getString("splitfieldvalue");
|
|
|
+ if (StringUtils.isNotEmpty(splitFieldObj)) {
|
|
|
+ baseDataMap = FaInventoryUtils.transferSplitFieldValue(splitFieldObj);
|
|
|
+ }
|
|
|
+
|
|
|
+ Iterator var9 = ((Map)baseDataMap).entrySet().iterator();
|
|
|
+
|
|
|
+ while(var9.hasNext()) {
|
|
|
+ Map.Entry<String, Set<Long>> entry = (Map.Entry)var9.next();
|
|
|
+ Set<Long> ids = (Set)queryMap.get(entry.getKey());
|
|
|
+ ids.addAll((Collection)entry.getValue());
|
|
|
+ queryMap.put(entry.getKey(), ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ FaInventoryTaskListNew.this.idAndBaseDataMap.put(row.getLong("id"), baseDataMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ FaInventoryUtils.setResultMapValue(queryMap, FaInventoryTaskListNew.this.baseEntityIdMap, FaInventoryTaskListNew.this.resultMap);
|
|
|
+ return rows;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|