结构社区:列表、增加、删除、数据维度
This commit is contained in:
parent
91154b45b4
commit
a679213cdc
@ -87,8 +87,8 @@ public class XhpcChargeOrderController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/stopUp")
|
||||
public AjaxResult stopUp(@RequestParam Long userId,@RequestParam String serialNumber,@RequestParam Long chargingOrderId){
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<停止充电>>>>>>>>>>>>>>>>>");
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<停止充电>>>>>>>>>>>>>>>>>");
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<停止充电>>>>>>>>>>>>>>chargingOrderId>>>"+chargingOrderId);
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<停止充电>>>>>>>>>>>>>>chargingOrderId>>>"+chargingOrderId);
|
||||
return iXhpcChargeOrderService.stopUp(userId, serialNumber, chargingOrderId);
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ public class XhpcPileOrderController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/chargeOrder/pileStop")
|
||||
public R pileStop(@RequestParam(value = "orderNo")String orderNo, @RequestParam(value = "status")Integer status,@RequestParam(value = "remark") String remark) {
|
||||
logger.info("桩停止回调接口>>>>>状态:"+status+"备注++"+"remark"+"订单号"+orderNo);
|
||||
logger.info("桩停止回调接口>>>>>状态:"+status+"备注++"+remark+"订单号"+orderNo);
|
||||
|
||||
//解析订单编号
|
||||
Integer code = 500;
|
||||
|
||||
@ -650,12 +650,17 @@
|
||||
ho.platform_svc_commisssion as platformSvcCommisssion,
|
||||
ho.operation_commission as operationCommission,
|
||||
ho.operation_svc_commission as operationSvcCommission,
|
||||
ho.charging_mode as chargingModeName,
|
||||
case when co.source=0 then "C端用户"
|
||||
when co.source=1 then "流量方用户"
|
||||
when co.source=2 then "社区用户"
|
||||
else "B端客户!"
|
||||
end sourceName
|
||||
end sourceName,
|
||||
case when ho.charging_mode="1" then "快电"
|
||||
when ho.charging_mode="2" then "恒大"
|
||||
when ho.charging_mode="3" then "新电途"
|
||||
when ho.charging_mode="4" then "小桔"
|
||||
else "C端客户"
|
||||
end chargingModeName
|
||||
from xhpc_history_order as ho
|
||||
left join xhpc_charging_station as ct on ct.charging_station_id = ho.charging_station_id
|
||||
left join xhpc_operator as op on op.operator_id = ct.operator_id
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
package com.xhpc.user.controller;
|
||||
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.core.web.page.TableDataInfo;
|
||||
import com.xhpc.common.domain.XhpcChargingPile;
|
||||
import com.xhpc.user.domain.XhpcCommunity;
|
||||
import com.xhpc.user.dto.MechanismDto;
|
||||
import com.xhpc.user.service.IMechanismService;
|
||||
import com.xhpc.user.service.IXhpcCommunityService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/20 10:12
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/community")
|
||||
public class XhpcCommunityController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IXhpcCommunityService xhpcCommunityService;
|
||||
@Autowired
|
||||
private IMechanismService mechanismService;
|
||||
|
||||
/**
|
||||
* 社区组树列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(String name) {
|
||||
startPage();
|
||||
List<Map<String, Object>> list = xhpcCommunityService.list(name);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增社区组树
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/addCommunity")
|
||||
public AjaxResult addCommunity(@RequestBody XhpcCommunity xhpcCommunity) {
|
||||
return xhpcCommunityService.addCommunity(xhpcCommunity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除社区组树
|
||||
*/
|
||||
@PostMapping(value = "/deleteCommunity")
|
||||
public AjaxResult deleteCommunity(@RequestBody XhpcCommunity xhpcCommunity) {
|
||||
xhpcCommunityService.deleteCommunity(xhpcCommunity);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据维度
|
||||
* @param status 0 地区 1.运营商 2. 运营商-地区
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getMechanism")
|
||||
public AjaxResult getMechanism(@RequestParam(value = "status")Integer status) {
|
||||
List<MechanismDto> mechanismDtos = mechanismService.dataList(1L, status);
|
||||
return AjaxResult.success(mechanismDtos);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
package com.xhpc.user.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* 社区组
|
||||
* yuyang
|
||||
*/
|
||||
@Data
|
||||
public class XhpcCommunity extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 社区组ID
|
||||
*/
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 社区组名称
|
||||
*/
|
||||
@NotEmpty(message = "社区组名称不能为空")
|
||||
@Length(min = 2,max = 10,message = "社区组名称长度2~10之间")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 服务费优惠比例
|
||||
*/
|
||||
private Double servicePreferential;
|
||||
|
||||
/**
|
||||
* 享受折扣人数最低限制
|
||||
*/
|
||||
private Integer minPeople;
|
||||
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
@NotEmpty(message = "联系人不能为空")
|
||||
private String contactName;
|
||||
|
||||
/**
|
||||
* 联系人电话
|
||||
*/
|
||||
@NotEmpty(message = "联系人电话不能为空")
|
||||
private String contactPhone;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@NotEmpty(message = "地址不能为空")
|
||||
@Length(max = 200,message = "地址最大200位")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 父级为0,子集为父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 社区组类型 (1.平台 2.运营商)
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 数据维度 0 地区 1.运营商 2. 运营商地区
|
||||
*/
|
||||
@NotEmpty(message = "数据维度不能为空")
|
||||
private Integer dimension;
|
||||
|
||||
/**
|
||||
* 是否有不参与合作的场站 (0 没有 1有)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 电站id
|
||||
*/
|
||||
private String chargingStationIds;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.xhpc.user.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/21 10:42
|
||||
*/
|
||||
@Data
|
||||
public class MechanismDto {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String label;
|
||||
|
||||
private List<MechanismDto> children;
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.xhpc.user.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/20 14:36
|
||||
*/
|
||||
public interface MechanismMapper {
|
||||
|
||||
/**
|
||||
* 获取登陆用户信息
|
||||
*/
|
||||
Map<String, Object> getLandUser(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 通过登录用户查询省地址
|
||||
* @param userId
|
||||
* @return 结果
|
||||
*/
|
||||
public List<Map<String, Object>> groupProvinceById(@Param("userId") Long userId, @Param("type") Integer type, @Param("operatorId")Long operatorId);
|
||||
|
||||
/**
|
||||
* 通过登录用户分组查询市地址
|
||||
* @return 结果
|
||||
*/
|
||||
public List<Map<String, Object>> groupCityById(@Param("userId") Long userId, @Param("type") Integer type,@Param("provinceCode") String provinceCode, @Param("operatorId")Long operatorId);
|
||||
/**
|
||||
* 通过登录用户分组查询区地址
|
||||
* @return 结果
|
||||
*/
|
||||
public List<Map<String, Object>> groupAreaById(@Param("userId") Long userId, @Param("type") Integer type,@Param("cityCode") String cityCode, @Param("operatorId")Long operatorId);
|
||||
|
||||
/**
|
||||
* 通过登录用户分组查询运营商
|
||||
* @return 结果
|
||||
*/
|
||||
public List<Map<String, Object>> groupOperatorById(@Param("userId") Long userId, @Param("type") Integer type,@Param("code") String cityCode);
|
||||
|
||||
/**
|
||||
* 通过登录用户分组查询场站
|
||||
* @return 结果
|
||||
*/
|
||||
public List<Map<String, Object>> dataCodeById(@Param("userId") Long userId, @Param("type") Integer type,@Param("code") String cityCode);
|
||||
|
||||
/**
|
||||
* 通过登录用户分组查询场站
|
||||
* @return 结果
|
||||
*/
|
||||
public List<Map<String, Object>> dataChargingStationId(@Param("userId") Long userId, @Param("type") Integer type,@Param("operatorId") String operatorId,@Param("code") String cityCode);
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.xhpc.user.mapper;
|
||||
|
||||
import com.xhpc.user.domain.XhpcCommunity;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface XhpcCommunityMapper {
|
||||
|
||||
/**
|
||||
* 获取登陆用户信息
|
||||
*/
|
||||
Map<String, Object> getLandUser(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 社区组树列表
|
||||
*
|
||||
* @param name 桩名称
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> list(@Param("name") String name);
|
||||
|
||||
/**
|
||||
* 添加数据维度
|
||||
*/
|
||||
int addMechanism(@Param("chargingStationIds") List<String> chargingStationIds,@Param("mechanismId")Long mechanismId,@Param("source")Integer source);
|
||||
|
||||
/**
|
||||
* 添加社区组
|
||||
* @param xhpcCommunity
|
||||
* @return
|
||||
*/
|
||||
int addCommunity(XhpcCommunity xhpcCommunity);
|
||||
|
||||
/**
|
||||
* 社区社区组
|
||||
* @param communityId
|
||||
*/
|
||||
void deleteCommunity(@Param("communityId")Long communityId);
|
||||
|
||||
/**
|
||||
* 检查改组是否还存在社区人员
|
||||
*/
|
||||
int countCommunityPersonnel(@Param("communityId")Long communityId);
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.xhpc.user.service;
|
||||
|
||||
import com.xhpc.user.dto.MechanismDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/20 14:30
|
||||
*/
|
||||
public interface IMechanismService {
|
||||
|
||||
/**
|
||||
* 用户拥有数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 结果
|
||||
*/
|
||||
public List<MechanismDto> dataList(Long userId, Integer status);
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.xhpc.user.service;
|
||||
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.domain.XhpcChargingPile;
|
||||
import com.xhpc.user.domain.XhpcCommunity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/20 9:59
|
||||
*/
|
||||
public interface IXhpcCommunityService {
|
||||
|
||||
/**
|
||||
* 社区组树列表
|
||||
*
|
||||
* @param name 桩名称
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> list(String name);
|
||||
|
||||
/**
|
||||
* 新增社区组树
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
AjaxResult addCommunity(XhpcCommunity xhpcCommunity);
|
||||
|
||||
/**
|
||||
* 删除社区组树
|
||||
*/
|
||||
void deleteCommunity(XhpcCommunity xhpcCommunity);
|
||||
}
|
||||
@ -0,0 +1,218 @@
|
||||
package com.xhpc.user.service.impl;
|
||||
|
||||
import com.xhpc.common.core.utils.SecurityUtils;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.user.dto.MechanismDto;
|
||||
import com.xhpc.user.mapper.MechanismMapper;
|
||||
import com.xhpc.user.service.IMechanismService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/20 14:30
|
||||
*/
|
||||
@Service
|
||||
public class IMechanismServiceImpl implements IMechanismService {
|
||||
|
||||
@Autowired
|
||||
private MechanismMapper mechanismMapper;
|
||||
@Override
|
||||
public List<MechanismDto> dataList(Long userId, Integer status) {
|
||||
//获取登陆用户
|
||||
//Long logUserId = SecurityUtils.getUserId();
|
||||
Long logUserId = 1L;
|
||||
int type =1;
|
||||
//根据权限获取场站
|
||||
if(logUserId !=1){
|
||||
Map<String, Object> landUser = mechanismMapper.getLandUser(logUserId);
|
||||
if(landUser !=null){
|
||||
if(landUser.get("userType") !=null){
|
||||
if("01".equals(landUser.get("userType").toString()) || "03".equals(landUser.get("userType").toString())){
|
||||
Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString());
|
||||
logUserId=logOperatorId;
|
||||
type =1;
|
||||
}else{
|
||||
type =2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
type=0;
|
||||
}
|
||||
if(status==0){
|
||||
return regionTree(logUserId,type);
|
||||
}else if(status==1){
|
||||
return operatorTree(logUserId,type);
|
||||
}else{
|
||||
return operatorRegionTree(logUserId,type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 地区树
|
||||
* @param userId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public List<MechanismDto> regionTree(Long userId, Integer type){
|
||||
List<MechanismDto> mechanismDtos =new ArrayList<>();
|
||||
//省
|
||||
List<Map<String, Object>> list = mechanismMapper.groupProvinceById(userId, type,null);
|
||||
if(list !=null && list.size()>0){
|
||||
for (Map<String, Object> map:list) {
|
||||
MechanismDto mechanismDto =new MechanismDto();
|
||||
String code = map.get("code").toString();
|
||||
mechanismDto.setId(Integer.valueOf(code));
|
||||
mechanismDto.setLabel(map.get("name").toString());
|
||||
List<MechanismDto> mechanismCityList =new ArrayList<>();
|
||||
//市
|
||||
List<Map<String, Object>> cityList = mechanismMapper.groupCityById(userId, type, code,null);
|
||||
for (Map<String, Object> cityMap:cityList) {
|
||||
MechanismDto mechanismCity =new MechanismDto();
|
||||
String codeCity = cityMap.get("code").toString();
|
||||
mechanismCity.setId(Integer.valueOf(codeCity));
|
||||
mechanismCity.setLabel(cityMap.get("name").toString());
|
||||
List<MechanismDto> mechanismAreaList =new ArrayList<>();
|
||||
//区
|
||||
List<Map<String, Object>> areaList = mechanismMapper.groupAreaById(userId, type, codeCity,null);
|
||||
for (Map<String, Object> areaMap:areaList) {
|
||||
MechanismDto mechanismArea =new MechanismDto();
|
||||
String codeArea = areaMap.get("code").toString();
|
||||
mechanismArea.setId(Integer.valueOf(codeArea));
|
||||
mechanismArea.setLabel(areaMap.get("name").toString());
|
||||
List<MechanismDto> mechanismOperatorList =new ArrayList<>();
|
||||
//运营商
|
||||
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, codeArea);
|
||||
for (Map<String, Object> operatorMap:operatorList) {
|
||||
MechanismDto mechanismOperator =new MechanismDto();
|
||||
String operatorId = operatorMap.get("operatorId").toString();
|
||||
mechanismOperator.setId(Integer.valueOf(operatorId));
|
||||
mechanismOperator.setLabel(operatorMap.get("name").toString());
|
||||
List<MechanismDto> mechanismdataList =new ArrayList<>();
|
||||
//场站
|
||||
List<Map<String, Object>> dataList = mechanismMapper.dataChargingStationId(userId, type, operatorId,codeArea);
|
||||
for (Map<String, Object> dataMap:dataList) {
|
||||
MechanismDto mechanismData =new MechanismDto();
|
||||
String codeData = dataMap.get("chargingStationId").toString();
|
||||
mechanismData.setId(Integer.valueOf(codeData));
|
||||
mechanismData.setLabel(dataMap.get("name").toString());
|
||||
mechanismdataList.add(mechanismData);
|
||||
}
|
||||
mechanismOperator.setChildren(mechanismdataList);
|
||||
mechanismOperatorList.add(mechanismOperator);
|
||||
}
|
||||
mechanismArea.setChildren(mechanismOperatorList);
|
||||
mechanismAreaList.add(mechanismArea);
|
||||
}
|
||||
mechanismCity.setChildren(mechanismAreaList);
|
||||
mechanismCityList.add(mechanismCity);
|
||||
}
|
||||
mechanismDto.setChildren(mechanismCityList);
|
||||
mechanismDtos.add(mechanismDto);
|
||||
}
|
||||
}
|
||||
return mechanismDtos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 运营商树
|
||||
*/
|
||||
public List<MechanismDto> operatorTree(Long userId, Integer type){
|
||||
List<MechanismDto> mechanismDtos =new ArrayList<>();
|
||||
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, null);
|
||||
if(operatorList !=null && operatorList.size()>0){
|
||||
for (Map<String, Object> operatorMap:operatorList) {
|
||||
MechanismDto mechanismOperator =new MechanismDto();
|
||||
String operatorId = operatorMap.get("operatorId").toString();
|
||||
mechanismOperator.setId(Integer.valueOf(operatorId));
|
||||
mechanismOperator.setLabel(operatorMap.get("name").toString());
|
||||
List<MechanismDto> mechanismdataList =new ArrayList<>();
|
||||
//场站
|
||||
List<Map<String, Object>> dataList = mechanismMapper.dataChargingStationId(userId, type, operatorId,null);
|
||||
for (Map<String, Object> dataMap:dataList) {
|
||||
MechanismDto mechanismData =new MechanismDto();
|
||||
String codeData = dataMap.get("chargingStationId").toString();
|
||||
mechanismData.setId(Integer.valueOf(codeData));
|
||||
mechanismData.setLabel(dataMap.get("name").toString());
|
||||
mechanismdataList.add(mechanismData);
|
||||
}
|
||||
mechanismOperator.setChildren(mechanismdataList);
|
||||
mechanismDtos.add(mechanismOperator);
|
||||
}
|
||||
}
|
||||
return mechanismDtos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 运营商--地区树
|
||||
* @param userId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public List<MechanismDto> operatorRegionTree(Long userId, Integer type){
|
||||
|
||||
List<MechanismDto> mechanismDtos =new ArrayList<>();
|
||||
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, null);
|
||||
if(operatorList !=null && operatorList.size()>0){
|
||||
for (Map<String, Object> operatorMap:operatorList) {
|
||||
MechanismDto mechanismOperator =new MechanismDto();
|
||||
String operatorId = operatorMap.get("operatorId").toString();
|
||||
mechanismOperator.setId(Integer.valueOf(operatorId));
|
||||
mechanismOperator.setLabel(operatorMap.get("name").toString());
|
||||
List<MechanismDto> mechanismdataList =new ArrayList<>();
|
||||
//省
|
||||
List<Map<String, Object>> list = mechanismMapper.groupProvinceById(userId, 3,Long.valueOf(operatorId));
|
||||
for (Map<String, Object> map:list) {
|
||||
MechanismDto mechanismDto =new MechanismDto();
|
||||
String code = map.get("code").toString();
|
||||
mechanismDto.setId(Integer.valueOf(code));
|
||||
mechanismDto.setLabel(map.get("name").toString());
|
||||
List<MechanismDto> mechanismCityList =new ArrayList<>();
|
||||
//市
|
||||
List<Map<String, Object>> cityList = mechanismMapper.groupCityById(userId, 3, code,Long.valueOf(operatorId));
|
||||
for (Map<String, Object> cityMap:cityList) {
|
||||
MechanismDto mechanismCity =new MechanismDto();
|
||||
String codeCity = cityMap.get("code").toString();
|
||||
mechanismCity.setId(Integer.valueOf(codeCity));
|
||||
mechanismCity.setLabel(cityMap.get("name").toString());
|
||||
List<MechanismDto> mechanismAreaList =new ArrayList<>();
|
||||
//区
|
||||
List<Map<String, Object>> areaList = mechanismMapper.groupAreaById(userId, 3,codeCity,Long.valueOf(operatorId));
|
||||
for (Map<String, Object> areaMap:areaList) {
|
||||
MechanismDto mechanismArea =new MechanismDto();
|
||||
String codeArea = areaMap.get("code").toString();
|
||||
mechanismArea.setId(Integer.valueOf(codeArea));
|
||||
mechanismArea.setLabel(areaMap.get("name").toString());
|
||||
List<MechanismDto> mechanismOperatorList =new ArrayList<>();
|
||||
//场站
|
||||
List<Map<String, Object>> dataList = mechanismMapper.dataChargingStationId(userId, type, operatorId,codeArea);
|
||||
for (Map<String, Object> dataMap:dataList) {
|
||||
MechanismDto mechanismData =new MechanismDto();
|
||||
String codeData = dataMap.get("chargingStationId").toString();
|
||||
mechanismData.setId(Integer.valueOf(codeData));
|
||||
mechanismData.setLabel(dataMap.get("name").toString());
|
||||
mechanismOperatorList.add(mechanismData);
|
||||
}
|
||||
mechanismArea.setChildren(mechanismOperatorList);
|
||||
mechanismAreaList.add(mechanismArea);
|
||||
}
|
||||
mechanismCity.setChildren(mechanismAreaList);
|
||||
mechanismCityList.add(mechanismCity);
|
||||
}
|
||||
mechanismDto.setChildren(mechanismCityList);
|
||||
mechanismdataList.add(mechanismDto);
|
||||
}
|
||||
mechanismOperator.setChildren(mechanismdataList);
|
||||
mechanismDtos.add(mechanismOperator);
|
||||
}
|
||||
}
|
||||
return mechanismDtos;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.xhpc.user.service.impl;
|
||||
|
||||
import com.xhpc.common.core.utils.SecurityUtils;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.user.domain.XhpcCommunity;
|
||||
import com.xhpc.user.mapper.XhpcCommunityMapper;
|
||||
import com.xhpc.user.service.IXhpcCommunityService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/20 9:59
|
||||
*/
|
||||
@Service
|
||||
public class XhpcCommunityServiceImpl implements IXhpcCommunityService {
|
||||
|
||||
@Autowired
|
||||
private XhpcCommunityMapper xhpcCommunityMapper;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> list(String name) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<Map<String, Object>> list =new ArrayList<>();
|
||||
if(userId !=null){
|
||||
Map<String, Object> landUser = xhpcCommunityMapper.getLandUser(userId);
|
||||
if(landUser !=null && landUser.get("userType") !=null){
|
||||
if("00".equals(landUser.get("userType").toString())){
|
||||
list = xhpcCommunityMapper.list(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult addCommunity(XhpcCommunity xhpcCommunity) {
|
||||
|
||||
String chargingStationIds = xhpcCommunity.getChargingStationIds();
|
||||
if("".equals(chargingStationIds) || chargingStationIds ==null){
|
||||
xhpcCommunity.setStatus(0);
|
||||
}
|
||||
xhpcCommunityMapper.addCommunity(xhpcCommunity);
|
||||
if(!"".equals(chargingStationIds) && chargingStationIds !=null){
|
||||
xhpcCommunityMapper.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCommunity.getCommunityId(),1);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCommunity(XhpcCommunity xhpcCommunity) {
|
||||
if(xhpcCommunity !=null && xhpcCommunity.getCommunityId() !=null){
|
||||
int i = xhpcCommunityMapper.countCommunityPersonnel(xhpcCommunity.getCommunityId());
|
||||
if(i==0){
|
||||
xhpcCommunityMapper.deleteCommunity(xhpcCommunity.getCommunityId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xhpc.user.mapper.MechanismMapper">
|
||||
|
||||
<select id="getLandUser" resultType="map">
|
||||
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
|
||||
</select>
|
||||
|
||||
<select id="groupProvinceById" parameterType="java.lang.String" resultType="java.util.Map">
|
||||
select `code` ,`name` from xhpc_area where `code` in (
|
||||
select `pxa`.pcode province
|
||||
from xhpc_charging_station xcs
|
||||
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xcs.area_code
|
||||
LEFT JOIN xhpc_area pxa on `xa`.pcode = pxa.`code`
|
||||
where xcs.del_flag = 0
|
||||
<if test="type==1">
|
||||
and xcs.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
|
||||
</if>
|
||||
<if test="type==2">
|
||||
and xcs.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
|
||||
</if>
|
||||
<if test="type==3">
|
||||
and xcs.operator_id=#{operatorId}
|
||||
</if>
|
||||
GROUP BY `pxa`.pcode
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="groupCityById" parameterType="java.lang.String" resultType="java.util.Map">
|
||||
select `code` ,`name` from xhpc_area where `code` in (
|
||||
select `xa`.pcode city
|
||||
from xhpc_charging_station xcs
|
||||
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xcs.area_code
|
||||
LEFT JOIN xhpc_area pxa on `xa`.pcode = pxa.`code`
|
||||
where xcs.del_flag = 0
|
||||
<if test="type==1">
|
||||
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
|
||||
</if>
|
||||
<if test="type==2">
|
||||
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
|
||||
</if>
|
||||
<if test="null != provinceCode and '' != provinceCode">
|
||||
and pxa.pcode = #{provinceCode}
|
||||
</if>
|
||||
<if test="type==3">
|
||||
and xcs.operator_id=#{operatorId}
|
||||
</if>
|
||||
GROUP BY `pxa`.code
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="groupAreaById" parameterType="java.lang.String" resultType="java.util.Map">
|
||||
select `code` ,`name` from xhpc_area where `code` in (
|
||||
select `xa`.code
|
||||
from xhpc_charging_station xcs
|
||||
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xcs.area_code
|
||||
LEFT JOIN xhpc_area pxa on `xa`.pcode = pxa.`code`
|
||||
where xcs.del_flag = 0
|
||||
<if test="type==1">
|
||||
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
|
||||
</if>
|
||||
<if test="type==2">
|
||||
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
|
||||
</if>
|
||||
<if test="null != cityCode and '' != cityCode">
|
||||
and xa.pcode = #{cityCode}
|
||||
</if>
|
||||
<if test="type==3">
|
||||
and xcs.operator_id=#{operatorId}
|
||||
</if>
|
||||
GROUP BY `xa`.code
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="groupOperatorById" parameterType="java.lang.String" resultType="java.util.Map">
|
||||
|
||||
select operator_id operatorId,name from xhpc_operator where operator_id in (
|
||||
select xcs.operator_id
|
||||
from xhpc_charging_station xcs
|
||||
where xcs.del_flag = 0
|
||||
<if test="type==1">
|
||||
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
|
||||
</if>
|
||||
<if test="type==2">
|
||||
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
|
||||
</if>
|
||||
<if test="null != code and '' != code">
|
||||
and xcs.area_code = #{code}
|
||||
</if>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="dataCodeById" parameterType="java.lang.String" resultType="java.util.Map">
|
||||
select xcs.charging_station_id chargingStationId,xcs.name
|
||||
from xhpc_charging_station xcs
|
||||
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xcs.area_code
|
||||
LEFT JOIN xhpc_area pxa on `xa`.pcode = pxa.`code`
|
||||
where xcs.del_flag = 0
|
||||
<if test="type==1">
|
||||
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
|
||||
</if>
|
||||
<if test="type==2">
|
||||
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
|
||||
</if>
|
||||
<if test="null != code and '' != code">
|
||||
and `xa`.`code` = #{code}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="dataChargingStationId" parameterType="java.lang.String" resultType="java.util.Map">
|
||||
select xcs.charging_station_id chargingStationId,xcs.name
|
||||
from xhpc_charging_station xcs
|
||||
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xcs.area_code
|
||||
LEFT JOIN xhpc_area pxa on `xa`.pcode = pxa.`code`
|
||||
where xcs.del_flag = 0
|
||||
<if test="type==1">
|
||||
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
|
||||
</if>
|
||||
<if test="type==2">
|
||||
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
|
||||
</if>
|
||||
<if test="null != operatorId ">
|
||||
and xcs.operator_id =#{operatorId}
|
||||
</if>
|
||||
<if test="null != code and '' != code">
|
||||
and xcs.area_code = #{code}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xhpc.user.mapper.XhpcCommunityMapper">
|
||||
|
||||
<resultMap type="com.xhpc.user.domain.XhpcCommunity" id="XhpcCommunityResult">
|
||||
<result column="community_id" property="communityId"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="service_preferential" property="servicePreferential"/>
|
||||
<result column="min_people" property="minPeople"/>
|
||||
<result column="contact_name" property="contactName"/>
|
||||
<result column="contact_phone" property="contactPhone"/>
|
||||
<result column="address" property="address"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="dimension" property="dimension"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="del_flag" property="delFlag"/>
|
||||
<result column="create_by" property="createBy"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_by" property="updateBy"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getLandUser" resultType="map">
|
||||
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
|
||||
</select>
|
||||
|
||||
<select id="list" resultType="map">
|
||||
select
|
||||
community_id as communityId,
|
||||
name as name
|
||||
from xhpc_community
|
||||
where del_flag =1
|
||||
<if test="name !=null and name !=''">
|
||||
and name like CONCAT('%',#{name},'%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="addMechanism">
|
||||
<foreach collection="chargingStationIds" item="item" index="index" open="" close="" separator="">
|
||||
insert into xhpc_mechanism (charging_station_id,mechanism_id,source) VALUE (#{item},#{mechanismId},#{source})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="addCommunity" parameterType="com.xhpc.user.domain.XhpcCommunity" useGeneratedKeys="true" keyProperty="communityId">
|
||||
insert into xhpc_community
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="null != communityId">
|
||||
community_id,
|
||||
</if>
|
||||
<if test="null != name and '' != name">
|
||||
name,
|
||||
</if>
|
||||
<if test="null != servicePreferential">
|
||||
service_preferential,
|
||||
</if>
|
||||
<if test="null != minPeople">
|
||||
min_people,
|
||||
</if>
|
||||
<if test="null != contactName and '' != contactName">
|
||||
contact_name,
|
||||
</if>
|
||||
<if test="null != contactPhone and '' != contactPhone">
|
||||
contact_phone,
|
||||
</if>
|
||||
<if test="null != address and '' != address">
|
||||
address,
|
||||
</if>
|
||||
<if test="null != dimension">
|
||||
dimension,
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
del_flag,
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="null != createBy and '' != createBy">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="null != updateBy and '' != updateBy">
|
||||
update_by,
|
||||
</if>
|
||||
<if test="null != remark and '' != remark">
|
||||
remark,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="null != communityId">
|
||||
#{communityId},
|
||||
</if>
|
||||
<if test="null != name and '' != name">
|
||||
#{name},
|
||||
</if>
|
||||
<if test="null != servicePreferential">
|
||||
#{servicePreferential},
|
||||
</if>
|
||||
<if test="null != minPeople">
|
||||
#{minPeople},
|
||||
</if>
|
||||
<if test="null != contactName and '' != contactName">
|
||||
#{contactName},
|
||||
</if>
|
||||
<if test="null != contactPhone and '' != contactPhone">
|
||||
#{contactPhone},
|
||||
</if>
|
||||
<if test="null != address and '' != address">
|
||||
#{address},
|
||||
</if>
|
||||
<if test="null != dimension">
|
||||
#{dimension},
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
#{delFlag},
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="null != createBy and '' != createBy">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="null != updateBy and '' != updateBy">
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="null != remark and '' != remark">
|
||||
#{remark},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="deleteCommunity">
|
||||
update xhpc_community set del_flag =1 where community_id=#{communityId}
|
||||
</update>
|
||||
|
||||
<select id="countCommunityPersonnel" resultType="java.lang.Integer">
|
||||
select count (community_personnel_id) from xhpc_community_personnel where community_id=#{communityId} and del_flag=0
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user