|
@@ -0,0 +1,348 @@
|
|
|
|
+package nckd.jimin.jyyy.fi.plugin.operate;
|
|
|
|
+
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import kd.bos.context.RequestContext;
|
|
|
|
+import kd.bos.dataentity.OperateOption;
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
+import kd.bos.dataentity.utils.StringUtils;
|
|
|
|
+import kd.bos.db.tx.TX;
|
|
|
|
+import kd.bos.db.tx.TXHandle;
|
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
|
+import kd.bos.entity.operate.result.OperateErrorInfo;
|
|
|
|
+import kd.bos.entity.operate.result.OperationResult;
|
|
|
|
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
|
+import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
|
|
|
+import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
|
|
+import kd.bos.entity.validate.ErrorLevel;
|
|
|
|
+import kd.bos.exception.KDBizException;
|
|
|
|
+import kd.bos.logging.Log;
|
|
|
|
+import kd.bos.logging.LogFactory;
|
|
|
|
+import kd.bos.org.utils.DynamicObjectUtils;
|
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
+import kd.fi.gl.util.BigDecimalUtil;
|
|
|
|
+import nckd.jimin.jyyy.fi.common.constant.BillTypeConstants;
|
|
|
|
+import nckd.jimin.jyyy.fi.common.constant.LimitRelasetConstant;
|
|
|
|
+import nckd.jimin.jyyy.fi.common.constant.PersonReimSyncTaskConstant;
|
|
|
|
+import nckd.jimin.jyyy.fi.common.util.CommonUtils;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+public class PersonReimSyncTaskOp extends AbstractOperationServicePlugIn {
|
|
|
|
+ private static final Log logger = LogFactory.getLog(PersonReimSyncTaskOp.class);
|
|
|
|
+ @Override
|
|
|
|
+ public void onPreparePropertys(PreparePropertysEventArgs e) {
|
|
|
|
+ super.onPreparePropertys(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
|
|
+ super.afterExecuteOperationTransaction(e);
|
|
|
|
+ DynamicObject[] dataEntities = e.getDataEntities();
|
|
|
|
+ String operationKey = e.getOperationKey();
|
|
|
|
+
|
|
|
|
+ List<Object> billIdList = Arrays.stream(dataEntities).map(r -> r.get(PersonReimSyncTaskConstant.ID)).collect(Collectors.toList());
|
|
|
|
+ // 同步个人额度
|
|
|
|
+ if(PersonReimSyncTaskConstant.OPERATE.SYNCPERSONREIM.equals(operationKey)){
|
|
|
|
+ List<List<Object>> patchList = Lists.partition(billIdList, 50);
|
|
|
|
+ for(List<Object> patchBillList : patchList){
|
|
|
|
+ DynamicObject[] billDatas = BusinessDataServiceHelper.load(patchBillList.toArray(), EntityMetadataCache.getDataEntityType(PersonReimSyncTaskConstant.ENTITYID));
|
|
|
|
+ Arrays.stream(billDatas).forEach(r -> doSyncPersonReim(r));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ protected void doSyncPersonReim(DynamicObject billInfo){
|
|
|
|
+ // 校验数据是否合格
|
|
|
|
+ DynamicObject user = billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_USER);
|
|
|
|
+ DynamicObject org = billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_ORG);
|
|
|
|
+ DynamicObject preOrg = billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_ORG_PRE);
|
|
|
|
+ DynamicObject position = billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_POSITIONHR);
|
|
|
|
+ DynamicObject prePosition = billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_POSITIONHR_PRE);
|
|
|
|
+ DynamicObject jobLever = billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_JOBLEVELHR);
|
|
|
|
+ DynamicObject preJobLever = billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_JOBLEVELHR_PRE);
|
|
|
|
+
|
|
|
|
+ int year = billInfo.getInt(PersonReimSyncTaskConstant.KEY_NCKD_YEAR);
|
|
|
|
+ // 增加事务控制,如果发生异常,回滚生成的额度信息,保持数据一致
|
|
|
|
+ try(TXHandle h = TX.requiresNew(getClass().getName()+"doSyncPersonReim")){
|
|
|
|
+ try {
|
|
|
|
+ // 校验数据
|
|
|
|
+ checkData(billInfo);
|
|
|
|
+ // 获取总额度 费用项目、职级、岗位
|
|
|
|
+ Map<Long, Map<Long, BigDecimal>> currencyReimJobAmount = getExpenseJobAmount(position.getPkValue(), jobLever.getPkValue());
|
|
|
|
+ // 判断组织是否存在便变更,组织变更则作废原组织
|
|
|
|
+ if(!org.getPkValue().equals(preOrg.getPkValue())){
|
|
|
|
+ doInvalidPersonReim(user.getLong(PersonReimSyncTaskConstant.ID),preOrg.getLong(PersonReimSyncTaskConstant.ID),null,null,year);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 变更前岗位、职位为空,直接新增
|
|
|
|
+ if(prePosition == null || preJobLever == null){
|
|
|
|
+ createPersonReimDirect(billInfo,currencyReimJobAmount);
|
|
|
|
+ }else{
|
|
|
|
+ Map<Long, Map<Long, BigDecimal>> sourceCurrencyReimJobAmount = getExpenseJobAmount(prePosition.getPkValue(), preJobLever.getPkValue());
|
|
|
|
+ Set<Long> invalidCurrencySet = sourceCurrencyReimJobAmount.keySet().stream()
|
|
|
|
+ .filter(r -> !currencyReimJobAmount.keySet().contains(r)).collect(Collectors.toSet());
|
|
|
|
+ // 作废已删除的币别数据
|
|
|
|
+ logger.info(String.format("需要作废的币别ID为:" + StringUtils.join(",",invalidCurrencySet)));
|
|
|
|
+ invalidCurrencySet.forEach(r -> doInvalidPersonReim(user.getLong(PersonReimSyncTaskConstant.ID),org.getLong(PersonReimSyncTaskConstant.ID),null,r,year));
|
|
|
|
+ for(Map.Entry<Long, Map<Long, BigDecimal>> currencyRow : currencyReimJobAmount.entrySet()){
|
|
|
|
+ Long currencyId = currencyRow.getKey();
|
|
|
|
+ Map<Long, BigDecimal> expenseJobAmount = currencyRow.getValue();
|
|
|
|
+ if(sourceCurrencyReimJobAmount.containsKey(currencyId)){
|
|
|
|
+ Set<Long> invalidExpenseSet = sourceCurrencyReimJobAmount.get(currencyId).keySet().stream()
|
|
|
|
+ .filter(r -> !expenseJobAmount.keySet().contains(r)).collect(Collectors.toSet());
|
|
|
|
+ logger.info(String.format("需要作废的费用类型ID为:" + StringUtils.join(",",invalidExpenseSet)));
|
|
|
|
+ invalidExpenseSet.forEach(r -> doInvalidPersonReim(user.getLong(PersonReimSyncTaskConstant.ID),org.getLong(PersonReimSyncTaskConstant.ID),r,currencyId,year));
|
|
|
|
+ }
|
|
|
|
+ for(Map.Entry<Long, BigDecimal> dataRow : expenseJobAmount.entrySet()){
|
|
|
|
+ Long expenseItemId = dataRow.getKey();
|
|
|
|
+ BigDecimal amount = dataRow.getValue();
|
|
|
|
+ createPersonReimByExpense(billInfo,currencyId,expenseItemId,amount);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ addRecord(billInfo,"创建成功。",Boolean.TRUE);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ logger.error(String.format("单据%s同步额度失败",billInfo.getString(PersonReimSyncTaskConstant.KEY_NUMBER)),e);
|
|
|
|
+ String errorMsg = StringUtils.isEmpty(e.getMessage())?"同步额度时发生未知异常,请用traceid在monitor通过任务编码查看日志详情。":e.getMessage();
|
|
|
|
+ addRecord(billInfo,errorMsg,Boolean.FALSE);
|
|
|
|
+ h.markRollback();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ SaveServiceHelper.save(new DynamicObject[]{billInfo});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 直接创建个人额度信息
|
|
|
|
+ * @param billInfo
|
|
|
|
+ * @param currencyReimJobAmount
|
|
|
|
+ */
|
|
|
|
+ protected void createPersonReimDirect(DynamicObject billInfo,Map<Long, Map<Long, BigDecimal>> currencyReimJobAmount){
|
|
|
|
+ for(Map.Entry<Long, Map<Long, BigDecimal>> currencyRow : currencyReimJobAmount.entrySet()){
|
|
|
|
+ Long currencyId = currencyRow.getKey();
|
|
|
|
+ Map<Long, BigDecimal> expenseJobAmount = currencyRow.getValue();
|
|
|
|
+ for(Map.Entry<Long, BigDecimal> dataRow : expenseJobAmount.entrySet()){
|
|
|
|
+ Long expenseItemId = dataRow.getKey();
|
|
|
|
+ BigDecimal amount = dataRow.getValue();
|
|
|
|
+ createPersonReimByExpense(billInfo,currencyId,expenseItemId,amount);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected void createPersonReimByExpense(DynamicObject billInfo,Long currencyId,Long expenseItemId,BigDecimal amount){
|
|
|
|
+ // 创建个人额度表
|
|
|
|
+ DynamicObject personReim = createPersonReim(
|
|
|
|
+ billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_USER).getLong(PersonReimSyncTaskConstant.ID),
|
|
|
|
+ billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_ORG).getLong(PersonReimSyncTaskConstant.ID),
|
|
|
|
+ expenseItemId,
|
|
|
|
+ currencyId,amount,billInfo);
|
|
|
|
+ // 调用审核
|
|
|
|
+ OperationResult saveOp = OperationServiceHelper.executeOperate("save", BillTypeConstants.ER_REIMBURSEAMOUNT, new DynamicObject[]{personReim}, OperateOption.create());
|
|
|
|
+ if(!saveOp.isSuccess() || saveOp.getSuccessPkIds().size() == 0){
|
|
|
|
+ throw new KDBizException(CommonUtils.getOperationResultErrorInfos(saveOp));
|
|
|
|
+ }
|
|
|
|
+ OperationResult approveOp = OperationServiceHelper.executeOperate("approve", BillTypeConstants.ER_REIMBURSEAMOUNT, new Object[]{saveOp.getSuccessPkIds().get(0)}, OperateOption.create());
|
|
|
|
+ if(!approveOp.isSuccess() || approveOp.getSuccessPkIds().size() == 0){
|
|
|
|
+ throw new KDBizException(CommonUtils.getOperationResultErrorInfos(approveOp));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ protected void checkData(DynamicObject billInfo){
|
|
|
|
+ if(billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_USER) == null){
|
|
|
|
+ throw new KDBizException("同步人员不能为空。");
|
|
|
|
+ }
|
|
|
|
+ if(billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_ORG) == null){
|
|
|
|
+ throw new KDBizException("组织不能为空。");
|
|
|
|
+ }
|
|
|
|
+ if(billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_POSITIONHR) == null){
|
|
|
|
+ throw new KDBizException("岗位人员不能为空。");
|
|
|
|
+ }
|
|
|
|
+ if(billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_JOBLEVELHR) == null){
|
|
|
|
+ throw new KDBizException("职级不能为空。");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 作废条件范围内的个人额度信息
|
|
|
|
+ * @param userId
|
|
|
|
+ * @param companyId
|
|
|
|
+ * @param expenseItemId
|
|
|
|
+ * @param currencyId
|
|
|
|
+ */
|
|
|
|
+ protected void doInvalidPersonReim(Long userId , Long companyId , Long expenseItemId ,Long currencyId , int year){
|
|
|
|
+ // 作废币别下
|
|
|
|
+ List<QFilter> filterList = new ArrayList<>();
|
|
|
|
+ if(userId != null && userId == 0L){
|
|
|
|
+ filterList.add(new QFilter("employee.id", QCP.equals, userId));
|
|
|
|
+ if(companyId != null && companyId != 0L){
|
|
|
|
+ filterList.add(new QFilter("company.id", QCP.equals, companyId));
|
|
|
|
+ }
|
|
|
|
+ if(expenseItemId != null && expenseItemId != 0L){
|
|
|
|
+ filterList.add(new QFilter("expenseitem.id", QCP.equals, expenseItemId));
|
|
|
|
+ }
|
|
|
|
+ filterList.add(new QFilter("currency.id", QCP.equals, currencyId));
|
|
|
|
+ filterList.add(new QFilter("auditstatus", QCP.equals, "1"));
|
|
|
|
+ filterList.add(new QFilter("dateyear", QCP.equals, String.valueOf(year)));
|
|
|
|
+ DynamicObject[] invalidPersonReimArray = BusinessDataServiceHelper.load(BillTypeConstants.ER_REIMBURSEAMOUNT, "auditstatus", filterList.toArray(new QFilter[0]));
|
|
|
|
+ for(DynamicObject invalidPersonReim : invalidPersonReimArray){
|
|
|
|
+ invalidPersonReim.set("auditstatus","2");
|
|
|
|
+ }
|
|
|
|
+ SaveServiceHelper.save(invalidPersonReimArray);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取个人额度同步表 创建某个费用类型的个人额度
|
|
|
|
+ * @param userId
|
|
|
|
+ * @param companyId
|
|
|
|
+ * @param expenseItemId
|
|
|
|
+ * @param currencyId
|
|
|
|
+ * @param amount
|
|
|
|
+ * @param billInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ protected DynamicObject createPersonReim(Long userId , Long companyId , Long expenseItemId ,Long currencyId,
|
|
|
|
+ BigDecimal amount , DynamicObject billInfo){
|
|
|
|
+
|
|
|
|
+ int year = billInfo.getInt(PersonReimSyncTaskConstant.KEY_NCKD_YEAR);
|
|
|
|
+
|
|
|
|
+ int month = billInfo.getInt(PersonReimSyncTaskConstant.KEY_NCKD_MONTH);
|
|
|
|
+
|
|
|
|
+ Date now = new Date();
|
|
|
|
+ long currUserId = RequestContext.get().getCurrUserId();
|
|
|
|
+
|
|
|
|
+ // 已与实施确认,通过公司、费用类型、人员、币别、年度确认是否已经创建个人额度表;如果没有则新增,存在则修改
|
|
|
|
+ DynamicObject queryPersonAmount = QueryServiceHelper.queryOne(BillTypeConstants.ER_REIMBURSEAMOUNT, "id", new QFilter[]{
|
|
|
|
+ new QFilter("company.id", QCP.equals, companyId),
|
|
|
|
+ new QFilter("employee.id", QCP.equals, userId),
|
|
|
|
+ new QFilter("expenseitem.id", QCP.equals, expenseItemId),
|
|
|
|
+ new QFilter("currency.id", QCP.equals, currencyId),
|
|
|
|
+ new QFilter("auditstatus", QCP.equals, "1"),
|
|
|
|
+ new QFilter("dateyear", QCP.equals, String.valueOf(year))
|
|
|
|
+ });
|
|
|
|
+ DynamicObject personAmountBill = BusinessDataServiceHelper.newDynamicObject(BillTypeConstants.ER_REIMBURSEAMOUNT);
|
|
|
|
+ // 如果存在则从个人额度中复制
|
|
|
|
+ if(queryPersonAmount != null){
|
|
|
|
+ DynamicObject oriPersonAmount = BusinessDataServiceHelper.loadSingle(queryPersonAmount.get("id"), BillTypeConstants.ER_REIMBURSEAMOUNT);
|
|
|
|
+ Set<String> ignoreSet = new HashSet<>(Arrays.asList("id"));
|
|
|
|
+ DynamicObjectUtils.copy(oriPersonAmount,personAmountBill);
|
|
|
|
+ // 标准字段
|
|
|
|
+ personAmountBill.set("wbsrcbilltype","er_reimctl_modify");
|
|
|
|
+ personAmountBill.set("wbsrcbillid",oriPersonAmount.getPkValue());
|
|
|
|
+ setPersonAmountData(personAmountBill,amount,month);
|
|
|
|
+ }else{
|
|
|
|
+ DynamicObject userInfo = BusinessDataServiceHelper.loadSingleFromCache(userId, "bos_user");
|
|
|
|
+ DynamicObject companyInfo = BusinessDataServiceHelper.loadSingleFromCache(companyId, "bos_org");
|
|
|
|
+ DynamicObject expenseItemInfo = BusinessDataServiceHelper.loadSingleFromCache(expenseItemId, "er_expenseitemedit");
|
|
|
|
+ DynamicObject currencyInfo = BusinessDataServiceHelper.loadSingleFromCache(currencyId, "bd_currency");
|
|
|
|
+
|
|
|
|
+ personAmountBill.set("company", companyInfo);
|
|
|
|
+ personAmountBill.set("expenseitem", expenseItemInfo);
|
|
|
|
+ personAmountBill.set("currency", currencyInfo);
|
|
|
|
+ personAmountBill.set("dateyear", String.valueOf(year));
|
|
|
|
+ personAmountBill.set("costcompany", companyId);
|
|
|
|
+
|
|
|
|
+ personAmountBill.set("amounttype", "1");
|
|
|
|
+ personAmountBill.set("employee", userInfo);
|
|
|
|
+ //personAmountBill.set("dept", reimburseQuota.get("dept.id"));
|
|
|
|
+ personAmountBill.set("auditstatus", "0");
|
|
|
|
+ personAmountBill.set("createtime", now);
|
|
|
|
+ personAmountBill.set("modifytime", now);
|
|
|
|
+ personAmountBill.set("creator", currUserId);
|
|
|
|
+ personAmountBill.set("modifier", currUserId);
|
|
|
|
+ personAmountBill.set("wbsrcbilltype", "er_reimctl_new");
|
|
|
|
+ setPersonAmountData(personAmountBill,amount,1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
|
+ // 计算年总额度
|
|
|
|
+ for(int i = 1; i <= 12; i++) {
|
|
|
|
+ totalAmount = BigDecimalUtil.add(totalAmount,personAmountBill.getBigDecimal("month" + i));
|
|
|
|
+ }
|
|
|
|
+ personAmountBill.set("totalamount", totalAmount);
|
|
|
|
+ personAmountBill.set("auditstatus", "0");
|
|
|
|
+
|
|
|
|
+ // 岗位新增变动:positionchange ;年度复制:yearcopy ; 新增字段,与标准字段区分,防止与标品逻辑冲突
|
|
|
|
+ personAmountBill.set("nckd_sourcetype","positionchange");
|
|
|
|
+ personAmountBill.set("nckd_sourcebillid",billInfo.getPkValue());
|
|
|
|
+
|
|
|
|
+ return personAmountBill;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 对个人额度表的额度字段赋值
|
|
|
|
+ * @param personAmountBill 个人额度表
|
|
|
|
+ * @param amount 额度
|
|
|
|
+ * @param startMonth 开始月份,新单则从0开始,非新单则从指定月份开始
|
|
|
|
+ */
|
|
|
|
+ protected void setPersonAmountData(DynamicObject personAmountBill , BigDecimal amount , int startMonth){
|
|
|
|
+
|
|
|
|
+ for(int i = startMonth; i <= 12; i++) {
|
|
|
|
+
|
|
|
|
+ personAmountBill.set("month" + i, amount);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ protected void addRecord(DynamicObject billInfo , String successMsg , Boolean isSuccess){
|
|
|
|
+ DynamicObjectCollection recordEntryCol = billInfo.getDynamicObjectCollection(PersonReimSyncTaskConstant.NCKD_RECORDENTRY.ENTITYID);
|
|
|
|
+ DynamicObject record = recordEntryCol.addNew();
|
|
|
|
+ record.set(PersonReimSyncTaskConstant.NCKD_RECORDENTRY.KEY_NCKD_SYNC_DATE,new Date());
|
|
|
|
+ record.set(PersonReimSyncTaskConstant.NCKD_RECORDENTRY.KEY_NCKD_TRACEID, RequestContext.get().getTraceId());
|
|
|
|
+ record.set(PersonReimSyncTaskConstant.NCKD_RECORDENTRY.KEY_NCKD_SYNC_ISSUCCESS,isSuccess?1:0);
|
|
|
|
+ record.set(PersonReimSyncTaskConstant.NCKD_RECORDENTRY.KEY_NCKD_SYNC_MSG, StringUtils.substring(successMsg,0,500));
|
|
|
|
+
|
|
|
|
+ billInfo.set(PersonReimSyncTaskConstant.KEY_NCKD_SYNCSTATUS,isSuccess?"40":"30");
|
|
|
|
+
|
|
|
|
+ if(!isSuccess){
|
|
|
|
+ OperationResult operationResult = this.getOperationResult();
|
|
|
|
+ operationResult.setSuccess(false);
|
|
|
|
+ operationResult.getSuccessPkIds().removeIf(r -> billInfo.getPkValue().equals(r));
|
|
|
|
+ OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
|
|
|
|
+ operateErrorInfo.setMessage(successMsg);
|
|
|
|
+ operateErrorInfo.setLevel(ErrorLevel.Error);
|
|
|
|
+ operationResult.addErrorInfo(operateErrorInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过 费用项目与职级岗位关系配置 获取额度信息
|
|
|
|
+ * 按照币别分组,允许设置不同币别的方案
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ protected Map<Long, Map<Long, BigDecimal>> getExpenseJobAmount(Object positionId , Object jobLeverId){
|
|
|
|
+
|
|
|
|
+ StringJoiner joiner = new StringJoiner(",");
|
|
|
|
+ joiner.add(LimitRelasetConstant.KEY_NCKD_CURRENCY);
|
|
|
|
+ joiner.add(LimitRelasetConstant.KEY_NCKD_EXPENSEITEM);
|
|
|
|
+ joiner.add(LimitRelasetConstant.KEY_NCKD_AMOUNT);
|
|
|
|
+
|
|
|
|
+ DynamicObject[] limitRelasetArray = BusinessDataServiceHelper.load(LimitRelasetConstant.ENTITYID, joiner.toString(), new QFilter[]{
|
|
|
|
+ new QFilter(LimitRelasetConstant.KEY_NCKD_POSITIONHR, QCP.equals, positionId),
|
|
|
|
+ new QFilter(LimitRelasetConstant.KEY_NCKD_JOBLEVELHR, QCP.equals, jobLeverId),
|
|
|
|
+ new QFilter(LimitRelasetConstant.KEY_ENABLE, QCP.equals, "1"),
|
|
|
|
+ new QFilter(LimitRelasetConstant.KEY_STATUS, QCP.equals, "C")
|
|
|
|
+ });
|
|
|
|
+ if(limitRelasetArray == null || limitRelasetArray.length == 0){
|
|
|
|
+ return new HashMap<>();
|
|
|
|
+ }
|
|
|
|
+ return Arrays.stream(limitRelasetArray)
|
|
|
|
+ .filter(r -> r.getDynamicObject(LimitRelasetConstant.KEY_NCKD_EXPENSEITEM) != null)
|
|
|
|
+ .collect(Collectors.groupingBy(r -> r.getDynamicObject(LimitRelasetConstant.KEY_NCKD_CURRENCY).getLong(PersonReimSyncTaskConstant.ID),
|
|
|
|
+ Collectors.toMap(r -> r.getDynamicObject(LimitRelasetConstant.KEY_NCKD_EXPENSEITEM).getLong(PersonReimSyncTaskConstant.ID),
|
|
|
|
+ r -> r.getBigDecimal(LimitRelasetConstant.KEY_NCKD_AMOUNT), (a, b) -> a)));
|
|
|
|
+ }
|
|
|
|
+}
|