Commit 21671747 by 刘宇峰

特约店、围栏bug 修复

1 parent c2c740ec
...@@ -45,8 +45,13 @@ public enum ResultEnum { ...@@ -45,8 +45,13 @@ public enum ResultEnum {
/** /**
* 试驾围栏管理相关业务异常错误码,错误信息 1213开头 * 试驾围栏管理相关业务异常错误码,错误信息 1213开头
*/ */
ELECTRIC_FENCE_EXISTED(121230001, "围栏名称已存在") ELECTRIC_FENCE_EXISTED(121330001, "线路名称已存在"),
/**
* 特约店围栏管理相关业务异常错误码,错误信息 1214开头
*/
TRIAL_DRIVE_SHOP_EXISTED(121430001, "此特约店已存在"),
TRIAL_DRIVE_SHOP_FENCE_EXISTED(121430002, "特约店围栏名称已存在")
; ;
private final Integer code; private final Integer code;
......
...@@ -24,7 +24,7 @@ public interface ElectricFenceMapper extends CommonBaseMapper<ElectricFence> { ...@@ -24,7 +24,7 @@ public interface ElectricFenceMapper extends CommonBaseMapper<ElectricFence> {
List<ElectricFence> selectAllNotDel(); List<ElectricFence> selectAllNotDel();
ElectricFence selectByFenceName(@Param("fenceName") String fenceName); ElectricFence selectByFenceNameAndBizType(@Param("fenceName") String fenceName, @Param("bizFenceType") Integer bizFenceType);
/** /**
* 逻辑删除 * 逻辑删除
......
...@@ -21,9 +21,7 @@ import cn.com.glsx.admin.modules.model.param.ApprovalBo; ...@@ -21,9 +21,7 @@ import cn.com.glsx.admin.modules.model.param.ApprovalBo;
import cn.com.glsx.admin.modules.model.param.ElectricFenceBO; import cn.com.glsx.admin.modules.model.param.ElectricFenceBO;
import cn.com.glsx.admin.modules.model.param.ElectricFenceSearch; import cn.com.glsx.admin.modules.model.param.ElectricFenceSearch;
import cn.com.glsx.auth.utils.ShieldContextHolder; import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.usercenter.api.dto.response.Organization;
import cn.com.glsx.usercenter.api.dto.response.User; import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.feign.OrganizationService;
import cn.com.glsx.usercenter.api.feign.UserService; import cn.com.glsx.usercenter.api.feign.UserService;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
...@@ -32,7 +30,6 @@ import com.github.pagehelper.PageHelper; ...@@ -32,7 +30,6 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -40,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -40,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Type;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -79,7 +75,7 @@ public class ElectricFenceService { ...@@ -79,7 +75,7 @@ public class ElectricFenceService {
Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize()); Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<ElectricFenceDTO> list = electricFenceMapper.search(search); List<ElectricFenceDTO> list = electricFenceMapper.search(search);
organizaService.drawOrganization(list); organizaService.drawOrganization(list);
list.forEach(index->{ list.forEach(index -> {
index.setBizFenceType(BizFenceTypeEnum.getNameByCode(Integer.valueOf(index.getBizFenceType()))); index.setBizFenceType(BizFenceTypeEnum.getNameByCode(Integer.valueOf(index.getBizFenceType())));
}); });
return new PageInfo<>(list); return new PageInfo<>(list);
...@@ -88,7 +84,7 @@ public class ElectricFenceService { ...@@ -88,7 +84,7 @@ public class ElectricFenceService {
public List<ElectricFenceExport> export(ElectricFenceSearch search) { public List<ElectricFenceExport> export(ElectricFenceSearch search) {
List<ElectricFenceExport> list = electricFenceMapper.export(search); List<ElectricFenceExport> list = electricFenceMapper.export(search);
organizaService.drawOrganization(list); organizaService.drawOrganization(list);
list.forEach(index->{ list.forEach(index -> {
index.setBizFenceType(BizFenceTypeEnum.getNameByCode(Integer.valueOf(index.getBizFenceType()))); index.setBizFenceType(BizFenceTypeEnum.getNameByCode(Integer.valueOf(index.getBizFenceType())));
}); });
return list; return list;
...@@ -102,8 +98,6 @@ public class ElectricFenceService { ...@@ -102,8 +98,6 @@ public class ElectricFenceService {
*/ */
public void addFenceHandler(ElectricFenceBO fenceBO) throws Exception { public void addFenceHandler(ElectricFenceBO fenceBO) throws Exception {
checkElectricFence(fenceBO, false);
// 2021/5/24 围栏审核 特约店用户修改才提交 // 2021/5/24 围栏审核 特约店用户修改才提交
List<Long> shopOrgIds = trialDriveShopService.getShopOrgIds(); List<Long> shopOrgIds = trialDriveShopService.getShopOrgIds();
...@@ -160,13 +154,13 @@ public class ElectricFenceService { ...@@ -160,13 +154,13 @@ public class ElectricFenceService {
*/ */
public void checkElectricFence(ElectricFenceBO fenceBO, boolean updateFlag) { public void checkElectricFence(ElectricFenceBO fenceBO, boolean updateFlag) {
if (updateFlag) { if (updateFlag) {
ElectricFence existFence = electricFenceMapper.selectByFenceName(fenceBO.getFenceName()); ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(fenceBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_ROUTE.getCode());
if (existFence != null && !fenceBO.getId().equals(existFence.getId())) { if (existedFence != null && !fenceBO.getId().equals(existedFence.getId())) {
throw new AdminException(ResultEnum.ELECTRIC_FENCE_EXISTED); throw new AdminException(ResultEnum.ELECTRIC_FENCE_EXISTED);
} }
} else { } else {
ElectricFence existFence = electricFenceMapper.selectByFenceName(fenceBO.getFenceName()); ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(fenceBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_ROUTE.getCode());
if (existFence != null) { if (existedFence != null) {
throw new AdminException(ResultEnum.ELECTRIC_FENCE_EXISTED); throw new AdminException(ResultEnum.ELECTRIC_FENCE_EXISTED);
} }
} }
......
package cn.com.glsx.admin.modules.service; package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.common.enums.BizFenceTypeEnum;
import cn.com.glsx.admin.common.enums.ResultEnum;
import cn.com.glsx.admin.common.exception.AdminException;
import cn.com.glsx.admin.modules.converter.TrialDriveShopConverter; import cn.com.glsx.admin.modules.converter.TrialDriveShopConverter;
import cn.com.glsx.admin.modules.entity.ElectricFence; import cn.com.glsx.admin.modules.entity.ElectricFence;
import cn.com.glsx.admin.modules.entity.TrialDriveShop; import cn.com.glsx.admin.modules.entity.TrialDriveShop;
...@@ -31,7 +34,6 @@ import org.springframework.beans.BeanUtils; ...@@ -31,7 +34,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.Type;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -73,7 +75,8 @@ public class TrialDriveShopService { ...@@ -73,7 +75,8 @@ public class TrialDriveShopService {
public void addTrialDriveShop(TrialDriveShopBO shopBO) throws Exception { public void addTrialDriveShop(TrialDriveShopBO shopBO) throws Exception {
//todo 校验数据 // 校验数据
checkTrialDriveShop(shopBO, true);
//同步生成特约店围栏记录在围栏表 //同步生成特约店围栏记录在围栏表
ElectricFence fence = syncAddFence(shopBO); ElectricFence fence = syncAddFence(shopBO);
...@@ -115,7 +118,8 @@ public class TrialDriveShopService { ...@@ -115,7 +118,8 @@ public class TrialDriveShopService {
public void updateTrialDriveShop(TrialDriveShopBO shopBO) throws Exception { public void updateTrialDriveShop(TrialDriveShopBO shopBO) throws Exception {
//todo 校验数据 // 校验数据
checkTrialDriveShop(shopBO, true);
//同步更新特约店围栏记录在围栏表 //同步更新特约店围栏记录在围栏表
syncUpdateFence(shopBO); syncUpdateFence(shopBO);
...@@ -131,6 +135,30 @@ public class TrialDriveShopService { ...@@ -131,6 +135,30 @@ public class TrialDriveShopService {
trialDriveShopMapper.updateByPrimaryKey(shop); trialDriveShopMapper.updateByPrimaryKey(shop);
} }
/**
* 校验数据
*
* @param shopBO
* @param updateFlag
*/
public void checkTrialDriveShop(TrialDriveShopBO shopBO, boolean updateFlag) {
//1、特约店和账号
//2、特约店和特约店围栏
if (updateFlag) {
TrialDriveShop trialDriveShop = trialDriveShopMapper.selectById(shopBO.getId());
ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode());
if (existedFence != null && !trialDriveShop.getFenceId().equals(existedFence.getId())) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
}
} else {
ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode());
if (existedFence != null) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
}
}
}
public void syncUpdateFence(TrialDriveShopBO shopBO) throws Exception { public void syncUpdateFence(TrialDriveShopBO shopBO) throws Exception {
TrialDriveShop shop = trialDriveShopMapper.selectById(shopBO.getId()); TrialDriveShop shop = trialDriveShopMapper.selectById(shopBO.getId());
......
...@@ -59,12 +59,13 @@ ...@@ -59,12 +59,13 @@
and id = #{id} and id = #{id}
</select> </select>
<select id="selectByFenceName" resultMap="BaseResultMap"> <select id="selectByFenceNameAndBizType" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from t_electric_fence from t_electric_fence
where del_flag = 0 where del_flag = 0
and fence_name = #{fenceName} and fence_name = #{fenceName}
and biz_fence_type = #{bizFenceType}
limit 1 limit 1
</select> </select>
...@@ -89,6 +90,7 @@ ...@@ -89,6 +90,7 @@
left join t_user tu on tu.id = tef.created_by left join t_user tu on tu.id = tef.created_by
left join t_trial_drive_shop ttds on ttds.fence_id = tef.id left join t_trial_drive_shop ttds on ttds.fence_id = tef.id
where tef.del_flag = 0 where tef.del_flag = 0
and tef.biz_fence_type = 12
<if test="term != null and term !=''"> <if test="term != null and term !=''">
and ( and (
ttds.shop_name like CONCAT('%',#{term},'%') ttds.shop_name like CONCAT('%',#{term},'%')
...@@ -114,6 +116,7 @@ ...@@ -114,6 +116,7 @@
left join t_user tu on tu.id = tef.created_by left join t_user tu on tu.id = tef.created_by
left join t_trial_drive_shop ttds on ttds.fence_id = tef.id left join t_trial_drive_shop ttds on ttds.fence_id = tef.id
where tef.del_flag = 0 where tef.del_flag = 0
and tef.biz_fence_type = 12
<if test="term != null and term !=''"> <if test="term != null and term !=''">
and ( and (
ttds.shop_name like CONCAT('%',#{term},'%') ttds.shop_name like CONCAT('%',#{term},'%')
...@@ -131,5 +134,4 @@ ...@@ -131,5 +134,4 @@
set del_flag = -1 set del_flag = -1
where id = #{id} where id = #{id}
</update> </update>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -108,6 +108,23 @@ ...@@ -108,6 +108,23 @@
and ttds.id = #{id} and ttds.id = #{id}
</select> </select>
<select id="selectByShopName" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_trial_drive_shop ttds
where ttds.del_flag = 0
and ttds.id = #{id}
</select>
<select id="selectBySpecialShopId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_trial_drive_shop ttds
where ttds.del_flag = 0
and ttds.created_by = #{specialShopId}
limit 1
</select>
<update id="logicDeleteById"> <update id="logicDeleteById">
update t_trial_drive_shop update t_trial_drive_shop
set del_flag = -1 set del_flag = -1
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!