|
@@ -2,15 +2,19 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.mysql.cj.protocol.MessageSender;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.biz.dal.dao.RedemptionCodeDao;
|
|
|
import com.ym.mec.biz.dal.entity.AppRedemptionCode;
|
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.service.AppRedemptionCodeService;
|
|
|
+import com.ym.mec.biz.service.SysMessageService;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
|
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.excel.POIUtil;
|
|
|
import com.ym.mec.util.ini.IniFileUtil;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
@@ -32,7 +36,8 @@ import java.util.*;
|
|
|
* @since 2021-12-27 14:27:57
|
|
|
*/
|
|
|
@Service("redemptionCodeService")
|
|
|
-public class AppRedemptionCodeServiceImpl extends ServiceImpl<RedemptionCodeDao, AppRedemptionCode> implements AppRedemptionCodeService {
|
|
|
+public class AppRedemptionCodeServiceImpl extends ServiceImpl<RedemptionCodeDao, AppRedemptionCode>
|
|
|
+ implements AppRedemptionCodeService {
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(AppRedemptionCodeServiceImpl.class);
|
|
|
|
|
@@ -42,14 +47,18 @@ public class AppRedemptionCodeServiceImpl extends ServiceImpl<RedemptionCodeDao,
|
|
|
@Autowired
|
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
+
|
|
|
private final static Logger logger = LoggerFactory.getLogger(AppRedemptionCodeServiceImpl.class);
|
|
|
|
|
|
@Override
|
|
|
public List<AppRedemptionCode> importRedemptionCode(MultipartFile file) throws Exception {
|
|
|
- Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(new ByteArrayInputStream(file.getBytes()), 2, file.getOriginalFilename());
|
|
|
-
|
|
|
+ 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.REDEMPTIONCODE.getMsg());
|
|
|
+ Map<String, String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.REDEMPTIONCODE.getMsg());
|
|
|
|
|
|
List<AppRedemptionCode> redemptionCodesList = new ArrayList<>();
|
|
|
for (String e : sheetsListMap.keySet()) {
|
|
@@ -61,18 +70,19 @@ public class AppRedemptionCodeServiceImpl extends ServiceImpl<RedemptionCodeDao,
|
|
|
|
|
|
JSONObject objectMap = new JSONObject();
|
|
|
for (String s : row.keySet()) {
|
|
|
- if(!columns.containsKey(s)){
|
|
|
+ if (!columns.containsKey(s)) {
|
|
|
continue;
|
|
|
}
|
|
|
String columnValue = columns.get(s);
|
|
|
- if(null == row.get(s) || StringUtils.isBlank(row.get(s).toString())){
|
|
|
- LOGGER.error("导入异常:参数{}不可为空 param:{}",columnValue,objectMap);
|
|
|
- continue ;
|
|
|
+ if (null == row.get(s) || StringUtils.isBlank(row.get(s).toString())) {
|
|
|
+ LOGGER.error("导入异常:参数{}不可为空 param:{}", columnValue, objectMap);
|
|
|
+ continue;
|
|
|
}
|
|
|
objectMap.put(columnValue, row.get(s));
|
|
|
}
|
|
|
try {
|
|
|
- AppRedemptionCode redemptionCode = JSONObject.parseObject(objectMap.toJSONString(),AppRedemptionCode.class);
|
|
|
+ AppRedemptionCode redemptionCode = JSONObject.parseObject(objectMap.toJSONString(),
|
|
|
+ AppRedemptionCode.class);
|
|
|
redemptionCodesList.add(redemptionCode);
|
|
|
redemptionCodeDao.insert(redemptionCode);
|
|
|
} catch (Exception ex) {
|
|
@@ -96,5 +106,17 @@ public class AppRedemptionCodeServiceImpl extends ServiceImpl<RedemptionCodeDao,
|
|
|
}
|
|
|
return redemptionCode;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void checkLowVolume() {
|
|
|
+ Integer volume = redemptionCodeDao.findNull();
|
|
|
+ if (volume == null || volume < 10) {
|
|
|
+ Map<Integer, String> receivers = new HashMap<>(1);
|
|
|
+ receivers.put(0, "13512341234");
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS,
|
|
|
+ MessageTypeEnum.APP_REDEMPTION_CODE, receivers, null, 0, null, null,
|
|
|
+ volume, null, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|