From e28e50566946c9c69b562a107048a004f855f333 Mon Sep 17 00:00:00 2001 From: liushaowen <565850092@qq.com> Date: Mon, 9 Nov 2020 10:58:34 +0800 Subject: [PATCH] useradvice --- .../java/com/epmet/dto/UserAdviceImgDTO.java | 7 +- .../com/epmet/dto/form/AdviceListFormDTO.java | 56 +++++++++ .../dto/result/AdviceDetailResultDTO.java | 54 ++++++++- .../epmet/constant/UserAdviceConstant.java | 7 ++ .../controller/UserAdviceController.java | 21 +++- .../com/epmet/entity/UserAdviceImgEntity.java | 5 + .../com/epmet/excel/UserAdviceImgExcel.java | 5 +- .../epmet/service/UserAdviceImgService.java | 11 +- .../com/epmet/service/UserAdviceService.java | 20 ++++ .../impl/UserAdviceImgServiceImpl.java | 14 ++- .../service/impl/UserAdviceServiceImpl.java | 112 +++++++++++++++++- .../resources/mapper/UserAdviceImgDao.xml | 3 +- 12 files changed, 301 insertions(+), 14 deletions(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AdviceListFormDTO.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserAdviceConstant.java diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserAdviceImgDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserAdviceImgDTO.java index 37a50e3df6..cb39a925d5 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserAdviceImgDTO.java +++ b/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; -} \ No newline at end of file +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AdviceListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AdviceListFormDTO.java new file mode 100644 index 0000000000..1e001b988a --- /dev/null +++ b/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; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/AdviceDetailResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/AdviceDetailResultDTO.java index 462f053373..2f8bbbc262 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/AdviceDetailResultDTO.java +++ b/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 imgList; + + /** + * 政府回应图片 + */ + private List govImgList; + + /** + * 政府回应文字 + */ + private String govContent; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserAdviceConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserAdviceConstant.java new file mode 100644 index 0000000000..fb82d09fd7 --- /dev/null +++ b/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 = "软件功能及体验问题"; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java index de9e8b00c6..b58cc793a3 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java +++ b/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().ok(userAdviceService.adviceDetail(adviceId)); + } + + @PostMapping("advicelist") + public Result> adviceList(AdviceListFormDTO dto){ + ValidatorUtils.validateEntity(dto); + PageData page = userAdviceService.adviceList(dto); + return new Result>().ok(page); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserAdviceImgEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserAdviceImgEntity.java index a507b96b38..849b0ba467 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserAdviceImgEntity.java +++ b/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 */ diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/UserAdviceImgExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/UserAdviceImgExcel.java index 55b27a6b7e..f32014927c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/UserAdviceImgExcel.java +++ b/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; -} \ No newline at end of file +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceImgService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceImgService.java index 0e5cd1d5b5..86ed81cb83 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceImgService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceImgService.java @@ -92,4 +92,13 @@ public interface UserAdviceImgService extends BaseService { * @date 2020-11-04 */ void delete(String[] ids); -} \ No newline at end of file + + /** + * @Description 根据adviceId获取关联的图片 + * @param adviceId + * @return void + * @Author liushaowen + * @Date 2020/11/9 9:59 + */ + List getImgsByAdviceId(String adviceId); +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceService.java index f13d6f9eda..8e018df061 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserAdviceService.java +++ b/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 { * @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 + * @Author liushaowen + * @Date 2020/11/9 10:41 + */ + PageData adviceList(AdviceListFormDTO dto); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceImgServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceImgServiceImpl.java index bb0828b9a2..cc8a164969 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceImgServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceImgServiceImpl.java @@ -101,4 +101,16 @@ public class UserAdviceImgServiceImpl extends BaseServiceImpl getImgsByAdviceId(String adviceId) { + return baseDao.selectList(new QueryWrapper().eq("ADVICE_ID",adviceId)); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceServiceImpl.java index ceae0d177c..df0ca66996 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceServiceImpl.java +++ b/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 page(Map params) { IPage page = baseDao.selectPage( @@ -66,8 +83,8 @@ public class UserAdviceServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -112,6 +129,95 @@ public class UserAdviceServiceImpl extends BaseServiceImpl govImgList = dto.getGovImgList(); + if (!Collections.isEmpty(govImgList)) { + List 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 imgsByAdviceId = userAdviceImgService.getImgsByAdviceId(adviceId); + List govImgList = new ArrayList<>(); + List 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 + * @Description 查询建议列表 + * @Author liushaowen + * @Date 2020/11/9 10:41 + */ + @Override + public PageData adviceList(AdviceListFormDTO dto) { + //page分页 + Page page = new Page<>(dto.getPageNo(), dto.getPageSize()); + //时间降序 + page.addOrder(OrderItem.desc(FieldConstant.CREATED_TIME)); + + //wrapper + QueryWrapper wrapper = new QueryWrapper<>(); + + + IPage result = baseDao.selectPage(page,wrapper); + return null; } } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserAdviceImgDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserAdviceImgDao.xml index 2af36ffe33..8bb5ff3792 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserAdviceImgDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserAdviceImgDao.xml @@ -6,6 +6,7 @@ + @@ -16,4 +17,4 @@ - \ No newline at end of file +