|
@@ -25,17 +25,24 @@ import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
+import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
+import com.ym.mec.util.excel.POIUtil;
|
|
|
+import com.ym.mec.util.ini.IniFileUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
@@ -1266,6 +1273,50 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<String> importMusicGroupPayment(MultipartFile file) throws Exception{
|
|
|
+ Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(new ByteArrayInputStream(file.getBytes()), 2, file.getOriginalFilename());
|
|
|
+ InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
|
|
|
+ Map<String, String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.MUSIC_GROUP_PAYMENT_IMPORT.getMsg());
|
|
|
+ List<MusicGroupPaymentImportDto> importDtos = new ArrayList<>();
|
|
|
+ List<String> errMsg = new ArrayList();
|
|
|
+ for (String sheetName : sheetsListMap.keySet()) {
|
|
|
+ List<Map<String, Object>> sheet = sheetsListMap.get(sheetName);
|
|
|
+ for (int i = 0; i < sheet.size(); i++) {
|
|
|
+ Map<String, Object> row = sheet.get(i);
|
|
|
+ if (row.size() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ JSONObject objectMap = new JSONObject();
|
|
|
+ valueIsNull: for (String s : row.keySet()) {
|
|
|
+ String columnValue = columns.get(s);
|
|
|
+ if (StringUtils.isEmpty(columnValue)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (null == row.get(s)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ objectMap.put(columnValue, row.get(s));
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ MusicGroupPaymentImportDto cost = JSONObject.parseObject(objectMap.toJSONString(), MusicGroupPaymentImportDto.class);
|
|
|
+ importDtos.add(cost);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ throw new BizException("导入数据出错", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!org.springframework.util.CollectionUtils.isEmpty(errMsg)) {
|
|
|
+ return errMsg;
|
|
|
+ }
|
|
|
+ if(!org.springframework.util.CollectionUtils.isEmpty(importDtos)){
|
|
|
+ //处理数据导入
|
|
|
+ List<String> phoneList = importDtos.stream().map(e -> e.getPhone()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
public boolean autoUpdateMusicGroupPaymentCalenderStatus() {
|
|
|
Date date = new Date();
|