diff --git a/sql/v2.1.sql b/sql/v2.1.sql index 9309ff33..fcb9a50b 100644 --- a/sql/v2.1.sql +++ b/sql/v2.1.sql @@ -603,3 +603,5 @@ ALTER TABLE `xhpc_operator` ALTER TABLE `t_iccard_client_users` ADD COLUMN `tenant_id` VARCHAR(50) NULL COMMENT '租户id' AFTER `usersTime`; + +ALTER TABLE `xhpc_real_time_order` ADD COLUMN `source` int(10) NULL DEFAULT NULL COMMENT '订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户)' AFTER `tenant_id`; \ No newline at end of file diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcTimingChargingModelController.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcTimingChargingModelController.java index 514811a9..303afa86 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcTimingChargingModelController.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcTimingChargingModelController.java @@ -92,7 +92,7 @@ public class XhpcTimingChargingModelController extends BaseController { /** * 每5分钟执行一次 */ - @Scheduled(cron = "0 0/5 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void getXhpcTimingChargingModelCron(){ xhpcTimingChargingModelService.getXhpcTimingChargingModelCron(); } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTimingChargingModelServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTimingChargingModelServiceImpl.java index 546bf8fb..f511c936 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTimingChargingModelServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTimingChargingModelServiceImpl.java @@ -21,6 +21,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -42,6 +44,8 @@ public class XhpcTimingChargingModelServiceImpl extends BaseService implements I @Autowired private SmsService smsService; + private final ExecutorService executorService = Executors.newFixedThreadPool(20); + @Override public List> list(HttpServletRequest request, String reason, Integer status, String startTime, String endTime, Long chargingStationId) { @@ -431,6 +435,7 @@ public class XhpcTimingChargingModelServiceImpl extends BaseService implements I Long chargingStationId = timingCharging.getChargingStationId(); Long rateModelId = xhpcRateModel.getRateModelId(); Long timingChargingModelId = timingCharging.getTimingChargingModelId(); + String tenantId = timingCharging.getTenantId(); //修改场站费率 XhpcChargingStation xhpcChargingStation = xhpcChargingStationService.selectXhpcChargingStationById(chargingStationId); xhpcChargingStation.setRateModelId(rateModelId); @@ -478,15 +483,36 @@ public class XhpcTimingChargingModelServiceImpl extends BaseService implements I R r =powerPileService.setStationRateModel(chargingStationId,rateModelId,cacheRateModel); if (r.getCode() != 200) { //数据回滚-手动回滚 - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + //TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //短信通知 HashMap paramMap = new HashMap<>(); paramMap.put("phone", timingCharging.getPhone()); - paramMap.put("content", "【小华计费模型】尊敬的用户,计费模型"+timingChargingModelId+"更新失败,请快速处理"); + paramMap.put("content", "【小华充电】计费--尊敬的用户,计费模型"+timingChargingModelId+"更新失败,请快速处理"); smsService.sendNotice(paramMap); - return R.fail("添加费率入缓存失败,请稍后在试"); - } + executorService.execute(new Runnable() { + @Override + public void run() { + int k=0; + do{ + R r =powerPileService.setStationRateModel(chargingStationId,rateModelId,cacheRateModel); + if(r.getCode()==200){ + k++; + XhpcTimingChargingModel xhpcTimingChargingModel = xhpcTimingChargingModelMapper.getXhpcTimingChargingModelById(timingChargingModelId, tenantId); + xhpcTimingChargingModel.setStatus(1); + xhpcTimingChargingModel.setNumber(k); + xhpcTimingChargingModelMapper.updateXhpcTimingChargingModel(xhpcTimingChargingModel); + } + }while (k>0); + } + }); + } + //改变定时计费模型状态 + XhpcTimingChargingModel xhpcTimingChargingModel = xhpcTimingChargingModelMapper.getXhpcTimingChargingModelById(timingChargingModelId, tenantId); + xhpcTimingChargingModel.setStatus(2); + xhpcTimingChargingModel.setErrorReason(r.getMsg()); + xhpcTimingChargingModelMapper.updateXhpcTimingChargingModel(xhpcTimingChargingModel); + return R.ok(); } } } @@ -524,4 +550,6 @@ public class XhpcTimingChargingModelServiceImpl extends BaseService implements I xhpcTimingChargingTime.setCreateTime(new Date()); xhpcTimingChargingModelMapper.insertXhpcTimingChargingTime(xhpcTimingChargingTime); } + + } diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTimingChargingModelMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTimingChargingModelMapper.xml index 82451a24..b8c361aa 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTimingChargingModelMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTimingChargingModelMapper.xml @@ -562,7 +562,7 @@ tcm.charging_station_id chargingStationId, tcm.phone phone from xhpc_timing_charging_cache_rate_model crm - left join xhpc_timing_charging_model tcm on crm.timing_charging_model_id = tcm.timing_charging_model_id and tcm.number<4 and tcm.status =0 and tcm.del_flag =0 + join xhpc_timing_charging_model tcm on crm.timing_charging_model_id = tcm.timing_charging_model_id and tcm.status =0 and tcm.del_flag =0 and now() > tcm.timing_time where crm.del_flag=0 diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplate.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplate.java index e04df85b..2b79c782 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplate.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplate.java @@ -38,5 +38,8 @@ public class AliyunTemplate { */ public static final String REFUND_FAIL = "SMS_231445428"; - + /** + * 更新计费模型失败 + */ + public static final String CHARGING_MODEL = "SMS_234414364"; } diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java index 0e46ec9d..4f83fb7b 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java @@ -35,4 +35,9 @@ public class AliyunTemplateKeyWord { */ public static final String REFUND_FAIL = "退款-尊敬的用户"; + /** + * 退款失败 + */ + public static final String CHARGING_MODEL = "计费--尊敬的用户"; + } diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java index 51c7a5dc..046876ad 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java @@ -91,6 +91,9 @@ public class XhpcSmsController extends BaseController { } else if (content.contains(AliyunTemplateKeyWord.REFUND_FAIL)) { signatureName = AliyunTemplate.SIGNATURE_NAME; templateId = AliyunTemplate.REFUND_FAIL; + }else if (content.contains(AliyunTemplateKeyWord.CHARGING_MODEL)) { + signatureName = AliyunTemplate.SIGNATURE_NAME; + templateId = AliyunTemplate.CHARGING_MODEL; } xhpcSmsService.sendNotice(phone, signatureName, templateId, paramMap); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java index d522e2c2..b58c1b16 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java @@ -109,6 +109,10 @@ public class XhpcRealTimeOrder extends BaseEntity { */ private Long chargingStationId; + /** + * 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) + */ + private Integer source; public Long getChargingOrderId() { @@ -352,4 +356,11 @@ public class XhpcRealTimeOrder extends BaseEntity { this.chargingTimeNumber = chargingTimeNumber; } + public Integer getSource() { + return source; + } + + public void setSource(Integer source) { + this.source = source; + } } 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 3428ead5..0300c0a6 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 @@ -790,7 +790,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe Date date = new Date(); Long chargeOrderId = xhpcChargeOrder.getChargeOrderId(); XhpcRealTimeOrder xhpcRealTimeOrder = new XhpcRealTimeOrder(); - + xhpcRealTimeOrder.setSource(xhpcChargeOrder.getSource()); xhpcRealTimeOrder.setChargingOrderId(xhpcChargeOrder.getChargeOrderId()); xhpcRealTimeOrder.setTransactionNumber(orderNo); xhpcRealTimeOrder.setPileNumber(cacheRealtimeData.getPileNo()); diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml index 98afb3df..e05a47f0 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml @@ -118,7 +118,10 @@ charging_station_id, - charging_time_number + charging_time_number, + + + source @@ -201,7 +204,10 @@ #{chargingStationId}, - #{chargingTimeNumber} + #{chargingTimeNumber}, + + + #{source}