Browse Source

服务发起、编辑

master
sunyuchao 3 years ago
parent
commit
37f8ed1b59
  1. 91
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/IcServiceRecordV2AddEditFormDTO.java
  2. 15
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceRecordV2Controller.java
  3. 5
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordV2Service.java
  4. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordServiceImpl.java
  5. 80
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordV2ServiceImpl.java

91
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> 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;
}
}

15
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);

5
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<IcServiceRecordV2E
* @author generator
* @date 2022-07-18
*/
void save(IcServiceRecordV2DTO dto);
void save(IcServiceRecordV2AddEditFormDTO dto);
/**
* 默认更新
@ -65,7 +66,7 @@ public interface IcServiceRecordV2Service extends BaseService<IcServiceRecordV2E
* @author generator
* @date 2022-07-18
*/
void update(IcServiceRecordV2DTO dto);
void update(IcServiceRecordV2AddEditFormDTO dto);
/**
* 批量删除

2
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordServiceImpl.java

@ -249,7 +249,7 @@ public class IcServiceRecordServiceImpl extends BaseServiceImpl<IcServiceRecordD
* @param scopeObjectId
* @return
*/
private String[] getScopeObjectIdPath(String scopeObjectType, String scopeObjectId) {
public String[] getScopeObjectIdPath(String scopeObjectType, String scopeObjectId) {
if ("neighborhood".equals(scopeObjectType)) {
String msg = String.format("【服务项目】-发起服务-根据范围id查询小区信息失败。scopeObjectType:%s, scopeObjectId:%s",

80
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordV2ServiceImpl.java

@ -6,19 +6,27 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.IcServiceRecordV2Dao;
import com.epmet.dto.IcServiceRecordV2DTO;
import com.epmet.dto.form.IcServiceRecordV2AddEditFormDTO;
import com.epmet.dto.form.ServiceProjectFeedbackFormDTO;
import com.epmet.dto.form.ServiceRecordV2ListFormDTO;
import com.epmet.dto.result.IcServiceScopeDTO;
import com.epmet.dto.result.ServiceRecordV2ListResultDTO;
import com.epmet.entity.IcServiceRecordV2Entity;
import com.epmet.entity.*;
import com.epmet.redis.IcPartyUnitRedis;
import com.epmet.service.HeartAttachmentService;
import com.epmet.service.IcServiceFeedbackV2Service;
import com.epmet.service.IcServiceRecordV2Service;
import com.epmet.service.IcServiceScopeV2Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -37,10 +45,20 @@ import java.util.Map;
* @since v1.0.0 2022-07-18
*/
@Service
@Slf4j
public class IcServiceRecordV2ServiceImpl extends BaseServiceImpl<IcServiceRecordV2Dao, IcServiceRecordV2Entity> 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<IcServiceRecordV2DTO> page(Map<String, Object> params) {
@ -75,15 +93,67 @@ public class IcServiceRecordV2ServiceImpl extends BaseServiceImpl<IcServiceRecor
@Override
@Transactional(rollbackFor = Exception.class)
public void save(IcServiceRecordV2DTO dto) {
IcServiceRecordV2Entity entity = ConvertUtils.sourceToTarget(dto, IcServiceRecordV2Entity.class);
public void save(IcServiceRecordV2AddEditFormDTO formDTO) {
//1.获取工作人员缓存信息
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId());
if (null == staffInfo) {
throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId()));
}
//2.新增服务记录数据
IcServiceRecordV2Entity entity = ConvertUtils.sourceToTarget(formDTO, IcServiceRecordV2Entity.class);
insert(entity);
//3.新增服务范围数据
List<IcServiceScopeV2Entity> 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<HeartAttachmentEntity> 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);
}

Loading…
Cancel
Save