|
@@ -1,10 +1,7 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
|
|
|
-import com.alibaba.druid.sql.visitor.functions.If;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.ym.mec.auth.api.entity.SysUserDevice;
|
|
|
import com.ym.mec.biz.dal.dao.EmployeeDao;
|
|
|
import com.ym.mec.biz.dal.dao.FinancialExpenditureDao;
|
|
|
import com.ym.mec.biz.dal.dao.OrganizationDao;
|
|
@@ -12,21 +9,26 @@ import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.entity.Employee;
|
|
|
import com.ym.mec.biz.dal.entity.FinancialExpenditure;
|
|
|
import com.ym.mec.biz.dal.entity.Organization;
|
|
|
-import com.ym.mec.biz.dal.enums.*;
|
|
|
+import com.ym.mec.biz.dal.enums.ExpenditureTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.FeeProjectEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
+import com.ym.mec.biz.dal.enums.TemplateTypeEnum;
|
|
|
import com.ym.mec.biz.dal.page.FinancialExpenditureQueryInfo;
|
|
|
-import com.ym.mec.biz.service.*;
|
|
|
+import com.ym.mec.biz.service.FinancialExpenditureService;
|
|
|
+import com.ym.mec.biz.service.GroupClassService;
|
|
|
+import com.ym.mec.biz.service.MusicGroupService;
|
|
|
+import com.ym.mec.biz.service.VipGroupService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
-import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
-import com.ym.mec.common.page.QueryInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.excel.POIUtil;
|
|
|
import com.ym.mec.util.ini.IniFileUtil;
|
|
|
-
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -37,8 +39,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
+import java.io.File;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.net.URL;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -57,6 +61,8 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
private GroupClassService groupClassService;
|
|
|
@Autowired
|
|
|
private MusicGroupService musicGroupService;
|
|
|
+ @Autowired
|
|
|
+ private FinancialExpenditureService financialExpenditureService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, FinancialExpenditure> getDAO() {
|
|
@@ -217,7 +223,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void syncOaPayLog(Integer workOrderId) {
|
|
|
+ public void syncOaPayLog(Integer workOrderId,String fileUrl) throws Exception {
|
|
|
PWorkOrderInfo pWorkOrderInfo = financialExpenditureDao.getWorkOrderInfo(workOrderId);
|
|
|
if (pWorkOrderInfo != null){
|
|
|
Integer hasFinancial = financialExpenditureDao.findByBatchNoAndProcessNo(workOrderId);
|
|
@@ -354,25 +360,46 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
}else {
|
|
|
//退团
|
|
|
for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
- Boolean isRefundInstrumentFee = false;
|
|
|
- Boolean isRefundTeachingAssistantsFee = false;
|
|
|
- Boolean maintenanceFee = false;
|
|
|
String returnFeeType = financialExpenditure.getReturnFeeType();
|
|
|
if(StringUtils.isNotEmpty(returnFeeType)){
|
|
|
if(returnFeeType.contains("乐器")){
|
|
|
- isRefundInstrumentFee = true;
|
|
|
+ financialExpenditure.setRefundInstrumentFeeFlag(true);
|
|
|
}
|
|
|
if(returnFeeType.contains("乐保")){
|
|
|
- maintenanceFee = true;
|
|
|
+ financialExpenditure.setMaintenanceFeeFlag(true);
|
|
|
}
|
|
|
if(returnFeeType.contains("教辅")){
|
|
|
- isRefundTeachingAssistantsFee = true;
|
|
|
+ financialExpenditure.setRefundTeachingAssistantsFeeFlag(true);
|
|
|
}
|
|
|
}
|
|
|
- musicGroupService.directQuitMusicGroupOa(financialExpenditure.getMusicGroupId(), financialExpenditure.getStudentId(),
|
|
|
- financialExpenditure.getCause(), isRefundInstrumentFee,
|
|
|
- isRefundTeachingAssistantsFee, maintenanceFee, financialExpenditure.getAmount());
|
|
|
}
|
|
|
+ //处理excel文件
|
|
|
+ List<FinancialExpenditure> financialExpenditures = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotEmpty(fileUrl)){
|
|
|
+ String[] split = fileUrl.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ File file = FileUtils.toFile(new URL(s));
|
|
|
+ financialExpenditures.addAll(financialExpenditureService.checkOaQuitMusicGroupExcel(FileUtils.readFileToByteArray(file), file.getName()));
|
|
|
+ }
|
|
|
+ //去除重复数据
|
|
|
+ financialExpenditures.removeAll(Collections.singleton(null));
|
|
|
+ if(CollectionUtils.isNotEmpty(financialExpenditureList)){
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
+ if(financialExpenditures.contains(financialExpenditure)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ financialExpenditures.add(financialExpenditure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditures) {
|
|
|
+ financialExpenditure.setType(ExpenditureTypeEnum.REFUND);
|
|
|
+ financialExpenditure.setFeeProject(FeeProjectEnum.REFUND);
|
|
|
+ financialExpenditure.setBatchNo(pWorkOrderInfo.getId().toString());
|
|
|
+ financialExpenditure.setFinancialProcessNo(pWorkOrderInfo.getId().toString());
|
|
|
+ musicGroupService.directQuitMusicGroupOa(financialExpenditure);
|
|
|
+ }
|
|
|
+ financialExpenditureList = financialExpenditures;
|
|
|
}
|
|
|
financialExpenditureDao.batchInsert(financialExpenditureList);
|
|
|
}else {
|
|
@@ -518,7 +545,58 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void checkOaQuitMusicGroupExcel(MultipartFile file) {
|
|
|
-
|
|
|
+ public List<FinancialExpenditure> checkOaQuitMusicGroupExcel(byte[] buf,String filename) throws Exception {
|
|
|
+ Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(new ByteArrayInputStream(buf), 2, filename);
|
|
|
+ InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
|
|
|
+ Map<String, String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.OA_QUIT_MUSIC_GROUP.getMsg());
|
|
|
+ List<FinancialExpenditure> financialExpenditureList = new ArrayList<>();
|
|
|
+ List<Organization> organs = organizationDao.findAllOrgans(1);
|
|
|
+ Map<String, List<Organization>> collect = organs.stream().collect(Collectors.groupingBy(Organization::getName));
|
|
|
+ for (String e : sheetsListMap.keySet()) {
|
|
|
+ List<Map<String, Object>> sheet = sheetsListMap.get(e);
|
|
|
+ for (Map<String, Object> row : sheet) {
|
|
|
+ if (row.size() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ JSONObject objectMap = new JSONObject();
|
|
|
+ for (String s : row.keySet()) {
|
|
|
+ if (!columns.containsKey(s)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String columnValue = columns.get(s);
|
|
|
+ if(Objects.equals(columnValue,"refundInstrumentFeeFlag")
|
|
|
+ || Objects.equals(columnValue,"refundTeachingAssistantsFeeFlag")
|
|
|
+ || Objects.equals(columnValue,"maintenanceFeeFlag")
|
|
|
+ || Objects.equals(columnValue,"refundCourseFee")){
|
|
|
+ if(Objects.nonNull(row.get(s))){
|
|
|
+ objectMap.put(columnValue, Objects.equals("是",row.get(s))?true:false);
|
|
|
+ }
|
|
|
+ }else if(Objects.equals(columnValue,"amount")){
|
|
|
+ objectMap.put(columnValue, Objects.isNull(row.get(s)) || StringUtils.isEmpty(row.get(s).toString())?0:row.get(s));
|
|
|
+ }else if(Objects.equals(columnValue,"organName")){
|
|
|
+ if(Objects.isNull(row.get(s)) || StringUtils.isEmpty(row.get(s).toString())){
|
|
|
+ throw new BizException("乐团退费模板错误: 请录入分部信息");
|
|
|
+ }
|
|
|
+ if(!collect.containsKey(row.get(s).toString())){
|
|
|
+ throw new BizException("乐团退费模板错误: 分部 {} 不存在",row.get(s).toString());
|
|
|
+ }
|
|
|
+ objectMap.put("organId",collect.get(row.get(s).toString()).get(0).getId());
|
|
|
+ }else {
|
|
|
+ objectMap.put(columnValue, row.get(s));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FinancialExpenditure financialExpenditure = JSONObject.parseObject(objectMap.toJSONString(),FinancialExpenditure.class);
|
|
|
+ if(StringUtils.isEmpty(financialExpenditure.getMusicGroupId()) || Objects.isNull(financialExpenditure.getStudentId())){
|
|
|
+ throw new BizException("乐团退费模板错误: 乐团编号或学员编号不可为空");
|
|
|
+ }
|
|
|
+ financialExpenditureList.add(financialExpenditure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(CollectionUtils.isNotEmpty(financialExpenditureList)){
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
+ musicGroupService.checkDirectQuitMusicGroupOa(financialExpenditure.getMusicGroupId(), financialExpenditure.getStudentId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return financialExpenditureList;
|
|
|
}
|
|
|
}
|