package com.xzx.gc.user.controller; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.xzx.gc.common.Result; import com.xzx.gc.common.constant.CommonEnum; import com.xzx.gc.common.constant.Constants; import com.xzx.gc.common.dto.log.OperationAppLog; import com.xzx.gc.common.request.BaseController; import com.xzx.gc.entity.*; import com.xzx.gc.model.JsonResult; import com.xzx.gc.model.order.AreaDto; import com.xzx.gc.model.order.SysConfigDto; import com.xzx.gc.model.query.SettingMoneyQuery; import com.xzx.gc.user.mapper.ConfigMapper; import com.xzx.gc.user.mapper.FenceMapper; import com.xzx.gc.user.service.*; import com.xzx.gc.util.PreventManyCommit; import com.xzx.gc.util.SessionUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @author:andylei * @title * @Description * @date 2018/11/22/022 * @修改历史 */ @Api(tags = "合伙人区域管理") @RestController public class PartnerGaodeController extends BaseController { @Autowired private SessionUtil sessionUtil; @Autowired private CityPartnerService cityPartnerService; @Autowired private OtherUserService otherUserService; @Autowired private PartnerGaodeService partnerGaodeService; @Autowired private AddressLevelService addressLevelService; @PostMapping("/admin/front/partnerGaode/queryPartnerCityById.json") @ApiOperation(value="账户管理优化(查询回收人所属城市)", notes="test: 仅0有正确返回") public JsonResult> queryPartnerCityById(){ CoreUser currentUser = sessionUtil.getCurrentUser(); CityPartner partner = cityPartnerService.queryById(currentUser.getId()); List> list = cityPartnerService.queryPartnerCityById(partner); Map map = new HashMap<>(); map.put("data",list); map.put("code",0); return JsonResult.success(map); } @PostMapping( "/admin/front/partnerGaode/queryAreaObj.json") @ApiOperation(value="账户管理优化(查询回收人所属城市)", notes="test: 仅0有正确返回") public JsonResult> queryAreaObj(){ CoreUser currentUser = sessionUtil.getCurrentUser(); CityPartner partner = cityPartnerService.queryById(currentUser.getId()); List> list = cityPartnerService.queryAreaObj(partner); Map map = new HashMap<>(); map.put("data",list); map.put("code",0); return JsonResult.success(map); } @ApiOperation(value = "查看合伙人所属的区域",notes = "可能是市或者区") @PostMapping(value = "/partnerGaode/selectArea") public Result> selectArea(HttpServletRequest request){ List list=new ArrayList(); OtherUserInfo byId = otherUserService.findById(getUserId(request)); String partnerId = byId.getPartnerId(); if(StrUtil.isBlank(partnerId)){ return Result.error(-1,"当前用户没分配合伙人"); } List byPartnerId = partnerGaodeService.findByPartnerId(partnerId); if(CollUtil.isNotEmpty(byPartnerId)){ String townIds=byPartnerId.stream().map(x->x.getTownId()).collect(Collectors.joining(",")); //按多个区域对应 List byTownIds = addressLevelService.findByTownIds(townIds); for (AddressLevelInfo byTownId : byTownIds) { AreaDto areaDto=new AreaDto(); areaDto.setAreaName(byTownId.getLevel3Name()); areaDto.setAreaId(byTownId.getLevel3Id()); areaDto.setLevel(3); list.add(areaDto); } } return Result.success(list); } }