|
@@ -226,6 +226,8 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
return financialExpenditures;
|
|
|
}
|
|
|
|
|
|
+ //需要处理的oa模板id
|
|
|
+ Set<Integer> processValuesToCheck = new HashSet<>(Arrays.asList(33, 22, 19, 51, 28));
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -251,17 +253,14 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
realName = simpleUser.getRealName();
|
|
|
}
|
|
|
}
|
|
|
+ //获取模板
|
|
|
String formStructure = financialExpenditureDao.getFormStructure(workOrderId);
|
|
|
+ //获取用户填写的表单
|
|
|
JSONObject formData = JSONObject.parseObject(financialExpenditureDao.getFormData(workOrderId));
|
|
|
OaFormStructureDto oaFormStructureDto = JSONObject.parseObject(formStructure, OaFormStructureDto.class);
|
|
|
List<OaInputDto> oaInputDtos = oaFormStructureDto.getList();
|
|
|
//课程退费和乐团退费需要单独处理
|
|
|
- if(pWorkOrderInfo.getProcess().equals(33) ||
|
|
|
- pWorkOrderInfo.getProcess().equals(22) ||
|
|
|
- pWorkOrderInfo.getProcess().equals(19) ||
|
|
|
- pWorkOrderInfo.getProcess().equals(51) ||
|
|
|
- pWorkOrderInfo.getProcess().equals(28)
|
|
|
- ){
|
|
|
+ if(processValuesToCheck.contains(pWorkOrderInfo.getProcess())){
|
|
|
List<FinancialExpenditure> financialExpenditureList = new ArrayList<>();
|
|
|
Integer organId = null;
|
|
|
String note = "";
|
|
@@ -353,56 +352,10 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
financialExpenditure.setApplyUserId(pWorkOrderInfo.getCreator());
|
|
|
financialExpenditure.setProcessId(pWorkOrderInfo.getProcess());
|
|
|
financialExpenditure.setEffectiveTime(DateUtil.format(endTime,DateUtil.ISO_YEAR_MONTH_FORMAT));
|
|
|
- List<OaColumnDto> columns = oaInputDto.getColumns();
|
|
|
- if (columns != null && columns.size() > 0) {
|
|
|
- for (OaColumnDto column : columns) {
|
|
|
- List<OaInputDto> columnList = column.getList();
|
|
|
- if (columnList != null && columnList.size() > 0) {
|
|
|
- for (OaInputDto inputDto : columnList) {
|
|
|
- String name = inputDto.getName();
|
|
|
- Object o = hashMap.get(inputDto.getModel());
|
|
|
- if (Objects.isNull(o) || StringUtils.isEmpty(o.toString())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (StringUtils.equals(name,"课程组编号")) {
|
|
|
- financialExpenditure.setVipGroupId(Long.parseLong(o.toString()));
|
|
|
- } else if (StringUtils.equals(name,"课程类型")) {
|
|
|
- financialExpenditure.setGroupType(o.toString());
|
|
|
- } else if (StringUtils.equals(name,"乐团编号")) {
|
|
|
- financialExpenditure.setMusicGroupId(o.toString());
|
|
|
- } else if (StringUtils.equals(name,"退费项目")) {
|
|
|
- financialExpenditure.setReturnFeeType(o.toString());
|
|
|
- } else if (StringUtils.equals(name,"学员编号")) {
|
|
|
- financialExpenditure.setStudentId(Integer.parseInt(o.toString()));
|
|
|
- } else if (StringUtils.equals(name,"分部")) {
|
|
|
- Organization organization = organizationDao.get(Integer.parseInt(o.toString()));
|
|
|
- if (organization != null) {
|
|
|
- financialExpenditure.setOrganId(organization.getId());
|
|
|
- financialExpenditure.setOrganName(organization.getName());
|
|
|
- }
|
|
|
- } else if (StringUtils.equals(name,"学校")) {
|
|
|
- financialExpenditure.setCooperationOrganId(Integer.parseInt(o.toString()));
|
|
|
- } else if (StringUtils.contains(name,"金额")) {
|
|
|
- financialExpenditure.setAmount(financialExpenditure.getAmount().add(new BigDecimal(Double.parseDouble(o.toString()))));
|
|
|
- financialExpenditure.setCurrentAmount(financialExpenditure.getAmount());
|
|
|
- } else if (StringUtils.equals(name,"情况说明") || StringUtils.equals(name,"事由")) {
|
|
|
- financialExpenditure.setCause(o.toString());
|
|
|
- }else if (StringUtils.equals(name,"费用类型") || StringUtils.equals(name,"费用类别")) {
|
|
|
- FeeProjectEnum projectEnum = FeeProjectEnum.valueOfDesc(o.toString());
|
|
|
- if(projectEnum == null){
|
|
|
- projectEnum = feeProjectEnum;
|
|
|
- }
|
|
|
- financialExpenditure.setFeeProject(projectEnum);
|
|
|
- financialExpenditure.setType(getExpenditureType(projectEnum));
|
|
|
- }else if (StringUtils.equals(name,"日期") || StringUtils.equals(name,"费用发生日期")) {
|
|
|
- financialExpenditure.setPaymentTime(DateUtil.stringToDate(o.toString(),DateUtil.DEFAULT_PATTERN));
|
|
|
- } else if (StringUtils.equals(name,"费用分摊月份")) {
|
|
|
- financialExpenditure.setEffectiveTime(o.toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ financialExpenditure.setFeeProject(feeProjectEnum);
|
|
|
+ financialExpenditure.setType(getExpenditureType(feeProjectEnum));
|
|
|
+ //解析用户录入
|
|
|
+ this.setFinancialExpenditure(oaInputDto,hashMap,financialExpenditure);
|
|
|
if(StringUtils.isEmpty(financialExpenditure.getMusicGroupId()) || financialExpenditure.getStudentId() == null){
|
|
|
continue ;
|
|
|
}
|
|
@@ -416,83 +369,11 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //课程退费
|
|
|
- if(pWorkOrderInfo.getProcess().equals(22)){
|
|
|
- for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
- ReturnFeeDto returnFeeDto = new ReturnFeeDto();
|
|
|
- returnFeeDto.setGroupType(GroupType.valueOfDesc(financialExpenditure.getGroupType()));
|
|
|
- returnFeeDto.setAmount(financialExpenditure.getAmount());
|
|
|
- returnFeeDto.setStudentId(financialExpenditure.getStudentId());
|
|
|
- returnFeeDto.setConfirmReturnActivityGive(true);
|
|
|
- returnFeeDto.setGroupId(financialExpenditure.getVipGroupId());
|
|
|
- returnFeeDto.setVipGroupId(financialExpenditure.getVipGroupId());
|
|
|
- if(returnFeeDto.getGroupType() == GroupType.VIP || returnFeeDto.getGroupType() == GroupType.LIVE){
|
|
|
- vipGroupService.applyRefundForStudentOa(returnFeeDto);
|
|
|
- }else if(returnFeeDto.getGroupType() == GroupType.COMM || returnFeeDto.getGroupType() == GroupType.PRACTICE){
|
|
|
- groupClassService.cancelGroupOa(returnFeeDto);
|
|
|
- }
|
|
|
- }
|
|
|
- }else if(pWorkOrderInfo.getProcess().equals(33) || pWorkOrderInfo.getProcess().equals(19)){
|
|
|
- //退团
|
|
|
- for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
- String returnFeeType = financialExpenditure.getReturnFeeType();
|
|
|
- if(StringUtils.isNotEmpty(returnFeeType)){
|
|
|
- if(returnFeeType.contains("乐器")){
|
|
|
- financialExpenditure.setRefundInstrumentFeeFlag(true);
|
|
|
- }
|
|
|
- if(returnFeeType.contains("乐保")){
|
|
|
- financialExpenditure.setMaintenanceFeeFlag(true);
|
|
|
- }
|
|
|
- if(returnFeeType.contains("教辅")){
|
|
|
- financialExpenditure.setRefundTeachingAssistantsFeeFlag(true);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //处理excel文件
|
|
|
- List<FinancialExpenditure> financialExpenditures = new ArrayList<>();
|
|
|
- if(StringUtils.isNotEmpty(fileUrl)){
|
|
|
- String[] split = fileUrl.split(",");
|
|
|
- for (String s : split) {
|
|
|
- URL url = new URL(s);
|
|
|
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
|
- conn.setConnectTimeout(3*1000);
|
|
|
- File file = File.createTempFile(UUID.randomUUID().toString(), ".xls");
|
|
|
- FileUtils.copyInputStreamToFile(conn.getInputStream(),file);
|
|
|
- byte[] bytes = FileUtils.readFileToByteArray(file);
|
|
|
- String fileName = file.getName();
|
|
|
- //删除临时文件
|
|
|
- if (file.exists()) {
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- financialExpenditures.addAll(financialExpenditureService.checkOaQuitMusicGroupExcel(bytes, fileName));
|
|
|
- }
|
|
|
- //去除重复数据
|
|
|
- financialExpenditures.removeAll(Collections.singleton(null));
|
|
|
- if(CollectionUtils.isNotEmpty(financialExpenditureList)){
|
|
|
- for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
- if(financialExpenditures.contains(financialExpenditure)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- financialExpenditures.add(financialExpenditure);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(CollectionUtils.isNotEmpty(financialExpenditures)){
|
|
|
- for (FinancialExpenditure financialExpenditure : financialExpenditures) {
|
|
|
- financialExpenditure.setAprovalTime(endTime);
|
|
|
- financialExpenditure.setPaymentTime(endTime);
|
|
|
- financialExpenditure.setEffectiveTime(DateUtil.format(endTime,DateUtil.ISO_YEAR_MONTH_FORMAT));
|
|
|
- financialExpenditure.setApplyUser(realName);
|
|
|
- financialExpenditure.setFeeProject(FeeProjectEnum.REFUND);
|
|
|
- financialExpenditure.setType(getExpenditureType(financialExpenditure.getFeeProject()));
|
|
|
- financialExpenditure.setBatchNo(pWorkOrderInfo.getId().toString());
|
|
|
- financialExpenditure.setFinancialProcessNo(pWorkOrderInfo.getId().toString());
|
|
|
- }
|
|
|
- financialExpenditureList = financialExpenditures;
|
|
|
- }
|
|
|
- for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
- musicGroupService.directQuitMusicGroupOa(financialExpenditure);
|
|
|
- }
|
|
|
+ //处理业务退费(vip退学、乐团退费.....)
|
|
|
+ this.processBusinessReturns(pWorkOrderInfo,financialExpenditureList,realName,fileUrl);
|
|
|
+ if(CollectionUtils.isEmpty(financialExpenditureList)){
|
|
|
+ businessLogger.info("oa业务流程处理失败,请检查");
|
|
|
+ return;
|
|
|
}
|
|
|
financialExpenditureDao.batchInsert(financialExpenditureList);
|
|
|
}else {
|
|
@@ -517,14 +398,17 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
if(Objects.isNull(o) || StringUtils.isEmpty(o.toString())){
|
|
|
continue;
|
|
|
}
|
|
|
- if(StringUtils.equals(name,"金额")){
|
|
|
+ if(StringUtils.contains(name,"金额")){
|
|
|
financialExpenditure.setAmount(new BigDecimal(Double.parseDouble(o.toString())));
|
|
|
financialExpenditure.setCurrentAmount(financialExpenditure.getAmount());
|
|
|
}else if(StringUtils.equals(name,"情况说明")){
|
|
|
financialExpenditure.setCause(o.toString());
|
|
|
}else if(StringUtils.equals(name,"费用类型") || StringUtils.equals(name,"费用类别")){
|
|
|
- financialExpenditure.setFeeProject(FeeProjectEnum.valueOfDesc(o.toString()));
|
|
|
- financialExpenditure.setType(getExpenditureType(financialExpenditure.getFeeProject()));
|
|
|
+ FeeProjectEnum feeProjectEnum = FeeProjectEnum.valueOfDesc(o.toString());
|
|
|
+ if(feeProjectEnum != null){
|
|
|
+ financialExpenditure.setFeeProject(feeProjectEnum);
|
|
|
+ financialExpenditure.setType(getExpenditureType(financialExpenditure.getFeeProject()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
financialExpenditureDao.insert(financialExpenditure);
|
|
@@ -532,6 +416,153 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void setFinancialExpenditure(OaInputDto oaInputDto,HashMap hashMap,FinancialExpenditure financialExpenditure){
|
|
|
+ List<OaColumnDto> columns = oaInputDto.getColumns();
|
|
|
+ if (columns != null && columns.size() > 0) {
|
|
|
+ for (OaColumnDto column : columns) {
|
|
|
+ List<OaInputDto> columnList = column.getList();
|
|
|
+ if (columnList != null && columnList.size() > 0) {
|
|
|
+ //比对模板、获取用户录入
|
|
|
+ for (OaInputDto inputDto : columnList) {
|
|
|
+ String name = inputDto.getName();
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if (Objects.isNull(o) || StringUtils.isEmpty(o.toString())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (StringUtils.equals(name,"课程组编号")) {
|
|
|
+ financialExpenditure.setVipGroupId(Long.parseLong(o.toString()));
|
|
|
+ } else if (StringUtils.equals(name,"课程类型")) {
|
|
|
+ financialExpenditure.setGroupType(o.toString());
|
|
|
+ } else if (StringUtils.equals(name,"乐团编号")) {
|
|
|
+ financialExpenditure.setMusicGroupId(o.toString());
|
|
|
+ } else if (StringUtils.equals(name,"退费项目")) {
|
|
|
+ financialExpenditure.setReturnFeeType(o.toString());
|
|
|
+ } else if (StringUtils.equals(name,"学员编号")) {
|
|
|
+ financialExpenditure.setStudentId(Integer.parseInt(o.toString()));
|
|
|
+ } else if (StringUtils.equals(name,"分部")) {
|
|
|
+ Organization organization = organizationDao.get(Integer.parseInt(o.toString()));
|
|
|
+ if (organization != null) {
|
|
|
+ financialExpenditure.setOrganId(organization.getId());
|
|
|
+ financialExpenditure.setOrganName(organization.getName());
|
|
|
+ }
|
|
|
+ } else if (StringUtils.equals(name,"学校")) {
|
|
|
+ financialExpenditure.setCooperationOrganId(Integer.parseInt(o.toString()));
|
|
|
+ } else if (StringUtils.contains(name,"金额")) {
|
|
|
+ financialExpenditure.setAmount(financialExpenditure.getAmount().add(new BigDecimal(Double.parseDouble(o.toString()))));
|
|
|
+ financialExpenditure.setCurrentAmount(financialExpenditure.getAmount());
|
|
|
+ } else if (StringUtils.equals(name,"情况说明") || StringUtils.equals(name,"事由")) {
|
|
|
+ financialExpenditure.setCause(o.toString());
|
|
|
+ }else if (StringUtils.equals(name,"费用类型") || StringUtils.equals(name,"费用类别")) {
|
|
|
+ FeeProjectEnum projectEnum = FeeProjectEnum.valueOfDesc(o.toString());
|
|
|
+ if(projectEnum != null){
|
|
|
+ financialExpenditure.setFeeProject(projectEnum);
|
|
|
+ financialExpenditure.setType(getExpenditureType(projectEnum));
|
|
|
+ }
|
|
|
+ }else if (StringUtils.equals(name,"日期") || StringUtils.equals(name,"费用发生日期")) {
|
|
|
+ financialExpenditure.setPaymentTime(DateUtil.stringToDate(o.toString(),DateUtil.DEFAULT_PATTERN));
|
|
|
+ } else if (StringUtils.equals(name,"费用分摊月份")) {
|
|
|
+ financialExpenditure.setEffectiveTime(o.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理业务退费
|
|
|
+ private void processBusinessReturns(PWorkOrderInfo pWorkOrderInfo,List<FinancialExpenditure> financialExpenditureList,
|
|
|
+ String realName,String fileUrl) throws Exception {
|
|
|
+ //课程退费
|
|
|
+ if(pWorkOrderInfo.getProcess().equals(22)){
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
+ ReturnFeeDto returnFeeDto = new ReturnFeeDto();
|
|
|
+ returnFeeDto.setGroupType(GroupType.valueOfDesc(financialExpenditure.getGroupType()));
|
|
|
+ returnFeeDto.setAmount(financialExpenditure.getAmount());
|
|
|
+ returnFeeDto.setStudentId(financialExpenditure.getStudentId());
|
|
|
+ returnFeeDto.setConfirmReturnActivityGive(true);
|
|
|
+ returnFeeDto.setGroupId(financialExpenditure.getVipGroupId());
|
|
|
+ returnFeeDto.setVipGroupId(financialExpenditure.getVipGroupId());
|
|
|
+ if(returnFeeDto.getGroupType() == GroupType.VIP || returnFeeDto.getGroupType() == GroupType.LIVE){
|
|
|
+ vipGroupService.applyRefundForStudentOa(returnFeeDto);
|
|
|
+ }else if(returnFeeDto.getGroupType() == GroupType.COMM || returnFeeDto.getGroupType() == GroupType.PRACTICE){
|
|
|
+ groupClassService.cancelGroupOa(returnFeeDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(pWorkOrderInfo.getProcess().equals(33) || pWorkOrderInfo.getProcess().equals(19)){
|
|
|
+ //处理学员乐团退费项目
|
|
|
+ this.processRefundItem(financialExpenditureList);
|
|
|
+ //处理excel文件
|
|
|
+ List<FinancialExpenditure> financialExpenditures = this.processExcelFile(fileUrl, financialExpenditureList);
|
|
|
+ if(CollectionUtils.isNotEmpty(financialExpenditures)){
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditures) {
|
|
|
+ financialExpenditure.setAprovalTime(pWorkOrderInfo.getUpdateTime());
|
|
|
+ financialExpenditure.setPaymentTime(pWorkOrderInfo.getUpdateTime());
|
|
|
+ financialExpenditure.setEffectiveTime(DateUtil.format(pWorkOrderInfo.getUpdateTime(),DateUtil.ISO_YEAR_MONTH_FORMAT));
|
|
|
+ financialExpenditure.setApplyUser(realName);
|
|
|
+ financialExpenditure.setFeeProject(FeeProjectEnum.REFUND);
|
|
|
+ financialExpenditure.setType(getExpenditureType(financialExpenditure.getFeeProject()));
|
|
|
+ financialExpenditure.setBatchNo(pWorkOrderInfo.getId().toString());
|
|
|
+ financialExpenditure.setFinancialProcessNo(pWorkOrderInfo.getId().toString());
|
|
|
+ }
|
|
|
+ financialExpenditureList = financialExpenditures;
|
|
|
+ }
|
|
|
+ //批量处理oa审批退团逻辑
|
|
|
+ financialExpenditureList.stream().forEach(e->musicGroupService.directQuitMusicGroupOa(e));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理学员乐团退费项目
|
|
|
+ private void processRefundItem(List<FinancialExpenditure> financialExpenditureList){
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
+ String returnFeeType = financialExpenditure.getReturnFeeType();
|
|
|
+ if(StringUtils.isNotEmpty(returnFeeType)){
|
|
|
+ if(returnFeeType.contains("乐器")){
|
|
|
+ financialExpenditure.setRefundInstrumentFeeFlag(true);
|
|
|
+ }
|
|
|
+ if(returnFeeType.contains("乐保")){
|
|
|
+ financialExpenditure.setMaintenanceFeeFlag(true);
|
|
|
+ }
|
|
|
+ if(returnFeeType.contains("教辅")){
|
|
|
+ financialExpenditure.setRefundTeachingAssistantsFeeFlag(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理excel文件
|
|
|
+ private List<FinancialExpenditure> processExcelFile(String fileUrl, List<FinancialExpenditure> financialExpenditureList) throws Exception {
|
|
|
+ List<FinancialExpenditure> financialExpenditures = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotEmpty(fileUrl)){
|
|
|
+ String[] split = fileUrl.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ URL url = new URL(s);
|
|
|
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
|
+ conn.setConnectTimeout(3*1000);
|
|
|
+ File file = File.createTempFile(UUID.randomUUID().toString(), ".xls");
|
|
|
+ FileUtils.copyInputStreamToFile(conn.getInputStream(),file);
|
|
|
+ byte[] bytes = FileUtils.readFileToByteArray(file);
|
|
|
+ String fileName = file.getName();
|
|
|
+ //删除临时文件
|
|
|
+ if (file.exists()) {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ financialExpenditures.addAll(financialExpenditureService.checkOaQuitMusicGroupExcel(bytes, fileName));
|
|
|
+ }
|
|
|
+ //去除重复数据
|
|
|
+ financialExpenditures.removeAll(Collections.singleton(null));
|
|
|
+ if(CollectionUtils.isNotEmpty(financialExpenditureList)){
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
+ if(financialExpenditures.contains(financialExpenditure)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ financialExpenditures.add(financialExpenditure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return financialExpenditures;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static ExpenditureTypeEnum getExpenditureType(FeeProjectEnum feeProjectEnum) {
|
|
|
switch (feeProjectEnum) {
|
|
|
case REFUND:
|