|
@@ -0,0 +1,187 @@
|
|
|
+package com.fs.qw.service.impl;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import com.fs.common.utils.DateUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fs.course.domain.FsUserCourseComplaintRecord;
|
|
|
+import com.fs.qw.domain.QwCompany;
|
|
|
+import com.fs.qw.domain.QwUser;
|
|
|
+import com.fs.qw.mapper.QwCompanyMapper;
|
|
|
+import com.fs.qw.mapper.QwUserMapper;
|
|
|
+import com.fs.qw.param.QwUserComplaintRecordParam;
|
|
|
+import com.fs.qwApi.Result.QwSendMsgResult;
|
|
|
+import com.fs.qwApi.param.QwSendMsgParam;
|
|
|
+import com.fs.qwApi.service.QwApiService;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import com.fs.qw.mapper.QwUserComplainRecordMapper;
|
|
|
+import com.fs.qw.domain.QwUserComplainRecord;
|
|
|
+import com.fs.qw.service.IQwUserComplainRecordService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 企微员工投诉记录Service业务层处理
|
|
|
+ *
|
|
|
+ * @author fs
|
|
|
+ * @date 2025-10-22
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class QwUserComplainRecordServiceImpl extends ServiceImpl<QwUserComplainRecordMapper, QwUserComplainRecord> implements IQwUserComplainRecordService {
|
|
|
+
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(QwUserComplainRecordServiceImpl.class);
|
|
|
+ @Autowired
|
|
|
+ private QwUserMapper qwUserMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QwApiService qwApiService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QwCompanyMapper qwCompanyMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询企微员工投诉记录
|
|
|
+ *
|
|
|
+ * @param recordId 企微员工投诉记录主键
|
|
|
+ * @return 企微员工投诉记录
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public QwUserComplainRecord selectQwUserComplainRecordByRecordId(Long recordId)
|
|
|
+ {
|
|
|
+ return baseMapper.selectQwUserComplainRecordByRecordId(recordId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询企微员工投诉记录列表
|
|
|
+ *
|
|
|
+ * @param qwUserComplainRecord 企微员工投诉记录
|
|
|
+ * @return 企微员工投诉记录
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<QwUserComplainRecord> selectQwUserComplainRecordList(QwUserComplainRecord qwUserComplainRecord)
|
|
|
+ {
|
|
|
+ return baseMapper.selectQwUserComplainRecordList(qwUserComplainRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增企微员工投诉记录
|
|
|
+ *
|
|
|
+ * @param qwUserComplainRecord 企微员工投诉记录
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int insertQwUserComplainRecord(QwUserComplainRecord qwUserComplainRecord)
|
|
|
+ {
|
|
|
+ qwUserComplainRecord.setCreateTime(DateUtils.getNowDate());
|
|
|
+ return baseMapper.insertQwUserComplainRecord(qwUserComplainRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改企微员工投诉记录
|
|
|
+ *
|
|
|
+ * @param qwUserComplainRecord 企微员工投诉记录
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int updateQwUserComplainRecord(QwUserComplainRecord qwUserComplainRecord)
|
|
|
+ {
|
|
|
+ return baseMapper.updateQwUserComplainRecord(qwUserComplainRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除企微员工投诉记录
|
|
|
+ *
|
|
|
+ * @param recordIds 需要删除的企微员工投诉记录主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteQwUserComplainRecordByRecordIds(Long[] recordIds)
|
|
|
+ {
|
|
|
+ return baseMapper.deleteQwUserComplainRecordByRecordIds(recordIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除企微员工投诉记录信息
|
|
|
+ *
|
|
|
+ * @param recordId 企微员工投诉记录主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteQwUserComplainRecordByRecordId(Long recordId)
|
|
|
+ {
|
|
|
+ return baseMapper.deleteQwUserComplainRecordByRecordId(recordId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int submitRecordByQwUser(QwUserComplaintRecordParam param) {
|
|
|
+ QwUserComplainRecord qwUserComplainRecord = new QwUserComplainRecord();
|
|
|
+ BeanUtils.copyProperties(param, qwUserComplainRecord);
|
|
|
+ qwUserComplainRecord.setCreateTime(DateUtils.getNowDate());
|
|
|
+ String description = createDescription(qwUserComplainRecord);
|
|
|
+ //抛出发送消息出现的异常
|
|
|
+ try {
|
|
|
+ log.info("发送应用提醒:{},{}", param.getQwUserId(),description);
|
|
|
+ sendQwMsg(param.getQwUserId(), description);
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+ return baseMapper.insertQwUserComplainRecord(qwUserComplainRecord);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给企业微信的应用发送消息
|
|
|
+ */
|
|
|
+ private void sendQwMsg(Long qwUserId ,String msg){
|
|
|
+ //查询企微用户
|
|
|
+ QwUser qwUser = qwUserMapper.selectQwUserById(qwUserId);
|
|
|
+ //查询主体信息
|
|
|
+ QwCompany qwCompany = qwCompanyMapper.selectQwCompanyByCorpId(qwUser.getCorpId());
|
|
|
+ //应用消息组装
|
|
|
+ QwSendMsgParam sendMsgParam = new QwSendMsgParam();
|
|
|
+ sendMsgParam.setAgentid(Integer.parseInt(qwCompany.getServerAgentId().trim()));
|
|
|
+ sendMsgParam.setTouser(qwUser.getQwUserId());
|
|
|
+ sendMsgParam.setMsgtype("textcard");
|
|
|
+ //组合文本卡片消息
|
|
|
+ QwSendMsgParam.TextCard textCard = new QwSendMsgParam.TextCard();
|
|
|
+ textCard.setTitle("工单提醒");
|
|
|
+ textCard.setDescription(msg);
|
|
|
+ textCard.setUrl("https://www.baidu.com/");
|
|
|
+ textCard.setBtntxt("详情");
|
|
|
+ sendMsgParam.setTextcard(textCard);
|
|
|
+ log.info("发送投诉信息请求体:{}",sendMsgParam);
|
|
|
+ //发送消息
|
|
|
+ QwSendMsgResult result = qwApiService.sendMsg(sendMsgParam, qwCompany.getCorpId());
|
|
|
+ log.info("发送投诉应用消息返回:{}",result);
|
|
|
+ if (result.getErrcode()!=0 && !result.getErrmsg().equals("ok")) {
|
|
|
+ log.error("发送投诉应用消息返回失败:{}",result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建描述信息
|
|
|
+ * @param record
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String createDescription(QwUserComplainRecord record){
|
|
|
+ String content = "点击下方'详情'查看投诉内容";
|
|
|
+ int picCount = 0;
|
|
|
+ String complaintUrl = record.getComplaintUrl();
|
|
|
+ if (complaintUrl != null && !complaintUrl.trim().isEmpty()) {
|
|
|
+ picCount = complaintUrl.split(",").length;
|
|
|
+ }
|
|
|
+// String position = record.getPosition();
|
|
|
+ String position = "中国境内";
|
|
|
+
|
|
|
+// String recordDescription = "<div class=\\\"gray\\\">内容</div><div class=\\\"normal\\\">"+content+"</div><br><div class=\\\"gray\\\">图片</div><div class=\\\"normal\\\">"+picCount+"张</div><br><div class=\\\"gray\\\">位置</div><div class=\\\"normal\\\">"+position+"</div><br><div class=\\\"gray\\\">分类</div><div class=\\\"normal\\\">"+record.getComplaintContent()+"</div><br>";
|
|
|
+
|
|
|
+ String recordDescription = "<div class=\\\"gray\\\">2016年9月26日</div> <div class=\\\"normal\\\">恭喜你抽中iPhone 7一台,领奖码:xxxx</div><div class=\\\"highlight\\\">请于2016年10月10日前联系行政同事领取</div>";
|
|
|
+ return recordDescription;
|
|
|
+ }
|
|
|
+}
|