diff --git a/cweb/src/main/java/com/cweb/controller/BsStoreCidController.java b/cweb/src/main/java/com/cweb/controller/BsStoreCidController.java index 48fe2af..379c600 100644 --- a/cweb/src/main/java/com/cweb/controller/BsStoreCidController.java +++ b/cweb/src/main/java/com/cweb/controller/BsStoreCidController.java @@ -81,6 +81,8 @@ public class BsStoreCidController { bsStoreCidService.editStoreCid(bsStoreCid); } + bsStoreCidService.getPushRecord(storeCid.getStoreId()); + return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { diff --git a/service/src/main/java/com/hfkj/service/BsStoreCidService.java b/service/src/main/java/com/hfkj/service/BsStoreCidService.java index e2b9fa5..2db539a 100644 --- a/service/src/main/java/com/hfkj/service/BsStoreCidService.java +++ b/service/src/main/java/com/hfkj/service/BsStoreCidService.java @@ -2,7 +2,9 @@ package com.hfkj.service; import com.alibaba.fastjson.JSONObject; import com.hfkj.entity.BsStoreCid; +import com.hfkj.entity.BsStorePushRecord; +import java.util.List; import java.util.Map; /** @@ -51,5 +53,56 @@ public interface BsStoreCidService { */ void storePush(JSONObject object); + /** + * @Author Sum1Dream + * @Name getPushRecord + * @Description // 推送播报记录 + * @Date 10:56 2023/6/15 + * @Param [storeId] + * @Return void + */ + void getPushRecord(Long storeId); + + + /** + * @Author Sum1Dream + * @Name insertStoreCid + * @Description // 新增门店语音播报推送记录 + * @Date 15:14 2023/6/14 + * @Param [storeCid] + * @Return void + */ + void insertStorePushRecord(BsStorePushRecord storePushRecord); + + + /** + * @Author Sum1Dream + * @Name editStoreCid + * @Description // 编辑门店语音播报推送记录 + * @Date 15:15 2023/6/14 + * @Param [storeCid] + * @Return void + */ + void editStorePushRecord(BsStorePushRecord storePushRecord); + + /** + * @Author Sum1Dream + * @Name findByMap + * @Description // 查询门店语音播报推送记录 + * @Date 15:40 2023/6/14 + * @Param [map] + * @Return com.hfkj.entity.BsStoreCid + */ + BsStorePushRecord findPushRecordByMap(Map map); + + /** + * @Author Sum1Dream + * @Name getList + * @Description // 查询门店语音播报推送记录列表 + * @Date 10:41 2023/6/15 + * @Param [map] + * @Return java.util.List + */ + List getList(Map map); } diff --git a/service/src/main/java/com/hfkj/service/impl/BsStoreCidServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsStoreCidServiceImpl.java index b007da9..47059e3 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsStoreCidServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsStoreCidServiceImpl.java @@ -4,9 +4,13 @@ import com.alibaba.fastjson.JSONObject; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; +import com.hfkj.config.CommonSysConst; import com.hfkj.dao.BsStoreCidMapper; +import com.hfkj.dao.BsStorePushRecordMapper; import com.hfkj.entity.BsStoreCid; import com.hfkj.entity.BsStoreCidExample; +import com.hfkj.entity.BsStorePushRecord; +import com.hfkj.entity.BsStorePushRecordExample; import com.hfkj.service.BsStoreCidService; import com.hfkj.tts.HWYunSisService; import com.hfkj.unipush.UniPushService; @@ -17,6 +21,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,6 +37,9 @@ public class BsStoreCidServiceImpl implements BsStoreCidService { @Resource private BsStoreCidMapper bsStoreCidMapper; + @Resource + private BsStorePushRecordMapper storePushRecordMapper; + @Override public void insertStoreCid(BsStoreCid storeCid) { bsStoreCidMapper.insert(storeCid); @@ -93,13 +101,93 @@ public class BsStoreCidServiceImpl implements BsStoreCidService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "生成语音失败"); } - object.put("cid", bsStoreCid.getCid()); - object.put("body", auditPath); - UniPushService.pushToSingleByCid(object); + BsStorePushRecord storePushRecord = new BsStorePushRecord(); + storePushRecord.setStoreId(bsStoreCid.getStoreId()); + storePushRecord.setCreateTime(new Date()); + storePushRecord.setUpdateTime(new Date()); + storePushRecord.setStatus(2); + storePushRecord.setVoiceUrl(CommonSysConst.getSysConfig().getDomainName() + auditPath); + + storePushRecordMapper.insert(storePushRecord); + getPushRecord(bsStoreCid.getStoreId()); + } catch (Exception e) { log.info("请求超时:" + e); } } + @Override + public void getPushRecord(Long storeId) { + + Map map = new HashMap<>(); + map.put("storeId", storeId); + BsStoreCid bsStoreCid = findByMap(map); + + if (bsStoreCid == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "不存在推送关系"); + } + + // 查询可推送语音 + + Map pushMap = new HashMap<>(); + pushMap.put("storeId" , storeId); + pushMap.put("status" , 2); + BsStorePushRecord storePushRecord = findPushRecordByMap(pushMap); + + if (storePushRecord != null) { + JSONObject object = new JSONObject(); + object.put("cid", bsStoreCid.getCid()); + object.put("body", storePushRecord.getVoiceUrl()); + UniPushService.pushToSingleByCid(object); + } + + } + + @Override + public void insertStorePushRecord(BsStorePushRecord storePushRecord) { + storePushRecordMapper.insert(storePushRecord); + } + + @Override + public void editStorePushRecord(BsStorePushRecord storePushRecord) { + storePushRecordMapper.updateByPrimaryKey(storePushRecord); + } + + @Override + public BsStorePushRecord findPushRecordByMap(Map map) { + BsStorePushRecordExample example = new BsStorePushRecordExample(); + BsStorePushRecordExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "storeId") != null) { + criteria.andStoreIdEqualTo(MapUtils.getLong(map, "storeId")); + } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } + + List list = storePushRecordMapper.selectByExample(example); + + if (list.size() > 0) { + return list.get(0); + } + + return null; + } + + @Override + public List getList(Map map) { + + BsStorePushRecordExample example = new BsStorePushRecordExample(); + BsStorePushRecordExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "storeId") != null) { + criteria.andStoreIdEqualTo(MapUtils.getLong(map, "storeId")); + } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } + + return storePushRecordMapper.selectByExample(example); + } }