diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/Constants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/Constants.java index 41419af5..f36df6d9 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/Constants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/Constants.java @@ -106,9 +106,90 @@ public class Constants * 资源映射路径 前缀 */ public static final String RESOURCE_PREFIX = "/profile"; - + /** + * 帐户不足 + */ public static final String INSUFFICIENT_ACCOUNT = "insufficient account"; - + /** + * 锁定帐户 + */ public static final String LOCKED_ACCOUNT = "locked account"; + /** + * 无效终端 + */ + public static final String LNVALID_TERMINAL = "lnvalid terminal"; + + /** + * 无效运营商(桩的运营商和卡不对应) + */ + public static final String LNVALID_OPERATOR = "lnvalid operator"; + + /** + * 无效卡 + */ + public static final String LNVALID_CARD = "lnvalid card"; + + /** + * 无效用户 + */ + public static final String LNVALID_USER = "lnvalid user"; + + /** + * 离线卡 + */ + public static final String OFFLINE_CARD = "offline card"; + + /** + * 初始化 + */ + public static final String ZERO_CARD = "zero card"; + + /** + * 正常 + */ + public static final String ONE_CARD = "one card"; + + /** + * 锁卡 + */ + public static final String TWO_CARD = "two card"; + /** + * 挂失 + */ + public static final String THREE_CARD = "three card"; + /** + * 作废 + */ + public static final String FOUR_CARD = "four card"; + + //你有异常订单未解决,请拨打客服电话进行解决 + public static final String EXCEPTION_ORDER = "exception order"; + + //你有申请退款订单在审核中,需要充电请取消申请退款 + public static final String REFUND_ORDER = "refund order"; + + //车辆正在充电,请查询车辆充电信息 + public static final String CHARGE_ORDER = "charge order"; + + //未注册的终端,请选择其他终端充电 + public static final String UNREGISTERED_TERMINAL = "unregistered terminal"; + + //未知的终端状态,请选择其他终端充电 + public static final String UNKNOWN_TERMINAL = "unknown terminal"; + + //离线终端 + public static final String OFFLINE_TERMINAL = "offline terminal"; + + //故障终端 + public static final String FAULT_TERMINAL = "fault terminal"; + + //充电终端 + public static final String CHARGE_TERMINAL = "charge terminal"; + + //未知的枪 + public static final String UNKNOWN_GUN = "unknown gun"; + + //请插好充电枪 + public static final String INSERT_THE_GUN = "insert the gun"; } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/ServiceNameConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/ServiceNameConstants.java index 01530427..21e6b488 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/ServiceNameConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/ServiceNameConstants.java @@ -59,4 +59,9 @@ public class ServiceNameConstants { */ public static final String XHPC_CARD ="xhpc-card"; + /** + * 电站服务 + */ + public static final String XHPC_CHARGING_STATION ="xhpc-charging-station"; + } diff --git a/ruoyi-modules/ruoyi-job/pom.xml b/ruoyi-modules/ruoyi-job/pom.xml index 5b218aaa..a70a404b 100644 --- a/ruoyi-modules/ruoyi-job/pom.xml +++ b/ruoyi-modules/ruoyi-job/pom.xml @@ -72,11 +72,21 @@ ruoyi-common-log + + com.ruoyi + ruoyi-common-core + com.ruoyi ruoyi-common-swagger + + com.ruoyi + xhpc-common + 3.0.0 + compile + diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/RuoYiJobApplication.java b/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/RuoYiJobApplication.java similarity index 98% rename from ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/RuoYiJobApplication.java rename to ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/RuoYiJobApplication.java index 47ecf972..795d1172 100644 --- a/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/RuoYiJobApplication.java +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/RuoYiJobApplication.java @@ -1,4 +1,4 @@ -package com.xhpc.job; +package com.xhpc; import com.xhpc.common.security.annotation.EnableCustomConfig; import com.xhpc.common.security.annotation.EnableRyFeignClients; diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/service/CardJobServiceImpl.java b/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/service/CardJobServiceImpl.java new file mode 100644 index 00000000..f0089a59 --- /dev/null +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/service/CardJobServiceImpl.java @@ -0,0 +1,30 @@ +package com.xhpc.job.service; + +import com.xhpc.common.api.UserTypeService; +import com.xhpc.common.core.domain.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * @author yuyang + * @date 2022/1/24 13:32 + */ +@Service +public class CardJobServiceImpl implements ICardJobService{ + + + @Autowired + private UserTypeService userTypeService; + + @Override + public void cardStartup(String phone, String tenantId) { + R user = userTypeService.getUser(phone, null, null, null,tenantId); + if(user !=null && user.getData() !=null){ + Map map = (Map)user.getData(); + System.out.println("执行方法11有参方法map:" + map.toString()); + } + System.out.println("执行方法结束"); + } +} diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/service/ICardJobService.java b/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/service/ICardJobService.java new file mode 100644 index 00000000..0c3b45a8 --- /dev/null +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/service/ICardJobService.java @@ -0,0 +1,10 @@ +package com.xhpc.job.service; + +/** + * @author yuyang + * @date 2022/1/24 13:31 + */ +public interface ICardJobService { + + public void cardStartup(String phone, String tenantId); +} diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/task/CardTask.java b/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/task/CardTask.java new file mode 100644 index 00000000..2de1d807 --- /dev/null +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/xhpc/job/task/CardTask.java @@ -0,0 +1,29 @@ +package com.xhpc.job.task; +import com.xhpc.job.service.ICardJobService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @author yuyang + * @date 2022/1/24 11:26 + */ +@Component("cardTask") +public class CardTask { + + @Autowired + ICardJobService cardJobService; + + public void cardStartup(String cardNumber, String serialNumber){ + System.out.println("执行方法11有参方法cardNumber:" + cardNumber); + System.out.println("执行方法11有参方法serialNumber:" + serialNumber); + cardJobService.cardStartup(cardNumber,serialNumber); + } + + public void cardSotup(String phone, String tenantId){ + System.out.println("执行方法22有参方法phone:" + phone); + System.out.println("执行方法22有参方法tenantId:" + tenantId); + System.out.println("55555"); + } +} diff --git a/xhpc-modules/pom.xml b/xhpc-modules/pom.xml index e5a4a82c..565e7a67 100644 --- a/xhpc-modules/pom.xml +++ b/xhpc-modules/pom.xml @@ -20,6 +20,7 @@ xhpc-invoice xhpc-tradebill xhpc-message-board + xhpc-card xhpc-modules diff --git a/xhpc-modules/xhpc-card/pom.xml b/xhpc-modules/xhpc-card/pom.xml new file mode 100644 index 00000000..fc94483f --- /dev/null +++ b/xhpc-modules/xhpc-card/pom.xml @@ -0,0 +1,119 @@ + + + + xhpc-modules + com.ruoyi + 3.0.0 + + 4.0.0 + + xhpc-card + + + 卡服务 + + + + 8 + 8 + + + + + com.ruoyi + ruoyi-common-security + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.boot + spring-boot-starter-web + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-common-datasource + + + + + com.ruoyi + ruoyi-common-datascope + + + + com.ruoyi + xhpc-common + 3.0.0 + compile + + + + org.apache.shiro + shiro-core + 1.4.2 + + + com.ruoyi + ruoyi-common-log + + + + ${project.artifactId} + + + src/main/resources + + + src/main/java + + **/*.xml + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.4.0 + + + + repackage + + + + + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/CardApplication.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/CardApplication.java new file mode 100644 index 00000000..b1018368 --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/CardApplication.java @@ -0,0 +1,33 @@ +package com.xhpc; + +import com.xhpc.common.security.annotation.EnableCustomConfig; +import com.xhpc.common.security.annotation.EnableRyFeignClients; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +/** + * @author yuyang + * @date 2022/1/19 17:52 + */ +@EnableCustomConfig +@EnableRyFeignClients +@EnableFeignClients +@SpringBootApplication +@MapperScan("com.xhpc.card.mapper") +public class CardApplication { + public static void main(String[] args) { + SpringApplication.run(CardApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 卡服务启动成功 ლ(´ڡ`ლ)゙ \n" + + " .-------. ____ __ \n" + + " | _ _ \\ \\ \\ / / \n" + + " | ( ' ) | \\ _. / ' \n" + + " |(_ o _) / _( )_ .' \n" + + " | (_,_).' __ ___(_ o _)' \n" + + " | |\\ \\ | || |(_,_)' \n" + + " | | \\ `' /| `-' / \n" + + " | | \\ / \\ / \n" + + " ''-' `'-' `-..-' "); + } +} diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java new file mode 100644 index 00000000..1fd3c3e5 --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java @@ -0,0 +1,44 @@ +package com.xhpc.card.controller; + +import com.xhpc.card.service.IXhpcCardService; +import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.web.controller.BaseController; +import io.swagger.annotations.Api; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author yuyang + * @date 2022/1/20 11:33 + */ +@RestController +@RequestMapping("/card") +@Api(value = "卡管理", tags = "卡管理") +public class XhpcCardController extends BaseController { + + @Autowired + private IXhpcCardService xhpcCardService; + + private static final Logger logger = LoggerFactory.getLogger(XhpcCardController.class); + + /** + * 卡启动前判断 + * @param cardno 卡物理卡号 + * @param serialNumber 终端编号 + * @return + */ + @GetMapping("/cardStartup") + public R cardStartup(@RequestParam(value = "cardno") String cardno, @RequestParam(value = "serialNumber") String serialNumber){ + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<卡启动充电判断>>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<卡启动充电判断>>>>>>>>>>>>>>>>>"); + return xhpcCardService.cardStartup(cardno, serialNumber); + } +} diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCardMapper.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCardMapper.java new file mode 100644 index 00000000..fcab1a1b --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCardMapper.java @@ -0,0 +1,16 @@ +package com.xhpc.card.mapper; + +import com.xhpc.common.domain.IccardInfo; +import com.xhpc.common.domain.XhpcIcCardInfo; +import org.apache.ibatis.annotations.Param; + +/** + * @author yuyang + * @date 2022/1/20 13:45 + */ +public interface XhpcCardMapper { + + IccardInfo getIccardInfoCardno(@Param("cardno")String cardno); + + XhpcIcCardInfo getXhpcIcCardInfo(@Param("tIccardInfoId")String tIccardInfoId); +} diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java new file mode 100644 index 00000000..ef7d13a0 --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java @@ -0,0 +1,18 @@ +package com.xhpc.card.service; + +import com.xhpc.common.core.domain.R; + +/** + * @author yuyang + * @date 2022/1/20 13:44 + */ +public interface IXhpcCardService { + + /** + * 卡启动充电判断 + * @param cardno 卡物理卡号 + * @param serialNumber 终端卡号 + * @return + */ + R cardStartup(String cardno,String serialNumber); +} diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java new file mode 100644 index 00000000..3678c5ab --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java @@ -0,0 +1,69 @@ +package com.xhpc.card.service.impl; + +import com.xhpc.card.mapper.XhpcCardMapper; +import com.xhpc.card.service.IXhpcCardService; +import com.xhpc.common.api.CardHistoryOrderService; +import com.xhpc.common.core.constant.Constants; +import com.xhpc.common.core.domain.R; +import com.xhpc.common.domain.IccardInfo; +import com.xhpc.common.domain.XhpcIcCardInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author yuyang + * @date 2022/1/20 13:44 + */ +@Service +public class XhpcCardServiceImpl implements IXhpcCardService { + + @Autowired + private XhpcCardMapper xhpcCardMapper; + + @Autowired + private CardHistoryOrderService cardHistoryOrderService; + + + /** + * 卡启动充电判断 + * + * @param cardno + * @param serialNumber + * @return + */ + @Override + public R cardStartup(String cardno, String serialNumber) { + + IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno); + if(iccardInfo !=null){ + if(iccardInfo.getCardtype()==0){ + return R.fail(Constants.OFFLINE_CARD); + } + if(iccardInfo.getStatus()==0){ + return R.fail(Constants.ZERO_CARD); + } + if(iccardInfo.getStatus()==2){ + return R.fail(Constants.TWO_CARD); + } + if(iccardInfo.getStatus()==3){ + return R.fail(Constants.THREE_CARD); + } + if(iccardInfo.getStatus()==4){ + return R.fail(Constants.FOUR_CARD); + } + }else{ + return R.fail(Constants.LNVALID_CARD); + } + //查询卡号对应的用户 + XhpcIcCardInfo xhpcIcCardInfo = xhpcCardMapper.getXhpcIcCardInfo(iccardInfo.getId().toString()); + if(xhpcIcCardInfo ==null){ + return R.fail(Constants.LNVALID_USER); + } + Long userId=xhpcIcCardInfo.getUserId(); + Integer userType=xhpcIcCardInfo.getUserType(); + String tenantId=xhpcIcCardInfo.getTenantId(); + Integer type =1; + String grantOperator=xhpcIcCardInfo.getGrantOperatorId(); + return cardHistoryOrderService.cardStartup(userId, serialNumber, userType,tenantId,type,grantOperator); + } +} diff --git a/xhpc-modules/xhpc-card/src/main/resources/banner.txt b/xhpc-modules/xhpc-card/src/main/resources/banner.txt new file mode 100644 index 00000000..0dd5eee9 --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/resources/banner.txt @@ -0,0 +1,2 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} diff --git a/xhpc-modules/xhpc-card/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-card/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..f1df16d1 --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/resources/bootstrap.yml @@ -0,0 +1,28 @@ +# Tomcat +server: + port: 9809 + +# Spring +spring: + application: + # 应用名称 + name: xhpc-card + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 127.0.0.1:8848 + config: + # 配置中心地址 + server-addr: 127.0.0.1:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.xhpc.card.mapper: debug diff --git a/xhpc-modules/xhpc-card/src/main/resources/logback.xml b/xhpc-modules/xhpc-card/src/main/resources/logback.xml new file mode 100644 index 00000000..583ef0ee --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/resources/logback.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCardMapper.xml b/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCardMapper.xml new file mode 100644 index 00000000..cd31fad0 --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCardMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/CardHistoryOrderService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/CardHistoryOrderService.java new file mode 100644 index 00000000..82f369f6 --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/CardHistoryOrderService.java @@ -0,0 +1,29 @@ +package com.xhpc.common.api; + +import com.xhpc.common.api.factory.CardHistoryOrderFactory; +import com.xhpc.common.core.constant.ServiceNameConstants; +import com.xhpc.common.core.domain.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author yuyang + * @date 2022/1/24 17:50 + */ +@FeignClient(contextId ="cardHistoryOrderService",value = ServiceNameConstants.XHPC_ORDER, fallbackFactory = CardHistoryOrderFactory.class) +public interface CardHistoryOrderService { + + /** + * 卡启动前判断 + * @param userId 用户id + * @param serialNumber 桩号 + * @param userType 用户类型 + * @param tenantId 租户 + * @param type 0 平台 1运营商 + * @param grantOperator 运营商id + * @return + */ + @GetMapping("/api/chargeOrder/cardStartup") + R cardStartup(@RequestParam(value = "userId") Long userId, @RequestParam(value = "serialNumber") String serialNumber, @RequestParam(value = "userType") Integer userType, @RequestParam(value = "tenantId") String tenantId, @RequestParam(value = "type") Integer type, @RequestParam(value = "grantOperator") String grantOperator); +} diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/CardService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/CardService.java index 176e3d33..fd82d855 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/CardService.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/CardService.java @@ -17,10 +17,10 @@ public interface CardService { /** * 卡启动判断接口 - * @param cardNumber 卡号 + * @param cardno 卡编号 * @param serialNumber 终端编码 * @return */ @GetMapping("/card/cardStartup") - R cardStartup(@RequestParam(value = "cardNumber") String cardNumber, @RequestParam(value = "serialNumber") String serialNumber); + R cardStartup(@RequestParam(value = "cardno") String cardno, @RequestParam(value = "serialNumber") String serialNumber); } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/CardFallbackFactory.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/CardFallbackFactory.java index 99821d5b..8187ae7b 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/CardFallbackFactory.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/CardFallbackFactory.java @@ -16,7 +16,7 @@ public class CardFallbackFactory implements FallbackFactory { public CardService create(Throwable cause) { return new CardService() { @Override - public R cardStartup(String cardNumber, String serialNumber) { + public R cardStartup(String cardno, String serialNumber) { return R.fail("卡启动判断接口失败:" + cause.getMessage()); } }; diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/CardHistoryOrderFactory.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/CardHistoryOrderFactory.java new file mode 100644 index 00000000..549e0290 --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/CardHistoryOrderFactory.java @@ -0,0 +1,24 @@ +package com.xhpc.common.api.factory; + +import com.xhpc.common.api.CardHistoryOrderService; +import com.xhpc.common.core.domain.R; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * @author yuyang + * @date 2022/1/24 17:51 + */ +@Component +public class CardHistoryOrderFactory implements FallbackFactory { + @Override + public CardHistoryOrderService create(Throwable cause) { + + return new CardHistoryOrderService() { + @Override + public R cardStartup(Long userId,String serialNumber,Integer userType,String tenantId,Integer type,String grantOperator) { + return R.fail("卡启动前判断启动失败:" + cause.getMessage()); + } + }; + } +} diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcIcCardInfo.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcIcCardInfo.java index 9030abce..19e8fb9d 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcIcCardInfo.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcIcCardInfo.java @@ -1,5 +1,6 @@ package com.xhpc.common.domain; +import com.xhpc.common.core.web.domain.BaseEntity; import lombok.Data; import java.io.Serializable; @@ -10,11 +11,11 @@ import java.util.Date; * @author WH */ @Data -public class XhpcIcCardInfo implements Serializable { +public class XhpcIcCardInfo extends BaseEntity { /** * 记录id */ - private Integer id; + private Long icCardInfoId; /** * t_iccard_info表中的卡记录的id @@ -24,7 +25,7 @@ public class XhpcIcCardInfo implements Serializable { /** * 卡使用状态(0未使用,1已绑定) */ - private Long useStatus; + private Integer useStatus; /** * 创建日期 @@ -44,7 +45,7 @@ public class XhpcIcCardInfo implements Serializable { /** * 用户id */ - private Integer userId; + private Long userId; /** * 用户账户 @@ -54,7 +55,7 @@ public class XhpcIcCardInfo implements Serializable { /** * 用户类型(0 C端用户 1 流量方用户 2社区用户 3B端用户) */ - private Long userType; + private Integer userType; /** * 用户姓名 @@ -69,12 +70,12 @@ public class XhpcIcCardInfo implements Serializable { /** * 用户年龄 */ - private Long userAge; + private Integer userAge; /** * 用户性别(0女,1男) */ - private Long userSex; + private Integer userSex; /** * 用户手机号码 @@ -89,7 +90,5 @@ public class XhpcIcCardInfo implements Serializable { /** * 逻辑删除字段(默认为0,1为删除) */ - private Long delFlag; - - private static final long serialVersionUID = 1L; + private Integer delFlag; } \ No newline at end of file diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/iccard/mapper/IccardInfoMapper.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/iccard/mapper/IccardInfoMapper.java index 5427cd93..d94286fd 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/iccard/mapper/IccardInfoMapper.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/iccard/mapper/IccardInfoMapper.java @@ -2,6 +2,7 @@ package com.xhpc.iccard.mapper; import com.xhpc.common.domain.IccardInfo; import com.xhpc.common.domain.IccardInfoExample; +import com.xhpc.common.domain.XhpcIcCardInfo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java index 142be756..e01e2d6a 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java @@ -2,6 +2,7 @@ package com.xhpc.order.api; import com.alibaba.fastjson.JSONObject; import com.xhpc.common.api.WebSocketService; +import com.xhpc.common.core.domain.R; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; @@ -165,4 +166,19 @@ public class XhpcChargeOrderController extends BaseController { webSocketService.getMessage(message,json.toString()); logger.info("<<<<<<<<<<发送数据<<<<<<<<<<<<<<"+ json.toString()+">>>>>>>>>>>>>>>>>"); } + + /** + * 卡启动前判断 + * @return + */ + @GetMapping("/cardStartup") + public R cardStartup(Long userId, String serialNumber, Integer userType, String tenantId, Integer type, String grantOperator) + { + return iXhpcChargeOrderService.cardStartup(userId,serialNumber,userType,tenantId,type,grantOperator); + } + + + + + } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java index ad2cd3e3..e02ceed1 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java @@ -204,7 +204,7 @@ public class XhpcPileOrderController extends BaseController { String tenantId = xhpcChargeOrder.getTenantId(); //存入换成 JSONObject json = new JSONObject(map); - String message = tenantId + UserTypeUtil.USER + userId; + String message = ""; if(UserTypeUtil.USER_TYPE.equals(source)){ message = tenantId + UserTypeUtil.USER + userId; }else if(UserTypeUtil.COMMUNIT_TYPE.equals(source)){ diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java index 37ebc35b..ea57a7da 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java @@ -165,4 +165,8 @@ public interface IXhpcChargeOrderService { //获取桩信息 Map getXhpcChargingPileById(Long chargingPileId); + + + R cardStartup(Long userId,String serialNumber,Integer userType,String tenantId, Integer type, String grantOperator); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index 9f5a9567..d74ed830 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import com.xhpc.common.api.PowerPileService; import com.xhpc.common.api.UserTypeService; +import com.xhpc.common.core.constant.Constants; import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.domain.AjaxResult; @@ -268,8 +269,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar if (r1.getCode() != 200) { return AjaxResult.error(r1.getMsg()); } - - //创建充电订单(充电启动soc初始值,结束是获取,并修改状态) XhpcChargeOrder xhpcChargeOrder = new XhpcChargeOrder(); xhpcChargeOrder.setChargingStationId(xhpcTerminal.getChargingStationId()); @@ -628,6 +627,88 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar return xhpcChargeOrderMapper.getXhpcChargingPileById(chargingPileId,null); } + @Override + public R cardStartup(Long userId, String serialNumber, Integer userType,String tenantId, Integer type, String grantOperator) { + + R user = userTypeService.getUser(null, userId, userType, null,tenantId); + if(user ==null || user.getData() ==null){ + return R.fail(Constants.LNVALID_USER); + } + + Map userMessage = (Map)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.LNVALID_TERMINAL); + } + + //终端信息 + XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber,tenantId); + if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) { + return R.fail(Constants.LNVALID_TERMINAL); + } + + if(type !=0){ + //获取桩信息 + Map xhpcChargingPileById =xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId(),tenantId); + if(xhpcChargingPileById ==null || !xhpcChargingPileById.get("operatorId").toString().equals(grantOperator)){ + return R.fail(Constants.LNVALID_OPERATOR); + } + } + + + 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); + } + + //充电用户是否存在异常的订单 + int j = xhpcChargeOrderMapper.countXhpcChargeOrder(userId,userType,tenantId); + if (j > 0) { + return R.fail(Constants.EXCEPTION_ORDER); + } + //查看充电用户是否有申请退款的订单,还未处理 + if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) { + return R.fail(Constants.REFUND_ORDER); + } + //充电用户是否在充电中 + String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,userType,tenantId); + if (!"".equals(i) && i!=null) { + return R.fail(Constants.CHARGE_ORDER); + } + Map cacheMap = REDIS.getCacheMap("gun:" + serialNumber); + if(cacheMap==null){ + return R.fail(Constants.UNREGISTERED_TERMINAL); + }else{ + if(cacheMap.get("status") ==null){ + return R.fail(Constants.UNKNOWN_TERMINAL); + }else{ + String status = cacheMap.get("status").toString(); + //不同的状态 + if("离线".equals(status)){ + return R.fail(Constants.OFFLINE_TERMINAL); + } + if("故障".equals(status)){ + return R.fail(Constants.FAULT_TERMINAL); + } + if("充电".equals(status)){ + return R.fail(Constants.CHARGE_TERMINAL); + } + } + if(cacheMap.get("vehicleGunStatus") ==null){ + return R.fail(Constants.UNKNOWN_GUN); + }else{ + String vehicleGunStatus = cacheMap.get("vehicleGunStatus").toString(); + if(!"是".equals(vehicleGunStatus)){ + return R.fail(Constants.INSERT_THE_GUN); + } + } + } + return R.ok(); + } + public static boolean isValidDate(String str) { try { if (0 != str.length()) { diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index 680219a6..73c0aa0a 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -147,141 +147,151 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe @Transactional @Override public AjaxResult getExamineMessage(Long realTimeOrderId) { - //基本信息 Map message = xhpcRealTimeOrderMapper.getMessage(realTimeOrderId); - if(message ==null || message.get("chargeOrderId") ==null){ - return AjaxResult.success(new HashMap<>()); - } + try{ + if(message ==null || message.get("chargeOrderId") ==null){ + return AjaxResult.success(new HashMap<>()); + } + //获取开始充电时间、结束时间、计费模型、充电度数、已充金额 + XhpcChargeOrder chargeOrder = xhpcChargeOrderService.getChargingOrderId(Long.parseLong(message.get("chargeOrderId").toString())); - //获取开始充电时间、结束时间、计费模型、充电度数、已充金额 - XhpcChargeOrder chargeOrder = xhpcChargeOrderService.getChargingOrderId(Long.parseLong(message.get("chargeOrderId").toString())); + //获取该订单最后一条实时数据 + Map cacheMap = redisService.getCacheMap("order:" + chargeOrder.getSerialNumber()); + List list = (List) cacheMap.get("realtimeDataList"); - //获取该订单最后一条实时数据 - Map cacheMap = redisService.getCacheMap("order:" + chargeOrder.getSerialNumber()); - List list = (List) cacheMap.get("realtimeDataList"); + CacheRealtimeData startData =new CacheRealtimeData(); + CacheRealtimeData endData =new CacheRealtimeData(); - CacheRealtimeData startData =new CacheRealtimeData(); - CacheRealtimeData endData =new CacheRealtimeData(); - - if (list != null && list.size() > 0) { - endData =list.get(list.size()-1); - for (int i = 0; i 0){ - break; + if (list != null && list.size() > 0) { + endData =list.get(list.size()-1); + for (int i = 0; i 0){ + break; + } } } - } - Long rateModelId = chargeOrder.getRateModelId(); + Long rateModelId = chargeOrder.getRateModelId(); - if(endData !=null && endData.getAmountCharged() !=null && startData.getChargingTime()>0){ + if(endData !=null && endData.getAmountCharged() !=null && startData.getChargingTime()>0){ - message.put("soc",endData.getSoc()); - //最后一祯时间 - Date endTime = DateUtil.parse(endData.getCreateTime()); - Date startTime =DateUtil.parse(startData.getCreateTime()); - //充电时长 - Long tiem = (endTime.getTime() - startTime.getTime()) / 1000; - if (tiem > 3600) { - long hours = tiem / 3600; - double mins = (double) ((tiem - (hours * 3600)) / 60); - message.put("chargingTime",hours + "时" + new BigDecimal(mins).setScale(0) + "分"); - chargeOrder.setChargingTime(hours + "时" + new BigDecimal(mins).setScale(0) + "分"); - } else { - double mins = (double) (tiem / 60); - message.put("chargingTime",new BigDecimal(mins).setScale(0) + "分"); - chargeOrder.setChargingTime(new BigDecimal(mins).setScale(0) + "分"); - } - BigDecimal chargingDegree = new BigDecimal(endData.getChargingDegree()).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_DOWN); - message.put("chargingDegree",chargingDegree); + message.put("soc",endData.getSoc()); + //最后一祯时间 + Date endTime = DateUtil.parse(endData.getCreateTime()); + Date startTime =DateUtil.parse(startData.getCreateTime()); + //充电时长 + Long tiem = (endTime.getTime() - startTime.getTime()) / 1000; + if (tiem > 3600) { + long hours = tiem / 3600; + double mins = (double) ((tiem - (hours * 3600)) / 60); + message.put("chargingTime",hours + "时" + new BigDecimal(mins).setScale(0) + "分"); + chargeOrder.setChargingTime(hours + "时" + new BigDecimal(mins).setScale(0) + "分"); + } else { + double mins = (double) (tiem / 60); + message.put("chargingTime",new BigDecimal(mins).setScale(0) + "分"); + chargeOrder.setChargingTime(new BigDecimal(mins).setScale(0) + "分"); + } + BigDecimal chargingDegree = new BigDecimal(endData.getChargingDegree()).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_DOWN); + message.put("chargingDegree",chargingDegree); - chargeOrder.setStartTime(startTime); - chargeOrder.setEndTime(endTime); - chargeOrder.setStartSoc(startData.getSoc().toString()); - chargeOrder.setEndSoc(endData.getSoc().toString()); - chargeOrder.setChargingTimeNumber(tiem); - chargeOrder.setChargingDegree(chargingDegree); - chargeOrder.setType(0); - chargeOrder.setAmountCharged(new BigDecimal(endData.getAmountCharged()).divide(new BigDecimal(10000),2,BigDecimal.ROUND_DOWN)); - }else{ - //当没有缓存数据时,查询数据库 - XhpcRealTimeOrder startRealTimeOrder = xhpcRealTimeOrderMapper.getChargingOrderId(chargeOrder.getChargeOrderId(), 1); - - XhpcRealTimeOrder endRealTimeOrder = xhpcRealTimeOrderMapper.getChargingOrderId(chargeOrder.getChargeOrderId(), 2); - - message.put("soc",endRealTimeOrder.getSoc()); - //最后一祯时间 - Date endTime = endRealTimeOrder.getCreateTime(); - Date startTime = startRealTimeOrder.getCreateTime(); - - BigDecimal chargingDegree = endRealTimeOrder.getChargingDegree(); - message.put("chargingDegree",chargingDegree); - chargeOrder.setChargingTime(endRealTimeOrder.getChargingTime()); - message.put("chargingTime",endRealTimeOrder.getChargingTime()); - - if(chargeOrder.getStartTime().equals(chargeOrder.getEndTime())){ - message.put("powerPriceTotal",0); - message.put("servicePriceTotal",0); - return AjaxResult.success(message); - } - - chargeOrder.setStartTime(startTime); - chargeOrder.setEndTime(endTime); - chargeOrder.setStartSoc(startRealTimeOrder.getSoc()); - chargeOrder.setEndSoc(endRealTimeOrder.getSoc()); - Integer chargingTimeNumber = endRealTimeOrder.getChargingTimeNumber(); - if(chargingTimeNumber>0){ - chargeOrder.setChargingTimeNumber(Long.valueOf(chargingTimeNumber*60)); + chargeOrder.setStartTime(startTime); + chargeOrder.setEndTime(endTime); + chargeOrder.setStartSoc(startData.getSoc().toString()); + chargeOrder.setEndSoc(endData.getSoc().toString()); + chargeOrder.setChargingTimeNumber(tiem); + chargeOrder.setChargingDegree(chargingDegree); + chargeOrder.setType(0); + chargeOrder.setAmountCharged(new BigDecimal(endData.getAmountCharged()).divide(new BigDecimal(10000),2,BigDecimal.ROUND_DOWN)); }else{ - chargeOrder.setChargingTimeNumber(0L); + //当没有缓存数据时,查询数据库 + XhpcRealTimeOrder startRealTimeOrder = xhpcRealTimeOrderMapper.getChargingOrderId(chargeOrder.getChargeOrderId(), 1); + + if(startRealTimeOrder ==null){ + message.put("powerPriceTotal",0); + message.put("servicePriceTotal",0); + return AjaxResult.success(message); + } + XhpcRealTimeOrder endRealTimeOrder = xhpcRealTimeOrderMapper.getChargingOrderId(chargeOrder.getChargeOrderId(), 2); + + message.put("soc",endRealTimeOrder.getSoc()); + //最后一祯时间 + Date endTime = endRealTimeOrder.getCreateTime(); + Date startTime = startRealTimeOrder.getCreateTime(); + + BigDecimal chargingDegree = endRealTimeOrder.getChargingDegree(); + message.put("chargingDegree",chargingDegree); + chargeOrder.setChargingTime(endRealTimeOrder.getChargingTime()); + message.put("chargingTime",endRealTimeOrder.getChargingTime()); + + if(startRealTimeOrder.getRealTimeOrderId().equals(startRealTimeOrder.getRealTimeOrderId())){ + message.put("powerPriceTotal",0); + message.put("servicePriceTotal",0); + return AjaxResult.success(message); + } + + chargeOrder.setStartTime(startTime); + chargeOrder.setEndTime(endTime); + chargeOrder.setStartSoc(startRealTimeOrder.getSoc()); + chargeOrder.setEndSoc(endRealTimeOrder.getSoc()); + Integer chargingTimeNumber = endRealTimeOrder.getChargingTimeNumber(); + if(chargingTimeNumber>0){ + chargeOrder.setChargingTimeNumber(Long.valueOf(chargingTimeNumber*60)); + }else{ + chargeOrder.setChargingTimeNumber(0L); + } + chargeOrder.setChargingDegree(chargingDegree); + chargeOrder.setType(0); + chargeOrder.setAmountCharged(endRealTimeOrder.getAmountCharged()); + } - chargeOrder.setChargingDegree(chargingDegree); - chargeOrder.setType(0); - chargeOrder.setAmountCharged(endRealTimeOrder.getAmountCharged()); - } + Date startTime2 = chargeOrder.getStartTime(); + Date updateTime2 = chargeOrder.getEndTime(); + BigDecimal amountCharged = chargeOrder.getAmountCharged(); + //充电度数 + BigDecimal chargingDegree = chargeOrder.getChargingDegree(); + BigDecimal powerPriceTotal =new BigDecimal(0); + //1时间没有跨天 + DateTime parse = DateUtil.parse(DateUtil.format(startTime2, "yyyy-MM-dd"), "yyyy-MM-dd"); + DateTime parse1 = DateUtil.parse(DateUtil.format(updateTime2, "yyyy-MM-dd"), "yyyy-MM-dd"); + //每分钟多少度电 + BigDecimal decimal = new BigDecimal((updateTime2.getTime() - startTime2.getTime())).divide(new BigDecimal(60000),4,BigDecimal.ROUND_DOWN); + BigDecimal divide = chargingDegree.divide(decimal,4,BigDecimal.ROUND_DOWN); + long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY); + if(betweenDay==0){ + powerPriceTotal = getBigDecimal(rateModelId,DateUtil.formatTime(startTime2), DateUtil.formatTime(updateTime2), powerPriceTotal, divide); + }else{ + //跨天 + powerPriceTotal = getBigDecimal(rateModelId, DateUtil.formatTime(startTime2), "23:59:59", powerPriceTotal, divide); + System.out.println(">>>>>>跨天前>>>>>>>"+powerPriceTotal); + //明天 + DateTime tomorrow = DateUtil.offsetDay(startTime2,1); + Date startTime3 = DateUtil.beginOfDay(tomorrow); + powerPriceTotal = getBigDecimal(rateModelId, DateUtil.formatTime(startTime3), DateUtil.formatTime(updateTime2), powerPriceTotal, divide); + System.out.println(">>>>>>跨天后>>>>>>>"+powerPriceTotal); + } - Date startTime2 = chargeOrder.getStartTime(); - Date updateTime2 = chargeOrder.getEndTime(); - BigDecimal amountCharged = chargeOrder.getAmountCharged(); - //充电度数 - BigDecimal chargingDegree = chargeOrder.getChargingDegree(); - BigDecimal powerPriceTotal =new BigDecimal(0); - //1时间没有跨天 - DateTime parse = DateUtil.parse(DateUtil.format(startTime2, "yyyy-MM-dd"), "yyyy-MM-dd"); - DateTime parse1 = DateUtil.parse(DateUtil.format(updateTime2, "yyyy-MM-dd"), "yyyy-MM-dd"); - //每分钟多少度电 - BigDecimal decimal = new BigDecimal((updateTime2.getTime() - startTime2.getTime())).divide(new BigDecimal(60000),4,BigDecimal.ROUND_DOWN); - BigDecimal divide = chargingDegree.divide(decimal,4,BigDecimal.ROUND_DOWN); - long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY); - if(betweenDay==0){ - powerPriceTotal = getBigDecimal(rateModelId,DateUtil.formatTime(startTime2), DateUtil.formatTime(updateTime2), powerPriceTotal, divide); - }else{ - //跨天 - powerPriceTotal = getBigDecimal(rateModelId, DateUtil.formatTime(startTime2), "23:59:59", powerPriceTotal, divide); - System.out.println(">>>>>>跨天前>>>>>>>"+powerPriceTotal); - //明天 - DateTime tomorrow = DateUtil.offsetDay(startTime2,1); - Date startTime3 = DateUtil.beginOfDay(tomorrow); - powerPriceTotal = getBigDecimal(rateModelId, DateUtil.formatTime(startTime3), DateUtil.formatTime(updateTime2), powerPriceTotal, divide); - System.out.println(">>>>>>跨天后>>>>>>>"+powerPriceTotal); - } + //算服务费和电费 + if(amountCharged.compareTo(powerPriceTotal)>-1){ + BigDecimal servicePriceTotal =amountCharged.subtract(powerPriceTotal); + message.put("powerPriceTotal",powerPriceTotal); + message.put("servicePriceTotal",servicePriceTotal); + }else{ + message.put("powerPriceTotal",amountCharged); + message.put("servicePriceTotal",0); + } - //算服务费和电费 - if(amountCharged.compareTo(powerPriceTotal)>-1){ - BigDecimal servicePriceTotal =amountCharged.subtract(powerPriceTotal); - message.put("powerPriceTotal",powerPriceTotal); - message.put("servicePriceTotal",servicePriceTotal); - }else{ - message.put("powerPriceTotal",amountCharged); + //修改充电订单 + xhpcChargeOrderService.updateXhpcChargeOrder(chargeOrder); + + }catch (Exception e){ + message.put("powerPriceTotal",0); message.put("servicePriceTotal",0); } - - //修改充电订单 - xhpcChargeOrderService.updateXhpcChargeOrder(chargeOrder); return AjaxResult.success(message); + } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml index 64ece5ca..b4daeefd 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -388,13 +388,15 @@