Ver código fonte

feat(swc): 增加员工调薪申请单据构建与展示功能

- 在 BuildApplyBillOpPlugin 中增加日志记录支持
- 注释掉无效的 amount 和 salaryrank 字段赋值逻辑
- 优化调薪申请单据保存后的结果处理逻辑
- 增加对操作成功与否的判断及错误信息提示
- 提取并传递生成的申请单ID至前端界面
- 在 PendingSalaryAdjListPlugin 中实现申请单详情页跳转
- 新增对 applyID 参数的解析与单据打开逻辑
turborao 2 dias atrás
pai
commit
3d8951edb1

+ 13 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/init/plugin/form/PendingSalaryAdjListPlugin.java

@@ -1,6 +1,7 @@
 package nckd.jxccl.swc.init.plugin.form;
 
 import kd.bos.base.BaseShowParameter;
+import kd.bos.bill.BillShowParameter;
 import kd.bos.bill.OperationStatus;
 import kd.bos.dataentity.entity.DynamicObject;
 
@@ -9,6 +10,7 @@ import kd.bos.entity.MainEntityType;
 import kd.bos.entity.datamodel.ListSelectedRow;
 import kd.bos.entity.datamodel.ListSelectedRowCollection;
 import kd.bos.entity.datamodel.events.BizDataEventArgs;
+import kd.bos.entity.operate.result.OperationResult;
 import kd.bos.form.ShowType;
 import kd.bos.form.events.*;
 import kd.bos.form.operate.FormOperate;
@@ -96,6 +98,17 @@ public class PendingSalaryAdjListPlugin extends AbstractListPlugin implements Pl
         String key = formOperate.getOperateKey();
         switch (key) {
             case "apply_adj":
+                OperationResult ore =  args.getOperationResult();
+                Map<String, String> params = ore.getCustomData();
+                if(params != null && params.containsKey("applyID")){
+                    Long billid = Long.parseLong(params.get("applyID")) ;
+                    BillShowParameter billShowParameter = new BillShowParameter();
+                    billShowParameter.setFormId("hcdm_applybill");
+                    billShowParameter.setPkId(billid);//单据内码
+                    billShowParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
+                    billShowParameter.setStatus(OperationStatus.EDIT);
+                    this.getView().showForm(billShowParameter);
+                }
                 break;
             case "flag_adj":
                 break;

+ 42 - 4
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/init/plugin/operate/BuildApplyBillOpPlugin.java

@@ -7,11 +7,14 @@ import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 import kd.bos.entity.plugin.AddValidatorsEventArgs;
 import kd.bos.entity.plugin.PreparePropertysEventArgs;
 import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
 import kd.bos.orm.query.QCP;
 import kd.bos.orm.query.QFilter;
 import kd.bos.servicehelper.QueryServiceHelper;
 import kd.sdk.plugin.Plugin;
 import kd.sdk.swc.hcdm.business.helper.HCDMApplyBillServiceHelper;
+
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -23,6 +26,7 @@ import java.util.stream.Collectors;
  */
 public class BuildApplyBillOpPlugin extends AbstractOperationServicePlugIn implements Plugin {
 
+    private static final Log logger = LogFactory.getLog(BuildApplyBillOpPlugin.class);
     /**
      * 员工待定调薪清单  员工ID
      */
@@ -101,19 +105,53 @@ public class BuildApplyBillOpPlugin extends AbstractOperationServicePlugIn imple
             applyBillEntry.put("employee", employeeId);
             applyBillEntry.put("standarditem", 2321899710350111744L);    //定调薪项目   岗位工资标准
             applyBillEntry.put("frequency", 1095454108284088320L);       //频度  月
-            applyBillEntry.put("amount", BigDecimal.ZERO);
+            //applyBillEntry.put("amount", BigDecimal.ZERO);
             applyBillEntry.put("nckd_postgrade", salaryfile.getLong("position.nckd_postgrade.id"));  //岗级
             applyBillEntry.put("position", positionId);
-            applyBillEntry.put("salaryrank", data.getLong("nckd_newsalaryrank.id"));
+            //applyBillEntry.put("salaryrank", data.getLong("nckd_newsalaryrank.id"));
             applyBillEntryData.add(applyBillEntry);
         }
         applyBill.put("applybillent", applyBillEntryData);
         applyBillData.add(applyBill);
         papams.put("data", applyBillData);
+
+        Map<String, String> params = new HashMap<>();
         Map<String, Object> result = HCDMApplyBillServiceHelper.saveDraftApplyBill(papams);
         System.out.println("BuildApplyBillOpPlugin:"+result.toString());
-        ///返回界面的数据
-        //this.operationResult.setCustomData(result);
+        // 判断整体操作是否成功
+        Boolean overallSuccess = (Boolean) result.get("success");
+        String errorCode = (String) result.get("errorCode");
+        String errorMessage = (String) result.get("message");
+
+        if (overallSuccess != null && overallSuccess && "success".equals(errorCode)) {
+            // 提取数据部分
+            List<Map<String, Object>> dataList = (List<Map<String, Object>>) result.get("data");
+
+            if (dataList != null && !dataList.isEmpty()) {
+                Map<String, Object> dataMap = dataList.get(0);
+                // 安全地提取 id 值
+                Long idValue = ((Number) dataMap.get("id")).longValue();
+                System.out.println("提取的ID值为: " + idValue); // 输出 2360318043084569600
+                logger.info("员工待定调薪清单 操作成功," + idValue);
+                params.put("applyID",idValue.toString());
+                //区别:绿色提示语显示时间较短。红色一直存在。
+                this.operationResult.setSuccess(true);
+                ///返回界面的数据
+                this.operationResult.setCustomData(params);
+                // TODO: 可以在这里使用提取到的 idValue 进行后续操作
+            }
+        } else {
+            //区别:绿色提示语显示时间较短。红色一直存在。
+            this.operationResult.setSuccess(false);
+            //异常提示语
+            this.operationResult.setMessage("操作失败," + errorMessage);
+            logger.info("员工待定调薪清单 操作失败," + errorMessage);
+            //显示结果
+            this.operationResult.setShowMessage(true);
+            System.out.println("操作失败或返回错误码不为success");
+        }
+
+
 
         //OperationResult updatepersonOp = OperationServiceHelper.executeOperate("updatepersoninfo_and_match", "", new DynamicObject[]{change}, OperateOption.create());