桩列表增加日志和租户
This commit is contained in:
parent
0bc5a2b608
commit
8b4bbb2cf1
@ -7,10 +7,13 @@ 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.common.log.annotation.Log;
|
||||
import com.xhpc.common.log.enums.BusinessType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -34,10 +37,10 @@ public class XhpcChargingPileController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(String name, Integer type, String serialNumber, Long chargingStationId) {
|
||||
public TableDataInfo list(HttpServletRequest request,String name, Integer type, String serialNumber, Long chargingStationId) {
|
||||
|
||||
startPage();
|
||||
List<Map<String, Object>> list = xhpcChargingPileService.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId);
|
||||
List<Map<String, Object>> list = xhpcChargingPileService.selectXhpcChargingPileList(request,name, type, serialNumber, chargingStationId);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ -46,6 +49,7 @@ public class XhpcChargingPileController extends BaseController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "场站-添加桩", businessType = BusinessType.INSERT)
|
||||
@PostMapping(value = "/addXhpcChargingPile")
|
||||
public AjaxResult addXhpcChargingPile(@RequestBody XhpcChargingPile xhpcChargingPile) {
|
||||
|
||||
@ -57,6 +61,7 @@ public class XhpcChargingPileController extends BaseController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "场站-修改桩", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/updateXhpcChargingPile")
|
||||
public AjaxResult updateXhpcChargingPile(@RequestBody XhpcChargingPile xhpcChargingPile) {
|
||||
|
||||
@ -80,6 +85,7 @@ public class XhpcChargingPileController extends BaseController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "桩-停用", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/updateStatus")
|
||||
public AjaxResult updateStatus(@RequestBody XhpcChargingPile xhpcChargingPile) {
|
||||
|
||||
@ -87,8 +93,9 @@ public class XhpcChargingPileController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除电站
|
||||
* 桩-删除
|
||||
*/
|
||||
@Log(title = "桩-删除", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{chargingPileId}")
|
||||
public AjaxResult remove(@PathVariable Long chargingPileId) {
|
||||
|
||||
@ -98,6 +105,7 @@ public class XhpcChargingPileController extends BaseController {
|
||||
/**
|
||||
* 下载对应终端的图片
|
||||
*/
|
||||
@Log(title = "桩-下载对应终端的图片", businessType = BusinessType.EXPORT)
|
||||
@PostMapping(value = "/downloadsTerminalImgs")
|
||||
public AjaxResult downloadsTerminalImgs(@RequestBody List<Integer> terminalIds){
|
||||
List<Map<String,Object>> xhpcImgs = xhpcChargingPileService.downloadsTerminalImgs(terminalIds);
|
||||
@ -112,6 +120,7 @@ public class XhpcChargingPileController extends BaseController {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Log(title = "桩-导入电桩", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||
ExcelUtil<XhpcChargingPile> util = new ExcelUtil<XhpcChargingPile>(XhpcChargingPile.class);
|
||||
|
||||
@ -21,7 +21,7 @@ public interface XhpcChargingPileMapper {
|
||||
* @param name 桩名称
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> selectXhpcChargingPileList(@Param("name") String name, @Param("type") Integer type, @Param("serialNumber") String serialNumber, @Param("chargingStationId") Long chargingStationId,@Param("operatorId")Long operatorId,@Param("number")Integer number);
|
||||
List<Map<String, Object>> selectXhpcChargingPileList(@Param("name") String name, @Param("type") Integer type, @Param("serialNumber") String serialNumber, @Param("chargingStationId") Long chargingStationId,@Param("operatorId")Long operatorId,@Param("number")Integer number,@Param("tenantId") String tenantId);
|
||||
|
||||
/**
|
||||
* 终端
|
||||
@ -29,7 +29,7 @@ public interface XhpcChargingPileMapper {
|
||||
* @param xhpcChargingPile 终端
|
||||
* @return 结果
|
||||
*/
|
||||
int addXhpcChargingPile(XhpcChargingPile xhpcChargingPile);
|
||||
int insertXhpcChargingPile(XhpcChargingPile xhpcChargingPile);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -59,7 +59,7 @@ public interface XhpcTerminalMapper {
|
||||
* @param xhpcTerminal 终端
|
||||
* @return 结果
|
||||
*/
|
||||
int addXhpcTerminal(XhpcTerminal xhpcTerminal);
|
||||
int insertXhpcTerminal(XhpcTerminal xhpcTerminal);
|
||||
|
||||
/**
|
||||
* 终端详情
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xhpc.charging.station.service;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.domain.XhpcChargingPile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -20,7 +21,7 @@ public interface IXhpcChargingPileService {
|
||||
* @param name 桩名称
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> selectXhpcChargingPileList(String name, Integer type, String serialNumber, Long chargingStationId);
|
||||
List<Map<String, Object>> selectXhpcChargingPileList(HttpServletRequest request, String name, Integer type, String serialNumber, Long chargingStationId);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -10,6 +10,7 @@ import com.xhpc.charging.station.mapper.XhpcTerminalMapper;
|
||||
import com.xhpc.charging.station.utils.img.QrImgUtils;
|
||||
import com.xhpc.common.api.PowerPileService;
|
||||
import com.xhpc.common.core.constant.HttpStatus;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.exception.CustomException;
|
||||
import com.xhpc.common.core.utils.SecurityUtils;
|
||||
import com.xhpc.common.core.utils.StringUtils;
|
||||
@ -20,11 +21,15 @@ import com.xhpc.common.domain.XhpcTerminal;
|
||||
import com.xhpc.common.enums.ConnectorTypeEnum;
|
||||
import com.xhpc.common.enums.EquipmentTypeEnum;
|
||||
import com.xhpc.common.enums.PowerTypeEnum;
|
||||
import com.xhpc.common.util.LogUserUtils;
|
||||
import com.xhpc.system.api.model.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
@ -51,7 +56,8 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
private XhpcImgMapper xhpcImgMapper;
|
||||
@Autowired
|
||||
private IXhpcChargingStationService xhpcChargingStationService;
|
||||
|
||||
@Autowired
|
||||
private LogUserUtils logUserUtils;
|
||||
//字母集合
|
||||
private static Map letterMap;
|
||||
static{
|
||||
@ -74,27 +80,28 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> selectXhpcChargingPileList(String name, Integer type, String serialNumber, Long chargingStationId) {
|
||||
public List<Map<String, Object>> selectXhpcChargingPileList(HttpServletRequest request, String name, Integer type, String serialNumber, Long chargingStationId) {
|
||||
|
||||
//获取登陆用户
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
//桩的统计、该时段金额
|
||||
List<Map<String, Object>> list =new ArrayList<>();
|
||||
LoginUser logUser = logUserUtils.getLogUser(request);
|
||||
String tenantId = logUser.getTenantId();
|
||||
if(userId !=1) {
|
||||
Map<String, Object> landUser = xhpcChargingStationService.getLandUser(userId);
|
||||
if(landUser !=null){
|
||||
if(landUser.get("userType") !=null){
|
||||
if("01".equals(landUser.get("userType").toString()) || "03".equals(landUser.get("userType").toString())){
|
||||
Long operatorId = Long.valueOf(landUser.get("operatorId").toString());
|
||||
list= xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId,operatorId,1);
|
||||
list= xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId,operatorId,1,tenantId);
|
||||
}else{
|
||||
list= xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId,userId,2);
|
||||
list= xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId,userId,2,tenantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
list= xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId,userId,0);
|
||||
list= xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId,userId,0,tenantId);
|
||||
}
|
||||
|
||||
|
||||
@ -124,7 +131,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
return AjaxResult.error("桩编号重复");
|
||||
}
|
||||
//桩
|
||||
xhpcChargingPileMapper.addXhpcChargingPile(xhpcChargingPile);
|
||||
xhpcChargingPileMapper.insertXhpcChargingPile(xhpcChargingPile);
|
||||
//终端
|
||||
Long chargingPileId = xhpcChargingPile.getChargingPileId();
|
||||
|
||||
@ -138,7 +145,12 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
//插入redis 桩的编号
|
||||
HashSet<String> noSet = new HashSet<>();
|
||||
noSet.add(serialNumber);
|
||||
powerPileService.addPileWhitelist(chargingStationId,xhpcChargingPile.getCommunicationProtocolVersion(), noSet);
|
||||
R r = powerPileService.addPileWhitelist(chargingStationId, xhpcChargingPile.getCommunicationProtocolVersion(), noSet);
|
||||
if (r.getCode() != 200) {
|
||||
//数据回滚-手动回滚
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error("添加桩入缓存失败,请稍后在试");
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@ -159,7 +171,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
xhpcTerminal.setRateModelId(rateModelId);
|
||||
xhpcTerminal.setNumber(number);
|
||||
xhpcTerminal.setConnectorType(conType);
|
||||
xhpcTerminalMapper.addXhpcTerminal(xhpcTerminal);
|
||||
xhpcTerminalMapper.insertXhpcTerminal(xhpcTerminal);
|
||||
|
||||
//获取场站名称:
|
||||
String chargingStationName = xhpcChargingStationService.selectXhpcChargingStationById(xhpcTerminal.getChargingStationId()).getName();
|
||||
@ -201,7 +213,12 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
//插入redis 桩的编号
|
||||
HashSet<String> noSet = new HashSet<>();
|
||||
noSet.add(serialNumber);
|
||||
powerPileService.addPileWhitelist(chargingStationId,xhpcChargingPile.getCommunicationProtocolVersion(), noSet);
|
||||
R r = powerPileService.addPileWhitelist(chargingStationId, xhpcChargingPile.getCommunicationProtocolVersion(), noSet);
|
||||
if (r.getCode() != 200) {
|
||||
//数据回滚-手动回滚
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error("添加桩入缓存失败,请稍后在试");
|
||||
}
|
||||
}
|
||||
xhpcChargingPileMapper.updaeXhpcChargingPile(xhpcChargingPile);
|
||||
return AjaxResult.success();
|
||||
|
||||
@ -104,10 +104,13 @@
|
||||
<if test="number !=0 and number ==2">
|
||||
and cp.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId})
|
||||
</if>
|
||||
<if test="tenantId !=null and tenantId !=''">
|
||||
and cp.tenant_id=#{tenantId}
|
||||
</if>
|
||||
order by cp.create_time desc
|
||||
</select>
|
||||
|
||||
<insert id="addXhpcChargingPile" parameterType="com.xhpc.common.domain.XhpcChargingPile" useGeneratedKeys="true"
|
||||
<insert id="insertXhpcChargingPile" parameterType="com.xhpc.common.domain.XhpcChargingPile" useGeneratedKeys="true"
|
||||
keyProperty="chargingPileId">
|
||||
insert into xhpc_charging_pile
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
@ -138,7 +138,7 @@
|
||||
where terminal_id = #{terminalId}
|
||||
</update>
|
||||
|
||||
<insert id="addXhpcTerminal" parameterType="com.xhpc.common.domain.XhpcTerminal" useGeneratedKeys="true"
|
||||
<insert id="insertXhpcTerminal" parameterType="com.xhpc.common.domain.XhpcTerminal" useGeneratedKeys="true"
|
||||
keyProperty="terminalId">
|
||||
insert into xhpc_terminal
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user