|
|
@ -17,21 +17,32 @@ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
|
import com.epmet.constant.UserAdviceConstant; |
|
|
|
import com.epmet.dao.UserAdviceDao; |
|
|
|
import com.epmet.dto.UserAdviceDTO; |
|
|
|
import com.epmet.dto.form.AdviceListFormDTO; |
|
|
|
import com.epmet.dto.form.ReplyAdviceFormDTO; |
|
|
|
import com.epmet.dto.result.AdviceDetailResultDTO; |
|
|
|
import com.epmet.dto.result.AdviceListResultDTO; |
|
|
|
import com.epmet.dto.result.MyAdviceListResultDTO; |
|
|
|
import com.epmet.entity.UserAdviceEntity; |
|
|
|
import com.epmet.entity.UserAdviceImgEntity; |
|
|
|
import com.epmet.redis.UserAdviceRedis; |
|
|
@ -39,18 +50,15 @@ import com.epmet.service.UserAdviceImgService; |
|
|
|
import com.epmet.service.UserAdviceService; |
|
|
|
import io.jsonwebtoken.lang.Collections; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.ss.formula.functions.T; |
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* user_advice |
|
|
@ -61,12 +69,20 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAdviceEntity> implements UserAdviceService { |
|
|
|
|
|
|
|
private Logger logger = LogManager.getLogger(UserAdviceServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private UserAdviceRedis userAdviceRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserAdviceImgService userAdviceImgService; |
|
|
|
|
|
|
|
@Value("${openapi.scan.server.url}") |
|
|
|
private String scanApiUrl; |
|
|
|
@Value("${openapi.scan.method.textSyncScan}") |
|
|
|
private String textSyncScanMethod; |
|
|
|
@Value("${openapi.scan.method.imgSyncScan}") |
|
|
|
private String imgSyncScanMethod; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<UserAdviceDTO> page(Map<String, Object> params) { |
|
|
|
IPage<UserAdviceEntity> page = baseDao.selectPage( |
|
|
@ -134,6 +150,10 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd |
|
|
|
if (StringUtils.isNotBlank(userAdviceEntity.getReplyContent()) || StringUtils.isNotBlank(userAdviceEntity.getReplyUserId())) { |
|
|
|
throw new RenException("该建议已被回复,不能再次回复"); |
|
|
|
} |
|
|
|
//审核图片
|
|
|
|
auditPic(dto.getGovImgList()); |
|
|
|
//审核文字
|
|
|
|
auditText(dto.getReplyContent()); |
|
|
|
//更新advice表
|
|
|
|
baseDao.replyAdvice(dto.getAdviceId(), dto.getReplyContent(), dto.getGovContent(), loginUserId); |
|
|
|
//如果govImg不为空,插入advice_img表
|
|
|
@ -168,7 +188,6 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd |
|
|
|
AdviceDetailResultDTO adviceDetailResultDTO = new AdviceDetailResultDTO(); |
|
|
|
BeanUtils.copyProperties(userAdviceEntity, adviceDetailResultDTO); |
|
|
|
adviceDetailResultDTO.setAdviceId(userAdviceEntity.getId()); |
|
|
|
adviceDetailResultDTO.setAdviceTime(userAdviceEntity.getCreatedTime()); |
|
|
|
//拼接建议类型
|
|
|
|
if (!"*".equals(userAdviceEntity.getAdviceType())) { |
|
|
|
StringBuilder type = new StringBuilder(); |
|
|
@ -207,7 +226,7 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd |
|
|
|
* @Date 2020/11/9 10:41 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageData<UserAdviceDTO> adviceList(AdviceListFormDTO dto) { |
|
|
|
public PageData<AdviceListResultDTO> adviceList(AdviceListFormDTO dto) { |
|
|
|
//page分页
|
|
|
|
Page<UserAdviceEntity> page = new Page<>(dto.getPageNo(), dto.getPageSize()); |
|
|
|
//时间降序
|
|
|
@ -215,9 +234,108 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd |
|
|
|
|
|
|
|
//wrapper
|
|
|
|
QueryWrapper<UserAdviceEntity> wrapper = new QueryWrapper<>(); |
|
|
|
//客户Id
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(dto.getCustomerId()), "CUSTOMER_ID", dto.getCustomerId()); |
|
|
|
//是否回复
|
|
|
|
if ("1".equals(dto.getIsReply())) { |
|
|
|
wrapper.ne("REPLY_USER_ID", ""); |
|
|
|
wrapper.ne("REPLY_CONTENT", ""); |
|
|
|
} else if ("0".equals(dto.getIsReply())) { |
|
|
|
wrapper.eq("REPLY_USER_ID", ""); |
|
|
|
wrapper.eq("REPLY_CONTENT", ""); |
|
|
|
} |
|
|
|
// 组织id
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(dto.getAgencyId()), "AGENCY_ID", dto.getAgencyId()); |
|
|
|
//建议类型
|
|
|
|
wrapper.like(StringUtils.isNotBlank(dto.getAdviceType()), "ADVICE_TYPE", dto.getAdviceType()); |
|
|
|
//开始时间
|
|
|
|
wrapper.ge(dto.getStartTime() != null, "CREATED_TIME", dto.getStartTime()); |
|
|
|
//结束时间
|
|
|
|
wrapper.le(dto.getEndTime() != null, "CREATED_TIME", dto.getEndTime()); |
|
|
|
|
|
|
|
IPage<UserAdviceEntity> result = baseDao.selectPage(page, wrapper); |
|
|
|
|
|
|
|
List<UserAdviceEntity> records = result.getRecords(); |
|
|
|
|
|
|
|
//拼接type
|
|
|
|
|
|
|
|
IPage<UserAdviceEntity> result = baseDao.selectPage(page,wrapper); |
|
|
|
return null; |
|
|
|
for (int i = 0; i < records.size(); i++) { |
|
|
|
if (!"*".equals(records.get(i).getAdviceType())) { |
|
|
|
StringBuilder type = new StringBuilder(); |
|
|
|
if (records.get(i).getAdviceType().contains("gov")) { |
|
|
|
type.append(UserAdviceConstant.GOV_TYPE_TEXT); |
|
|
|
} |
|
|
|
if (records.get(i).getAdviceType().contains("software")) { |
|
|
|
if (type.length() != 0) { |
|
|
|
type.append("\\n"); |
|
|
|
} |
|
|
|
type.append(UserAdviceConstant.SOFTWARE_TYPE_TEXT); |
|
|
|
} |
|
|
|
records.get(i).setAdviceType(type.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
result.setRecords(records); |
|
|
|
|
|
|
|
return getPageData(result, AdviceListResultDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param pageSize |
|
|
|
* @param pageNo |
|
|
|
* @param loginUserId |
|
|
|
* @return java.util.List<com.epmet.dto.result.MyAdviceListResultDTO> |
|
|
|
* @Description 居民端-我的建议列表 |
|
|
|
* @Author liushaowen |
|
|
|
* @Date 2020/11/9 17:39 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<MyAdviceListResultDTO> myAdviceList(int pageSize, int pageNo, String loginUserId) { |
|
|
|
return baseDao.myAdviceList(pageSize, pageNo, loginUserId); |
|
|
|
} |
|
|
|
|
|
|
|
private void auditText(String text) { |
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
TextTaskDTO taskDTO = new TextTaskDTO(); |
|
|
|
taskDTO.setContent(text); |
|
|
|
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
textScanParamDTO.getTasks().add(taskDTO); |
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
logger.info("用户建议文字审核入参:" + JSON.toJSONString(textScanParamDTO)); |
|
|
|
logger.info("用户建议文字审核返参:" + JSON.toJSONString(textSyncScanResult)); |
|
|
|
if (!textSyncScanResult.success()) { |
|
|
|
logger.warn("用户建议文字审核接口返回失败,返参:", JSON.toJSONString(textSyncScanResult)); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
logger.warn("用户建议文字审核失败,文字:", text); |
|
|
|
throw new RenException(EpmetErrorCode.ACT_REQ_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
logger.info("用户建议文字审核成功"); |
|
|
|
} |
|
|
|
|
|
|
|
private void auditPic(List<String> imgList) { |
|
|
|
if (null != imgList && imgList.size() > 0) { |
|
|
|
//审核活动详情中的图片
|
|
|
|
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); |
|
|
|
imgList.forEach(url -> { |
|
|
|
ImgTaskDTO task = new ImgTaskDTO(); |
|
|
|
task.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
task.setUrl(url); |
|
|
|
imgScanParamDTO.getTasks().add(task); |
|
|
|
}); |
|
|
|
Result<SyncScanResult> imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); |
|
|
|
logger.info("图片审核入参:" + JSON.toJSONString(imgScanParamDTO)); |
|
|
|
logger.info("图片审核返参:" + JSON.toJSONString(imgScanResult)); |
|
|
|
if (!imgScanResult.success()) { |
|
|
|
logger.warn("图片审核接口失败,返参:", JSON.toJSONString(imgScanResult)); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!imgScanResult.getData().isAllPass()) { |
|
|
|
throw new RenException(EpmetErrorCode.ACT_CONTENT_IMG_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
logger.info("图片审核成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|