修改卡、VIN返回code
This commit is contained in:
parent
c58dceea4b
commit
2f40d39a01
@ -64,30 +64,30 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
|
||||
IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno);
|
||||
if (iccardInfo != null) {
|
||||
if (iccardInfo.getCardtype() == 0) {
|
||||
return R.fail(Constants.OFFLINE_CARD);
|
||||
return R.fail(1202,"离线卡");
|
||||
}
|
||||
if (iccardInfo.getStatus() == 0) {
|
||||
return R.fail(Constants.ZERO_CARD);
|
||||
return R.fail(1203,"未初始化卡");
|
||||
}
|
||||
if(iccardInfo.getStatus()==2){
|
||||
return R.fail(Constants.TWO_CARD);
|
||||
return R.fail(1204,"已锁卡");
|
||||
}
|
||||
if(iccardInfo.getStatus()==3){
|
||||
return R.fail(Constants.THREE_CARD);
|
||||
return R.fail(1205,"挂失卡");
|
||||
}
|
||||
if(iccardInfo.getStatus()==4){
|
||||
return R.fail(Constants.FOUR_CARD);
|
||||
return R.fail(1206,"作废卡");
|
||||
}
|
||||
}else{
|
||||
return R.fail(Constants.INVALID_CARD);
|
||||
return R.fail(1207,"无效卡");
|
||||
}
|
||||
if("".equals(rateModelId) || rateModelId==null){
|
||||
return R.fail(Constants.INVALID_RATE_MODE);
|
||||
return R.fail(1208,"费率模型id为空");
|
||||
}
|
||||
//查询卡号对应的用户
|
||||
XhpcIcCardInfo xhpcIcCardInfo = xhpcCardMapper.getXhpcIcCardInfo(iccardInfo.getId().toString());
|
||||
if(xhpcIcCardInfo ==null){
|
||||
return R.fail(Constants.INVALID_USER);
|
||||
return R.fail(1200, "无效用户");
|
||||
}
|
||||
Long userId=xhpcIcCardInfo.getUserId();
|
||||
Integer userType=xhpcIcCardInfo.getUserType();
|
||||
|
||||
@ -21,7 +21,7 @@ public interface XhpcPileEditionMapper {
|
||||
* @param type 1是去掉自己
|
||||
* @return
|
||||
*/
|
||||
int getXhpcPileEditions(@Param("pileEditionId")Long pileEditionId,@Param("chargingPileIds") String chargingPileIds,@Param("type")Integer type);
|
||||
int getXhpcPileEditions(@Param("pileEditionId")Long pileEditionId,@Param("chargingPileIds") List chargingPileIds,@Param("type")Integer type);
|
||||
|
||||
int insertXhpcPileEdition(XhpcPileEdition xhpcPileEdition);
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -74,7 +75,12 @@ public class XhpcPileEditionServiceImpl extends BaseService implements IXhpcPil
|
||||
public AjaxResult addPileEdition(HttpServletRequest request, XhpcPileEdition xhpcPileEdition) {
|
||||
|
||||
//判断是否已添加该桩
|
||||
int xhpcPileEditions = xhpcPileEditionMapper.getXhpcPileEditions(xhpcPileEdition.getPileEditionId(), xhpcPileEdition.getChargingPileIds(),1);
|
||||
String[] split = xhpcPileEdition.getChargingPileIds().split(",");
|
||||
if(split ==null || split.length==0){
|
||||
return AjaxResult.error(500, "请选择桩");
|
||||
}
|
||||
List list = Arrays.asList(split);
|
||||
int xhpcPileEditions = xhpcPileEditionMapper.getXhpcPileEditions(xhpcPileEdition.getPileEditionId(), list,1);
|
||||
|
||||
if(xhpcPileEditions >0){
|
||||
return AjaxResult.error(500, "有重复桩");
|
||||
@ -96,7 +102,7 @@ public class XhpcPileEditionServiceImpl extends BaseService implements IXhpcPil
|
||||
xhpcPileEdition.setPileEditionId(pileEditionId);
|
||||
xhpcPileEdition.setStatus(status);
|
||||
if(status==0){
|
||||
int xhpcPileEditions = xhpcPileEditionMapper.getXhpcPileEditions(xhpcPileEdition.getPileEditionId(), xhpcPileEdition.getChargingPileIds(),1);
|
||||
int xhpcPileEditions = xhpcPileEditionMapper.updatePileEdition(xhpcPileEdition);
|
||||
if(xhpcPileEditions >0){
|
||||
return AjaxResult.error(500, "有重复桩");
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
xpe.direct_number as directNumber,
|
||||
xpe.communication_number as communicationNumber,
|
||||
xpe.status as status,
|
||||
xcs.charging_station_id as chargingStationId,
|
||||
xpe.create_time as createTime,
|
||||
(SELECT concat(replace(group_concat(name),',','号桩,'),'号桩') FROM xhpc_charging_pile where find_in_set(charging_pile_id,xpe.charging_pile_ids)) as chargingPileName
|
||||
from xhpc_pile_edition as xpe
|
||||
@ -56,10 +57,14 @@
|
||||
select
|
||||
count(xpe.pile_edition_id) number
|
||||
from xhpc_pile_edition xpe
|
||||
where find_in_set(xpe.charging_pile_ids, #{chargingPileIds}) and xpe.del_flag=0 and xpe.status =0
|
||||
where xpe.del_flag=0 and xpe.status =0
|
||||
<if test="type ==1">
|
||||
and xpe.pile_edition_id != #{pileEditionId}
|
||||
</if>
|
||||
<foreach collection="chargingPileIds" separator="" item="pileId" close="" open="">
|
||||
and find_in_set(#{pileId},xpe.charging_pile_ids)
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="insertXhpcPileEdition">
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xhpc.order.mapper;
|
||||
import com.xhpc.order.domain.XhpcPileRegularInspect;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface XhpcPileRegularInspectMapper {
|
||||
@ -12,4 +13,6 @@ public interface XhpcPileRegularInspectMapper {
|
||||
int addPileRegularInspect(XhpcPileRegularInspect xhpcPileRegularInspect);
|
||||
|
||||
int updatePileRegularInspect(XhpcPileRegularInspect xhpcPileRegularInspect);
|
||||
|
||||
List<Map<String,Object>> verificationPileRepeat();
|
||||
}
|
||||
|
||||
@ -718,82 +718,76 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
|
||||
try {
|
||||
R user = userTypeService.getUser(null, userId, userType, null, tenantId);
|
||||
if (user == null || user.getData() == null) {
|
||||
return R.fail(Constants.INVALID_USER);
|
||||
return R.fail(1200, "无效用户");
|
||||
}
|
||||
|
||||
Map<String, Object> userMessage = (Map<String, Object>) user.getData();
|
||||
//桩号是否有效
|
||||
String pattern = "^([0-9]{16})";
|
||||
Pattern compile = Pattern.compile(pattern);
|
||||
Matcher m = compile.matcher(serialNumber);
|
||||
if (serialNumber.length() != 16 || !m.matches()) {
|
||||
return R.fail(Constants.INVALID_TERMINAL);
|
||||
return R.fail(1104, "无效的终端编号");
|
||||
}
|
||||
|
||||
//终端信息
|
||||
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber, tenantId);
|
||||
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
||||
return R.fail(Constants.INVALID_TERMINAL);
|
||||
return R.fail(1104, "无效的终端编号");
|
||||
}
|
||||
|
||||
Map<String, Object> xhpcChargingPileById =
|
||||
xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId(), tenantId);
|
||||
if (xhpcChargingPileById.size() == 0) {
|
||||
return R.fail(Constants.INVALID_OPERATOR);
|
||||
return R.fail(1201, "无效运营商(桩的运营商和卡不对应)");
|
||||
}
|
||||
if (type != 0) {
|
||||
//获取桩信息
|
||||
if (!grantOperator.equals(xhpcChargingPileById.get("corpNo").toString())) {
|
||||
return R.fail(Constants.INVALID_OPERATOR);
|
||||
return R.fail(1201, "无效运营商(桩的运营商和卡不对应)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BigDecimal a = new BigDecimal(5);
|
||||
if (userMessage == null || userMessage.get("balance") == null || a.compareTo(new BigDecimal(userMessage.get(
|
||||
"balance").toString())) == 1) {
|
||||
return R.fail(Constants.INSUFFICIENT_ACCOUNT);
|
||||
return R.fail(1100, "金额小于5元,不能充电,请充值后再进行充电");
|
||||
}
|
||||
|
||||
//充电用户是否存在异常的订单
|
||||
int j = xhpcChargeOrderMapper.countXhpcChargeOrder(userId,userType,tenantId);
|
||||
if (j > 0) {
|
||||
return R.fail(Constants.EXCEPTION_ORDER);
|
||||
return R.fail(1103, "你有异常订单未解决,请拨打客服电话进行解决");
|
||||
}
|
||||
//查看充电用户是否有申请退款的订单,还未处理
|
||||
if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) {
|
||||
return R.fail(Constants.REFUND_ORDER);
|
||||
return R.fail(1101, "你有申请退款订单在审核中,需要充电请取消申请退款");
|
||||
}
|
||||
//充电用户是否在充电中
|
||||
String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,userType,tenantId);
|
||||
if (!"".equals(i) && i!=null) {
|
||||
return R.fail(Constants.CHARGE_ORDER);
|
||||
return R.fail(1102, "车辆正在充电,请查询车辆充电信息");
|
||||
}
|
||||
Map<String, Object> cacheMap = REDIS.getCacheMap("gun:" + serialNumber);
|
||||
if(cacheMap==null){
|
||||
return R.fail(Constants.UNREGISTERED_TERMINAL);
|
||||
return R.fail(1105, "未注册的终端,请选择其他终端充电");
|
||||
}else{
|
||||
if(cacheMap.get("status") ==null){
|
||||
return R.fail(Constants.UNKNOWN_TERMINAL);
|
||||
return R.fail(1108, "未知的终端状态,请选择其他终端充电");
|
||||
}else{
|
||||
String status = cacheMap.get("status").toString();
|
||||
//不同的状态
|
||||
if("离线".equals(status)){
|
||||
return R.fail(Constants.OFFLINE_TERMINAL);
|
||||
return R.fail(1107, "此终端"+status+"中,请选择其他终端充电");
|
||||
}
|
||||
if ("故障".equals(status)) {
|
||||
return R.fail(Constants.FAULT_TERMINAL);
|
||||
return R.fail(1111, "此终端"+status+"中,请选择其他终端充电");
|
||||
}
|
||||
if ("充电".equals(status) || StringUtils.isNumeric(status)) {
|
||||
return R.fail(Constants.CHARGE_TERMINAL);
|
||||
return R.fail(1112, "此终端"+status+"中,请选择其他终端充电");
|
||||
}
|
||||
}
|
||||
if(cacheMap.get("vehicleGunStatus") ==null){
|
||||
return R.fail(Constants.UNKNOWN_GUN);
|
||||
return R.fail(1108, "未知的枪状态,请选择其他终端充电");
|
||||
}else{
|
||||
String vehicleGunStatus = cacheMap.get("vehicleGunStatus").toString();
|
||||
if(!"是".equals(vehicleGunStatus)){
|
||||
return R.fail(Constants.INSERT_THE_GUN);
|
||||
return R.fail(1109, "请插好充电枪");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -858,7 +852,7 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
|
||||
//数据回滚
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
return R.fail(Constants.INTERNAL_ERROR);
|
||||
return R.fail();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -870,17 +864,15 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
|
||||
}else if (vinNumber.length()!=17){
|
||||
return R.fail(1880, "无效VIN码");
|
||||
}
|
||||
//VIN码不存在 1881
|
||||
//Vin码表获取 用户id,用户类型
|
||||
Long userId = 1L;
|
||||
Integer userType = 0;
|
||||
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber,null);
|
||||
String tenantId = xhpcTerminal.getTenantId();
|
||||
long l1 = System.currentTimeMillis();
|
||||
logger.info("<<<<<<<"+serialNumber+"开始启动充电获取用户时间>>>>>:"+l1);
|
||||
R user = userTypeService.getUser(null, userId, userType, vinNumber,tenantId);
|
||||
long l2 = System.currentTimeMillis();
|
||||
logger.info("<<<<<<<"+serialNumber+"结束启动充电获取用户时间>>>>>:"+l2);
|
||||
logger.info("<<<<<<<"+serialNumber+"启动充电时间差>>>>>:"+(l2-l1));
|
||||
|
||||
Map<String, Object> userMessage = (Map<String, Object>)user.getData();
|
||||
if(UserTypeUtil.USER_TYPE !=userType){
|
||||
@ -934,13 +926,19 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
|
||||
return R.fail(1105, "未注册的终端,请选择其他终端充电");
|
||||
}else{
|
||||
if(cacheMap.get("status") ==null){
|
||||
return R.fail(1106, "未知的终端状态,请选择其他终端充电");
|
||||
return R.fail(1108, "未知的终端状态,请选择其他终端充电");
|
||||
}else{
|
||||
String status = cacheMap.get("status").toString();
|
||||
//不同的状态
|
||||
if("离线".equals(status)||"故障".equals(status) ||"充电".equals(status)){
|
||||
if("离线".equals(status)){
|
||||
return R.fail(1107, "此终端"+status+"中,请选择其他终端充电");
|
||||
}
|
||||
if("故障".equals(status)){
|
||||
return R.fail(1111, "此终端"+status+"中,请选择其他终端充电");
|
||||
}
|
||||
if("充电".equals(status)){
|
||||
return R.fail(1112, "此终端"+status+"中,请选择其他终端充电");
|
||||
}
|
||||
}
|
||||
if(cacheMap.get("vehicleGunStatus") ==null){
|
||||
return R.fail(1108, "未知的枪状态,请选择其他终端充电");
|
||||
@ -1046,15 +1044,16 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
|
||||
}
|
||||
}
|
||||
});
|
||||
logger.info("<<<<<<<<<1111<<<<<<<<<<<<<<<C端订单号>>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId);
|
||||
logger.info("<<<<<<<<<2222<<<<<<<<<<<<<<<C端订单号>>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId);
|
||||
logger.info("<<<<<<<<<3333<<<<<<<<<<<<<<<C端订单号>>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId);
|
||||
logger.info("<<<<<<<<<4444<<<<<<<<<<<<<<<C端订单号>>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId);
|
||||
return R.ok();
|
||||
Map<String,Object> map =new HashMap<>();
|
||||
map.put("balance",userMessage.get("balance"));
|
||||
map.put("serialNumber",orderNo);
|
||||
//用户、桩、平台(最小的)
|
||||
map.put("soc",number);
|
||||
return R.ok(map);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return R.fail(Constants.INTERNAL_ERROR);
|
||||
return R.fail();
|
||||
}
|
||||
|
||||
public static boolean isValidDate(String str) {
|
||||
|
||||
@ -10,6 +10,9 @@ import com.xhpc.system.api.model.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@ -99,33 +102,42 @@ public class XhpcPileRegularInspectServiceImpl extends BaseService implements IX
|
||||
return AjaxResult.error(500, "费率式不对");
|
||||
}
|
||||
}
|
||||
if(xhpcPileRegularInspect.getPileRegularInspectId()==null){
|
||||
Map<String, Object> map = xhpcPileRegularInspectMapper.getPileRegularInspectTenantId(tenantId);
|
||||
if(map !=null){
|
||||
return AjaxResult.error(500, "请重新登录!");
|
||||
}
|
||||
xhpcPileRegularInspect.setTenantId(tenantId);
|
||||
int i = xhpcPileRegularInspectMapper.addPileRegularInspect(xhpcPileRegularInspect);
|
||||
if(i>0){
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error(500, "请重新登录");
|
||||
}else{
|
||||
int i = xhpcPileRegularInspectMapper.updatePileRegularInspect(xhpcPileRegularInspect);
|
||||
if(i>0){
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error(500, "请重新登录");
|
||||
}
|
||||
}catch (Exception e){
|
||||
return AjaxResult.error(500, "费率格式不对");
|
||||
}
|
||||
//验证是否有重复的桩添加版本号
|
||||
|
||||
if(xhpcPileRegularInspect.getPileRegularInspectId()==null){
|
||||
Map<String, Object> map = xhpcPileRegularInspectMapper.getPileRegularInspectTenantId(tenantId);
|
||||
if(map !=null){
|
||||
return AjaxResult.error(500, "请重新登录!");
|
||||
}
|
||||
xhpcPileRegularInspect.setTenantId(tenantId);
|
||||
int i = xhpcPileRegularInspectMapper.addPileRegularInspect(xhpcPileRegularInspect);
|
||||
if(i>0){
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error(500, "请重新登录");
|
||||
}else{
|
||||
int i = xhpcPileRegularInspectMapper.updatePileRegularInspect(xhpcPileRegularInspect);
|
||||
if(i>0){
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error(500, "请重新登录");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getVersionTimer() {
|
||||
//获取
|
||||
//获取所有桩需要核对的版本号
|
||||
List<Map<String, Object>> list = xhpcPileRegularInspectMapper.verificationPileRepeat();
|
||||
for (int i = 0; i <list.size() ; i++) {
|
||||
Map<String, Object> map=list.get(i);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,5 +125,18 @@
|
||||
where tenant_id=#{tenantId} and del_flag =0
|
||||
</select>
|
||||
|
||||
|
||||
<select id="verificationPileRepeat" resultType="map">
|
||||
SELECT
|
||||
xcp.charging_pile_id,
|
||||
xcp.serial_number serialNumber,
|
||||
xpe.direct_number directNumber,
|
||||
xpe.communication_number communicationNumber
|
||||
FROM
|
||||
xhpc_charging_pile xcp
|
||||
LEFT JOIN xhpc_pile_edition xpe on xpe.charging_station_id = xcp.charging_station_id
|
||||
WHERE
|
||||
find_in_set(charging_pile_id,charging_pile_ids)
|
||||
ORDER BY
|
||||
xcp.charging_station_id
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user