From 37f8ed1b591a04a9998bfa09a146d2f1cef112f6 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Tue, 19 Jul 2022 16:36:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=8F=91=E8=B5=B7=E3=80=81?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/IcServiceRecordV2AddEditFormDTO.java | 91 +++++++++++++++++++ .../IcServiceRecordV2Controller.java | 15 +-- .../service/IcServiceRecordV2Service.java | 5 +- .../impl/IcServiceRecordServiceImpl.java | 2 +- .../impl/IcServiceRecordV2ServiceImpl.java | 80 +++++++++++++++- 5 files changed, 178 insertions(+), 15 deletions(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/IcServiceRecordV2AddEditFormDTO.java diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/IcServiceRecordV2AddEditFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/IcServiceRecordV2AddEditFormDTO.java new file mode 100644 index 0000000000..615e9b7a20 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/IcServiceRecordV2AddEditFormDTO.java @@ -0,0 +1,91 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + + +/** + * 服务记录反馈表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-07-18 + */ +@Data +public class IcServiceRecordV2AddEditFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 服务Id + */ + @NotBlank(message = "服务Id不能为空", groups = {UpdateGroup.class}) + private String serviceRecordId; + /** + * 服务名称 + */ + @NotBlank(message = "服务名称不能为空", groups = {AddGroup.class}) + private String serviceName; + /** + * 服务组织类型 社区自组织:community_org, 志愿者:ic_user_volunteer, 联建单位:party_unit + */ + @NotBlank(message = "服务名称不能为空", groups = {AddGroup.class}) + private String serviceOrgType; + /** + * 服务组织Id + */ + @NotBlank(message = "服务名称不能为空", groups = {AddGroup.class}) + private String serviceOrgId; + /** + * 服务范围集合 + */ + private List objList; + /** + * 政策依据Id + */ + private Integer policyId; + /** + * 经办人姓名 + */ + private String principalName; + /** + * 联系方式 + */ + private String principalContact; + /** + * 起始服务时间 + */ + @NotNull(message = "起始服务时间不能为空", groups = {AddGroup.class}) + @JsonFormat(pattern = "yyyy-MM-dd") + private String serviceTimeStart; + /** + * 终止服务时间 + */ + @NotNull(message = "终止服务时间不能为空", groups = {AddGroup.class}) + @JsonFormat(pattern = "yyyy-MM-dd") + private String serviceTimeEnd; + /** + * 备注信息 + */ + private String remark; + /** + * 反馈记录数据 + */ + private IcServiceFeedbackV2AddFormDTO feedback; + + private String customerId; + private String userId; + + @Data + public static class ObjList { + private String objectType; + private String objectId; + private String objectName; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceRecordV2Controller.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceRecordV2Controller.java index aa8b978b4c..538bee258d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceRecordV2Controller.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceRecordV2Controller.java @@ -7,10 +7,10 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; -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.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.IcServiceRecordV2DTO; +import com.epmet.dto.form.IcServiceRecordV2AddEditFormDTO; import com.epmet.dto.form.ServiceRecordV2ListFormDTO; import com.epmet.service.IcServiceRecordV2Service; import org.springframework.beans.factory.annotation.Autowired; @@ -46,16 +46,17 @@ public class IcServiceRecordV2Controller { @NoRepeatSubmit @PostMapping("save") - public Result save(@RequestBody IcServiceRecordV2DTO dto){ - //效验数据 - ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - icServiceRecordV2Service.save(dto); + public Result save(@LoginUser TokenDto tokenDto, @RequestBody IcServiceRecordV2AddEditFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + icServiceRecordV2Service.save(formDTO); return new Result(); } @NoRepeatSubmit @PostMapping("update") - public Result update(@RequestBody IcServiceRecordV2DTO dto){ + public Result update(@RequestBody IcServiceRecordV2AddEditFormDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); icServiceRecordV2Service.update(dto); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordV2Service.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordV2Service.java index f10012c762..a88b4f1a13 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordV2Service.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordV2Service.java @@ -3,6 +3,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcServiceRecordV2DTO; +import com.epmet.dto.form.IcServiceRecordV2AddEditFormDTO; import com.epmet.dto.form.ServiceRecordV2ListFormDTO; import com.epmet.entity.IcServiceRecordV2Entity; @@ -55,7 +56,7 @@ public interface IcServiceRecordV2Service extends BaseService implements IcServiceRecordV2Service { @Autowired private IcPartyUnitRedis partyUnitRedis; + @Autowired + private IcServiceScopeV2Service icServiceScopeV2Service; + @Autowired + private IcServiceRecordServiceImpl icServiceRecordServiceImpl; + @Autowired + private IcServiceFeedbackV2Service icServiceFeedbackV2Service; + @Autowired + private HeartAttachmentService heartAttachmentService; + @Override public PageData page(Map params) { @@ -75,15 +93,67 @@ public class IcServiceRecordV2ServiceImpl extends BaseServiceImpl scopeList = new ArrayList<>(); + formDTO.getObjList().stream().forEach(s -> { + String[] scopeObjectIdPathAndName = icServiceRecordServiceImpl.getScopeObjectIdPath(s.getObjectType(), s.getObjectId()); + IcServiceScopeV2Entity scope = new IcServiceScopeV2Entity(); + scope.setCustomerId(formDTO.getCustomerId()); + scope.setServiceRecordId(entity.getId()); + scope.setObjectType(s.getObjectType()); + scope.setObjectId(s.getObjectId()); + scope.setObjectIdPath(scopeObjectIdPathAndName[0]); + scope.setObjectName(scopeObjectIdPathAndName[1]); + scopeList.add(scope); + }); + + //4.新增服务反馈数据feedback + if(null != formDTO.getFeedback()){ + IcServiceFeedbackV2Entity feedback = ConvertUtils.sourceToTarget(formDTO.getFeedback(), IcServiceFeedbackV2Entity.class); + feedback.setCustomerId(formDTO.getCustomerId()); + feedback.setServiceRecordId(entity.getId()); + icServiceFeedbackV2Service.insert(feedback); + // 反馈附件列表 + if (CollectionUtils.isNotEmpty(formDTO.getFeedback().getFileList())) { + List attachmentList = new ArrayList<>(); + int[] sort = {0}; + formDTO.getFeedback().getFileList().forEach(f->{ + HeartAttachmentEntity attachment = ConvertUtils.sourceToTarget(f, HeartAttachmentEntity.class); + attachment.setCustomerId(formDTO.getCustomerId()); + attachment.setBusinessId(feedback.getId()); + attachment.setAttachTo("ic_service_record_v2"); + attachment.setSort(sort[0]); + attachment.setStatus("auto_passed"); + sort[0]++; + attachmentList.add(attachment); + }); + heartAttachmentService.insertBatch(attachmentList); + } + } + } @Override @Transactional(rollbackFor = Exception.class) - public void update(IcServiceRecordV2DTO dto) { - IcServiceRecordV2Entity entity = ConvertUtils.sourceToTarget(dto, IcServiceRecordV2Entity.class); + public void update(IcServiceRecordV2AddEditFormDTO formDTO) { + //1.校验数据是否存在 + if (null == baseDao.selectById(formDTO.getServiceRecordId())) { + log.error(String.format("修改服务记录失败,未查询到服务记录,服务记录Id->%s", formDTO.getServiceRecordId())); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "修改服务记录失败,未查询到服务记录"); + } + IcServiceRecordV2Entity entity = ConvertUtils.sourceToTarget(formDTO, IcServiceRecordV2Entity.class); + entity.setId(formDTO.getServiceRecordId()); updateById(entity); }