Browse Source

事件新增 修改判断重复名

master
zxc 4 years ago
parent
commit
5ed5d9ccfb
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPartyServiceCenterMatterDao.java
  3. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcPartyServiceCenterMatterService.java
  4. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterMatterServiceImpl.java
  5. 35
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java
  6. 9
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPartyServiceCenterMatterDao.xml

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -163,6 +163,7 @@ public enum EpmetErrorCode {
EXISTS_SAME_PHONE_ERROR(8529, "%s存在重复"),
COMMUNITY_SELF_ORGANIZATION_LIST_REPART_ERROR(8530, "%s社区自组织名称已存在"),
MATTER_NAME_EXISTS_APPOINTMENT_ERROR(8531, "存在重复预约事项"),
// 该错误不会提示给前端,只是后端传输错误信息用。
ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"),

12
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPartyServiceCenterMatterDao.java

@ -22,6 +22,8 @@ import com.epmet.entity.IcPartyServiceCenterMatterEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 党群服务中心可预约事项表
*
@ -38,5 +40,13 @@ public interface IcPartyServiceCenterMatterDao extends BaseDao<IcPartyServiceCen
* @date 2021/11/22 10:29 上午
*/
void deleteMattersByPartyServiceCenterId(@Param("partyServiceCenterId") String partyServiceCenterId);
/**
* @Description 根据党群服务中心ID查询事件名字
* @param centerId
* @author zxc
* @date 2021/12/10 8:56 上午
*/
List<String> selectMatterNameByCenterId(@Param("centerId") String centerId);
}

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcPartyServiceCenterMatterService.java

@ -100,4 +100,12 @@ public interface IcPartyServiceCenterMatterService extends BaseService<IcPartySe
* @date 2021/11/22 10:29 上午
*/
void deleteMattersByPartyServiceCenterId(String partyServiceCenterId);
/**
* @Description 根据党群服务中心ID查询事件名字
* @param centerId
* @author zxc
* @date 2021/12/10 8:56 上午
*/
List<String> selectMatterNameByCenterId(String centerId);
}

11
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterMatterServiceImpl.java

@ -109,4 +109,15 @@ public class IcPartyServiceCenterMatterServiceImpl extends BaseServiceImpl<IcPar
baseDao.deleteMattersByPartyServiceCenterId(partyServiceCenterId);
}
/**
* @Description 根据党群服务中心ID查询事件名字
* @param centerId
* @author zxc
* @date 2021/12/10 8:56 上午
*/
@Override
public List<String> selectMatterNameByCenterId(String centerId) {
return baseDao.selectMatterNameByCenterId(centerId);
}
}

35
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java

@ -25,6 +25,7 @@ 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.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
@ -164,6 +165,12 @@ public class IcPartyServiceCenterServiceImpl extends BaseServiceImpl<IcPartyServ
baseDao.insert(centerEntity);
if (CollectionUtils.isNotEmpty(formDTO.getMatterList())){
List<IcPartyServiceCenterMatterEntity> matters = ConvertUtils.sourceToTarget(formDTO.getMatterList(), IcPartyServiceCenterMatterEntity.class);
Map<String, List<IcPartyServiceCenterMatterEntity>> groupByMatterName = matters.stream().collect(Collectors.groupingBy(IcPartyServiceCenterMatterEntity::getMatterName));
groupByMatterName.forEach((k,v) -> {
if (v.size() > NumConstant.ONE){
throw new EpmetException(EpmetErrorCode.MATTER_NAME_EXISTS_APPOINTMENT_ERROR.getCode());
}
});
matters.forEach(m -> {
m.setCustomerId(customerId);
m.setPartyServiceCenterId(centerEntity.getId());
@ -194,14 +201,7 @@ public class IcPartyServiceCenterServiceImpl extends BaseServiceImpl<IcPartyServ
IcPartyServiceCenterEntity centerEntity = ConvertUtils.sourceToTarget(formDTO, IcPartyServiceCenterEntity.class);
centerEntity.setId(formDTO.getPartyServiceCenterId());
baseDao.updateById(centerEntity);
if (CollectionUtils.isNotEmpty(formDTO.getMatterList())){
List<IcPartyServiceCenterMatterEntity> matters = ConvertUtils.sourceToTarget(formDTO.getMatterList(), IcPartyServiceCenterMatterEntity.class);
matters.forEach(m -> {
m.setCustomerId(tokenDto.getCustomerId());
m.setPartyServiceCenterId(formDTO.getPartyServiceCenterId());
});
matterService.insertBatch(matters);
}
// del matter
if (CollectionUtils.isNotEmpty(formDTO.getDelMatterList())){
List<String> delMatterList = formDTO.getDelMatterList();
@ -218,6 +218,25 @@ public class IcPartyServiceCenterServiceImpl extends BaseServiceImpl<IcPartyServ
matterService.deleteBatchIds(delMatterList);
}
}
if (CollectionUtils.isNotEmpty(formDTO.getMatterList())){
List<String> existsMatterNames = matterService.selectMatterNameByCenterId(formDTO.getPartyServiceCenterId());
List<IcPartyServiceCenterMatterEntity> matters = ConvertUtils.sourceToTarget(formDTO.getMatterList(), IcPartyServiceCenterMatterEntity.class);
List<String> paramMatterNames = matters.stream().map(m -> m.getMatterName()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(existsMatterNames)){
paramMatterNames.addAll(existsMatterNames);
}
Integer allSize = paramMatterNames.size();
Integer distinctSize = paramMatterNames.stream().distinct().collect(Collectors.toList()).size();
if (distinctSize < allSize){
throw new EpmetException(EpmetErrorCode.MATTER_NAME_EXISTS_APPOINTMENT_ERROR.getCode());
}
matters.forEach(m -> {
m.setCustomerId(tokenDto.getCustomerId());
m.setPartyServiceCenterId(formDTO.getPartyServiceCenterId());
});
matterService.insertBatch(matters);
}
}
/**

9
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPartyServiceCenterMatterDao.xml

@ -10,4 +10,13 @@
AND PARTY_SERVICE_CENTER_ID = #{partyServiceCenterId}
</delete>
<!-- 根据党群服务中心ID查询事件名字 -->
<select id="selectMatterNameByCenterId" resultType="java.lang.String">
SELECT
matter_name
FROM ic_party_service_center_matter
WHERE DEL_FLAG = 0
AND party_service_center_id = #{centerId}
</select>
</mapper>
Loading…
Cancel
Save