|
@@ -61,62 +61,62 @@ public class PersonReimSyncQuotaTaskOp extends AbstractOperationServicePlugIn {
|
|
|
}
|
|
|
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 = personReimQuotaHelper.getExpenseJobAmount(position.getPkValue(), jobLever.getPkValue());
|
|
|
- // 判断组织是否存在便变更,组织变更则作废原组织
|
|
|
- if(!org.getPkValue().equals(preOrg.getPkValue())){
|
|
|
- personReimQuotaHelper.doInvalidPersonReim(user.getLong(PersonReimSyncTaskConstant.ID),preOrg.getLong(PersonReimSyncTaskConstant.ID),null,null,year);
|
|
|
- }
|
|
|
-
|
|
|
- // 变更前岗位、职位为空,直接新增
|
|
|
- if(prePosition == null || preJobLever == null){
|
|
|
- personReimQuotaHelper.createPersonReimDirect(billInfo,currencyReimJobAmount);
|
|
|
- }else{
|
|
|
- Map<Long, Map<Long, BigDecimal>> sourceCurrencyReimJobAmount = personReimQuotaHelper.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 -> personReimQuotaHelper.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 -> personReimQuotaHelper.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();
|
|
|
- personReimQuotaHelper.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});
|
|
|
+//// 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 = personReimQuotaHelper.getExpenseJobAmount(position.getPkValue(), jobLever.getPkValue());
|
|
|
+//// // 判断组织是否存在便变更,组织变更则作废原组织
|
|
|
+//// if(!org.getPkValue().equals(preOrg.getPkValue())){
|
|
|
+//// personReimQuotaHelper.doInvalidPersonReim(user.getLong(PersonReimSyncTaskConstant.ID),preOrg.getLong(PersonReimSyncTaskConstant.ID),null,null,year);
|
|
|
+//// }
|
|
|
+////
|
|
|
+//// // 变更前岗位、职位为空,直接新增
|
|
|
+//// if(prePosition == null || preJobLever == null){
|
|
|
+//// personReimQuotaHelper.createPersonReimDirect(billInfo,currencyReimJobAmount);
|
|
|
+//// }else{
|
|
|
+//// Map<Long, Map<Long, BigDecimal>> sourceCurrencyReimJobAmount = personReimQuotaHelper.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 -> personReimQuotaHelper.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 -> personReimQuotaHelper.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();
|
|
|
+//// personReimQuotaHelper.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});
|
|
|
}
|
|
|
|
|
|
|