Przeglądaj źródła

账号添加过期设置

lyhzzz 11 miesięcy temu
rodzic
commit
8ad09290ce

Plik diff jest za duży
+ 59 - 2
doc/rtk接口文档.md


+ 2 - 0
src/main/java/com/fdkankan/manage/common/ResultCode.java

@@ -101,6 +101,8 @@ public enum ResultCode  {
     RTK_ACCOUNT_NOT_EXIT(50079, "rtk账号库存不足"),
     SCENE_NOT_EXIST_E57(50080, "场景不存在e57文件"),
 
+    RTK_DEVICEIN_TEMPLATE_EMPTY(50081, "rtk批量导入数据为空"),
+
 
     ;
 

+ 63 - 0
src/main/java/com/fdkankan/manage/constant/RtkTypeEnum.java

@@ -0,0 +1,63 @@
+package com.fdkankan.manage.constant;
+
+import org.apache.commons.lang3.StringUtils;
+
+public enum RtkTypeEnum {
+    /**
+     * 填写说明:
+     * 1、相机SN:需是已入库设备的SN码;
+     * 2、板卡类型(请复制填入):千寻板卡千寻账号、千寻板卡移动账号、北云板卡移动账号;
+     * 3、板卡SN:按板卡SN号输入;
+     * 4、深光RTK插件SN:按插件SN输入;
+     */
+    QX_QX(0,"千寻板卡千寻账号"),
+    QX_YD(1,"千寻板卡移动账号"),
+    BY_YD(2,"北云板卡移动账号")
+
+    ;
+
+
+    int code;
+    String msg;
+
+    RtkTypeEnum(int code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+    public static RtkTypeEnum getByCode(int code){
+        RtkTypeEnum[] values = RtkTypeEnum.values();
+        for (RtkTypeEnum value : values) {
+            if(value.code == code){
+                return value;
+            }
+        }
+        return null;
+    }
+    public static RtkTypeEnum getByMsg(String msg){
+        if(StringUtils.isNotBlank(msg)){
+            RtkTypeEnum[] values = RtkTypeEnum.values();
+            for (RtkTypeEnum value : values) {
+                if(value.msg.equalsIgnoreCase(msg)){
+                    return value;
+                }
+            }
+        }
+        return null;
+    }
+}

+ 4 - 2
src/main/java/com/fdkankan/manage/controller/ExcelController.java

@@ -29,7 +29,7 @@ public class ExcelController {
 
     /**
      * 下载出入库模板
-     * type 0 入库模板, 1出库模板 ,2 客户关联模板
+     * type 0 入库模板, 1出库模板 ,2 客户关联模板,3 rtk设备模版,4rtk账号模版
      */
     @GetMapping("/downTemplate")
     public void downInTemplate(@RequestParam(required = false,defaultValue = "0") Integer type,
@@ -39,6 +39,8 @@ public class ExcelController {
             case 0 : fileName = "cameraIn.xlsx"; break;
             case 1 : fileName = "cameraOut.xlsx"; break;
             case 2 : fileName = "cameraCompany.xlsx"; break;
+            case 3 : fileName = "rtkDevice.xlsx"; break;
+            case 4 : fileName = "rtkAccount.xlsx"; break;
             default: throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("template/"+fileName);
@@ -63,7 +65,7 @@ public class ExcelController {
     }
     /**
      * 导入excel
-     * type 0 入库模板, 1出库模板 ,2 客户关联模板
+     * type 0 入库模板, 1出库模板 ,2 客户关联模板,3 rtk设备模版,4rtk账号模版
      */
     @PostMapping("/uploadExcel")
     public ResultData uploadExcel(@RequestParam(required = false) MultipartFile file,

+ 0 - 5
src/main/java/com/fdkankan/manage/controller/RtkAccountController.java

@@ -46,10 +46,5 @@ public class RtkAccountController {
         return ResultData.ok();
     }
 
-    @PostMapping("/uploadExcel")
-    public ResultData uploadExcel(@RequestBody RtkAccount param){
-        rtkAccountService.del(param);
-        return ResultData.ok();
-    }
 }
 

+ 6 - 0
src/main/java/com/fdkankan/manage/service/ICameraService.java

@@ -52,4 +52,10 @@ public interface ICameraService extends IService<Camera> {
     HashMap<Long, Camera> getByIds(List<Long> cameraIds);
 
     List<Camera> getBySnCodes(Set<String> snCodes);
+
+    Integer insExcelList(List<HashMap<Integer, String>> excelRowList);
+
+    Integer outExcelList(List<HashMap<Integer, String>> excelRowList);
+
+    Integer companyExcelList(List<HashMap<Integer, String>> excelRowList);
 }

+ 3 - 0
src/main/java/com/fdkankan/manage/service/IRtkAccountService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.manage.entity.RtkDevice;
 import com.fdkankan.manage.vo.request.RtkInfoParam;
 
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -32,4 +33,6 @@ public interface IRtkAccountService extends IService<RtkAccount> {
     RtkAccount getByUserName(String userName);
 
     List<RtkAccount> getByNotFailure();
+
+    Integer insExcelList(List<HashMap<Integer, String>> excelRowList);
 }

+ 5 - 0
src/main/java/com/fdkankan/manage/service/IRtkDeviceService.java

@@ -5,6 +5,9 @@ import com.fdkankan.manage.entity.RtkDevice;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.manage.vo.request.RtkInfoParam;
 
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * <p>
  *  服务类
@@ -26,4 +29,6 @@ public interface IRtkDeviceService extends IService<RtkDevice> {
     RtkDevice getSgRtkSn(String sgRtkSn);
 
     RtkDevice getByCameraSn(String cameraSnCode);
+
+    Integer insExcelList(List<HashMap<Integer, String>> excelRowList);
 }

+ 121 - 0
src/main/java/com/fdkankan/manage/service/impl/CameraServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.common.constant.Constant;
 import com.fdkankan.manage.common.*;
+import com.fdkankan.manage.constant.CameraOutTypeEnum;
 import com.fdkankan.manage.entity.*;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.common.util.DateUtil;
@@ -639,4 +640,124 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
         wrapper.in(Camera::getSnCode,snCodes);
         return this.list(wrapper);
     }
+
+    @Override
+    public Integer insExcelList(List<HashMap<Integer, String>> excelRowList) {
+        List<String> wifiNameList = new ArrayList<>();
+        Integer index = 0;
+        for (HashMap<Integer, String> map : excelRowList) {
+            index ++;
+            if(map.isEmpty()){
+                continue;
+            }
+            if(index == 0 && !map.get(0).equals("设备入库模板")){
+                throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
+            }
+            if(index <4){   //从第四行开始
+                continue;
+            }
+            String wifiName = map.get(0);
+            wifiNameList.add(wifiName);
+        }
+
+        if(wifiNameList.size() <=0){
+            throw new BusinessException(ResultCode.IN_TEMPLATE_EMPTY);
+        }
+        return this.ins(wifiNameList);
+    }
+
+    @Autowired
+    IAgentNewService agentNewService;
+    @Override
+    public Integer outExcelList(List<HashMap<Integer, String>> excelRowList) {
+        List<CameraInOutParam> params = new ArrayList<>();
+        List<Integer> errorIndex = new ArrayList<>();
+        Integer index = 0;
+        for (HashMap<Integer, String> map : excelRowList) {
+            index ++;
+            if(map.isEmpty()){
+                continue;
+            }
+            if(index == 0 && !map.get(0).equals("设备出库模板")){
+                throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
+            }
+            if(index <4){
+                continue;
+            }
+            String snCode = map.get(0);
+            String outTypeString = map.get(1);
+            String companyName = map.get(2);
+            String orderSn = map.get(3);
+            String agentName = map.get(4);
+            String buyDate = map.get(5);
+            CameraOutTypeEnum outTypeEnum = CameraOutTypeEnum.getByMsg(outTypeString);
+            if(outTypeEnum == null || StringUtils.isBlank(snCode) || StringUtils.isBlank(buyDate)){
+                log.error("outError-->出库错误:出库类型为空或snCode为空:snCode:{},outType:{},companyName:{},orderSn:{},agentName:{}"
+                        ,snCode,outTypeString,companyName,orderSn,agentName);
+                errorIndex.add(index -3);
+            }
+            CameraInOutParam param = new CameraInOutParam();
+            if(outTypeEnum != null){
+                int outType = outTypeEnum.getCode();
+                param.setOutType(outType);
+            }
+            param.setBuyDate(buyDate);
+            if(StringUtils.isNotBlank(agentName)){
+                AgentNew agentNew = agentNewService.getByName(agentName);
+                if(agentNew == null){
+                    log.error("outError-->出库错误:代理商不存在:snCode:{},outType:{},companyName:{},orderSn:{},agentName:{}"
+                            ,snCode,outTypeString,companyName,orderSn,agentName);
+                    errorIndex.add(index -3);
+                }else {
+                    param.setAgentId(agentNew.getId());
+                }
+            }
+            param.setCompanyName(companyName);
+            param.setOrderSn(orderSn);
+            param.setSnCode(snCode);
+            params.add(param);
+
+        }
+
+        excelService.toExcelError(errorIndex);
+
+        if(params.size() <=0){
+            throw new BusinessException(ResultCode.OUT_TEMPLATE_EMPTY);
+        }
+        return this.outs(params);
+    }
+
+    @Override
+    public Integer companyExcelList(List<HashMap<Integer, String>> excelRowList) {
+        List<CameraInOutParam> companyParams = new ArrayList<>();
+        List<Integer> errorIndex = new ArrayList<>();
+        Integer index = 0;
+        for (HashMap<Integer, String> map : excelRowList) {
+            index ++;
+            if(map.isEmpty()){
+                continue;
+            }
+            if(index == 0 && !map.get(0).equals("客户关联模板")){
+                throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
+            }
+            if(index <4){
+                continue;
+            }
+            CameraInOutParam param = new CameraInOutParam();
+            param.setCompanyName(map.get(0));
+            param.setSnCode(map.get(1));
+            if(StringUtils.isBlank(param.getSnCode()) || StringUtils.isBlank(param.getCompanyName())){
+                errorIndex.add(index -3 );
+            }
+            companyParams.add(param);
+
+        }
+        excelService.toExcelError(errorIndex);
+
+
+        if( companyParams.size() <=0){
+            throw new BusinessException(ResultCode.COMPANY_TEMPLATE_EMPTY);
+        }
+        return this.updateCompany(companyParams);
+    }
 }

+ 13 - 97
src/main/java/com/fdkankan/manage/service/impl/ExcelServiceImpl.java

@@ -9,10 +9,7 @@ import com.fdkankan.manage.entity.AgentNew;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.constant.CameraOutTypeEnum;
 import com.fdkankan.manage.entity.Company;
-import com.fdkankan.manage.service.IAgentNewService;
-import com.fdkankan.manage.service.ICameraService;
-import com.fdkankan.manage.service.ICompanyService;
-import com.fdkankan.manage.service.IExcelService;
+import com.fdkankan.manage.service.*;
 import com.fdkankan.manage.util.ExcelUtil;
 import com.fdkankan.manage.vo.request.CameraInOutParam;
 import lombok.extern.slf4j.Slf4j;
@@ -48,6 +45,10 @@ public class ExcelServiceImpl implements IExcelService {
     ICameraService cameraService;
     @Autowired
     IAgentNewService agentNewService;
+    @Autowired
+    IRtkDeviceService rtkDeviceService;
+    @Autowired
+    IRtkAccountService rtkAccountService;
 
     public void commonExport(HttpServletRequest request, HttpServletResponse response,String name,List<?> result,ExcelWriter excelWriter) throws Exception {
         response.setContentType("application/vnd.ms-excel");
@@ -93,100 +94,15 @@ public class ExcelServiceImpl implements IExcelService {
         }catch (Exception e){
             throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
         }
-        List<String> wifiNameList = new ArrayList<>();
-        List<CameraInOutParam> params = new ArrayList<>();
-        List<CameraInOutParam> companyParams = new ArrayList<>();
-        List<Integer> errorIndex = new ArrayList<>();
-        Integer index = 0;
-        for (HashMap<Integer, String> map : excelRowList) {
-            index ++;
-            if(map.isEmpty()){
-                continue;
-            }
-            if(type == 0){      //入库
-                if(index == 0 && !map.get(0).equals("设备入库模板")){
-                    throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
-                }
-                if(index <4){   //从第四行开始
-                    continue;
-                }
-                String wifiName = map.get(0);
-                wifiNameList.add(wifiName);
-            }else if(type == 1){    //出库
-                if(index == 0 && !map.get(0).equals("设备出库模板")){
-                    throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
-                }
-                if(index <4){
-                    continue;
-                }
-                String snCode = map.get(0);
-                String outTypeString = map.get(1);
-                String companyName = map.get(2);
-                String orderSn = map.get(3);
-                String agentName = map.get(4);
-                String buyDate = map.get(5);
-                CameraOutTypeEnum outTypeEnum = CameraOutTypeEnum.getByMsg(outTypeString);
-                if(outTypeEnum == null || StringUtils.isBlank(snCode) || StringUtils.isBlank(buyDate)){
-                    log.error("outError-->出库错误:出库类型为空或snCode为空:snCode:{},outType:{},companyName:{},orderSn:{},agentName:{}"
-                            ,snCode,outTypeString,companyName,orderSn,agentName);
-                    errorIndex.add(index -3);
-                }
-                CameraInOutParam param = new CameraInOutParam();
-                if(outTypeEnum != null){
-                    int outType = outTypeEnum.getCode();
-                    param.setOutType(outType);
-                }
-                param.setBuyDate(buyDate);
-                if(StringUtils.isNotBlank(agentName)){
-                    AgentNew agentNew = agentNewService.getByName(agentName);
-                    if(agentNew == null){
-                        log.error("outError-->出库错误:代理商不存在:snCode:{},outType:{},companyName:{},orderSn:{},agentName:{}"
-                                ,snCode,outTypeString,companyName,orderSn,agentName);
-                        errorIndex.add(index -3);
-                    }else {
-                        param.setAgentId(agentNew.getId());
-                    }
-                }
-                param.setCompanyName(companyName);
-                param.setOrderSn(orderSn);
-                param.setSnCode(snCode);
-                params.add(param);
-            }else if(type == 2){   //关联客户
-                if(index == 0 && !map.get(0).equals("客户关联模板")){
-                    throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
-                }
-                if(index <4){
-                    continue;
-                }
-                CameraInOutParam param = new CameraInOutParam();
-                param.setCompanyName(map.get(0));
-                param.setSnCode(map.get(1));
-                if(StringUtils.isBlank(param.getSnCode()) || StringUtils.isBlank(param.getCompanyName())){
-                    errorIndex.add(index -3 );
-                }
-                companyParams.add(param);
-            }
-        }
-         this.toExcelError(errorIndex);
-
-        if(type == 0 && wifiNameList.size() <=0){
-            throw new BusinessException(ResultCode.IN_TEMPLATE_EMPTY);
-        }else if(type == 1 && params.size() <=0){
-
-            throw new BusinessException(ResultCode.OUT_TEMPLATE_EMPTY);
-        }else if(type == 2 && companyParams.size() <=0){
-            throw new BusinessException(ResultCode.COMPANY_TEMPLATE_EMPTY);
-        }
-        if(wifiNameList.size() >0){
-            return cameraService.ins(wifiNameList);
-        }
-        if(params.size() >0){
-            return cameraService.outs(params);
-        }
-        if(companyParams.size() >0){
-            return cameraService.updateCompany(companyParams);
+        switch (type){
+            case 0 :return cameraService.insExcelList(excelRowList);
+            case 1 :return cameraService.outExcelList(excelRowList);
+            case 2 :return cameraService.companyExcelList(excelRowList);
+            case 3 :return rtkDeviceService.insExcelList(excelRowList);
+            case 4 :return rtkAccountService.insExcelList(excelRowList);
+            default:
+                throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
-        return 0;
     }
 
     @Override

+ 83 - 4
src/main/java/com/fdkankan/manage/service/impl/RtkAccountServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.manage.common.PageInfo;
 import com.fdkankan.manage.common.ResultCode;
+import com.fdkankan.manage.constant.RtkTypeEnum;
 import com.fdkankan.manage.entity.*;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.mapper.ICameraDetailMapper;
@@ -15,7 +16,10 @@ import com.fdkankan.manage.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.manage.task.DingdingService;
 import com.fdkankan.manage.task.TaskService;
+import com.fdkankan.manage.util.DateUtils;
 import com.fdkankan.manage.util.SendMailUtils;
+import com.fdkankan.manage.vo.request.RtkAccountInParam;
+import com.fdkankan.manage.vo.request.RtkDeviceInParam;
 import com.fdkankan.manage.vo.request.RtkInfoParam;
 import com.fdkankan.redis.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -27,10 +31,9 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -60,6 +63,8 @@ public class RtkAccountServiceImpl extends ServiceImpl<IRtkAccountMapper, RtkAcc
     ICameraService cameraService;
     @Autowired
     ICameraDetailService cameraDetailService;
+    @Autowired
+    IExcelService excelService;
 
     @Override
     public RtkAccount getOneNotUseAccount(String rtkSnCode,String cameraSn) {
@@ -224,4 +229,78 @@ public class RtkAccountServiceImpl extends ServiceImpl<IRtkAccountMapper, RtkAcc
         wrapper.le(RtkAccount::getFailureTime,new Date());
         return this.list(wrapper);
     }
+
+    @Override
+    public Integer insExcelList(List<HashMap<Integer, String>> excelRowList) {
+        List<RtkAccountInParam> params = new ArrayList<>();
+        List<Integer> errorIndex = new ArrayList<>();
+        Integer index = 0;
+        for (HashMap<Integer, String> map : excelRowList) {
+            index ++;
+            if(map.isEmpty()){
+                continue;
+            }
+            if(index == 0 && !map.get(0).equals("差分账号批量导入模板")){
+                throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
+            }
+            if(index <4){
+                continue;
+            }
+            String userName = map.get(0);
+            String password = map.get(1);
+            String operator = map.get(2);
+            String ipAddr = map.get(3);
+            String mountPoint = map.get(4);
+            String port = map.get(5);
+            String failureTimeStr = map.get(6);
+            log.info("rtkAccount-excel-in--userName:{},password:{},operator:{},ipAddr:{},mountPoint:{},port:{},failureTime:{}",userName,password,operator,ipAddr,mountPoint,port,failureTimeStr);
+            if(StringUtils.isBlank(userName) || StringUtils.isBlank(password) || StringUtils.isBlank(ipAddr) || StringUtils.isBlank(mountPoint) || StringUtils.isBlank(port)){
+                errorIndex.add(index);
+                continue;
+            }
+            RtkAccount rtkAccount = this.getByUserName(userName);
+            if(rtkAccount !=null){
+                errorIndex.add(index);
+                continue;
+            }
+            Date failureTime = null;
+            if(StringUtils.isNotBlank(failureTimeStr)){
+                try {
+                    failureTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(failureTimeStr);
+                } catch (ParseException e) {
+                    errorIndex.add(index);
+                    continue;
+                }
+            }
+            RtkAccountInParam param = new RtkAccountInParam(userName,password,operator,ipAddr,mountPoint,port,failureTime);
+            params.add(param);
+        }
+        excelService.toExcelError(errorIndex);
+
+        if(params.size() <=0){
+            throw new BusinessException(ResultCode.RTK_DEVICEIN_TEMPLATE_EMPTY);
+        }
+        return this.ins(params);
+    }
+
+    private Integer ins(List<RtkAccountInParam> params) {
+        List<RtkAccount> dbs = new ArrayList<>();
+        for (RtkAccountInParam param : params) {
+            RtkAccount rtkAccount = new RtkAccount();
+            rtkAccount.setUserName(param.getUserName());
+            rtkAccount.setPassword(param.getPassword());
+            rtkAccount.setIpAddr(param.getIpAddr());
+            rtkAccount.setMountPoint(param.getMountPoint());
+            rtkAccount.setPort(param.getPort());
+            rtkAccount.setOperator(param.getOperator());
+            rtkAccount.setFailureTime(param.getFailureTime());
+            rtkAccount.setCreateUserId(Long.valueOf( StpUtil.getLoginId().toString()));
+            dbs.add(rtkAccount);
+        }
+        if(dbs.isEmpty()){
+            return 0;
+        }
+        this.saveBatch(dbs);
+        return dbs.size();
+    }
 }

+ 76 - 4
src/main/java/com/fdkankan/manage/service/impl/RtkDeviceServiceImpl.java

@@ -6,21 +6,25 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.manage.common.PageInfo;
 import com.fdkankan.manage.common.ResultCode;
-import com.fdkankan.manage.entity.RtkAccount;
-import com.fdkankan.manage.entity.RtkDevice;
-import com.fdkankan.manage.entity.RtkInfo;
-import com.fdkankan.manage.entity.SysUser;
+import com.fdkankan.manage.constant.CameraOutTypeEnum;
+import com.fdkankan.manage.constant.RtkTypeEnum;
+import com.fdkankan.manage.entity.*;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.mapper.IRtkDeviceMapper;
+import com.fdkankan.manage.service.IExcelService;
 import com.fdkankan.manage.service.IRtkDeviceService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.manage.service.ISysUserService;
+import com.fdkankan.manage.vo.request.CameraInOutParam;
+import com.fdkankan.manage.vo.request.RtkDeviceInParam;
 import com.fdkankan.manage.vo.request.RtkInfoParam;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Set;
@@ -35,10 +39,13 @@ import java.util.stream.Collectors;
  * @since 2024-07-22
  */
 @Service
+@Slf4j
 public class RtkDeviceServiceImpl extends ServiceImpl<IRtkDeviceMapper, RtkDevice> implements IRtkDeviceService {
 
     @Autowired
     ISysUserService sysUserService;
+    @Autowired
+    IExcelService excelService;
     @Override
     public RtkDevice getByRtkSnCode(String rtkSnCode) {
         LambdaQueryWrapper<RtkDevice> wrapper = new LambdaQueryWrapper<>();
@@ -152,4 +159,69 @@ public class RtkDeviceServiceImpl extends ServiceImpl<IRtkDeviceMapper, RtkDevic
         wrapper.eq(RtkDevice::getCameraSnCode,cameraSnCode);
         return this.getOne(wrapper);
     }
+
+    @Override
+    public Integer insExcelList(List<HashMap<Integer, String>> excelRowList) {
+        List<RtkDeviceInParam> params = new ArrayList<>();
+        List<Integer> errorIndex = new ArrayList<>();
+        Integer index = 0;
+        for (HashMap<Integer, String> map : excelRowList) {
+            index ++;
+            if(map.isEmpty()){
+                continue;
+            }
+            if(index == 0 && !map.get(0).equals("RTK批量导入模板")){
+                throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
+            }
+            if(index <4){
+                continue;
+            }
+            String cameraSn = map.get(0);
+            String rtkTypeStr = map.get(1);
+            String rtkSn = map.get(2);
+            String rtkSgSn = map.get(3);
+            log.info("rtkDevice-excel-in--cameraSn:{},rtkTypeStr:{},rtkSn:{},rtkSgSn:{}",cameraSn,rtkTypeStr,rtkSn,rtkSgSn);
+            RtkTypeEnum rtkTypeEnum = RtkTypeEnum.getByMsg(rtkTypeStr);
+            if(StringUtils.isBlank(rtkSn) || rtkTypeEnum == null){
+                errorIndex.add(index);
+                continue;
+            }
+            RtkDevice rtkDevice = this.getByRtkSnCode(rtkSn);
+            if(rtkDevice !=null){
+                errorIndex.add(index);
+                continue;
+            }
+            RtkDevice rtkDevice2 = this.getByCameraSn(cameraSn);
+            if(rtkDevice2 !=null){
+                errorIndex.add(index);
+                continue;
+            }
+            RtkDeviceInParam param = new RtkDeviceInParam(cameraSn,rtkTypeEnum.getCode(),rtkSn,rtkSgSn);
+            params.add(param);
+        }
+        excelService.toExcelError(errorIndex);
+
+        if(params.size() <=0){
+            throw new BusinessException(ResultCode.RTK_DEVICEIN_TEMPLATE_EMPTY);
+        }
+        return this.ins(params);
+    }
+
+    private Integer ins(List<RtkDeviceInParam> params) {
+        List<RtkDevice> dbs = new ArrayList<>();
+        for (RtkDeviceInParam param : params) {
+            RtkDevice rtkDevice = new RtkDevice();
+            rtkDevice.setRtkSnCode(param.getRtkSn());
+            rtkDevice.setCameraSnCode(param.getCameraSn());
+            rtkDevice.setSgRtkSn(param.getRtkSgSn());
+            rtkDevice.setRtkType(param.getRtkType());
+            rtkDevice.setCreateUserId(Long.valueOf( StpUtil.getLoginId().toString()));
+            dbs.add(rtkDevice);
+        }
+        if(dbs.isEmpty()){
+            return 0;
+        }
+        this.saveBatch(dbs);
+        return dbs.size();
+    }
 }

+ 1 - 1
src/main/java/com/fdkankan/manage/test/TestController.java

@@ -82,7 +82,7 @@ public class TestController {
 
     /**
      * 导入excel
-     * type 0 入库模板, 1出库模板 ,2 客户关联模板
+     * type 0 入库模板, 1出库模板 ,2 客户关联模板 ,3 rtk设备模版,4rtk账号模版
      */
     @PostMapping("/uploadExcel")
     public ResultData uploadExcel(@RequestParam(required = false) MultipartFile file) throws IOException {

+ 18 - 0
src/main/java/com/fdkankan/manage/vo/request/RtkAccountInParam.java

@@ -0,0 +1,18 @@
+package com.fdkankan.manage.vo.request;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@AllArgsConstructor
+public class RtkAccountInParam {
+    private String userName ;
+    private String password ;
+    private String operator ;
+    private String ipAddr ;
+    private String mountPoint;
+    private String port ;
+    private Date failureTime ;
+}

+ 13 - 0
src/main/java/com/fdkankan/manage/vo/request/RtkDeviceInParam.java

@@ -0,0 +1,13 @@
+package com.fdkankan.manage.vo.request;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class RtkDeviceInParam {
+    private String cameraSn ;
+    private Integer rtkType ;
+    private String rtkSn ;
+    private String rtkSgSn ;
+}

BIN
src/main/resources/template/rtkAccount.xlsx


BIN
src/main/resources/template/rtkDevice.xlsx