Commit e227f134 authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/dev' into dev

parents 8a322215 3394d66a
...@@ -59,4 +59,5 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf ...@@ -59,4 +59,5 @@ public class AreaBiz extends BaseBiz<AreaMapper, Area> implements UserRestInterf
} }
} }
...@@ -13,6 +13,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO; ...@@ -13,6 +13,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.RedisKey; import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.entity.Area;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockInfo; import com.xxfc.platform.vehicle.entity.BranchCompanyStockInfo;
import com.xxfc.platform.vehicle.entity.SysRegion; import com.xxfc.platform.vehicle.entity.SysRegion;
...@@ -65,6 +66,9 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -65,6 +66,9 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
@Autowired @Autowired
UserFeign userFeign; UserFeign userFeign;
@Autowired
private AreaBiz areaBiz;
@Override @Override
public UserFeign getUserFeign() { public UserFeign getUserFeign() {
return userFeign; return userFeign;
...@@ -77,6 +81,8 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -77,6 +81,8 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
@Autowired @Autowired
private VehicleBiz vehicleBiz; private VehicleBiz vehicleBiz;
/** /**
* 按主键获取公司 * 按主键获取公司
* *
...@@ -152,17 +158,35 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -152,17 +158,35 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
} }
public PageDataVO<BranchCompany> getAll(Integer page, Integer limit, Integer addrProvince, Integer addrCity, public PageDataVO<BranchCompany> getAll(Integer page, Integer limit, Integer addrProvince, Integer addrCity,
Integer addrTown, UserDTO userDTO) { Integer addrTown,Integer zoneId, UserDTO userDTO) {
Example example = new Example(BranchCompany.class); Example example = new Example(BranchCompany.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
if (addrProvince != null) { String provinceIds="";
criteria.andCondition(" addr_province = '" + addrProvince + "'"); if (Objects.nonNull(zoneId)){
Area area = areaBiz.selectById(zoneId);
provinceIds = area.getProvinceIds();
}
if (StringUtils.isNotEmpty(provinceIds)){
List<String> provinceIdList = Arrays.asList(provinceIds.split(","));
if (Objects.nonNull(addrProvince)){
if (provinceIdList.contains(String.valueOf(addrProvince))){
criteria.andEqualTo("addrProvince",addrProvince);
}else {
return new PageDataVO<BranchCompany>();
}
}else {
criteria.andIn("addrProvince",provinceIdList);
}
}else {
if (addrProvince != null) {
criteria.andEqualTo("addrProvince",addrProvince);
}
} }
if (addrCity != null) { if (addrCity != null) {
criteria.andCondition(" addr_city = '" + addrCity + "'"); criteria.andEqualTo("addrCity",addrCity);
} }
if (addrTown != null) { if (addrTown != null) {
criteria.andCondition(" addr_town = '" + addrTown + "'"); criteria.andEqualTo("addrTown",addrTown);
} }
if (userDTO != null && DATA_ALL_FALSE.equals(userDTO.getDataAll())) { if (userDTO != null && DATA_ALL_FALSE.equals(userDTO.getDataAll())) {
if (StringUtils.isNotBlank(userDTO.getDataZone())) { if (StringUtils.isNotBlank(userDTO.getDataZone())) {
...@@ -172,7 +196,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -172,7 +196,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
criteria.andIn(ID, userDTO.dataCompany2List()); criteria.andIn(ID, userDTO.dataCompany2List());
} }
} }
example.setOrderByClause("`id` asc"); example.setOrderByClause("`id` desc");
PageHelper.startPage(page, limit); PageHelper.startPage(page, limit);
PageInfo<BranchCompany> branchCompanyPageInfo = new PageInfo<>(mapper.selectByExample(example)); PageInfo<BranchCompany> branchCompanyPageInfo = new PageInfo<>(mapper.selectByExample(example));
return PageDataVO.pageInfo(branchCompanyPageInfo); return PageDataVO.pageInfo(branchCompanyPageInfo);
......
...@@ -6,11 +6,14 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken; ...@@ -6,11 +6,14 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.vehicle.biz.AreaBiz;
import com.xxfc.platform.vehicle.biz.BranchCompanyBiz; import com.xxfc.platform.vehicle.biz.BranchCompanyBiz;
import com.xxfc.platform.vehicle.biz.VehicleBiz; import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.common.BaseController; import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.Area;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVo; import com.xxfc.platform.vehicle.pojo.BranchCompanyVo;
import com.xxfc.platform.vehicle.pojo.CompanyDetail; import com.xxfc.platform.vehicle.pojo.CompanyDetail;
...@@ -49,12 +52,15 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> { ...@@ -49,12 +52,15 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
@Autowired @Autowired
private UserAuthConfig userAuthConfig; private UserAuthConfig userAuthConfig;
@Autowired
private AreaBiz areaBiz;
@RequestMapping(value ="/page",method = RequestMethod.GET) @RequestMapping(value ="/page",method = RequestMethod.GET)
public RestResponse<PageDataVO<BranchCompany>> page(@RequestParam Integer page, @RequestParam Integer limit, public RestResponse<PageDataVO<BranchCompany>> page(@RequestParam Integer page, @RequestParam Integer limit,
@RequestParam(required = false) Integer addrProvince, @RequestParam(required = false) Integer addrCity, @RequestParam(required = false) Integer addrProvince, @RequestParam(required = false) Integer addrCity,
@RequestParam(required = false) Integer addrTown, @RequestParam(required = false) String location) { @RequestParam(required = false) Integer addrTown, @RequestParam(required = false) Integer zoneId) {
UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData(); UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();
return RestResponse.data(baseBiz.getAll(page,limit,addrProvince, addrCity, addrTown, userDTO)); return RestResponse.data(baseBiz.getAll(page,limit,addrProvince, addrCity, addrTown, zoneId,userDTO));
} }
@IgnoreUserToken @IgnoreUserToken
...@@ -62,7 +68,7 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> { ...@@ -62,7 +68,7 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
public RestResponse<PageDataVO<BranchCompany>> allPage(@RequestParam Integer page, @RequestParam Integer limit, public RestResponse<PageDataVO<BranchCompany>> allPage(@RequestParam Integer page, @RequestParam Integer limit,
@RequestParam(required = false) Integer addrProvince, @RequestParam(required = false) Integer addrCity, @RequestParam(required = false) Integer addrProvince, @RequestParam(required = false) Integer addrCity,
@RequestParam(required = false) Integer addrTown) { @RequestParam(required = false) Integer addrTown) {
return RestResponse.data(baseBiz.getAll(page,limit,addrProvince, addrCity, addrTown, null)); return RestResponse.data(baseBiz.getAll(page,limit,addrProvince, addrCity, addrTown, null,null));
} }
@RequestMapping(value ="/search",method = RequestMethod.GET) @RequestMapping(value ="/search",method = RequestMethod.GET)
...@@ -89,8 +95,16 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> { ...@@ -89,8 +95,16 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
} }
@RequestMapping(value ="",method = RequestMethod.POST) @RequestMapping(value ="",method = RequestMethod.POST)
public RestResponse<Integer> add(@RequestBody BranchCompanyVo branchCompanyVo) { public ObjectRestResponse<Integer> add(@RequestBody BranchCompanyVo branchCompanyVo) {
return RestResponse.data(baseBiz.add(branchCompanyVo)); if (branchCompanyVo==null){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
Area area=areaBiz.selectById(branchCompanyVo.getZoneId());
Integer provinc=branchCompanyVo.getAddrProvince()==null?0:branchCompanyVo.getAddrProvince();
if (area==null||StringUtils.isBlank(area.getProvinceIds())||!area.getProvinceIds().contains(provinc+"")){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"片区和省份不一致");
}
return ObjectRestResponse.succ(baseBiz.add(branchCompanyVo));
} }
@RequestMapping(value ="/app/unauth/getByZone",method = RequestMethod.GET) @RequestMapping(value ="/app/unauth/getByZone",method = RequestMethod.GET)
...@@ -113,9 +127,17 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> { ...@@ -113,9 +127,17 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
} }
@RequestMapping(value ="",method = RequestMethod.PUT) @RequestMapping(value ="",method = RequestMethod.PUT)
public RestResponse update(@RequestBody BranchCompany branchCompany) { public ObjectRestResponse update(@RequestBody BranchCompany branchCompany) {
if (branchCompany==null){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
Area area=areaBiz.selectById(branchCompany.getZoneId());
Integer provinc=branchCompany.getAddrProvince()==null?0:branchCompany.getAddrProvince();
if (area==null||StringUtils.isBlank(area.getProvinceIds())||!area.getProvinceIds().contains(provinc+"")){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"片区和省份不一致");
}
baseBiz.update(branchCompany); baseBiz.update(branchCompany);
return RestResponse.sucResponse(); return ObjectRestResponse.succ();
} }
@RequestMapping(value ="/{id}",method = RequestMethod.DELETE) @RequestMapping(value ="/{id}",method = RequestMethod.DELETE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment