ソースを参照

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

lijin 1 年間 前
コミット
7b0512ae5a

+ 19 - 0
device-api-cloud/src/main/java/com/xy/feign/DeviceSetRecordsFeign.java

@@ -0,0 +1,19 @@
+package com.xy.feign;
+
+import com.xy.service.DeviceSetRecordsService;
+import com.xy.FeignInterceptor;
+import com.xy.consts.ServiceConsts;
+import org.springframework.cloud.openfeign.FeignClient;
+
+/**
+ * <p>
+ *  feign
+ * </p>
+ *
+ * @author hechunping
+ * @since 2024-04-11
+ */
+@FeignClient(value = ServiceConsts.SERVICE_NAME, configuration = FeignInterceptor.class)
+public interface DeviceSetRecordsFeign extends DeviceSetRecordsService {
+
+}

+ 5 - 1
device-api-service/src/main/java/com/xy/entity/DeviceChargingConfig.java

@@ -2,6 +2,7 @@ package com.xy.entity;
 
 import java.time.LocalDateTime;
 import java.io.Serializable;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -19,7 +20,7 @@ import lombok.experimental.Accessors;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@ApiModel(value="DeviceChargingConfig对象", description="设备计费配置表")
+@ApiModel(value = "DeviceChargingConfig对象", description = "设备计费配置表")
 public class DeviceChargingConfig implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -35,6 +36,9 @@ public class DeviceChargingConfig implements Serializable {
 
     @ApiModelProperty(value = "赠送天数/预充金额")
     private Integer configValue;
+    
+    @ApiModelProperty(value = "代理商额外费用")
+    private Integer extraMoney;
 
     @ApiModelProperty(value = "类型")
     private Integer type;

+ 53 - 0
device-api-service/src/main/java/com/xy/entity/DeviceSetRecords.java

@@ -0,0 +1,53 @@
+package com.xy.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 设备设置记录
+ * </p>
+ *
+ * @author hechunping
+ * @since 2024-04-11
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="DeviceSetRecords对象", description="")
+public class DeviceSetRecords implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
+    private Long id;
+
+    @ApiModelProperty(value = "设备ID")
+    private Long deviceId;
+
+    @ApiModelProperty(value = "类型")
+    private String type;
+
+    @ApiModelProperty(value = "设置内容")
+    private String content;
+
+    @ApiModelProperty(value = "创建人")
+    @TableField(fill = FieldFill.INSERT)
+    private Long createUser;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private LocalDateTime createTime;
+
+
+}

+ 16 - 0
device-api-service/src/main/java/com/xy/mapper/DeviceSetRecordsMapper.java

@@ -0,0 +1,16 @@
+package com.xy.mapper;
+
+import com.xy.entity.DeviceSetRecords;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author hechunping
+ * @since 2024-04-11
+ */
+public interface DeviceSetRecordsMapper extends BaseMapper<DeviceSetRecords> {
+
+}

+ 15 - 0
device-api-service/src/main/java/com/xy/mapper/mapper/DeviceSetRecordsMapper.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xy.mapper.DeviceSetRecordsMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.xy.entity.DeviceSetRecords">
+        <id column="id" property="id" />
+        <result column="device_id" property="deviceId" />
+        <result column="type" property="type" />
+        <result column="content" property="content" />
+        <result column="create_user" property="createUser" />
+        <result column="create_time" property="createTime" />
+    </resultMap>
+
+</mapper>

+ 113 - 64
device-api-service/src/main/java/com/xy/service/DeviceChargingConfigServiceImpl.java

@@ -3,21 +3,30 @@ package com.xy.service;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.map.MapUtil;
+import com.alipay.api.domain.Person;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.yitter.idgen.YitIdHelper;
+import com.xy.annotation.LogOperate;
 import com.xy.device.EnumDeviceCharging;
 import com.xy.device.EnumDeviceChargingConfigType;
 import com.xy.dto.DeviceChargingConfigDto;
+import com.xy.dto.DeviceTypeAlgorithmBeforConfigDto;
+import com.xy.dto.MemberFeedBackDto;
 import com.xy.dto.be.MercDto;
 import com.xy.entity.DeviceChargingConfig;
+import com.xy.entity.DeviceTypeAlgorithmBeforConfig;
+import com.xy.error.CommRuntimeException;
 import com.xy.mapper.DeviceChargingConfigMapper;
 import com.xy.service.be.MercService;
 import com.xy.utils.*;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -26,8 +35,11 @@ import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
+import static com.xy.utils.Beans.copy;
+
 
 /**
  * <p>
@@ -58,90 +70,127 @@ public class DeviceChargingConfigServiceImpl extends ServiceImpl<DeviceChargingC
         return R.ok(Beans.copy(DeviceChargingConfigDto.Vo.class, list));
     }
 
+
     @PostMapping("listByFeeConfig")
     @ApiOperation("设备管理费用配置查询")
-    public R<List<DeviceChargingConfigDto.FeeConfigVO>> listByFeeConfig(@RequestBody @Validated DeviceChargingConfigDto.ListByFeeConfigDTO dto) {
+    public R<DeviceChargingConfigDto.DeviceManagerFeeConfigVO> listByFeeConfig(@RequestBody @Validated DeviceChargingConfigDto.ListByFeeConfigDTO dto) {
+        DeviceChargingConfigDto.DeviceManagerFeeConfigVO data = new DeviceChargingConfigDto.DeviceManagerFeeConfigVO();
+        List<Integer> deviceTypes = dto.getDeviceTypes();
+        //设备管理费-平台默认配置
+        List<DeviceChargingConfigDto.DeviceManagerFeePlatformVO> dmFeePlatforms = new ArrayList<>();
+        for (Integer type : deviceTypes) {//默认年费,赠送天数
+            DeviceChargingConfigDto.DeviceManagerFeePlatformVO vo = new DeviceChargingConfigDto.DeviceManagerFeePlatformVO();
+            int defaultMoney = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), String.valueOf(type), Integer.class);
+            //默认赠送天数
+            int giveDays = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_X.getCode(), Integer.class);
+            vo.setDefFee(defaultMoney);
+            vo.setDefGiveDay(giveDays);
+            vo.setDeviceType(type);
+            dmFeePlatforms.add(vo);
+        }
         MercDto.Vo merc = mercService.obj(new MercDto.Vo().setId(dto.getMercId())).getData();
+
+        // 设备管理费-商家自定义费用
+        List<DeviceChargingConfigDto.DeviceManagerFeeMercVO> dmFeeMercs = new ArrayList<>();
         LambdaQueryWrapper<DeviceChargingConfig> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(dto, DeviceChargingConfig.class)
-                .in(DeviceChargingConfig::getDeviceType, dto.getDeviceTypes())
-                .eq(DeviceChargingConfig::getType, SysDictUtils.getValue(EnumDeviceChargingConfigType.Code.CODE.getCode(), EnumDeviceChargingConfigType.N_2.getCode(), Integer.class))
+                .in(DeviceChargingConfig::getDeviceType, deviceTypes)
                 .eq(DeviceChargingConfig::getMercCode, merc.getMercCode())
                 .build();
         //默认配置 type 2预充 1赠送天数
         List<DeviceChargingConfig> list = list(lambdaQueryWrapper);
-        Map<Integer, DeviceChargingConfig> typeConfigMap = MapUtil.newHashMap();
         if (CollUtil.isNotEmpty(list)) {
-            typeConfigMap = list.stream().collect(Collectors.toMap(DeviceChargingConfig::getDeviceType, c -> c));
-        }
-        //赠送天数
-        LambdaQueryWrapper<DeviceChargingConfig> lambdaQueryWrapper2 = new MybatisPlusQuery().eqWrapper(dto, DeviceChargingConfig.class)
-                .in(DeviceChargingConfig::getDeviceType, dto.getDeviceTypes())
-                .eq(DeviceChargingConfig::getType, SysDictUtils.getValue(EnumDeviceChargingConfigType.Code.CODE.getCode(), EnumDeviceChargingConfigType.N_1.getCode(), Integer.class))
-                .eq(DeviceChargingConfig::getMercCode, merc.getMercCode())
-                .build();
-        List<DeviceChargingConfig> list2 = list(lambdaQueryWrapper2);
-        Map<Integer, DeviceChargingConfig> typeConfigMap2 = MapUtil.newHashMap();
-        if (CollUtil.isNotEmpty(list2)) {
-            typeConfigMap2 = list2.stream().collect(Collectors.toMap(DeviceChargingConfig::getDeviceType, c -> c));
-        }
-
-        List<DeviceChargingConfigDto.FeeConfigVO> voList = new ArrayList<>();
-        List<Integer> deviceTypes = dto.getDeviceTypes();
-        for (Integer type : deviceTypes) {//默认年费,赠送天数
-            DeviceChargingConfigDto.FeeConfigVO vo = new DeviceChargingConfigDto.FeeConfigVO();
-            int defaultMoney = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), String.valueOf(type), Integer.class);
-            //默认赠送天数
-            int giveDays = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_X.getCode(), Integer.class);
-            if ((CollUtil.isNotEmpty(typeConfigMap) && typeConfigMap.get(type) != null) || (CollUtil.isNotEmpty(typeConfigMap2) && typeConfigMap2.get(type) != null)) {
-                DeviceChargingConfig deviceChargingConfig = new DeviceChargingConfig();
-                //存在自定义配置 预充
-                if (CollUtil.isNotEmpty(typeConfigMap) && typeConfigMap.get(type) != null) {
-                    deviceChargingConfig = typeConfigMap.get(type);
-                    BeanUtil.copyProperties(deviceChargingConfig, vo);
+            for (DeviceChargingConfig dcc : list) {
+                Integer type = dcc.getType();
+                Integer deviceType = dcc.getDeviceType();
+                //预充
+                if (String.valueOf(type).equals(EnumDeviceChargingConfigType.N_2.getCode())) {
+                    int defaultMoney = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), String.valueOf(deviceType), Integer.class);
+                    //默认赠送天数
+                    int giveDays = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_X.getCode(), Integer.class);
+                    DeviceChargingConfigDto.DeviceManagerFeeMercVO vo = new DeviceChargingConfigDto.DeviceManagerFeeMercVO();
+                    BeanUtil.copyProperties(dcc, vo);
                     vo.setDefFee(defaultMoney);
                     vo.setDefGiveDay(giveDays);
-                    vo.setFee(deviceChargingConfig.getConfigValue());
-                    vo.setGiveDay(giveDays);
+                    vo.setFee(dcc.getConfigValue());
+                    Optional<DeviceChargingConfig> dcObj = list.stream()
+                            .filter(dc -> String.valueOf(dc.getType()).equals(EnumDeviceChargingConfigType.N_1.getCode()))
+                            .filter(dc -> dc.getDeviceType().intValue() == deviceType.intValue())
+                            .findFirst();
+                    vo.setGiveDay(dcObj.get().getConfigValue());
+                    dmFeeMercs.add(vo);
                 }
+            }
+        }
 
-                //存在自定义配置 赠送天数
-                if (CollUtil.isNotEmpty(typeConfigMap2) && typeConfigMap2.get(type) != null) {
-                    if (deviceChargingConfig != null) {
-                        DeviceChargingConfig deviceChargingConfig2 = typeConfigMap2.get(type);
-                        vo.setDefFee(defaultMoney);
-                        vo.setDefGiveDay(giveDays);
-                        vo.setGiveDay(deviceChargingConfig2.getConfigValue());
-                        voList.add(vo);
-                    } else {
-                        //未设置预充
-                        deviceChargingConfig = typeConfigMap2.get(type);
-                        BeanUtil.copyProperties(deviceChargingConfig, vo);
-                        vo.setDefFee(defaultMoney);
-                        vo.setDefGiveDay(giveDays);
-                        vo.setFee(defaultMoney);
-                        vo.setGiveDay(deviceChargingConfig.getConfigValue());
-                        voList.add(vo);
-                    }
+        data.setDmFeeMercs(dmFeeMercs);
+        data.setDmFeePlatforms(dmFeePlatforms);
+        return R.ok(data);
+    }
 
-                }
+    @PostMapping("save")
+    @ApiOperation("添加")
+    public R save(@RequestBody @Validated DeviceChargingConfigDto.Save save) {
+        LocalDateTime now = LocalDateTime.now();
 
+        Integer deviceType = save.getDeviceType();
+        Long mercId = save.getMercId();
+        MercDto.Vo merc = R.feignCheckData(mercService.obj(new MercDto.Vo().setId(mercId)));
+        String mercCode = merc.getMercCode();
+        DeviceChargingConfig dc = this.getOne(Wrappers.<DeviceChargingConfig>lambdaQuery()
+                .eq(DeviceChargingConfig::getMercCode, mercCode)
+                .eq(DeviceChargingConfig::getDeviceType, deviceType)
+                .eq(DeviceChargingConfig::getType, EnumDeviceChargingConfigType.N_2.getCode())
+        );
+
+        if (dc != null) {
+            throw new CommRuntimeException("该类型配置已存在,请勿重复添加!");
+        }
 
-            } else {
-                //不存在,则取字典默认值
-                vo.setId(YitIdHelper.nextId());
-                vo.setFee(defaultMoney);
-                vo.setGiveDay(giveDays);
-                vo.setDeviceType(type);
-                vo.setMercCode(merc.getMercCode());
-                vo.setDefFee(defaultMoney);
-                vo.setDefGiveDay(giveDays);
-                voList.add(vo);
-            }
+        //默认赠送天数
+        int giveDays = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_X.getCode(), Integer.class);
+        //新增赠送天数
+        DeviceChargingConfig newDc = new DeviceChargingConfig().setDeviceType(deviceType).setConfigValue(giveDays).setMercCode(mercCode)
+                .setType(Integer.valueOf(EnumDeviceChargingConfigType.N_1.getCode())).setCreateTime(now)
+                .setUpdateTime(now).setMercCode(mercCode);
+        save(newDc);
 
+
+        DeviceChargingConfig saveInfo = copy(DeviceChargingConfig.class, save)
+                .setCreateTime(now)
+                .setUpdateTime(now).setMercCode(mercCode);
+        save(saveInfo);
+        return R.ok();
+    }
+
+    @PostMapping("update")
+    @ApiOperation("修改")
+    public R update(@RequestBody @Validated DeviceChargingConfigDto.Update update) {
+//        DeviceChargingConfig dcc = getById(update.getId());
+        DeviceChargingConfig updateInfo = copy(DeviceChargingConfig.class, update)
+                .setUpdateTime(LocalDateTime.now());
+        updateById(updateInfo);
+        return R.ok();
+    }
+
+    @PostMapping("delete")
+    @ApiOperation("删除")
+    @Transactional(rollbackFor = Exception.class)
+    public R delete(@RequestBody @Validated DeviceChargingConfigDto.Delete delete) {
+        Long id = delete.getId();
+        DeviceChargingConfig dcc = getById(delete.getId());
+        DeviceChargingConfig one = getOne(Wrappers.<DeviceChargingConfig>lambdaQuery()
+                .eq(DeviceChargingConfig::getMercCode, dcc.getMercCode())
+                .eq(DeviceChargingConfig::getDeviceType, dcc.getDeviceType())
+                .eq(DeviceChargingConfig::getType, Integer.valueOf(EnumDeviceChargingConfigType.N_1.getCode()))
+        );
+        if (one != null) {
+            removeById(one.getId());
         }
-        return R.ok(voList);
+        removeById(delete.getId());
+        return R.ok();
     }
 
+
     @PostMapping("saveOrUpdate")
     @ApiOperation("添加或修改")
     public R saveOrUpdate(@RequestBody @Validated DeviceChargingConfigDto.SaveOrUpdate saveOrUpdate) {

+ 108 - 0
device-api-service/src/main/java/com/xy/service/DeviceSetRecordsServiceImpl.java

@@ -0,0 +1,108 @@
+package com.xy.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xy.dto.DeviceSetRecordsDto;
+import com.xy.entity.DeviceSetRecords;
+import com.xy.mapper.DeviceSetRecordsMapper;
+import com.xy.utils.Emptys;
+import com.xy.utils.MybatisPlusQuery;
+import com.xy.utils.PageBean;
+import com.xy.utils.R;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.xy.utils.Beans.copy;
+import static com.xy.utils.PlusBeans.toIPage;
+import static com.xy.utils.PlusBeans.toPageBean;
+
+
+/**
+ * <p>
+ * 设备设置记录 服务实现类
+ * </p>
+ *
+ * @author hechunping
+ * @since 2024-04-11
+ */
+@Service
+@AllArgsConstructor
+@Api(tags = "设备设置记录")
+public class DeviceSetRecordsServiceImpl extends ServiceImpl<DeviceSetRecordsMapper, DeviceSetRecords> implements DeviceSetRecordsService {
+
+    @PostMapping("lastOne")
+    @ApiOperation("返显最后一条记录")
+    public R lastOne(@RequestBody DeviceSetRecordsDto.LastOneDto dto) {
+        List<DeviceSetRecordsDto.LastOneVo> voList = new ArrayList<>();
+        dto.getTypeList().forEach(type -> {
+            LambdaQueryWrapper<DeviceSetRecords> lqw = new LambdaQueryWrapper<DeviceSetRecords>()
+                    .eq(DeviceSetRecords::getDeviceId, dto.getDeviceId())
+                    .eq(DeviceSetRecords::getType, type)
+                    .orderByDesc(DeviceSetRecords::getCreateTime)
+                    .last("limit 1");
+            DeviceSetRecords one = getOne(lqw);
+            if (Emptys.check(one)) {
+                DeviceSetRecordsDto.LastOneVo vo = new DeviceSetRecordsDto.LastOneVo()
+                        .setType(type)
+                        .setContent(one.getContent());
+                voList.add(vo);
+            }
+
+        });
+        return R.ok(voList);
+    }
+
+
+    @PostMapping("obj")
+    @ApiOperation("对象查询")
+    public R<DeviceSetRecordsDto.Vo> obj(@RequestBody DeviceSetRecordsDto.Vo vo) {
+        DeviceSetRecordsDto.SelectList selectList = copy(DeviceSetRecordsDto.SelectList.class, vo);
+        List<DeviceSetRecordsDto.Vo> list = list(selectList).getData();
+        if (Emptys.check(list)) {
+            return R.ok(list.get(0));
+        }
+        return R.ok();
+    }
+
+    @PostMapping("list")
+    @ApiOperation("集合查询")
+    public R<List<DeviceSetRecordsDto.Vo>> list(@RequestBody DeviceSetRecordsDto.SelectList selectList) {
+        LambdaQueryWrapper<DeviceSetRecords> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(selectList, DeviceSetRecords.class).build();
+        List<DeviceSetRecords> list = list(lambdaQueryWrapper);
+        return R.ok(copy(DeviceSetRecordsDto.Vo.class, list));
+    }
+
+    @PostMapping("page")
+    @ApiOperation("分页查询")
+    public R<PageBean<DeviceSetRecordsDto.Vo>> page(@RequestBody DeviceSetRecordsDto.Page page) {
+        PageBean pageBean = page.getPage();
+        LambdaQueryWrapper<DeviceSetRecords> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(page, DeviceSetRecords.class).build();
+        IPage<DeviceSetRecords> iPage = page(toIPage(pageBean), lambdaQueryWrapper);
+        return R.ok(toPageBean(DeviceSetRecordsDto.Vo.class, iPage));
+    }
+
+    @PostMapping("save")
+    @ApiOperation("添加")
+    public R save(@RequestBody @Validated DeviceSetRecordsDto.Save save) {
+        DeviceSetRecords saveInfo = copy(DeviceSetRecords.class, save);
+        save(saveInfo);
+        return R.ok();
+    }
+
+    @PostMapping("update")
+    @ApiOperation("修改")
+    public R update(@RequestBody @Validated DeviceSetRecordsDto.Update update) {
+        DeviceSetRecords updateInfo = copy(DeviceSetRecords.class, update);
+        updateById(updateInfo);
+        return R.ok();
+    }
+}

+ 101 - 15
device-api-service/src/main/java/com/xy/service/MercFeeConfigAlgorithmTypeServiceImpl.java

@@ -1,25 +1,39 @@
 package com.xy.service;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.xy.device.EnumAlgorithmPayConfig;
+import com.xy.device.EnumAlgorithmTypes;
+import com.xy.device.EnumDeviceCharging;
+import com.xy.device.EnumDeviceChargingConfigType;
+import com.xy.dto.*;
+import com.xy.dto.be.MercDto;
+import com.xy.entity.DeviceChargingConfig;
+import com.xy.entity.DeviceTypeAlgorithmBeforConfig;
 import com.xy.entity.MercFeeConfigAlgorithmType;
+import com.xy.entity.SysDictRedis;
+import com.xy.error.CommRuntimeException;
 import com.xy.mapper.MercFeeConfigAlgorithmTypeMapper;
 import com.xy.service.MercFeeConfigAlgorithmTypeService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xy.service.be.MercService;
+import com.xy.utils.*;
+import io.swagger.annotations.ApiModelProperty;
 import org.springframework.stereotype.Service;
 import io.swagger.annotations.Api;
 import lombok.AllArgsConstructor;
 
-import java.util.List;
-import com.xy.utils.R;
-import com.xy.utils.PageBean;
-import com.xy.dto.MercFeeConfigAlgorithmTypeDto;
+import java.util.*;
+import java.util.stream.Collectors;
+
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.PostMapping;
 import io.swagger.annotations.ApiOperation;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.xy.utils.MybatisPlusQuery;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.validation.annotation.Validated;
-import com.xy.utils.Emptys;
 
 import static com.xy.utils.Beans.copy;
 import static com.xy.utils.PlusBeans.toIPage;
@@ -27,24 +41,27 @@ import static com.xy.utils.PlusBeans.toPageBean;
 
 
 /**
-* <p>
-* 商户算法扣费标准配置扩展 服务实现类
-* </p>
-*
-* @author 谭斌
-* @since 2024-04-07
-*/
+ * <p>
+ * 商户算法扣费标准配置扩展 服务实现类
+ * </p>
+ *
+ * @author 谭斌
+ * @since 2024-04-07
+ */
 @Service
 @AllArgsConstructor
 @Api(tags = "商户算法扣费标准配置扩展")
 public class MercFeeConfigAlgorithmTypeServiceImpl extends ServiceImpl<MercFeeConfigAlgorithmTypeMapper, MercFeeConfigAlgorithmType> implements MercFeeConfigAlgorithmTypeService {
 
+    private MercService mercService;
+    private AlgorithmService algorithmService;
+
     @PostMapping("obj")
     @ApiOperation("对象查询")
     public R<MercFeeConfigAlgorithmTypeDto.Vo> obj(@RequestBody MercFeeConfigAlgorithmTypeDto.Vo vo) {
         MercFeeConfigAlgorithmTypeDto.SelectList selectList = copy(MercFeeConfigAlgorithmTypeDto.SelectList.class, vo);
         List<MercFeeConfigAlgorithmTypeDto.Vo> list = list(selectList).getData();
-        if(Emptys.check(list)) {
+        if (Emptys.check(list)) {
             return R.ok(list.get(0));
         }
         return R.ok();
@@ -58,6 +75,66 @@ public class MercFeeConfigAlgorithmTypeServiceImpl extends ServiceImpl<MercFeeCo
         return R.ok(copy(MercFeeConfigAlgorithmTypeDto.Vo.class, list));
     }
 
+    @PostMapping("listByFeeConfig")
+    @ApiOperation("设备算法费用配置查询")
+    public R<MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmConfigVO> listByFeeConfig(@RequestBody @Validated MercFeeConfigAlgorithmTypeDto.ListByFeeConfigDTO dto) {
+        MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmConfigVO data = new MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmConfigVO();
+        Long mercId = dto.getMercId();
+        MercDto.Vo merc = R.feignCheckData(mercService.obj(new MercDto.Vo().setId(mercId)));
+
+        //查询默认算法信息
+        //算法费-平台默认配置
+        List<MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmPlatformVO> deviceAcPlatformList = new ArrayList<>();
+        List<AlgorithmDto.ListNameId> listNameIds = R.feignCheckData(algorithmService.ListNameId());
+        List<Long> algorithmIds = listNameIds.stream().map(AlgorithmDto.ListNameId::getId).collect(Collectors.toList());
+//        Map<Long, String> agMap = listNameIds.stream().collect(Collectors.toMap(AlgorithmDto.ListNameId::getId, AlgorithmDto.ListNameId::getName));
+        Map<Long, String> algorithmPayConfigMap = new HashMap<>();
+        for (Long algorithmId : algorithmIds) {
+            SysDictRedis moonAlgorithmTypes = SysDictUtils.get(EnumAlgorithmTypes.Code.CODE.getCode(), String.valueOf(algorithmId));
+            //算法类型对应的字典配置的默认激活费(无设备类型)
+            SysDictRedis algorithmPayConfig = SysDictUtils.get(EnumAlgorithmPayConfig.Code.CODE.getCode(), String.valueOf(algorithmId));
+            if (Emptys.check(algorithmPayConfig)) {
+                MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmPlatformVO dap = new MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmPlatformVO();
+                dap.setAlgorithmId(algorithmId);
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig algorithmMoonConfig = JSONUtil.parseObj(algorithmPayConfig.getValue()).toBean(DeviceAlgorithmChargingDto.AlgorithmMoonConfig.class);
+//                DeviceAlgorithmChargingDto.AlgorithmMoonConfig.Inf inf = algorithmMoonConfig.getInf();
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig.Moon moon = algorithmMoonConfig.getMoon();
+                dap.setMoonMoney(moon.getMoney());
+                dap.setMoonSize(moon.getSize());
+                dap.setSingleMoney(algorithmMoonConfig.getPrice());
+                deviceAcPlatformList.add(dap);
+                algorithmPayConfigMap.put(algorithmId, algorithmPayConfig.getValue());
+            }
+        }
+
+        // 设备管理费-商家自定义费用
+        List<MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmMercVO> deviceAcMercList = new ArrayList<>();
+        LambdaQueryWrapper<MercFeeConfigAlgorithmType> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(dto, MercFeeConfigAlgorithmType.class)
+                .in(MercFeeConfigAlgorithmType::getAlgorithmId, algorithmIds)
+                .eq(MercFeeConfigAlgorithmType::getMercCode, merc.getMercCode())
+                .build();
+        //默认配置 type 2预充 1赠送天数
+        List<MercFeeConfigAlgorithmType> list = list(lambdaQueryWrapper);
+        if (CollUtil.isNotEmpty(list)) {
+            for (MercFeeConfigAlgorithmType cfg : list) {
+                MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmMercVO damVo = BeanUtil.copyProperties(cfg, MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmMercVO.class);
+                Long algorithmId = damVo.getAlgorithmId();
+                String algorithmPayConfig = algorithmPayConfigMap.get(algorithmId);
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig algorithmMoonConfig = JSONUtil.parseObj(algorithmPayConfig).toBean(DeviceAlgorithmChargingDto.AlgorithmMoonConfig.class);
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig.Inf inf = algorithmMoonConfig.getInf();
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig.Moon moon = algorithmMoonConfig.getMoon();
+                damVo.setMoonMoney(moon.getMoney());
+                damVo.setMoonSize(moon.getSize());
+                damVo.setSingleMoney(algorithmMoonConfig.getPrice());
+                deviceAcMercList.add(damVo);
+            }
+        }
+        data.setDeviceAcMercList(deviceAcMercList);
+        data.setDeviceAcPlatformList(deviceAcPlatformList);
+        return R.ok(data);
+    }
+
+
     @PostMapping("page")
     @ApiOperation("分页查询")
     public R<PageBean<MercFeeConfigAlgorithmTypeDto.Vo>> page(@RequestBody MercFeeConfigAlgorithmTypeDto.Page page) {
@@ -70,6 +147,15 @@ public class MercFeeConfigAlgorithmTypeServiceImpl extends ServiceImpl<MercFeeCo
     @PostMapping("save")
     @ApiOperation("添加")
     public R save(@RequestBody @Validated MercFeeConfigAlgorithmTypeDto.Save save) {
+        Long mercId = save.getMercId();
+        Long algorithmId = save.getAlgorithmId();
+        MercFeeConfigAlgorithmType mc = this.getOne(Wrappers.<MercFeeConfigAlgorithmType>lambdaQuery()
+                .eq(MercFeeConfigAlgorithmType::getMercId, mercId)
+                .eq(MercFeeConfigAlgorithmType::getAlgorithmId, algorithmId)
+        );
+        if (mc != null) {
+            throw new CommRuntimeException("该类型配置已存在,请勿重复添加!");
+        }
         MercFeeConfigAlgorithmType saveInfo = copy(MercFeeConfigAlgorithmType.class, save);
         save(saveInfo);
         return R.ok();
@@ -82,4 +168,4 @@ public class MercFeeConfigAlgorithmTypeServiceImpl extends ServiceImpl<MercFeeCo
         updateById(updateInfo);
         return R.ok();
     }
-}
+}

+ 10 - 0
device-api-service/src/main/java/com/xy/service/factory/cmd/impl/SetsCmdServiceImpl.java

@@ -3,10 +3,12 @@ package com.xy.service.factory.cmd.impl;
 import cn.hutool.json.JSONObject;
 import com.xy.annotate.Factory;
 import com.xy.device.EnumMqttCmdTempletSets;
+import com.xy.dto.DeviceSetRecordsDto;
 import com.xy.dto.DeviceTempSetDto;
 import com.xy.dto.MqttCmdDto;
 import com.xy.dto.PaterDto;
 import com.xy.entity.DeviceTempSet;
+import com.xy.service.DeviceSetRecordsServiceImpl;
 import com.xy.service.DeviceTempSetServiceImpl;
 import com.xy.service.factory.cmd.CmdService;
 import com.xy.utils.R;
@@ -22,6 +24,7 @@ import java.util.List;
 public class SetsCmdServiceImpl implements CmdService {
 
     private DeviceTempSetServiceImpl deviceTempSetService;
+    private DeviceSetRecordsServiceImpl deviceSetRecordsService;
 
     @Override
     public R senCommand(List<MqttCmdDto> mqttDtos) {
@@ -53,6 +56,13 @@ public class SetsCmdServiceImpl implements CmdService {
                     save.setWarningHigh(Integer.valueOf(warningHigh));
                 }
                 deviceTempSetService.save(save);
+            } else {
+                DeviceSetRecordsDto.Save save = new DeviceSetRecordsDto.Save();
+                save.setType(type)
+                        .setDeviceId(mqttDto.getDeviceId())
+                        .setContent(data.toString())
+                        ;
+                deviceSetRecordsService.save(save);
             }
         }
         return R.ok();

+ 122 - 0
device-api/src/main/java/com/xy/dto/DeviceChargingConfigDto.java

@@ -49,6 +49,50 @@ public class DeviceChargingConfigDto {
         private List<Integer> deviceTypes;
     }
 
+    @Data
+    @Accessors(chain = true)
+    public static class Save extends Vo {
+       
+
+        @NotNull(message = "mercId不能为空")
+        @ApiModelProperty(value = "商户id")
+        private Long mercId;
+
+        @NotNull(message = "deviceType不能为空")
+        @ApiModelProperty(value = "设备类型")
+        private Integer deviceType;
+
+        @ApiModelProperty(value = "代理商费用;单位:分")
+        private Integer extraMoney;
+
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class Delete {
+
+        @NotNull(message = "id不能为空")
+        @ApiModelProperty(value = "id")
+        private Long id;
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class Update extends Vo {
+
+        @NotNull(message = "id不能为空")
+        @ApiModelProperty(value = "id")
+        private Long id;
+
+        @NotNull(message = "type不能为空")
+        @ApiModelProperty(value = "类型", required = true)
+        private Integer type;
+
+        @NotNull(message = "money不能为空")
+        @ApiModelProperty(value = "预充金额;单位:分")
+        private Integer configValue;
+    }
+
 
     @Data
     @Accessors(chain = true)
@@ -113,6 +157,84 @@ public class DeviceChargingConfigDto {
         @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
         private LocalDateTime updateTime;
 
+        @ApiModelProperty(value = "代理商额外费用")
+        private Integer extraMoney;
+
+
+    }
+
+    /**
+     * 设备管理费配置
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceManagerFeeConfigVO {
+        @ApiModelProperty(value = "设备管理费-平台默认配置")
+        private List<DeviceManagerFeePlatformVO> dmFeePlatforms;
+        @ApiModelProperty(value = "设备管理费-商家自定义费用")
+        private List<DeviceManagerFeeMercVO> dmFeeMercs;
+    }
+
+    /**
+     * 设备管理费-平台默认配置
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceManagerFeePlatformVO {
+        @ApiModelProperty(value = "默认赠送年费")
+        private Integer defFee;
+        @ApiModelProperty(value = "默认赠送天数")
+        private Integer defGiveDay;
+
+        @ApiModelProperty(value = "设备类型")
+        private Integer deviceType;
+
+
+    }
+
+    /**
+     * 设备管理费-商家自定义费用
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceManagerFeeMercVO {
+        @ApiModelProperty(value = "默认赠送年费")
+        private Integer defFee;
+        @ApiModelProperty(value = "默认赠送天数")
+        private Integer defGiveDay;
+
+        @ApiModelProperty(value = "id")
+        private Long id;
+
+        @ApiModelProperty(value = "商户编码")
+        private String mercCode;
+
+        @ApiModelProperty(value = "设备类型")
+        private Integer deviceType;
+
+        @ApiModelProperty(value = "自定义赠送天数")
+        private Integer giveDay;
+
+        @ApiModelProperty(value = "自定义年费")
+        private Integer fee;
+
+        @ApiModelProperty(value = "备注")
+        private String note;
+
+        @ApiModelProperty(value = "类型")
+        private Integer type;
+
+        @ApiModelProperty(value = "创建时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime createTime;
+
+        @ApiModelProperty(value = "更新时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime updateTime;
+
+        @ApiModelProperty(value = "代理商额外费用")
+        private Integer extraMoney;
+
 
     }
 

+ 95 - 0
device-api/src/main/java/com/xy/dto/DeviceSetRecordsDto.java

@@ -0,0 +1,95 @@
+package com.xy.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.xy.utils.PageBean;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author hechunping
+ * @since 2024-04-11
+ */
+public class DeviceSetRecordsDto {
+
+    @Data
+    @Accessors(chain = true)
+    public static class LastOneVo {
+        @ApiModelProperty(value = "类型")
+        private String type;
+
+        @ApiModelProperty(value = "内容")
+        private String content;
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class LastOneDto {
+        @ApiModelProperty(value = "设备ID")
+        private Long deviceId;
+
+        @ApiModelProperty(value = "查询类型列表")
+        private List<String> typeList;
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class SelectList extends Vo {
+
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class Page extends Vo {
+
+        @ApiModelProperty(value = "分页对象", required = true)
+        private PageBean page;
+
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class Save extends Vo {
+
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class Update extends Vo {
+
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class Vo {
+
+        private Long id;
+
+        @ApiModelProperty(value = "设备ID")
+        private Long deviceId;
+
+        @ApiModelProperty(value = "类型")
+        private String type;
+
+        @ApiModelProperty(value = "设置内容")
+        private String content;
+
+
+        @ApiModelProperty(value = "创建人")
+        private Long createUser;
+
+        @ApiModelProperty(value = "创建时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime createTime;
+
+
+    }
+
+}

+ 82 - 0
device-api/src/main/java/com/xy/dto/MercFeeConfigAlgorithmTypeDto.java

@@ -3,6 +3,7 @@ package com.xy.dto;
 import java.time.LocalDateTime;
 
 import java.io.Serializable;
+import java.util.List;
 
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -10,6 +11,9 @@ import lombok.experimental.Accessors;
 import com.xy.utils.PageBean;
 import com.fasterxml.jackson.annotation.JsonFormat;
 
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
 /**
  * <p>
  * 商户算法扣费标准配置扩展
@@ -26,6 +30,14 @@ public class MercFeeConfigAlgorithmTypeDto {
 
     }
 
+    @Data
+    @Accessors(chain = true)
+    public static class ListByFeeConfigDTO extends Vo {
+        @NotNull(message = "mercId不能为空")
+        @ApiModelProperty(value = "商户id", required = true)
+        private Long mercId;
+    }
+
     @Data
     @Accessors(chain = true)
     public static class Page extends Vo {
@@ -45,6 +57,76 @@ public class MercFeeConfigAlgorithmTypeDto {
     @Accessors(chain = true)
     public static class Update extends Vo {
 
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceAlgorithmConfigVO {
+        @ApiModelProperty(value = "算法费-平台默认配置")
+        private List<DeviceAlgorithmPlatformVO> deviceAcPlatformList;
+        @ApiModelProperty(value = "算法费-商家自定义费用")
+        private List<DeviceAlgorithmMercVO> deviceAcMercList;
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceAlgorithmPlatformVO {
+
+        @ApiModelProperty(value = "包月费用,单位 分")
+        private Integer moonMoney;
+        @ApiModelProperty(value = "包月笔数")
+        private Integer moonSize;
+        @ApiModelProperty(value = "单笔费用,单位 分")
+        private Integer singleMoney;
+        @ApiModelProperty(value = "算法类型")
+        private Long algorithmId;
+
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceAlgorithmMercVO {
+
+        @ApiModelProperty(value = "ID")
+        private Long id;
+
+        @ApiModelProperty(value = "商户编码")
+        private String mercCode;
+
+        @ApiModelProperty(value = "商户id")
+        private Long mercId;
+
+        @ApiModelProperty(value = "创建时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime createTime;
+
+        @ApiModelProperty(value = "创建人")
+        private Long createUser;
+
+        @ApiModelProperty(value = "更新人")
+        private Long updateUser;
+
+        @ApiModelProperty(value = "更新时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime updateTime;
+
+        @ApiModelProperty(value = "算法ID")
+        private Long algorithmId;
+
+        @ApiModelProperty(value = "包月费用(比平台多收的金额)")
+        private Integer extraMonthMoney;
+
+        @ApiModelProperty(value = "算法单笔金额(比平台多收的金额)")
+        private Integer extraSingleMoney;
+
+        @ApiModelProperty(value = "平台包月费用,单位 分")
+        private Integer moonMoney;
+        @ApiModelProperty(value = "平台单笔费用,单位 分")
+        private Integer singleMoney;
+        @ApiModelProperty(value = "包月笔数")
+        private Integer moonSize;
+
+
     }
 
     @Data

+ 16 - 0
device-api/src/main/java/com/xy/service/DeviceSetRecordsService.java

@@ -0,0 +1,16 @@
+package com.xy.service;
+
+import com.xy.annotate.RestMappingController;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author hechunping
+ * @since 2024-04-11
+ */
+@RestMappingController("/device-set-records")
+public interface DeviceSetRecordsService {
+
+}