Browse Source

...

feature/teamB_zz_wgh
zxc 3 years ago
parent
commit
83c4c67eb1
  1. 51
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/ServiceProjectFormDTO.java
  2. 19
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceProjectController.java
  3. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceProjectService.java
  4. 50
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceProjectServiceImpl.java

51
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/ServiceProjectFormDTO.java

@ -0,0 +1,51 @@
package com.epmet.dto.form;
import com.epmet.dto.IcServiceProjectAttachmentDTO;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @Author zxc
* @DateTime 2022/5/27 15:53
* @DESC
*/
@Data
public class ServiceProjectFormDTO implements Serializable {
private static final long serialVersionUID = -4573264697450644498L;
public interface ServiceProjectAddForm{}
@NotBlank(message = "服务类别不能为空",groups = {ServiceProjectAddForm.class})
private String serviceCategoryKey;
@NotBlank(message = "服务名称不能为空",groups = {ServiceProjectAddForm.class})
private String serviceName;
@NotBlank(message = "服务内容不能为空",groups = {ServiceProjectAddForm.class})
private String serviceContent;
/**
* 政策依据
*/
private String policyGround;
/**
* 政策级别0市级1区级2街道级
*/
private String policyLevel;
private String customerId;
private String userId;
/**
* 附件集合
*/
@Valid
private List<IcServiceProjectAttachmentDTO> attachmentList;
}

19
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceProjectController.java

@ -1,7 +1,9 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
@ -10,6 +12,7 @@ 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.IcServiceProjectDTO;
import com.epmet.dto.form.ServiceProjectFormDTO;
import com.epmet.service.IcServiceProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -70,4 +73,20 @@ public class IcServiceProjectController {
return new Result();
}
/**
* Desc: 服务项目新增
* @param tokenDto
* @param formDTO
* @author zxc
* @date 2022/5/27 16:04
*/
@PostMapping("serviceProjectAdd")
public Result serviceProjectAdd(@LoginUser TokenDto tokenDto,@RequestBody ServiceProjectFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, ServiceProjectFormDTO.ServiceProjectAddForm.class);
formDTO.setUserId(tokenDto.getUserId());
formDTO.setCustomerId(tokenDto.getCustomerId());
icServiceProjectService.serviceProjectAdd(formDTO);
return new Result();
}
}

10
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceProjectService.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.IcServiceProjectDTO;
import com.epmet.dto.form.ServiceProjectFormDTO;
import com.epmet.entity.IcServiceProjectEntity;
import java.util.List;
@ -75,4 +76,13 @@ public interface IcServiceProjectService extends BaseService<IcServiceProjectEnt
* @date 2022-05-27
*/
void delete(String[] ids);
/**
* Desc: 服务项目新增
* @param formDTO
* @author zxc
* @date 2022/5/27 16:04
*/
void serviceProjectAdd(ServiceProjectFormDTO formDTO);
}

50
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceProjectServiceImpl.java

@ -3,14 +3,23 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.IcServiceProjectDao;
import com.epmet.dto.IcServiceProjectDTO;
import com.epmet.dto.form.ServiceProjectFormDTO;
import com.epmet.entity.IcServiceProjectAttachmentEntity;
import com.epmet.entity.IcServiceProjectEntity;
import com.epmet.redis.IcServiceProjectRedis;
import com.epmet.service.IcServiceProjectAttachmentService;
import com.epmet.service.IcServiceProjectService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -30,7 +39,7 @@ import java.util.Map;
public class IcServiceProjectServiceImpl extends BaseServiceImpl<IcServiceProjectDao, IcServiceProjectEntity> implements IcServiceProjectService {
@Autowired
private IcServiceProjectRedis icServiceProjectRedis;
private IcServiceProjectAttachmentService attachmentService;
@Override
public PageData<IcServiceProjectDTO> page(Map<String, Object> params) {
@ -84,4 +93,41 @@ public class IcServiceProjectServiceImpl extends BaseServiceImpl<IcServiceProjec
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* Desc: 服务项目新增
* @param formDTO
* @author zxc
* @date 2022/5/27 16:04
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void serviceProjectAdd(ServiceProjectFormDTO formDTO) {
IcServiceProjectEntity entity = ConvertUtils.sourceToTarget(formDTO, IcServiceProjectEntity.class);
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId());
if (null == staffInfo){
throw new EpmetException("未查询到此工作人员"+formDTO.getUserId());
}
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfo.getAgencyId());
if (null == agencyInfo){
throw new EpmetException("未查询到此组织信息"+staffInfo.getStaffId());
}
entity.setEnabled(NumConstant.ZERO);
entity.setAgencyId(staffInfo.getAgencyId());
entity.setPid(agencyInfo.getPid());
entity.setAgencyIdPath((StringUtils.isBlank(agencyInfo.getPids()) || agencyInfo.getPids().equals(NumConstant.ZERO_STR)) ? staffInfo.getAgencyId() : agencyInfo.getPids().concat(":").concat(staffInfo.getAgencyId()));
baseDao.insert(entity);
if (CollectionUtils.isNotEmpty(formDTO.getAttachmentList())){
List<IcServiceProjectAttachmentEntity> entities = ConvertUtils.sourceToTarget(formDTO.getAttachmentList(), IcServiceProjectAttachmentEntity.class);
Integer sort = NumConstant.ZERO;
for (IcServiceProjectAttachmentEntity e : entities) {
e.setCustomerId(formDTO.getCustomerId());
e.setStatus("auto_passed");
e.setSort(sort);
e.setIcServiceId(entity.getId());
sort++;
}
attachmentService.insertBatch(entities);
}
}
}
Loading…
Cancel
Save