|
@@ -1,28 +1,16 @@
|
|
-package nckd.jimin.jyyy.fi.plugin.operate;
|
|
|
|
|
|
+package nckd.jimin.jyyy.fi.plugin.operate.Helper;
|
|
|
|
|
|
-import com.google.common.collect.Lists;
|
|
|
|
import kd.bos.context.RequestContext;
|
|
import kd.bos.context.RequestContext;
|
|
import kd.bos.dataentity.OperateOption;
|
|
import kd.bos.dataentity.OperateOption;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
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.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.exception.KDBizException;
|
|
-import kd.bos.logging.Log;
|
|
|
|
-import kd.bos.logging.LogFactory;
|
|
|
|
import kd.bos.org.utils.DynamicObjectUtils;
|
|
import kd.bos.org.utils.DynamicObjectUtils;
|
|
import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.bos.servicehelper.QueryServiceHelper;
|
|
import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.basedata.BaseDataServiceHelper;
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
import kd.fi.gl.util.BigDecimalUtil;
|
|
import kd.fi.gl.util.BigDecimalUtil;
|
|
@@ -35,88 +23,62 @@ import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
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);
|
|
|
|
- }
|
|
|
|
|
|
+public class PersonReimQuotaHelper {
|
|
|
|
+ /**
|
|
|
|
+ * 通过 费用项目与职级岗位关系配置 获取额度信息
|
|
|
|
+ * 按照币别分组,允许设置不同币别的方案
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Map<Long, Map<Long, BigDecimal>> getExpenseJobAmount(Object positionId , Object jobLeverId){
|
|
|
|
|
|
- @Override
|
|
|
|
- public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
|
|
- super.afterExecuteOperationTransaction(e);
|
|
|
|
- DynamicObject[] dataEntities = e.getDataEntities();
|
|
|
|
- String operationKey = e.getOperationKey();
|
|
|
|
|
|
+ StringJoiner joiner = new StringJoiner(",");
|
|
|
|
+ joiner.add(LimitRelasetConstant.KEY_NCKD_CURRENCY);
|
|
|
|
+ joiner.add(LimitRelasetConstant.KEY_NCKD_EXPENSEITEM);
|
|
|
|
+ joiner.add(LimitRelasetConstant.KEY_NCKD_AMOUNT);
|
|
|
|
|
|
- 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));
|
|
|
|
- }
|
|
|
|
|
|
+ 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)));
|
|
}
|
|
}
|
|
- 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();
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 作废条件范围内的个人额度信息
|
|
|
|
+ * @param userId
|
|
|
|
+ * @param companyId
|
|
|
|
+ * @param expenseItemId
|
|
|
|
+ * @param currencyId
|
|
|
|
+ */
|
|
|
|
+ public 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);
|
|
}
|
|
}
|
|
- SaveServiceHelper.save(new DynamicObject[]{billInfo});
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -124,7 +86,7 @@ public class PersonReimSyncTaskOp extends AbstractOperationServicePlugIn {
|
|
* @param billInfo
|
|
* @param billInfo
|
|
* @param currencyReimJobAmount
|
|
* @param currencyReimJobAmount
|
|
*/
|
|
*/
|
|
- protected void createPersonReimDirect(DynamicObject billInfo,Map<Long, Map<Long, BigDecimal>> currencyReimJobAmount){
|
|
|
|
|
|
+ public void createPersonReimDirect(DynamicObject billInfo,Map<Long, Map<Long, BigDecimal>> currencyReimJobAmount){
|
|
for(Map.Entry<Long, Map<Long, BigDecimal>> currencyRow : currencyReimJobAmount.entrySet()){
|
|
for(Map.Entry<Long, Map<Long, BigDecimal>> currencyRow : currencyReimJobAmount.entrySet()){
|
|
Long currencyId = currencyRow.getKey();
|
|
Long currencyId = currencyRow.getKey();
|
|
Map<Long, BigDecimal> expenseJobAmount = currencyRow.getValue();
|
|
Map<Long, BigDecimal> expenseJobAmount = currencyRow.getValue();
|
|
@@ -136,13 +98,18 @@ public class PersonReimSyncTaskOp extends AbstractOperationServicePlugIn {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- protected void createPersonReimByExpense(DynamicObject billInfo,Long currencyId,Long expenseItemId,BigDecimal amount){
|
|
|
|
- // 创建个人额度表
|
|
|
|
- DynamicObject personReim = createPersonReim(
|
|
|
|
|
|
+ public void createPersonReimByExpense(DynamicObject billInfo,Long currencyId,Long expenseItemId,BigDecimal amount){
|
|
|
|
+
|
|
|
|
+ PersonReimQuotaVO personReimQuotaVO = new PersonReimQuotaVO(
|
|
billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_USER).getLong(PersonReimSyncTaskConstant.ID),
|
|
billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_USER).getLong(PersonReimSyncTaskConstant.ID),
|
|
billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_ORG).getLong(PersonReimSyncTaskConstant.ID),
|
|
billInfo.getDynamicObject(PersonReimSyncTaskConstant.KEY_NCKD_ORG).getLong(PersonReimSyncTaskConstant.ID),
|
|
expenseItemId,
|
|
expenseItemId,
|
|
- currencyId,amount,billInfo);
|
|
|
|
|
|
+ currencyId,amount,
|
|
|
|
+ billInfo.getInt(PersonReimSyncTaskConstant.KEY_NCKD_YEAR),
|
|
|
|
+ billInfo.getInt(PersonReimSyncTaskConstant.KEY_NCKD_MONTH),
|
|
|
|
+ billInfo.getString(PersonReimSyncTaskConstant.ID));
|
|
|
|
+ // 创建个人额度表
|
|
|
|
+ DynamicObject personReim = createPersonReim(personReimQuotaVO,true);
|
|
// 调用审核
|
|
// 调用审核
|
|
OperationResult saveOp = OperationServiceHelper.executeOperate("save", BillTypeConstants.ER_REIMBURSEAMOUNT, new DynamicObject[]{personReim}, OperateOption.create());
|
|
OperationResult saveOp = OperationServiceHelper.executeOperate("save", BillTypeConstants.ER_REIMBURSEAMOUNT, new DynamicObject[]{personReim}, OperateOption.create());
|
|
if(!saveOp.isSuccess() || saveOp.getSuccessPkIds().size() == 0){
|
|
if(!saveOp.isSuccess() || saveOp.getSuccessPkIds().size() == 0){
|
|
@@ -154,68 +121,20 @@ public class PersonReimSyncTaskOp extends AbstractOperationServicePlugIn {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- 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
|
|
|
|
|
|
+ * @param quotaVO
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- protected DynamicObject createPersonReim(Long userId , Long companyId , Long expenseItemId ,Long currencyId,
|
|
|
|
- BigDecimal amount , DynamicObject billInfo){
|
|
|
|
-
|
|
|
|
- int year = billInfo.getInt(PersonReimSyncTaskConstant.KEY_NCKD_YEAR);
|
|
|
|
|
|
+ public DynamicObject createPersonReim(PersonReimQuotaVO quotaVO , boolean isAddnew){
|
|
|
|
|
|
- int month = billInfo.getInt(PersonReimSyncTaskConstant.KEY_NCKD_MONTH);
|
|
|
|
|
|
+ int year = quotaVO.getYear();
|
|
|
|
+ int month = quotaVO.getMonth();
|
|
|
|
+ BigDecimal amount = quotaVO.getAmount();
|
|
|
|
+ Long userId = quotaVO.getUserId();
|
|
|
|
+ Long companyId = quotaVO.getCompanyId();
|
|
|
|
+ Long expenseItemId = quotaVO.getExpenseItemId();
|
|
|
|
+ Long currencyId = quotaVO.getCurrencyId();
|
|
|
|
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
long currUserId = RequestContext.get().getCurrUserId();
|
|
long currUserId = RequestContext.get().getCurrUserId();
|
|
@@ -240,6 +159,11 @@ public class PersonReimSyncTaskOp extends AbstractOperationServicePlugIn {
|
|
personAmountBill.set("wbsrcbillid",oriPersonAmount.getPkValue());
|
|
personAmountBill.set("wbsrcbillid",oriPersonAmount.getPkValue());
|
|
setPersonAmountData(personAmountBill,amount,month);
|
|
setPersonAmountData(personAmountBill,amount,month);
|
|
}else{
|
|
}else{
|
|
|
|
+ // 无需新增时直接返回
|
|
|
|
+ if(!isAddnew){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
DynamicObject userInfo = BusinessDataServiceHelper.loadSingleFromCache(userId, "bos_user");
|
|
DynamicObject userInfo = BusinessDataServiceHelper.loadSingleFromCache(userId, "bos_user");
|
|
DynamicObject companyInfo = BusinessDataServiceHelper.loadSingleFromCache(companyId, "bos_org");
|
|
DynamicObject companyInfo = BusinessDataServiceHelper.loadSingleFromCache(companyId, "bos_org");
|
|
DynamicObject expenseItemInfo = BusinessDataServiceHelper.loadSingleFromCache(expenseItemId, "er_expenseitemedit");
|
|
DynamicObject expenseItemInfo = BusinessDataServiceHelper.loadSingleFromCache(expenseItemId, "er_expenseitemedit");
|
|
@@ -273,11 +197,37 @@ public class PersonReimSyncTaskOp extends AbstractOperationServicePlugIn {
|
|
|
|
|
|
// 岗位新增变动:positionchange ;年度复制:yearcopy ; 新增字段,与标准字段区分,防止与标品逻辑冲突
|
|
// 岗位新增变动:positionchange ;年度复制:yearcopy ; 新增字段,与标准字段区分,防止与标品逻辑冲突
|
|
personAmountBill.set("nckd_sourcetype","positionchange");
|
|
personAmountBill.set("nckd_sourcetype","positionchange");
|
|
- personAmountBill.set("nckd_sourcebillid",billInfo.getPkValue());
|
|
|
|
|
|
+ personAmountBill.set("nckd_sourcebillid",quotaVO.getSourcebillid());
|
|
|
|
|
|
return personAmountBill;
|
|
return personAmountBill;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void syncReimLever(Long userId ,Long companyId,Long jobId){
|
|
|
|
+
|
|
|
|
+ DynamicObject reimLever = getReimLever(jobId, companyId);
|
|
|
|
+ if(reimLever != null){
|
|
|
|
+ DynamicObject realReimSettingQuery = QueryServiceHelper.queryOne("er_reimbursesetting_rel", "id", new QFilter[]{
|
|
|
|
+ new QFilter("user", QCP.equals, userId),
|
|
|
|
+ new QFilter("company", QCP.equals, companyId)
|
|
|
|
+ });
|
|
|
|
+ // 存在则修改
|
|
|
|
+ if(realReimSettingQuery != null){
|
|
|
|
+ DynamicObject reimSettingInfo = BusinessDataServiceHelper.loadSingle(realReimSettingQuery.get("id"),"er_reimbursesetting_rel");
|
|
|
|
+ reimSettingInfo.set("reimburselevel",reimLever.get("id"));
|
|
|
|
+ SaveServiceHelper.save(new DynamicObject[]{ reimSettingInfo });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private DynamicObject getReimLever(Long jobId , Long companyId) {
|
|
|
|
+ // 查询差旅级别
|
|
|
|
+ List<QFilter> leverFilterList = new ArrayList<>();
|
|
|
|
+ // 基础资料标准过滤条件
|
|
|
|
+ leverFilterList.add(BaseDataServiceHelper.getBaseDataFilter("er_reimburselevel", companyId));
|
|
|
|
+ leverFilterList.add(new QFilter("enable", QCP.equals,"1"));
|
|
|
|
+ leverFilterList.add(new QFilter("nckd_joblevelhr.fbasedataid", QCP.equals,jobId));
|
|
|
|
+ return QueryServiceHelper.queryOne("er_reimburselevel", "id", leverFilterList.toArray(new QFilter[0]));
|
|
|
|
+ }
|
|
/**
|
|
/**
|
|
* 对个人额度表的额度字段赋值
|
|
* 对个人额度表的额度字段赋值
|
|
* @param personAmountBill 个人额度表
|
|
* @param personAmountBill 个人额度表
|
|
@@ -293,56 +243,4 @@ public class PersonReimSyncTaskOp extends AbstractOperationServicePlugIn {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
- 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)));
|
|
|
|
- }
|
|
|
|
}
|
|
}
|