Jelajahi Sumber

feat(swc): 新增薪资明细查询和批量新增功能

Tyx 6 hari lalu
induk
melakukan
3dfb4b4b5d

+ 399 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/SinsurTempDataViewBillListPlugin.java

@@ -0,0 +1,399 @@
+package nckd.jxccl.sit.hcsi.formplugin.web.tp;
+
+import com.kingdee.util.DateTimeUtils;
+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.entity.EntityMetadataCache;
+import kd.bos.entity.MainEntityType;
+import kd.bos.entity.datamodel.events.GetEntityTypeEventArgs;
+import kd.bos.entity.property.DateProp;
+import kd.bos.entity.property.TextProp;
+import kd.bos.exception.KDBizException;
+import kd.bos.form.FormShowParameter;
+import kd.bos.form.container.Container;
+import kd.bos.form.control.Control;
+import kd.bos.form.events.BeforeCreateListColumnsArgs;
+import kd.bos.form.events.BeforeCreateListDataProviderArgs;
+import kd.bos.form.events.OnGetControlArgs;
+import kd.bos.list.BillList;
+import kd.bos.list.DateListColumn;
+import kd.bos.list.IListColumn;
+import kd.bos.list.ListColumn;
+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.mvc.list.ListView;
+import kd.bos.orm.query.QFilter;
+import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
+import kd.sdk.plugin.Plugin;
+import nckd.jxccl.base.swc.helper.SWCHelper;
+import nckd.jxccl.sit.hcsi.business.importtaskguide.utils.ImportTaskUtils;
+import org.apache.commons.lang.exception.ExceptionUtils;
+
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Tyx 2025-11-27
+ * 外部数据导入中间表列表插件
+ * 根据模板配置的项目动态配置列
+ * 包含构建列及provider
+ */
+public class SinsurTempDataViewBillListPlugin extends AbstractListPlugin implements Plugin {
+
+    private static final Log logger = LogFactory.getLog(SinsurTempDataViewBillListPlugin.class);
+    private SisurTempDataEntityTypeBillList billList;
+    // 定义一个静态集合,存储常用列的key
+    private static final Set<String> COMMONCOLUMNSET = new HashSet(8);
+
+    // 静态代码块,初始化常用列集合
+    static {
+        COMMONCOLUMNSET.add("fseq");
+        COMMONCOLUMNSET.add("nckd_datastatus");
+        COMMONCOLUMNSET.add("billstatus");
+        COMMONCOLUMNSET.add("nckd_importtask.name");
+        COMMONCOLUMNSET.add("nckd_empname");
+        COMMONCOLUMNSET.add("nckd_idcard");
+        COMMONCOLUMNSET.add("nckd_periodname");
+    }
+
+    /**
+     * 获取实体类型
+     * @param args 获取实体类型的事件参数
+     */
+    public void getEntityType(GetEntityTypeEventArgs args) {
+        super.getEntityType(args);
+        args.setNewEntityType(this.getEntityType());
+    }
+
+    /**
+     * 获取新的实体类型
+     * @return 返回处理后的实体类型
+     */
+    private MainEntityType getEntityType() {
+        MainEntityType mainType = EntityMetadataCache.getDataEntityType("nckd_sinsurtempdata");
+        MainEntityType mainEntityType = null;
+
+        try {
+            mainEntityType = (MainEntityType)mainType.clone();
+        } catch (CloneNotSupportedException var4) {
+            logger.error("getNewEntityType: ", var4);
+            throw new KDBizException(ExceptionUtils.getFullStackTrace(var4));
+        }
+
+        if (mainEntityType == null) {
+            return mainType;
+        } else {
+            List<Map<String, String>> columnHeadList = this.getColumnHeadList();
+            this.addItemProp(mainEntityType, columnHeadList);
+            return mainEntityType;
+        }
+    }
+
+    /**
+     * 获取控件
+     * @param args 获取控件的事件参数
+     */
+    public void onGetControl(OnGetControlArgs args) {
+        super.onGetControl(args);
+        String key = args.getKey();
+        Control customControl = null;
+        if ("billlistap".equals(key)) {
+            customControl = this.createBillList(key);
+        }
+        if (customControl != null) {
+            args.setControl(customControl);
+        }
+    }
+
+
+    /**
+     * 构建列表
+     * @param key 列表的key值
+     * @return 返回构建好的BillList对象
+     */
+    protected BillList createBillList(String key) {
+        if (this.billList != null) {
+            return this.billList;
+        } else {
+            this.billList = new SisurTempDataEntityTypeBillList(this.getEntityType());
+            this.billList.setKey(key);
+            this.billList.setEntityId("nckd_sinsurtempdata");
+            ListView listView = (ListView)this.getView();
+            this.billList.setBillFormId(listView.getBillFormId());
+            this.billList.setView(listView);
+            Container rootControl = (Container)this.getView().getRootControl();
+            this.replaceBillList(rootControl.getItems(), this.billList);
+            return this.billList;
+        }
+    }
+
+    /**
+     * 替换列表控件
+     * @param items 控件列表
+     * @param billList 要替换的列表控件
+     */
+    private void replaceBillList(List<Control> items, Control billList) {
+        for(int i = 0; i < items.size(); ++i) {
+            Control control = (Control)items.get(i);
+            if (control.getKey().equals(billList.getKey())) {
+                items.set(i, billList);
+                return;
+            }
+            if (control instanceof Container) {
+                this.replaceBillList(((Container)control).getItems(), billList);
+            }
+        }
+    }
+
+    /**
+     * 构建列表列之前方法
+     * @param args
+     */
+    @Override
+    public void beforeCreateListColumns(BeforeCreateListColumnsArgs args) {
+        List<IListColumn> columnList = args.getListColumns();
+        List<IListColumn> commonColumnList = new ArrayList(10);
+        Map<String, IListColumn> otherFixColumnMap = new HashMap(16);
+        Iterator it = columnList.iterator();
+
+        while(it.hasNext()) {
+            IListColumn obj = (IListColumn)it.next();
+            if (COMMONCOLUMNSET.contains(obj.getListFieldKey())) {
+                commonColumnList.add(obj);
+            } else {
+                otherFixColumnMap.put(obj.getListFieldKey(), obj);
+            }
+        }
+
+        columnList.clear();
+        columnList.addAll(commonColumnList);
+        List<Map<String, String>> columnHeadList = this.getColumnHeadList();
+        if (!SWCHelper.isEmpty(columnList)) {
+            int seq = columnList.size() + 1;
+            String key = null;
+            String itemType = null;
+            it = columnHeadList.iterator();
+
+            while(it.hasNext()) {
+                Map<String, String> tempMap = (Map)it.next();
+                Long dataTypeId = Long.valueOf((String)tempMap.get("datatypeid"));
+                String name = (String)tempMap.get("name");
+                key = (String)tempMap.get("key");
+                itemType = (String)tempMap.get("itemType");
+                if ("0".equals(itemType)) {
+                    if (!COMMONCOLUMNSET.contains(key)) {
+                        IListColumn tempColumn = (IListColumn)otherFixColumnMap.get(key);
+                        if (tempColumn != null) {
+                            columnList.add(tempColumn);
+                            ++seq;
+                        }
+                    }
+                } else {
+                    if (1050L == dataTypeId) {
+                        DateListColumn dateListColumn = new DateListColumn();
+                        dateListColumn.setDisplayFormatString("yyyy-MM-dd");
+                        dateListColumn.setCaption(new LocaleString(name));
+                        dateListColumn.setKey(key);
+                        dateListColumn.setListFieldKey(key);
+                        dateListColumn.setSeq(seq);
+                        columnList.add(dateListColumn);
+                    } else {
+                        ListColumn column = new ListColumn();
+                        column.setCaption(new LocaleString(name));
+                        column.setKey(key);
+                        column.setListFieldKey(key);
+                        column.setSeq(seq);
+                        columnList.add(column);
+                    }
+                    ++seq;
+                }
+            }
+
+        }
+    }
+
+    /**
+     * 获取导入任务模板上的字段
+     * @return
+     */
+    private List<Map<String, String>> getColumnHeadList() {
+        List<Map<String, String>> columnHeadList = new ArrayList(10);
+        Long sinsurTplId = (Long)this.getView().getFormShowParameter().getCustomParam("sinsurTplId");
+        FormShowParameter parameter = this.getView().getFormShowParameter();
+        return (List)(sinsurTplId != null && sinsurTplId != 0L ? ImportTaskUtils.getColumnHeadList(sinsurTplId, (Long)parameter.getCustomParam("importTaskId")) : columnHeadList);
+    }
+
+    /**
+     * 添加ListDataProvider
+     * @param args
+     */
+    @Override
+    public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {
+        args.setListDataProvider(new ImportItemDataResultImpl());
+    }
+
+    private void addItemProp(DynamicObjectType mainEntityType, List<Map<String, String>> columnHeadList) {
+        String key = null;
+        Long dataTypeId = null;
+        String name = null;
+        String itemType = null;
+        Iterator it = columnHeadList.iterator();
+
+        while(true) {
+            while(true) {
+                Map temMap;
+                do {
+                    if (!it.hasNext()) {
+                        return;
+                    }
+                    temMap = (Map)it.next();
+                    key = (String)temMap.get("key");
+                    itemType = (String)temMap.get("itemType");
+                } while("0".equals(itemType));
+
+                dataTypeId = Long.valueOf((String)temMap.get("datatypeid"));
+                name = (String)temMap.get("name");
+                if (1030L != dataTypeId && 1010L != dataTypeId && 1020L != dataTypeId) {
+                    if (1050L == dataTypeId) {
+                        DateProp property = new DateProp();
+                        property.setName(key);
+                        property.setDisplayName(new LocaleString(name));
+                        mainEntityType.addProperty(property);
+                    }
+                } else {
+                    TextProp property = new TextProp();
+                    property.setName(key);
+                    property.setDisplayName(new LocaleString(name));
+                    property.setMaxLenth(200);
+                    mainEntityType.addProperty(property);
+                }
+            }
+        }
+    }
+
+
+    public class ImportItemDataResultImpl extends ListDataProvider {
+        public ImportItemDataResultImpl() {
+        }
+        @Override
+        public DynamicObjectCollection getData(int start, int limit) {
+            DynamicObjectCollection list = super.getData(start, limit);
+            if (this.getQueryBuilder().isSelectedAllRows()) {
+                return list;
+            } else {
+                List<Map<String, String>> columnHeadList = SinsurTempDataViewBillListPlugin.this.getColumnHeadList();
+                if (SWCHelper.isEmpty(columnHeadList)) {
+                    return list;
+                } else {
+                    SinsurTempDataViewBillListPlugin.this.addItemProp(list.getDynamicObjectType(), columnHeadList);
+                    List<Long> idList = (List)list.stream().map((objx) -> {
+                        return objx.getLong("id");
+                    }).collect(Collectors.toList());
+                    Map<Long, Map<String, Object>> itemDataMap = this.getItemDataMap(idList);
+                    if (itemDataMap.size() == 0) {
+                        return list;
+                    } else {
+                        Map<String, Object> tempMap = null;
+                        Iterator it = list.iterator();
+                        while(true) {
+                            DynamicObject obj;
+                            do {
+                                do {
+                                    if (!it.hasNext()) {
+                                        return list;
+                                    }
+                                    obj = (DynamicObject)it.next();
+                                    tempMap = (Map)itemDataMap.get(obj.getLong("id"));
+                                } while(tempMap == null);
+                            } while(tempMap.size() == 0);
+
+                            Iterator it1 = tempMap.entrySet().iterator();
+
+                            while(it1.hasNext()) {
+                                Map.Entry<String, Object> entry = (Map.Entry)it1.next();
+                                obj.set((String)entry.getKey(), entry.getValue());
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        private Map<Long, Map<String, Object>> getItemDataMap(List<Long> idList) {
+            Map<Long, Map<String, Object>> itemDataMap = new HashMap(16);
+            HRBaseServiceHelper helper = new HRBaseServiceHelper("nckd_sinsurtempdata");
+            String fields = "id,entryentity.nckd_itemtype,entryentity.nckd_itemid,entryentity.nckd_datatype,entryentity.nckd_itemvalue";
+            QFilter qFilter = new QFilter("id", "in", idList);
+            DynamicObjectCollection itemData = helper.queryOriginalCollection(fields, new QFilter[]{qFilter});
+            if (itemData.size() == 0) {
+                return itemDataMap;
+            } else {
+                Map<String, Object> tempMap = null;
+                long dataTypeId = 0L;
+                String itemValue = null;
+                String columnKey = null;
+                Iterator var12 = itemData.iterator();
+
+                while(true) {
+                    while(true) {
+                        DynamicObject obj;
+                        do {
+                            if (!var12.hasNext()) {
+                                return itemDataMap;
+                            }
+
+                            obj = (DynamicObject)var12.next();
+                            tempMap = (Map)itemDataMap.get(obj.getLong("id"));
+                            if (tempMap == null) {
+                                tempMap = new HashMap(16);
+                                itemDataMap.put(obj.getLong("id"), tempMap);
+                            }
+
+                            dataTypeId = obj.getLong("entryentity.nckd_itemtype");
+                            itemValue = obj.getString("entryentity.nckd_itemvalue");
+                        } while(itemValue == null);
+
+                        columnKey = this.getColumnKey(obj.getString("entryentity.nckd_itemtype"), obj.getLong("entryentity.nckd_itemid"));
+                        if (1020L != dataTypeId && 1010L != dataTypeId) {
+                            if (1050L == dataTypeId) {
+                                try {
+                                    ((Map)tempMap).put(columnKey, DateTimeUtils.parseDate(itemValue, "yyyy-MM-dd"));
+                                } catch (ParseException var15) {
+                                    SinsurTempDataViewBillListPlugin.logger.error("parse itemValue error", var15);
+                                    throw new KDBizException(ExceptionUtils.getFullStackTrace(var15));
+                                }
+                            } else {
+                                ((Map)tempMap).put(columnKey, itemValue);
+                            }
+                        } else {
+                            ((Map)tempMap).put(columnKey, new BigDecimal(itemValue));
+                        }
+                    }
+                }
+            }
+        }
+
+        private String getColumnKey(String itemType, long itemId) {
+            String columnKey = "";
+            if ("4".equals(itemType)) {
+                columnKey = "ft" + itemId;
+            } else if ("1".equals(itemType)) {
+                columnKey = "ii" + itemId;
+            } else if ("3".equals(itemType)) {
+                columnKey = "bs" + itemId;
+            } else if ("2".equals(itemType)) {
+                columnKey = "sp" + itemId;
+            }
+
+            return columnKey;
+        }
+
+
+    }
+}

+ 33 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/SisurTempDataEntityTypeBillList.java

@@ -0,0 +1,33 @@
+package nckd.jxccl.sit.hcsi.formplugin.web.tp;
+
+import kd.bos.entity.EntityType;
+import kd.bos.list.BillList;
+
+/**
+ * SisurTempDataEntityTypeBillList 类,继承自 BillList
+ * 用于处理临时数据实体类型账单列表
+ */
+public class SisurTempDataEntityTypeBillList extends BillList {
+
+    // 实体类型属性
+    private EntityType entityType;
+
+    /**
+     * 构造函数
+     * @param entityType 实体类型对象
+     */
+    public SisurTempDataEntityTypeBillList(EntityType entityType) {
+        this.entityType = entityType;
+    }
+
+    /**
+     * 获取实体类型
+     * 如果当前对象的 entityType 为 null,则返回父类的 entityType
+     * @return 返回实体类型对象
+     */
+    public EntityType getEntityType() {
+        super.getEntityType();
+        return this.entityType == null ? super.getEntityType() : this.entityType;
+    }
+
+}

+ 15 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/hcdm/business/annualincome/AnnualIncomeService.java

@@ -4,6 +4,8 @@ package nckd.jxccl.swc.hcdm.business.annualincome;
 import kd.bos.algo.DataSet;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.db.DB;
+import kd.bos.db.DBRoute;
 import kd.bos.entity.EntityMetadataCache;
 import kd.bos.entity.QueryEntityType;
 import kd.bos.logging.Log;
@@ -14,6 +16,7 @@ import kd.bos.orm.query.QFilter;
 import kd.hr.hbp.business.servicehelper.HRQueryEntityHelper;
 import kd.sdk.swc.hsas.business.internal.spi.CalResultQueryService;
 import nckd.jxccl.swc.constants.SwcConstant;
+import nckd.jxccl.swc.utils.SwcUtils;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -105,6 +108,18 @@ public class AnnualIncomeService {
         return calPersonCols;
     }
 
+    /**
+     * 根据薪资核算组+日期范围获取薪资明细
+     * @return
+     */
+    public DynamicObjectCollection querySalaryDetailBySql() {
+        StringBuilder sb = SwcUtils.getSalaryDetailSql(groupIds, startDate, endDate);
+        DataSet dataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("swc"), sb.toString());
+        DynamicObjectCollection cols = ORM.create().toPlainDynamicObjectCollection(dataSet);
+        return cols;
+
+    }
+
     /**
      * 查询年收入的人员ID,后续排除用
      * @return

+ 53 - 5
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/hcdm/formplugin/annualincome/IncomeBatchAddnewEdit.java

@@ -7,15 +7,14 @@ import kd.bos.form.events.AfterDoOperationEventArgs;
 import kd.bos.form.plugin.AbstractFormPlugin;
 import kd.bos.orm.query.QCP;
 import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.coderule.CodeRuleServiceHelper;
+import kd.bos.servicehelper.operation.SaveServiceHelper;
 import kd.sdk.plugin.Plugin;
 import nckd.jxccl.swc.constants.SwcConstant;
 import nckd.jxccl.swc.hcdm.business.annualincome.AnnualIncomeService;
 import nckd.jxccl.swc.utils.SwcUtils;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.EventObject;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -48,6 +47,54 @@ public class IncomeBatchAddnewEdit extends AbstractFormPlugin implements Plugin
      * 3、
      */
     private void doBatchAddnew() {
+        String msg;
+        DynamicObject dyn = this.getModel().getDataEntity();
+        // 获取当前窗口选择的年份 实际值是yyyy-01-01
+        Date startDate = dyn.getDate("nckd_year");
+        DynamicObjectCollection cols = queryData();
+        if(cols.size() == 0) {
+            msg = "所有核算组都已生成,请勿重复生成!";
+            this.getView().returnDataToParent(msg);
+            this.getView().close();
+            return;
+        }
+        // 根据groupId提取出来
+        Map<Long, List<DynamicObject>> groupMap = cols.stream().collect(Collectors.groupingBy(obj -> obj.getLong("groupId")));
+
+        Set<Long> keySet = groupMap.keySet();
+        DynamicObjectCollection billCols = new DynamicObjectCollection();
+        for(Long groupId : keySet) {
+            DynamicObject bill = SwcConstant.SALANNUALINCOMEBILL_ENTITY.generateEmptyDynamicObject();
+            bill.set("nckd_payrollgrp", groupId);
+            bill.set("nckd_calyear", startDate);
+            bill.set("billstatus", "A");
+            DynamicObjectCollection entryCols = bill.getDynamicObjectCollection("nckd_entryentity");
+            for(DynamicObject obj : groupMap.get(groupId)) {
+                DynamicObject entry = entryCols.addNew();
+                entry.set("nckd_employee", obj.getLong("employeeId"));
+                entry.set("nckd_idcardno", obj.getString("idCardNo"));
+                entry.set("nckd_month", obj.getInt("monthCount"));
+                entry.set("nckd_totalsalary", obj.getBigDecimal("amount"));
+                entry.set("nckd_pushstatus", "0");
+                bill.set("org", obj.getLong("orgId"));
+            }
+
+            bill.set("billno", CodeRuleServiceHelper.getNumber(SwcConstant.SALANNUALINCOMEBILL_ENTITY.getEntityName(), bill, bill.getString("org")));
+            billCols.add(bill);
+        }
+        Object[] a = SwcConstant.SALANNUALINCOMEBILL_ENTITY.save(billCols);
+        msg = String.format("共生成%d条薪资核算组数据", a.length);
+        this.getView().returnDataToParent(msg);
+        this.getView().close();
+    }
+
+
+    /**
+     * 查询数据,包含字段:
+     *
+     * @return
+     */
+    public DynamicObjectCollection queryData() {
         DynamicObject dyn = this.getModel().getDataEntity();
         // 获取当前窗口选择的年份 实际值是yyyy-01-01
         Date startDate = dyn.getDate("nckd_year");
@@ -57,7 +104,8 @@ public class IncomeBatchAddnewEdit extends AbstractFormPlugin implements Plugin
         Date endDate = SwcUtils.getLastDayOfYear(startDate);
 
         AnnualIncomeService service = new AnnualIncomeService(groupIds, startDate, endDate);
-        //service.
+        DynamicObjectCollection cols = service.querySalaryDetailBySql();
+        return cols;
     }
 
     public List<Long> getPayRollGroupIds (Date startDate) {

+ 49 - 1
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/hcdm/formplugin/annualincome/SalAnnualIncomeBillList.java

@@ -2,6 +2,7 @@ package nckd.jxccl.swc.hcdm.formplugin.annualincome;
 
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.utils.ObjectUtils;
 import kd.bos.dataentity.utils.StringUtils;
 import kd.bos.entity.datamodel.ListSelectedRowCollection;
 import kd.bos.form.CloseCallBack;
@@ -10,6 +11,7 @@ import kd.bos.form.IFormView;
 import kd.bos.form.ShowType;
 import kd.bos.form.events.AfterDoOperationEventArgs;
 import kd.bos.form.events.BeforeDoOperationEventArgs;
+import kd.bos.form.events.ClosedCallBackEvent;
 import kd.bos.form.operate.FormOperate;
 import kd.bos.list.IListView;
 import kd.bos.list.plugin.AbstractListPlugin;
@@ -24,19 +26,30 @@ import java.util.stream.Collectors;
 /**
  * Tyx 2025-11-25
  * 年收入证明统计单列表插件 【nckd_salinnualincomebill】
+ * 该类是一个年收入证明统计单列表的插件实现,继承自AbstractListPlugin并实现Plugin接口。
+ * 主要功能包括批量新增、废弃操作等。
  */
 public class SalAnnualIncomeBillList extends AbstractListPlugin implements Plugin {
 
+    /**
+     * 操作前事件处理方法
+     * @param args 操作事件参数
+     */
     @Override
     public void beforeDoOperation(BeforeDoOperationEventArgs args) {
         super.beforeDoOperation(args);
         FormOperate formOperate = (FormOperate)args.getSource();
         String opKey = formOperate.getOperateKey();
+        // 判断是否为批量新增操作
         if (StringUtils.equals(opKey, "donothing_batchaddnew")) {
             this.openBatchAddnewWindow(args);
         }
     }
 
+    /**
+     * 打开批量新增窗口
+     * @param args 操作事件参数
+     */
     private void openBatchAddnewWindow(BeforeDoOperationEventArgs args) {
         FormShowParameter formShowParameter = new FormShowParameter();
         formShowParameter.setFormId("nckd_incomebatchaddnew");
@@ -45,6 +58,36 @@ public class SalAnnualIncomeBillList extends AbstractListPlugin implements Plugi
         this.getView().showForm(formShowParameter);
     }
 
+    /**
+     * 窗口关闭回调方法
+     * @param closedCallBackEvent 关闭回调事件参数
+     */
+    @Override
+    public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
+        super.closedCallBack(closedCallBackEvent);
+        String actionId = closedCallBackEvent.getActionId();
+        switch(actionId) {
+            case "batchAddnew":
+                doBatchAddnewClosedCallBackEvent(closedCallBackEvent);
+        }
+    }
+
+    /**
+     * 处理批量新增窗口关闭后的回调事件
+     * @param closedCallBackEvent 关闭回调事件参数
+     */
+    private void doBatchAddnewClosedCallBackEvent(ClosedCallBackEvent closedCallBackEvent) {
+        // 如果有返回数据,则显示成功消息并刷新列表
+        if(!ObjectUtils.isEmpty(closedCallBackEvent.getReturnData())) {
+            this.getView().showSuccessNotification(closedCallBackEvent.getReturnData().toString());
+            this.getView().invokeOperation("refresh");
+        }
+    }
+
+    /**
+     * 操作后事件处理方法
+     * @param afterDoOperationEventArgs 操作后事件参数
+     */
     @Override
     public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
         super.afterDoOperation(afterDoOperationEventArgs);
@@ -57,7 +100,8 @@ public class SalAnnualIncomeBillList extends AbstractListPlugin implements Plugi
     }
 
     /**
-     * 按行废弃
+     * 按行废弃方法
+     * 将选中的行状态设置为废弃状态,并刷新列表
      */
     private void doDiscardByRow() {
         IFormView view = this.getView();
@@ -65,12 +109,15 @@ public class SalAnnualIncomeBillList extends AbstractListPlugin implements Plugi
         ListSelectedRowCollection selectedRows = listview.getSelectedRows();
         Object[] entryIds = selectedRows.getEntryPrimaryKeyValues();
 
+        // 将选中的行ID转换为Long类型的List
         List<Long> entryIdsList = Arrays.stream(entryIds).map(obj -> {
             return (Long) obj;
         }).collect(Collectors.toList());
 
+        // 创建查询过滤器,获取选中的行数据
         QFilter filter = new QFilter("nckd_entryentity.id", "in", entryIdsList);
         DynamicObject[] billDyns = SwcConstant.SALANNUALINCOMEBILL_ENTITY.load("nckd_entryentity.nckd_pushstatus", filter.toArray());
+        // 遍历数据,将选中的行状态设置为废弃(3)
         for(DynamicObject bill : billDyns) {
             DynamicObjectCollection entryDyns = bill.getDynamicObjectCollection("nckd_entryentity");
             for(DynamicObject entry : entryDyns) {
@@ -79,6 +126,7 @@ public class SalAnnualIncomeBillList extends AbstractListPlugin implements Plugi
                 }
             }
         }
+        // 更新数据并刷新列表
         SwcConstant.AGENCYPAYBILL_ENTITY.update(billDyns);
         view.showSuccessNotification("废弃成功!");
         view.invokeOperation("refresh");

+ 42 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/utils/SwcUtils.java

@@ -3,11 +3,13 @@ package nckd.jxccl.swc.utils;
 import com.grapecity.documents.excel.H;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.utils.StringUtils;
 import kd.bos.orm.query.QCP;
 import kd.bos.orm.query.QFilter;
 import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
 import nckd.jxccl.swc.constants.SwcConstant;
 
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.ZoneId;
 import java.time.temporal.TemporalAdjusters;
@@ -62,4 +64,44 @@ public class SwcUtils {
     }
 
 
+    public static StringBuilder getSalaryDetailSql(List<Long> groupIds, Date startDate, Date endDate) {
+        String ids = String.join(",",groupIds.stream().map(String::valueOf).toArray(String[]::new));
+        String startDateStr = dateToStr(startDate);
+        String endDateStr = dateToStr(endDate);
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("/*dialect*/ SELECT a.fid groupId,\n" +
+                "       a.fname groupName,\n" +
+                "       b.forgid orgId,\n" +
+                "       d.fid employeeId,\n" +
+                "       d.fname empName,\n" +
+                "       d.fempnumber empNumber,\n" +
+                "       e.fnumber idCardNo,\n" +
+                "       count(distinct to_char(b1.fpaydate,'yyyy-MM')) monthCount,\n" +
+                "       sum(g.fcalamountvalue) amount\n" +
+                "from t_hsas_payrollgrp a\n" +
+                "left join t_hsas_calpayrolltask b on a.fid = b.fpayrollgroupid\n" +
+                "left join t_hsas_calpayrolltask_a b1 on b1.fid = b.fid\n" +
+                "left join t_hsas_calperson c on c.fcaltaskid = b.fid\n" +
+                "left join t_hrpi_employee d on d.fid = c.femployeeid\n" +
+                "left join t_hrpi_percre e on e.femployeeid = d.fid and e.fcredentialstypeid = '1010'\n" +
+                "left join t_hsas_caltable f on f.fcaltaskid = b.fid and f.fcalpersonid = c.fid\n" +
+                "left join t_hsas_caltableentry g on g.fid = f.fid\n" +
+                "left join t_hsbs_salaryitem h on h.fid = g.fsalaryitemid\n" +
+                "where 1 = 1\n" +
+                "  and a.fiscurrentversion = '1'\n" +
+                "  and h.fnumber = 'JT_283'\n");
+        sb.append("and b1.fpaydate >= '"+startDateStr+"'\n");
+        sb.append("and b1.fpaydate <= '"+endDateStr+"'\n");
+        sb.append("and a.fid in ("+ids+") \n");
+        sb.append("group by a.fid, b.forgid, a.fname, d.fid, d.fname, d.fempnumber, e.fnumber");
+
+        return sb;
+    }
+
+    public static String dateToStr(Date date) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.format(date);
+    }
+
 }