|
|
@@ -3,8 +3,10 @@ package com.fdkankan.manage.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.manage.common.DistrictUtil;
|
|
|
import com.fdkankan.manage.common.PageInfo;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
|
+import com.fdkankan.manage.entity.DistrictCode;
|
|
|
import com.fdkankan.manage.entity.JyPlatform;
|
|
|
import com.fdkankan.manage.entity.JyUser;
|
|
|
import com.fdkankan.manage.entity.SysUser;
|
|
|
@@ -42,6 +44,8 @@ public class JyPlatformServiceImpl extends ServiceImpl<IJyPlatformMapper, JyPlat
|
|
|
ISysUserService sysUserService;
|
|
|
@Autowired
|
|
|
IJyUserService jyUserService;
|
|
|
+ @Autowired
|
|
|
+ IDistrictCodeService districtCodeService;
|
|
|
|
|
|
@Override
|
|
|
public Object pageList(JyPlatformParam param) {
|
|
|
@@ -216,4 +220,68 @@ public class JyPlatformServiceImpl extends ServiceImpl<IJyPlatformMapper, JyPlat
|
|
|
wrapper.eq(JyPlatform::getStatus,0);
|
|
|
return this.list(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JyPlatform getByDistrictCode(String districtCode,String phone ,String idCard) {
|
|
|
+ DistrictCode district = getPlatFormDistrictCode(districtCode);
|
|
|
+ if(district != null){
|
|
|
+ JyPlatform jyPlatform = getPlatformByCode(district.getCode());
|
|
|
+ if(jyPlatform != null){
|
|
|
+ return jyPlatform;
|
|
|
+ }
|
|
|
+ String platflormName = DistrictUtil.getPureCityName(district.getName()) +"公安";
|
|
|
+ jyPlatform = this.getPlatformName(platflormName);
|
|
|
+ if(jyPlatform!=null){
|
|
|
+ LambdaUpdateWrapper<JyPlatform> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(JyPlatform::getId,jyPlatform.getId());
|
|
|
+ wrapper.set(JyPlatform::getDistrictCode,district.getCode());
|
|
|
+ wrapper.set(JyPlatform::getDistrictName,district.getName());
|
|
|
+ this.update(wrapper);
|
|
|
+ return jyPlatform;
|
|
|
+ }
|
|
|
+ String uuid = UUID.randomUUID().toString().substring(0, 18).replace("-", "");
|
|
|
+ jyPlatform = new JyPlatform();
|
|
|
+ jyPlatform.setPlatformName(platflormName);
|
|
|
+ jyPlatform.setPlatformAddress(uuid);
|
|
|
+ jyPlatform.setName(platflormName);
|
|
|
+ jyPlatform.setIdCard(idCard);
|
|
|
+ jyPlatform.setDistrictCode(district.getCode());
|
|
|
+ jyPlatform.setDistrictName(district.getName());
|
|
|
+ jyPlatform.setIsNew(true);
|
|
|
+ this.save(jyPlatform);
|
|
|
+ return jyPlatform;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private JyPlatform getPlatformName(String platflormName) {
|
|
|
+ LambdaQueryWrapper<JyPlatform> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(JyPlatform::getPlatformName,platflormName);
|
|
|
+ List<JyPlatform> list = this.list(wrapper);
|
|
|
+ if(list == null || list.isEmpty()){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return list.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ private JyPlatform getPlatformByCode(String code){
|
|
|
+ LambdaQueryWrapper<JyPlatform> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(JyPlatform::getDistrictCode,code);
|
|
|
+ List<JyPlatform> list = this.list(wrapper);
|
|
|
+ if(list == null || list.isEmpty()){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return list.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ private DistrictCode getPlatFormDistrictCode(String districtCode){
|
|
|
+ DistrictCode byCode = districtCodeService.getByCode(districtCode);
|
|
|
+ if(byCode == null || StringUtils.isBlank(byCode.getParentCode())){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if(DistrictUtil.isCityLevel(districtCode)){
|
|
|
+ return byCode;
|
|
|
+ }
|
|
|
+ return getPlatFormDistrictCode(byCode.getParentCode());
|
|
|
+ }
|
|
|
}
|