Browse Source

Merge remote-tracking branch 'origin/dev' into dev

zuy 2 năm trước cách đây
mục cha
commit
884ba2aae4

+ 7 - 4
admin-web/src/views/admin/investor/index.vue

@@ -168,17 +168,20 @@ const state = reactive({
     data: [] as Array<any>,
     loading: false,
     columns: [
-      {label: '电话号码', prop: 'telephone', resizable: true},
       {label: '客户姓名', prop: 'adminUserName', resizable: true},
+      {label: '电话号码', prop: 'telephone', resizable: true},
       {label: '站点', prop: 'stationId', resizable: true},
+      {label: '分成比例', prop: 'splittingProportion', resizable: true, width: 90},
+      {label: '电损承担比例', prop: 'elecLossProportion', resizable: true, width: 120},
+      {label: '增值税率', prop: 'vatRate', resizable: true, width: 90},
       {label: '账户名', prop: 'accountName', resizable: true},
       {label: '银行卡号', prop: 'bankCardNo', resizable: true, width: 180},
       {label: '开户行名称', prop: 'bankName', resizable: true, width: 180},
       {label: '税号', prop: 'taxNo', resizable: true, width: 180},
       // {label: '备注', prop: 'remark', resizable: true},
-      {label: '状态', prop: 'status', sortable: 'custom', align: 'center'},
-      {label: '创建时间', prop: 'createTime', sortable: 'custom', resizable: true, width: 180},
-      {label: '更新时间', prop: 'updateTime', sortable: 'custom', resizable: true, width: 180},
+      // {label: '状态', prop: 'status', sortable: 'custom', align: 'center'},
+      // {label: '创建时间', prop: 'createTime', sortable: 'custom', resizable: true, width: 180},
+      // {label: '更新时间', prop: 'updateTime', sortable: 'custom', resizable: true, width: 180},
       {
         label: '操作', prop: 'action', width: 180, align: 'center', fixed: 'right',
       }

+ 1 - 0
admin-web/src/views/admin/invoice/index.vue

@@ -234,6 +234,7 @@ const state = reactive({
       {label: '发票金额', prop: 'invoiceAmount', resizable: true, width: 90},
       {label: '订单总额', prop: 'totalMoney', resizable: true, width: 90},
       {label: '总服务费', prop: 'serviceMoney', resizable: true, width: 90},
+      {label: '总服务费', prop: 'elecMoney', resizable: true, width: 90},
       {label: '服务费优惠', prop: 'serviceMoneyDiscount', resizable: true, width: 105},
       {label: '开票人', prop: 'biller', resizable: true, width: 80},
       {label: '公司税号', prop: 'taxId', resizable: true, width: 110},

+ 12 - 12
admin-web/src/views/admin/station/statment/index.vue

@@ -160,22 +160,22 @@ const state = reactive({
     columns: [
       {label: '客户姓名', prop: 'adminUserName', resizable: true, fixed: 'left', width: 150},
       {label: '站点', prop: 'stationId', resizable: true, width: 130},
-      {label: '统计时间(月)', prop: 'statMonth', resizable: true, width: 160},
-      {label: '状态', prop: 'status', sortable: 'custom', align: 'center', width: 130},
-      {label: '实际抄表电费金额', prop: 'actualElecMoney', resizable: true, width: 160},
+      {label: '统计时间(月)', prop: 'statMonth', resizable: true, width: 135},
+      // {label: '状态', prop: 'status', sortable: 'custom', align: 'center', width: 130},
+      {label: '实际抄表电费金额', prop: 'actualElecMoney', resizable: true, width: 150},
       {label: '实际参与分成的服务费', prop: 'actualServiceMoney', resizable: true, width: 180},
-      {label: '实际分成金额', prop: 'actualSplittingAmount', resizable: true, width: 160},
+      {label: '实际分成金额', prop: 'actualSplittingAmount', resizable: true, width: 140},
 
-      {label: '优惠金额', prop: 'discountAmount', resizable: true, width: 160},
-      {label: '电损电费金额', prop: 'elecLossMoney', resizable: true, width: 160},
-      {label: '订单电费金额', prop: 'elecMoney', resizable: true, width: 160},
+      {label: '优惠金额', prop: 'discountAmount', resizable: true, width: 100},
+      {label: '电损电费金额', prop: 'elecLossMoney', resizable: true, width: 120},
+      {label: '订单电费金额', prop: 'elecMoney', resizable: true, width: 120},
 
-      {label: '服务费金额', prop: 'serviceMoney', resizable: true, width: 160},
-      {label: '服务费优惠金额', prop: 'serviceMoneyDiscount', resizable: true, width: 160},
-      {label: '分成金额', prop: 'splittingAmount', resizable: true, width: 160},
+      {label: '服务费金额', prop: 'serviceMoney', resizable: true, width: 120},
+      {label: '服务费优惠金额', prop: 'serviceMoneyDiscount', resizable: true, width: 130},
+      {label: '分成金额', prop: 'splittingAmount', resizable: true, width: 100},
 
-      {label: '订单金额', prop: 'totalMoney', resizable: true, width: 160},
-      {label: '增值税额', prop: 'vatAmount', resizable: true, width: 160},
+      {label: '订单金额', prop: 'totalMoney', resizable: true, width: 100},
+      {label: '增值税额', prop: 'vatAmount', resizable: true, width: 100},
       {label: '创建时间', prop: 'createTime', sortable: 'custom', resizable: true, width: 200, fixed: 'right'},
       {
         label: '操作', prop: 'action', width: 100, align: 'center', fixed: 'right',

+ 11 - 0
admin/src/main/java/com/kym/admin/controller/StationController.java

@@ -4,11 +4,14 @@ import cn.dev33.satoken.stp.StpUtil;
 import com.kym.common.R;
 import com.kym.common.annotation.SysLog;
 import com.kym.entity.admin.Station;
+import com.kym.entity.admin.vo.ConnectorVo;
 import com.kym.service.admin.StationService;
 import com.kym.service.cache.KymCache;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 import static com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNotNull;
 
 /**
@@ -71,4 +74,12 @@ public class StationController {
         return R.success();
     }
 
+    // 新增站点
+    @SysLog("初始化新站点信息")
+    @PostMapping("/addStation")
+    R<?> addStation(@RequestBody List<ConnectorVo> stationInfo) {
+        stationService.addStation(stationInfo);
+        return R.success();
+    }
+
 }

+ 50 - 0
entity/src/main/java/com/kym/entity/admin/vo/ConnectorVo.java

@@ -0,0 +1,50 @@
+package com.kym.entity.admin.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 充电设备信息
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+public class ConnectorVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 充电站id
+     */
+    private String stationId;
+
+    /**
+     * 充电站名称
+     */
+    private String stationName;
+
+    /**
+     * 充电设备id
+     */
+    private String equipmentId;
+
+    /**
+     * 充电设备接口id
+     */
+    private String connectorId;
+
+    /**
+     * 充电设备接口短编号
+     */
+    private String shortId;
+
+    /**
+     * 车位编号
+     */
+    private String parkingNo;
+
+
+}

+ 3 - 2
miniapp/src/main/java/com/kym/miniapp/jobs/StartChargeDelayJob.java

@@ -90,7 +90,8 @@ public class StartChargeDelayJob implements DelayService<DelayChargeOrder> {
                     if (e instanceof InterruptedException) {
                         log.error("预约充电队列take异常", e);
                     } else {
-                        log.info("预约启动充电失败,订单号:{}", threadLocal.get(), e);
+                        log.info("预约启动充电失败,订单号:{}", threadLocal.get());
+                        log.error(e.getMessage());
                         // 启动失败将订单状态修改为充电状态已结束,订单状态已确认,结束原因:预约启动失败
                         chargeOrderService.lambdaUpdate()
                                 .eq(ChargeOrder::getStartChargeSeq, threadLocal.get())
@@ -98,7 +99,7 @@ public class StartChargeDelayJob implements DelayService<DelayChargeOrder> {
                                 .set(ChargeOrder::getOrderStatus, ChargeOrder.ORDER_STATUS_失败)
                                 .set(ChargeOrder::getStopReason, "预约启动充电失败")
                                 .update();
-
+                        // todo 这里是否会阻塞线程
                     }
                 } finally {
                     threadLocal.remove();

+ 3 - 0
service/src/main/java/com/kym/service/admin/StationService.java

@@ -3,6 +3,7 @@ package com.kym.service.admin;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.github.yulichang.base.MPJBaseService;
 import com.kym.entity.admin.Station;
+import com.kym.entity.admin.vo.ConnectorVo;
 import com.kym.entity.admin.vo.StationVo;
 import com.kym.entity.enplus.EnStationStatsInfo;
 import com.kym.entity.enplus.EnStationStatusInfo;
@@ -30,4 +31,6 @@ public interface StationService extends MPJBaseService<Station> {
     public void pullEnStationInfos();
 
     void modifyStation(Station station);
+
+    void addStation(List<ConnectorVo> connectorVos);
 }

+ 1 - 0
service/src/main/java/com/kym/service/admin/impl/RoleServiceImpl.java

@@ -31,6 +31,7 @@ public class RoleServiceImpl extends MPJBaseServiceImpl<RoleMapper, Role> implem
     @Transactional(rollbackFor = Exception.class)
     @Override
     public Object add(Role role) {
+        role.setId(null);
         return save(role);
     }
 

+ 39 - 1
service/src/main/java/com/kym/service/admin/impl/StationServiceImpl.java

@@ -10,7 +10,9 @@ import com.kym.common.utils.AESUtil;
 import com.kym.common.utils.CommUtil;
 import com.kym.entity.admin.ConnectorInfo;
 import com.kym.entity.admin.EquipmentInfo;
+import com.kym.entity.admin.EquipmentRelation;
 import com.kym.entity.admin.Station;
+import com.kym.entity.admin.vo.ConnectorVo;
 import com.kym.entity.admin.vo.StationVo;
 import com.kym.entity.enplus.EnEquipmentInfo;
 import com.kym.entity.enplus.EnStationStatsInfo;
@@ -18,6 +20,7 @@ import com.kym.entity.enplus.EnStationStatusInfo;
 import com.kym.mapper.admin.StationMapper;
 import com.kym.service.admin.ConnectorInfoService;
 import com.kym.service.admin.EquipmentInfoService;
+import com.kym.service.admin.EquipmentRelationService;
 import com.kym.service.admin.StationService;
 import com.kym.service.cache.KymCache;
 import com.kym.service.enplus.EnPlusService;
@@ -46,11 +49,13 @@ public class StationServiceImpl extends MPJBaseServiceImpl<StationMapper, Statio
     private final EnPlusService enPlusService;
     private final EquipmentInfoService equipmentInfoService;
     private final ConnectorInfoService connectorInfoService;
+    private final EquipmentRelationService equipmentRelationService;
 
-    public StationServiceImpl(EnPlusService enPlusService, EquipmentInfoService equipmentInfoService, ConnectorInfoService connectorInfoService) {
+    public StationServiceImpl(EnPlusService enPlusService, EquipmentInfoService equipmentInfoService, ConnectorInfoService connectorInfoService, EquipmentRelationService equipmentRelationService) {
         this.enPlusService = enPlusService;
         this.equipmentInfoService = equipmentInfoService;
         this.connectorInfoService = connectorInfoService;
+        this.equipmentRelationService = equipmentRelationService;
     }
 
     @PostConstruct
@@ -197,4 +202,37 @@ public class StationServiceImpl extends MPJBaseServiceImpl<StationMapper, Statio
                 .eq(Station::getStationId, station.getStationId()).update();
     }
 
+    @Override
+    @Transactional
+    public void addStation(List<ConnectorVo> connectorVos) {
+        // 1、组装t_station数据
+
+        // 2、组装t_equipment_info数据
+        var equipmentInfos = connectorVos.stream().map(item -> {
+            var equipmentInfo = new EquipmentInfo();
+            BeanUtils.copyProperties(item, equipmentInfo);
+            return equipmentInfo;
+        }).toList();
+        equipmentInfoService.saveBatch(equipmentInfos);
+
+        // 3、组装t_connector_info数据
+        var connectorInfos = connectorVos.stream().map(item -> {
+            var connectorInfo = new ConnectorInfo();
+            BeanUtils.copyProperties(item, connectorInfo);
+            return connectorInfo;
+        }).toList();
+        connectorInfoService.saveBatch(connectorInfos);
+
+        // 4、组装t_equipment_relation数据
+        var equipmentRelations = connectorVos.stream().map(item -> {
+            var equipmentRelation = new EquipmentRelation();
+            BeanUtils.copyProperties(item, equipmentRelation);
+            return equipmentRelation;
+        }).toList();
+        equipmentRelationService.saveBatch(equipmentRelations);
+
+        // 5、更新KymCache数据
+        // TODO redis发布订阅?
+    }
+
 }

+ 6 - 6
service/src/main/java/com/kym/service/cache/KymCache.java

@@ -80,6 +80,11 @@ public enum KymCache {
         return STATION_MAPPING.get(stationId);
     }
 
+    /**
+     * 操作员对应有权限的站点
+     *
+     * @param map
+     */
     public void putAdminUser2Stations(Map<Long, List<String>> map) {
         ADMIN_USER_STATIONS.putAll(map);
     }
@@ -106,12 +111,7 @@ public enum KymCache {
      * @return
      */
     public List<String> getAdminUserStationIds(Long adminUserId) {
-        var res = ADMIN_USER_STATIONS.get(adminUserId);
-//        if (res == null) {
-//            var adminUserStation = adminUserStationService.lambdaQuery().eq(AdminUserStation::getAdminUserId, adminUserId).one();
-//            res = adminUserStation == null ? null : adminUserStation.getStationId();
-//        }
-        return res;
+        return ADMIN_USER_STATIONS.get(adminUserId);
     }
 
     public void putConnectorId2ParkingNo(Map<String, String> map) {

+ 1 - 1
service/src/main/java/com/kym/service/miniapp/impl/ChargeOrderServiceImpl.java

@@ -125,7 +125,7 @@ public class ChargeOrderServiceImpl extends MPJBaseServiceImpl<ChargeOrderMapper
         result = result.stream().map(item ->
                         item.setShortId(KymCache.INSTANCE.getShortIdByEquipmentIdOrConnectorId(item.getConnectorId()))
                                 .setStationName(KymCache.INSTANCE.getStationNameById(item.getStationId())))
-                .collect(Collectors.toList());
+                .toList();
 
         // stationId,startChargeSeq,connectorId,startTime,endTime,totalPower,totalMoney,elecMoney,serviceMoney,orderStatus,chargeStatus,stopReason,invoiceStatus
         var rows = result.stream().map(item -> {

+ 2 - 1
service/src/main/java/com/kym/service/miniapp/impl/InvoiceServiceImpl.java

@@ -138,7 +138,8 @@ public class InvoiceServiceImpl extends MPJBaseServiceImpl<InvoiceMapper, Invoic
                 .like(CommUtil.isNotEmptyAndNull(params.getTaxId()), Invoice::getTaxId, params.getTaxId())
                 .like(CommUtil.isNotEmptyAndNull(params.getInvoiceType()), Invoice::getInvoiceType, params.getInvoiceType())
                 .like(CommUtil.isNotEmptyAndNull(params.getEmail()), Invoice::getEmail, params.getEmail())
-                .eq(params.getStatus() != null, Invoice::getStatus, params.getStatus());
+                .eq(params.getStatus() != null, Invoice::getStatus, params.getStatus())
+                .orderByDesc(Invoice::getId);
         var list = selectJoinList(InvoiceVo.class, wrapper);
         return new PageBean<>(list);
     }