Browse Source

useradvice

dev_shibei_match
liushaowen 5 years ago
parent
commit
e28e505669
  1. 7
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserAdviceImgDTO.java
  2. 56
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AdviceListFormDTO.java
  3. 54
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/AdviceDetailResultDTO.java
  4. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserAdviceConstant.java
  5. 21
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java
  6. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserAdviceImgEntity.java
  7. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/UserAdviceImgExcel.java
  8. 11
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceImgService.java
  9. 20
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceService.java
  10. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceImgServiceImpl.java
  11. 112
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceServiceImpl.java
  12. 3
      epmet-user/epmet-user-server/src/main/resources/mapper/UserAdviceImgDao.xml

7
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserAdviceImgDTO.java

@ -43,6 +43,11 @@ public class UserAdviceImgDTO implements Serializable {
*/
private String adviceId;
/**
* 类型resi为用户上传,oper为运营上传
*/
private String type;
/**
* 图片url
*/
@ -78,4 +83,4 @@ public class UserAdviceImgDTO implements Serializable {
*/
private Date updatedTime;
}
}

56
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AdviceListFormDTO.java

@ -0,0 +1,56 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.Min;
import java.util.Date;
/**
* @description:
* @author: liushaowen
* @date: 2020/11/9 10:37
*/
@Data
public class AdviceListFormDTO {
/**
* 客户id 不填查询所有
*/
private String customerId;
/**
* 组织id 不填查询所有
*/
private String agencyId;
/**
* 是否被回复,0未回复1回复, 传空查询所有
*/
private String isReply;
/**
* 问题类型 gov政府,software软件 ,传空查询全部单选
*/
private String adviceType;
/**
* 开始时间 可不填
*/
private Date startTime;
/**
* 结束时间 可不填
*/
private Date endTime;
/**
* 页码
*/
@Min(1)
private int pageNo;
/**
* 页大小
*/
@Min(1)
private int pageSize;
}

54
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/AdviceDetailResultDTO.java

@ -1,8 +1,10 @@
package com.epmet.dto.result;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
@ -18,20 +20,51 @@ public class AdviceDetailResultDTO implements Serializable {
*/
private String adviceId;
/**
* 客户名
*/
private String customerName;
/**
* 组织名
*/
private String agencyName;
/**
* 网格名
*/
private String gridName;
/**
* 注册电话
*/
private String regPhone;
/**
* 意见类型
*/
private String adviceType;
/**
* 提建议人姓名
*/
private String userName;
/**
* 建议内容
*/
private String adviceContent;
/**
* 电话
* 填写的电话
*/
private String phone;
/**
* 建议时间
*/
private String adviceTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date adviceTime;
/**
* 回复内容
@ -41,15 +74,26 @@ public class AdviceDetailResultDTO implements Serializable {
/**
* 回复时间
*/
private String replyTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date replyTime;
/**
* 回复人
* 回复人姓名
*/
private String replyUser;
private String replyUserName;
/**
* 建议图片列表
*/
private List<String> imgList;
/**
* 政府回应图片
*/
private List<String> govImgList;
/**
* 政府回应文字
*/
private String govContent;
}

7
epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserAdviceConstant.java

@ -0,0 +1,7 @@
package com.epmet.constant;
public interface UserAdviceConstant {
String GOV_TYPE_TEXT = "政府业务建议";
String SOFTWARE_TYPE_TEXT = "软件功能及体验问题";
}

21
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java

@ -17,6 +17,7 @@
package com.epmet.controller;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ExcelUtils;
@ -27,9 +28,12 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
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.excel.UserAdviceExcel;
import com.epmet.service.UserAdviceService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -97,9 +101,24 @@ public class UserAdviceController {
}
@PostMapping("replyadvice")
public Result replyAdvice(ReplyAdviceFormDTO dto){
public Result replyAdvice(@RequestBody ReplyAdviceFormDTO dto){
ValidatorUtils.validateEntity(dto);
userAdviceService.replyAdvice(dto,loginUserUtil.getLoginUserId());
return new Result();
}
@PostMapping("advicedetail")
public Result adviceDetail(String adviceId){
if (StringUtils.isBlank(adviceId)){
throw new RenException("adviceId不能为空");
}
return new Result<AdviceDetailResultDTO>().ok(userAdviceService.adviceDetail(adviceId));
}
@PostMapping("advicelist")
public Result<PageData<UserAdviceDTO>> adviceList(AdviceListFormDTO dto){
ValidatorUtils.validateEntity(dto);
PageData<UserAdviceDTO> page = userAdviceService.adviceList(dto);
return new Result<PageData<UserAdviceDTO>>().ok(page);
}
}

5
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserAdviceImgEntity.java

@ -43,6 +43,11 @@ public class UserAdviceImgEntity extends BaseEpmetEntity {
*/
private String adviceId;
/**
* 类型resi为用户上传,oper为运营上传
*/
private String type;
/**
* 图片url
*/

5
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/UserAdviceImgExcel.java

@ -37,6 +37,9 @@ public class UserAdviceImgExcel {
@Excel(name = "建议id")
private String adviceId;
@Excel(name = "类型")
private String type;
@Excel(name = "图片url")
private String imgUrl;
@ -59,4 +62,4 @@ public class UserAdviceImgExcel {
private Date updatedTime;
}
}

11
epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceImgService.java

@ -92,4 +92,13 @@ public interface UserAdviceImgService extends BaseService<UserAdviceImgEntity> {
* @date 2020-11-04
*/
void delete(String[] ids);
}
/**
* @Description 根据adviceId获取关联的图片
* @param adviceId
* @return void
* @Author liushaowen
* @Date 2020/11/9 9:59
*/
List<UserAdviceImgEntity> getImgsByAdviceId(String adviceId);
}

20
epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceService.java

@ -20,7 +20,9 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
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.entity.UserAdviceEntity;
import java.util.List;
@ -103,4 +105,22 @@ public interface UserAdviceService extends BaseService<UserAdviceEntity> {
* @Date 2020/11/6 16:44
*/
void replyAdvice(ReplyAdviceFormDTO dto, String loginUserId);
/**
* @Description 建议详情
* @param adviceId
* @return com.epmet.dto.result.AdviceDetailResultDTO
* @Author liushaowen
* @Date 2020/11/6 17:19
*/
AdviceDetailResultDTO adviceDetail(String adviceId);
/**
* @Description 查询建议列表
* @param dto
* @return com.epmet.commons.tools.page.PageData<com.epmet.dto.UserAdviceDTO>
* @Author liushaowen
* @Date 2020/11/9 10:41
*/
PageData<UserAdviceDTO> adviceList(AdviceListFormDTO dto);
}

14
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceImgServiceImpl.java

@ -101,4 +101,16 @@ public class UserAdviceImgServiceImpl extends BaseServiceImpl<UserAdviceImgDao,
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}
/**
* @param adviceId
* @return UserAdviceImgEntity
* @Description 根据adviceId获取关联的图片
* @Author liushaowen
* @Date 2020/11/9 9:59
*/
@Override
public List<UserAdviceImgEntity> getImgsByAdviceId(String adviceId) {
return baseDao.selectList(new QueryWrapper<UserAdviceImgEntity>().eq("ADVICE_ID",adviceId));
}
}

112
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceServiceImpl.java

@ -19,21 +19,35 @@ package com.epmet.service.impl;
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.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
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.entity.UserAdviceEntity;
import com.epmet.entity.UserAdviceImgEntity;
import com.epmet.redis.UserAdviceRedis;
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.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
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;
@ -50,6 +64,9 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd
@Autowired
private UserAdviceRedis userAdviceRedis;
@Autowired
private UserAdviceImgService userAdviceImgService;
@Override
public PageData<UserAdviceDTO> page(Map<String, Object> params) {
IPage<UserAdviceEntity> page = baseDao.selectPage(
@ -66,8 +83,8 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd
return ConvertUtils.sourceToTarget(entityList, UserAdviceDTO.class);
}
private QueryWrapper<UserAdviceEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<UserAdviceEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<UserAdviceEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -112,6 +129,95 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd
*/
@Override
public void replyAdvice(ReplyAdviceFormDTO dto, String loginUserId) {
baseDao.replyAdvice(dto.getAdviceId(),dto.getReplyContent(),dto.getGovContent(),loginUserId);
//检验是否已经回复过
UserAdviceEntity userAdviceEntity = baseDao.selectById(dto.getAdviceId());
if (StringUtils.isNotBlank(userAdviceEntity.getReplyContent()) || StringUtils.isNotBlank(userAdviceEntity.getReplyUserId())) {
throw new RenException("该建议已被回复,不能再次回复");
}
//更新advice表
baseDao.replyAdvice(dto.getAdviceId(), dto.getReplyContent(), dto.getGovContent(), loginUserId);
//如果govImg不为空,插入advice_img表
List<String> govImgList = dto.getGovImgList();
if (!Collections.isEmpty(govImgList)) {
List<UserAdviceImgEntity> userAdviceImgEntities = new ArrayList<>();
for (int i = 0; i < govImgList.size(); i++) {
//最多存三张图片
if (i == 3) {
break;
}
UserAdviceImgEntity entity = new UserAdviceImgEntity();
entity.setImgUrl(govImgList.get(i));
entity.setAdviceId(dto.getAdviceId());
entity.setType("oper");
userAdviceImgEntities.add(entity);
}
userAdviceImgService.insertBatch(userAdviceImgEntities);
}
}
/**
* @param adviceId
* @return com.epmet.dto.result.AdviceDetailResultDTO
* @Description 建议详情
* @Author liushaowen
* @Date 2020/11/6 17:19
*/
@Override
public AdviceDetailResultDTO adviceDetail(String adviceId) {
UserAdviceEntity userAdviceEntity = baseDao.selectById(adviceId);
AdviceDetailResultDTO adviceDetailResultDTO = new AdviceDetailResultDTO();
BeanUtils.copyProperties(userAdviceEntity, adviceDetailResultDTO);
adviceDetailResultDTO.setAdviceId(userAdviceEntity.getId());
adviceDetailResultDTO.setAdviceTime(userAdviceEntity.getCreatedTime());
//拼接建议类型
if (!"*".equals(userAdviceEntity.getAdviceType())) {
StringBuilder type = new StringBuilder();
if (userAdviceEntity.getAdviceType().contains("gov")) {
type.append(UserAdviceConstant.GOV_TYPE_TEXT);
}
if (userAdviceEntity.getAdviceType().contains("software")) {
if (type.length() != 0) {
type.append(",");
}
type.append(UserAdviceConstant.SOFTWARE_TYPE_TEXT);
}
adviceDetailResultDTO.setAdviceType(type.toString());
}
//获取建议图片
List<UserAdviceImgEntity> imgsByAdviceId = userAdviceImgService.getImgsByAdviceId(adviceId);
List<String> govImgList = new ArrayList<>();
List<String> resiImgList = new ArrayList<>();
for (UserAdviceImgEntity entity : imgsByAdviceId) {
if ("resi".equals(entity.getType())) {
resiImgList.add(entity.getImgUrl());
} else if ("oper".equals(entity.getType())) {
govImgList.add(entity.getImgUrl());
}
}
adviceDetailResultDTO.setImgList(resiImgList);
adviceDetailResultDTO.setGovImgList(govImgList);
return adviceDetailResultDTO;
}
/**
* @param dto
* @return com.epmet.commons.tools.page.PageData<com.epmet.dto.UserAdviceDTO>
* @Description 查询建议列表
* @Author liushaowen
* @Date 2020/11/9 10:41
*/
@Override
public PageData<UserAdviceDTO> adviceList(AdviceListFormDTO dto) {
//page分页
Page<UserAdviceEntity> page = new Page<>(dto.getPageNo(), dto.getPageSize());
//时间降序
page.addOrder(OrderItem.desc(FieldConstant.CREATED_TIME));
//wrapper
QueryWrapper<UserAdviceEntity> wrapper = new QueryWrapper<>();
IPage<UserAdviceEntity> result = baseDao.selectPage(page,wrapper);
return null;
}
}

3
epmet-user/epmet-user-server/src/main/resources/mapper/UserAdviceImgDao.xml

@ -6,6 +6,7 @@
<resultMap type="com.epmet.entity.UserAdviceImgEntity" id="userAdviceImgMap">
<result property="id" column="ID"/>
<result property="adviceId" column="ADVICE_ID"/>
<result property="type" column="TYPE"/>
<result property="imgUrl" column="IMG_URL"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
@ -16,4 +17,4 @@
</resultMap>
</mapper>
</mapper>

Loading…
Cancel
Save