From d94dcc163fcf5d9686f71753ac227cc0db412202 Mon Sep 17 00:00:00 2001 From: eric <465889110@qq.com> Date: Tue, 9 Sep 2025 21:48:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=99=E5=85=A5=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sczx/sync/dto/NoticeReq.java | 27 +++ .../sczx/sync/mapper/CompanyInfoMapper.java | 6 - .../com/sczx/sync/mapper/NoticeMapper.java | 21 ++ src/main/java/com/sczx/sync/po/SysNotic.java | 186 ++++++++++++++++++ .../sync/service/impl/ReceiveServiceImpl.java | 40 +++- .../resources/mapper/CompanyInfoMapper.xml | 2 +- src/main/resources/mapper/NoticeMapper.xml | 42 ++++ 7 files changed, 314 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/sczx/sync/dto/NoticeReq.java create mode 100644 src/main/java/com/sczx/sync/mapper/NoticeMapper.java create mode 100644 src/main/java/com/sczx/sync/po/SysNotic.java create mode 100644 src/main/resources/mapper/NoticeMapper.xml diff --git a/src/main/java/com/sczx/sync/dto/NoticeReq.java b/src/main/java/com/sczx/sync/dto/NoticeReq.java new file mode 100644 index 0000000..03d3e1b --- /dev/null +++ b/src/main/java/com/sczx/sync/dto/NoticeReq.java @@ -0,0 +1,27 @@ +package com.sczx.sync.dto; + +import lombok.Data; + +@Data +public class NoticeReq { + + + private Long noticeId; + + /** 公告标题 */ + private String noticeTitle; + + /** 公告类型(1通知 2公告) */ + private String noticeType; + + /** 公告内容 */ + private String noticeContent; + + /** 公告状态(0正常 1关闭) */ + private String status; + + private String readStatus; + + private Long userId; + +} diff --git a/src/main/java/com/sczx/sync/mapper/CompanyInfoMapper.java b/src/main/java/com/sczx/sync/mapper/CompanyInfoMapper.java index 4bd97ee..8fa62b1 100644 --- a/src/main/java/com/sczx/sync/mapper/CompanyInfoMapper.java +++ b/src/main/java/com/sczx/sync/mapper/CompanyInfoMapper.java @@ -29,12 +29,6 @@ public interface CompanyInfoMapper extends BaseMapper { CompanyInfo selectByCompanyName(CompanyInfo companyInfo); - /** - * 根据电话号码更新公司信息 - * @param companyInfo 公司信息 - * @return 影响行数 - */ - int updateByPhone(CompanyInfo companyInfo); int updateByCompanyName(CompanyInfo companyInfo); diff --git a/src/main/java/com/sczx/sync/mapper/NoticeMapper.java b/src/main/java/com/sczx/sync/mapper/NoticeMapper.java new file mode 100644 index 0000000..a50a669 --- /dev/null +++ b/src/main/java/com/sczx/sync/mapper/NoticeMapper.java @@ -0,0 +1,21 @@ +package com.sczx.sync.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sczx.sync.dto.NoticeReq; +import com.sczx.sync.po.SysNotic; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + + +@Mapper +public interface NoticeMapper extends BaseMapper { + + + int insertNotice( SysNotic noticeReq); + + List selectIdsByGroupId(Long opretion_id); + + List selectOpIds(); + +} \ No newline at end of file diff --git a/src/main/java/com/sczx/sync/po/SysNotic.java b/src/main/java/com/sczx/sync/po/SysNotic.java new file mode 100644 index 0000000..7d95efb --- /dev/null +++ b/src/main/java/com/sczx/sync/po/SysNotic.java @@ -0,0 +1,186 @@ +package com.sczx.sync.po; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 通知公告表实体类 + */ +@TableName("sys_notice") +@Data +public class SysNotic implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 公告ID + */ + @TableId(value = "notice_id", type = IdType.AUTO) + private Integer noticeId; + + /** + * 公告标题 + */ + @TableField("notice_title") + private String noticeTitle; + + /** + * 公告类型(1通知 2公告) + */ + @TableField("notice_type") + private String noticeType; + + /** + * 公告内容 + */ + @TableField("notice_content") + private byte[] noticeContent; + + /** + * 公告状态(0正常 1关闭) + */ + @TableField("status") + private String status; + + /** + * 创建者 + */ + @TableField("create_by") + private String createBy; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新者 + */ + @TableField("update_by") + private String updateBy; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 0未读1已读 + */ + @TableField("read_status") + private String readStatus; + + /** + * 用户ID + */ + @TableField("user_id") + private Long userId; + + // Getters and Setters + + public Integer getNoticeId() { + return noticeId; + } + + public void setNoticeId(Integer noticeId) { + this.noticeId = noticeId; + } + + public String getNoticeTitle() { + return noticeTitle; + } + + public void setNoticeTitle(String noticeTitle) { + this.noticeTitle = noticeTitle; + } + + public String getNoticeType() { + return noticeType; + } + + public void setNoticeType(String noticeType) { + this.noticeType = noticeType; + } + + public byte[] getNoticeContent() { + return noticeContent; + } + + public void setNoticeContent(byte[] noticeContent) { + this.noticeContent = noticeContent; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public LocalDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(LocalDateTime createTime) { + this.createTime = createTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + public LocalDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(LocalDateTime updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getReadStatus() { + return readStatus; + } + + public void setReadStatus(String readStatus) { + this.readStatus = readStatus; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } +} diff --git a/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java b/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java index 08bfeae..80fdbf4 100644 --- a/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java +++ b/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java @@ -3,6 +3,7 @@ package com.sczx.sync.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.nacos.common.utils.MD5Utils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sczx.sync.dto.NoticeReq; import com.sczx.sync.entity.UserInfo; import com.sczx.sync.mapper.*; import com.sczx.sync.po.*; @@ -13,8 +14,10 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; +import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; import java.util.HashMap; +import java.util.List; import java.util.Map; @Slf4j @@ -33,6 +36,8 @@ public class ReceiveServiceImpl implements ReceiveService { private CompanyInfoMapper companyInfoMapper; @Autowired private CompanyStoreMapper companyStoreMapper; + @Autowired + private NoticeMapper noticeMapper; @Value("${battery-platform.appid}") private String appId; @@ -41,7 +46,7 @@ public class ReceiveServiceImpl implements ReceiveService { @Override public Map recceiveMeals(String request) { - log.info("/meals 接收套餐数据:{}",JSON.toJSONString( request)); + log.info("/meals 接收套餐数据:{}", JSON.toJSONString(request)); SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); Map map = new HashMap<>(); if (!syncRequest.getAppid().equals(appId) || !syncRequest.getAccessToken().equals(accessToken)) { @@ -144,7 +149,7 @@ public class ReceiveServiceImpl implements ReceiveService { @Override public Map recceiveUserInfo(String request) { - log.info("/userinfo 接收用户数据:{}",JSON.toJSONString( request)); + log.info("/userinfo 接收用户数据:{}", JSON.toJSONString(request)); SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); Map map = new HashMap<>(); if (!syncRequest.getAppid().equals(appId) || !syncRequest.getAccessToken().equals(accessToken)) { @@ -299,6 +304,20 @@ public class ReceiveServiceImpl implements ReceiveService { } else { companyInfoMapper.insertCompanyInfo(companyInfo); } + List userIds = noticeMapper.selectOpIds(); + if (userIds != null) { + for (Long userId : userIds) { + SysNotic noticeReq = new SysNotic(); + noticeReq.setNoticeTitle("运营商信息同步新增通知"); + noticeReq.setNoticeType("1"); + noticeReq.setNoticeContent("接收到租电平台同步的运营商信息,请前往运营商管理页面进行运营数据维护!".getBytes(StandardCharsets.UTF_8)); + noticeReq.setStatus("0"); + noticeReq.setReadStatus("0"); + noticeReq.setUserId(userId); + noticeMapper.insertNotice(noticeReq); + } + } + map.put("msg", "成功"); map.put("code", "200"); @@ -383,9 +402,24 @@ public class ReceiveServiceImpl implements ReceiveService { storeInfo.setOperator_id(companyInfo.getId()); if (companyStoreMapper.selectByBid(storeInfo.getStore_id()) != null) { companyStoreMapper.updateByBid(storeInfo); - } else { + } else { companyStoreMapper.insertStoreInfo(storeInfo); } + + List userIds = noticeMapper.selectIdsByGroupId(companyInfo.getId()); + if (userIds != null) { + for (Long userId : userIds) { + SysNotic noticeReq = new SysNotic(); + noticeReq.setNoticeTitle("门店信息同步新增通知"); + noticeReq.setNoticeType("1"); + noticeReq.setNoticeContent("接收到租电平台同步的门店信息,请前往门店管理页面进行运营数据维护!".getBytes(StandardCharsets.UTF_8)); + noticeReq.setStatus("0"); + noticeReq.setReadStatus("0"); + noticeReq.setUserId(userId); + noticeMapper.insertNotice(noticeReq); + } + } + map.put("msg", "成功"); map.put("code", "200"); map.put("store_id", storeInfo.getId().toString()); diff --git a/src/main/resources/mapper/CompanyInfoMapper.xml b/src/main/resources/mapper/CompanyInfoMapper.xml index c6ab0a3..ddee575 100644 --- a/src/main/resources/mapper/CompanyInfoMapper.xml +++ b/src/main/resources/mapper/CompanyInfoMapper.xml @@ -133,7 +133,7 @@ SELECT id from zc_company - where phone = #{phone} + where b_op_id = #{operator_id} UPDATE zc_company diff --git a/src/main/resources/mapper/NoticeMapper.xml b/src/main/resources/mapper/NoticeMapper.xml new file mode 100644 index 0000000..6fd8c0c --- /dev/null +++ b/src/main/resources/mapper/NoticeMapper.xml @@ -0,0 +1,42 @@ + + + + + + + insert into sys_notice ( + notice_title, + notice_type, + notice_content, + status, + user_id, + create_time, + update_time + )values( + #{noticeTitle}, + #{noticeType}, + #{noticeContent}, + #{status}, + #{userId}, + sysdate(), + sysdate() + ) + + + + + + + + +