添加设备导入页面功能
diff --git a/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java b/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java
index 382d024..99c59f9 100644
--- a/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java
+++ b/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java
@@ -289,8 +289,8 @@
/**
* 1. 设置列信息:name:列标题 key: 列属性
*/
+ entity.add(new ExcelExportEntity("市民卡号(必填)", "cardno"));
entity.add(new ExcelExportEntity("姓名", "custname"));
- entity.add(new ExcelExportEntity("市民卡号(必填)", "cardno"));
entity.add(new ExcelExportEntity("银行卡号", "bankcarno"));
// entity.add(new ExcelExportEntity("物理卡号()","cardphyid"));
// entity.add(new ExcelExportEntity("性别", "sex"));
@@ -386,6 +386,9 @@
int succCnt = 0;
int errCnt = 0;
long startTime = System.currentTimeMillis();
+ if (logger.isInfoEnabled()){
+ logger.info("开始进行名单导入");
+ }
for (CustomerListBean list : doorList) {
String cardno = list.getCardno();
@@ -405,7 +408,9 @@
tCustomerNoExistInfos.add(list);
continue;
}
-
+ if (logger.isInfoEnabled()){
+ logger.info(cardno+"--核心平台验证通过,开始进行导入!");
+ }
succCnt++;
tmpi++;
TCustomer customer = webInterfaceService.findCustomerById(response.getUserid());
@@ -456,7 +461,7 @@
// customerTmp.setEmail(list.getEmail());
// customerTmp.setMobile(list.getMobile());
// customerTmp.setAddr(list.getAddr());
- customerTmp.setOpendate(now.substring(0, 7));
+ customerTmp.setOpendate(now.substring(0, 8));
customerTmp.setClosedate(response.getExpiredate());
customerTmp.setLastsavedtime(now);
customerTmp.setAddoperid(operid);
diff --git a/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java b/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java
index 1ae8da0..6b014f8 100644
--- a/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java
+++ b/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java
@@ -1,5 +1,12 @@
package com.supwisdom.dlpay.ncmgr.controller;
+import cn.afterturn.easypoi.entity.vo.MapExcelConstants;
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
+import cn.afterturn.easypoi.view.PoiBaseView;
import com.supwisdom.dlpay.framework.domain.TOperator;
import com.supwisdom.dlpay.framework.util.DateUtil;
import com.supwisdom.dlpay.framework.util.StringUtil;
@@ -20,9 +27,13 @@
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.File;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -64,6 +75,11 @@
return "ncmgr/nc_devweek";
}
+ @RequestMapping("/impdevindex")
+ public String impdevindex(){
+ return "ncmgr/nc_impDev";
+ }
+
/**
* 分页查询设备信息
* @param request
@@ -1147,4 +1163,352 @@
return map;
}
+ /**
+ * 设备导入模板下载
+ * @param request
+ * @param response
+ */
+ @ResponseBody
+ @RequestMapping("/downNcDevExcelTemplate")
+ public void downNcDevExcelTemplate(HttpServletRequest request, HttpServletResponse response){
+ Map map = new HashMap();
+ try {
+ List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
+ /**
+ * 1. 设置列信息:name:列标题 key: 列属性
+ */
+ entity.add(new ExcelExportEntity("设备名称", "devname"));
+ entity.add(new ExcelExportEntity("设备类型", "devtype"));
+ //entity.add(new ExcelExportEntity("设备使用类型", "usetype")); 默认全部为门禁 MJ
+ entity.add(new ExcelExportEntity("上级设备编号", "fdevid"));
+ entity.add(new ExcelExportEntity("终端物理编号", "devphyid"));
+ entity.add(new ExcelExportEntity("读头号", "devno"));
+ entity.add(new ExcelExportEntity("IP地址", "ip"));
+ entity.add(new ExcelExportEntity("区域编号", "regionid"));
+ entity.add(new ExcelExportEntity("楼栋编号", "buildingid"));
+ List<Map> personList = new ArrayList<Map>();
+ /**
+ * 2.设置表格属性: title:标题 sheetName:工作簿名 type:表格类型
+ */
+ ExportParams params = new ExportParams(null, "sheet1", ExcelType.HSSF);
+ map.put(MapExcelConstants.MAP_LIST, personList);
+ map.put(MapExcelConstants.ENTITY_LIST, entity);
+ map.put(MapExcelConstants.PARAMS, params);
+ map.put(MapExcelConstants.FILE_NAME, "设备导入模板");//文件名
+ map.put("result", "导出excel文件完成");
+ PoiBaseView.render(map, request, response, MapExcelConstants.EASYPOI_MAP_EXCEL_VIEW);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ map.put("result", "导出excel文件失败");
+ }
+ }
+
+
+ /**
+ * 设备导入
+ * @param file
+ * @param request
+ * @param response
+ * @return
+ */
+ @ResponseBody
+ @RequestMapping(value = "/saveNcDevByExcel",method = {RequestMethod.POST})
+ public Map saveNcDevByExcel(@RequestParam(value = "file", required = false) MultipartFile file,
+ HttpServletRequest request,HttpServletResponse response){
+ Map map = new HashMap();
+ try {
+ String devTypeId = request.getParameter("devTypeId");
+ String path = request.getSession().getServletContext().getRealPath("upload");
+ String fileName = file.getOriginalFilename();
+ File targetFile = new File(path, fileName);
+ if (!targetFile.exists()) {
+ targetFile.mkdirs();
+ }
+ file.transferTo(targetFile);
+ map = impNcDevList(path + "/" + fileName,devTypeId, map);
+
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+
+ return map;
+ }
+
+ private Map impNcDevList(String fpath,String devTypeId,Map map){
+ ImportParams params = new ImportParams();
+ params.setTitleRows(0);
+ List<TNcDevice> tNcDeviceList = ExcelImportUtil.importExcel(new File(fpath), TNcDevice.class, params);
+ int totCnt = tNcDeviceList.size();
+ int flag = 0;
+ if (totCnt<=0){
+ map.put("impDev_succ","导入文件中未查询到数据!");
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ String failStr = "";
+ try{
+ TNcDevice device;
+
+ //判断导入数据是否合法
+ for (int i=0;i<tNcDeviceList.size();i++){
+ if (tNcDeviceList.get(i).getRegionid()==null||"".equals(tNcDeviceList.get(i).getRegionid())){
+ failStr = "第"+(i+1)+"条数据--设备所属区域编号为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ TRegion regionById = systemService.getRegionById(tNcDeviceList.get(i).getRegionid());
+ if (regionById==null){
+ failStr = "第"+(i+1)+"条数据--设备所属区域不存在!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+
+ if (tNcDeviceList.get(i).getBuildingid()==null||"".equals(tNcDeviceList.get(i).getBuildingid())){
+ failStr = "第"+(i+1)+"条数据--设备所属楼栋编号为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ TBuilding buildingById = systemService.getBuildingById(tNcDeviceList.get(i).getBuildingid());
+ if (buildingById==null){
+ failStr = "第"+(i+1)+"条数据--设备所属楼栋不存在!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+
+ //控制器设备类型
+ if (devTypeId.equals("C")){
+ if (!tNcDeviceList.get(i).getDevtype().equals("C")){
+ failStr = "第"+(i+1)+"条数据--设备类型和所选设备类型不一致!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevphyid()==null){
+ failStr = "第"+(i+1)+"条数据--终端物理编号为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevname()==null){
+ failStr = "第"+(i+1)+"条数据--设备名称为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevtype()==null){
+ failStr = "第"+(i+1)+"条数据--设备类型为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ device = ncService.validDevPhyid(0,tNcDeviceList.get(i).getDevphyid());
+ if (device!=null && device.getDeviceid()>0){
+ failStr = "第"+(i+1)+"条数据--终端物理编号已存在!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ device = ncService.validDevName(0,tNcDeviceList.get(i).getDevname());
+ if (device!=null && device.getDeviceid()>0){
+ failStr = "第"+(i+1)+"条数据--设备名称已存在!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getFdevid()!=null){
+ failStr = "第"+(i+1)+"条数据--控制器类型上级设备必须为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevno()!=null){
+ failStr = "第"+(i+1)+"条数据--控制器类型读头号必须为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevtype().equals("C") && tNcDeviceList.get(i).getDevphyid().length()!=12){
+ failStr = "第"+(i+1)+"条数据--控制器类型终端物理编号必须为12位!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ }
+
+
+ //读头设备类型
+ if (devTypeId.equals("R")){
+ if (!tNcDeviceList.get(i).getDevtype().equals("R")){
+ failStr = "第"+(i+1)+"条数据--设备类型和所选设备类型不一致!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevphyid()==null){
+ failStr = "第"+(i+1)+"条数据--终端物理编号为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevname()==null){
+ failStr = "第"+(i+1)+"条数据--设备名称为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevtype()==null){
+ failStr = "第"+(i+1)+"条数据--设备类型为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ device = ncService.validDevPhyid(0,tNcDeviceList.get(i).getDevphyid());
+ if (device!=null && device.getDeviceid()>0){
+ failStr = "第"+(i+1)+"条数据--终端物理编号已存在!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ device = ncService.validDevName(0,tNcDeviceList.get(i).getDevname());
+ if (device!=null && device.getDeviceid()>0){
+ failStr = "第"+(i+1)+"条数据--设备名称已存在!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevtype().equals("R") && tNcDeviceList.get(i).getFdevid()==null){
+ failStr = "第"+(i+1)+"条数据--读头类型上级设备不可为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevtype().equals("R") && tNcDeviceList.get(i).getDevno()==null){
+ failStr = "第"+(i+1)+"条数据--读头类型读头号不可为空!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ if (tNcDeviceList.get(i).getDevtype().equals("R")){
+ device = ncService.findDevById(tNcDeviceList.get(i).getFdevid());
+ if (device==null){
+ failStr = "第"+(i+1)+"条数据--此上级设备不存在!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ }
+ device = ncService.findDevById(tNcDeviceList.get(i).getFdevid());
+ if (!(device.getDevtype().equals("C"))){
+ failStr = "第"+(i+1)+"条数据--此上级设备不为控制器!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ device=ncService.validDevNo(tNcDeviceList.get(i).getFdevid(),tNcDeviceList.get(i).getDevno(),0);
+ if (device!=null && device.getDeviceid()>0){
+ failStr = "第"+(i+1)+"条数据--该控制器下此读头号已存在!";
+ map.put("impDev_succ",failStr);
+ flag = -1;
+ map.put("flag", flag);
+ return map;
+ }
+ }
+
+ }
+
+ //批量添加设备
+ int successCnt = 0;
+ int errCnt = 0;
+ for (TNcDevice tNcDeviceTemp:tNcDeviceList){
+ TNcDevice validDevName = ncService.validDevName(0, tNcDeviceTemp.getDevname());
+ if (validDevName!=null && validDevName.getDeviceid()>0){
+ errCnt++;
+ continue;
+ }
+ TNcDevice validDevPhyid = ncService.validDevPhyid(0, tNcDeviceTemp.getDevphyid());
+ if (validDevPhyid!=null){
+ errCnt++;
+ continue;
+ }
+ if (tNcDeviceTemp.getDevtype().equals("R")){
+ TNcDevice validDevNo = ncService.validDevNo(tNcDeviceTemp.getFdevid(), tNcDeviceTemp.getDevno(), 0);
+ if (validDevNo!=null){
+ errCnt++;
+ continue;
+ }
+ RedisUtil.del("ncdev_" + tNcDeviceTemp.getDevphyid() + "_" + tNcDeviceTemp.getDevno());
+ RedisUtil.set("ncdev_" + tNcDeviceTemp.getDevphyid() + "_" + tNcDeviceTemp.getDevno(),String.valueOf(tNcDeviceTemp.getDeviceid()));
+ }
+ int maxId = ncService.getMaxId();
+ TNcDevice devAdd = new TNcDevice();
+ devAdd.setDeviceid(maxId+1);
+ devAdd.setDevname(tNcDeviceTemp.getDevname());
+ devAdd.setDevphyid(tNcDeviceTemp.getDevphyid().toUpperCase());
+ devAdd.setDevtype(tNcDeviceTemp.getDevtype());
+ devAdd.setFdevid(tNcDeviceTemp.getFdevid());
+ if (tNcDeviceTemp.getDevtype().equals("C")){
+ devAdd.setDevno(0);//控制器读头为0
+ }else {
+ devAdd.setDevno(tNcDeviceTemp.getDevno());
+ }
+ devAdd.setIp(tNcDeviceTemp.getIp());
+ devAdd.setOperflag("A");
+ devAdd.setSyncflag("S");
+ String now = DateUtil.getNow();
+ devAdd.setSynctime(now);
+ devAdd.setUpdtime(now);
+ devAdd.setUsetype("MJ");//设备使用类型全为门禁"MJ"
+ devAdd.setRegionid(tNcDeviceTemp.getRegionid());
+ devAdd.setBuildingid(tNcDeviceTemp.getBuildingid());
+ TBuilding buildingById = systemService.getBuildingById(tNcDeviceTemp.getBuildingid());
+ devAdd.setBuildingname(buildingById.getBuildingname());
+ if(tNcDeviceTemp.getDevtype().equals("R")){
+ TNcDevice fdev = ncService.findDevById(tNcDeviceTemp.getFdevid());
+ RedisUtil.set("ncdev_" + fdev.getDevphyid() + "_" + tNcDeviceTemp.getDevno(),String.valueOf(devAdd.getDeviceid()));
+ }
+ ncService.saveDevice(devAdd);
+ successCnt++;
+ }
+ map.put("resultStr","共导入"+totCnt+"条数据,"+successCnt+"条数据成功,"+errCnt+"条数据失败!");
+ map.put("impDev_succ", "");
+ }catch (Exception e){
+ map.put("impDev_succ","导入失败");
+ logger.error("设备名单导入失败--"+e.getMessage());
+ flag = -2;
+ map.put("flag", flag);
+ return map;
+ }
+ map.put("flag", flag);
+ return map;
+ }
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/ncmgr/dao/NcDeviceDao.java b/src/main/java/com/supwisdom/dlpay/ncmgr/dao/NcDeviceDao.java
index 2b3d7f1..c280e6e 100644
--- a/src/main/java/com/supwisdom/dlpay/ncmgr/dao/NcDeviceDao.java
+++ b/src/main/java/com/supwisdom/dlpay/ncmgr/dao/NcDeviceDao.java
@@ -59,4 +59,6 @@
public List<TDoordevInfo> getOperatorDevList(String devname,String regionid,String buildingid,String operRegionid);
public List<TDoordevInfo> getBuildingOperDevList(String devname,String regionid,String buildingid,String operid);
+
+ public void updateBuildingnameByBuildingid(String buildingid,String buildingname);
}
diff --git a/src/main/java/com/supwisdom/dlpay/ncmgr/dao/impl/NcDeviceDaoImpl.java b/src/main/java/com/supwisdom/dlpay/ncmgr/dao/impl/NcDeviceDaoImpl.java
index 69195bc..bdbc13c 100644
--- a/src/main/java/com/supwisdom/dlpay/ncmgr/dao/impl/NcDeviceDaoImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/ncmgr/dao/impl/NcDeviceDaoImpl.java
@@ -684,4 +684,14 @@
List<TDoordevInfo> list = query.getResultList();
return list;
}
+
+ @Transactional
+ @Override
+ public void updateBuildingnameByBuildingid(String buildingid, String buildingname) {
+ String sql = "update t_nc_device set buildingname=:buildingname where buildingid = :buildingid";
+ Query query = entityManager.createNativeQuery(sql);
+ query.setParameter("buildingid", buildingid);
+ query.setParameter("buildingname" ,buildingname );
+ query.executeUpdate();
+ }
}
diff --git a/src/main/java/com/supwisdom/dlpay/ncmgr/domain/TNcDevice.java b/src/main/java/com/supwisdom/dlpay/ncmgr/domain/TNcDevice.java
index e0bd051..67bf9a9 100644
--- a/src/main/java/com/supwisdom/dlpay/ncmgr/domain/TNcDevice.java
+++ b/src/main/java/com/supwisdom/dlpay/ncmgr/domain/TNcDevice.java
@@ -33,11 +33,10 @@
private Integer devno;
@Excel(name = "设备使用类型")
private String usetype;
- @Excel(name="设备所在楼栋编号")
+ @Excel(name="楼栋编号")
private String buildingid;
- @Excel(name = "设备所在楼栋名称")
private String buildingname;
- @Excel(name = "设备所在区域编号")
+ @Excel(name = "区域编号")
private String regionid;
// Constructors
diff --git a/src/main/java/com/supwisdom/dlpay/ncmgr/service/NcService.java b/src/main/java/com/supwisdom/dlpay/ncmgr/service/NcService.java
index 41b5fa3..ecfce32 100644
--- a/src/main/java/com/supwisdom/dlpay/ncmgr/service/NcService.java
+++ b/src/main/java/com/supwisdom/dlpay/ncmgr/service/NcService.java
@@ -87,6 +87,10 @@
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class})
public void delDevById(int devid);
+ //根据楼栋id更新设备的所属楼栋名称
+ @Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class})
+ public void updateBuildingnameByBuildingid(String buildingid,String buildingname);
+
//根据设备编号查询是否绑定时间周
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class})
public boolean getDevWeekByDevid(int devid);
diff --git a/src/main/java/com/supwisdom/dlpay/ncmgr/service/impl/NcServiceImpl.java b/src/main/java/com/supwisdom/dlpay/ncmgr/service/impl/NcServiceImpl.java
index a949f67..b038b9b 100644
--- a/src/main/java/com/supwisdom/dlpay/ncmgr/service/impl/NcServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/ncmgr/service/impl/NcServiceImpl.java
@@ -126,6 +126,11 @@
}
@Override
+ public void updateBuildingnameByBuildingid(String buildingid, String buildingname) {
+ ncDeviceDao.updateBuildingnameByBuildingid(buildingid, buildingname);
+ }
+
+ @Override
public boolean getDevWeekByDevid(int devid) {
return ncDevWeekDao.getDevWeekByDevid(devid);
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java b/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java
index 8116b13..375ec39 100644
--- a/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java
+++ b/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java
@@ -586,6 +586,10 @@
building.setFlag("A");
systemService.updateBuilding(building);
+
+ //修改楼栋信息后相应更新设备的栋楼信息
+ ncService.updateBuildingnameByBuildingid(postData.getBuildingid(), postData.getBuildingname());
+
map.put("errStr", "");
}catch (Exception e){
e.printStackTrace();
diff --git a/src/main/resources/templates/ncmgr/nc_dev.html b/src/main/resources/templates/ncmgr/nc_dev.html
index c09c728..e701a07 100644
--- a/src/main/resources/templates/ncmgr/nc_dev.html
+++ b/src/main/resources/templates/ncmgr/nc_dev.html
@@ -278,7 +278,7 @@
</el-form-item>
<el-form-item label="读头号:" prop="devno">
<el-col :span="18">
- <el-input v-model.number="devUpform.devno" :disabled="devnoDis"
+ <el-input v-model="devUpform.devno" :disabled="devnoDis"
placeholder="读头需输入读头号" style="width: 187px;" maxlength="2">
</el-input>
diff --git a/src/main/resources/templates/ncmgr/nc_impDev.html b/src/main/resources/templates/ncmgr/nc_impDev.html
new file mode 100644
index 0000000..cec1788
--- /dev/null
+++ b/src/main/resources/templates/ncmgr/nc_impDev.html
@@ -0,0 +1,184 @@
+<div class="layui-card">
+ <div class="layui-card-header">
+ <h2 class="header-title">设备管理</h2>
+ <span class="layui-breadcrumb pull-right">
+ <a href="#">设备管理</a>
+ <a><cite>设备导入</cite></a>
+ </span>
+ </div>
+ <div class="layui-card-body" id="impDev">
+ <div id="impDev_impExcel" v-loading.lock="loading"
+ element-loading-text="拼命导入ing不要取消~~~"
+ element-loading-spinner="el-icon-loading"
+ element-loading-background="rgba(0, 0, 0, 0.8)">
+ <el-alert
+ title="设备导入:"
+ type="info"
+ :closable="false">
+ </el-alert>
+ <el-form :inline="true" ref="impDevForm" label-width="130px"
+ data-parsley-validate class="form-horizontal form-label-left el-form-item el-form-item--mini">
+ <el-row>
+ <el-col :span="12" style="margin-top: 15px">
+ <el-form-item label="选择设备类型">
+ <el-select v-model="devTypeId" placeholder="请选择要导入的设备类型">
+ <el-option
+ v-for="dt in devType"
+ :key="dt.value"
+ :label="dt.label"
+ :value="dt.value"
+ >
+ </el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <br>
+ <el-row>
+ <el-col :span="12">
+ <el-form-item label="选择导入文件" style="height: 56px">
+ <form th:attr="action=@{/ncmgr/saveNcDevByExcel}" method="post" style="float:left;" id="impDev_uploadExcelId" name="formUpload" enctype="multipart/form-data" target="_top">
+
+ <el-button size="small" type="primary" @click="impDev_openExcel">打开Excel<i class="el-icon-upload el-icon--right"></i></el-button>
+
+ <label >文件路径: {{ textfield }}</label>
+ <el-input v-model="devTypeId" type="hidden" name="devTypeId"></el-input>
+ <el-input v-model="textfield" type="hidden" name="textfield" ></el-input>
+
+ <input type="file" name="file" style="display: none" id="impDev_filePath" onchange="impDev_vue.textfield=this.value" />
+ </form>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row>
+ <el-col :span="12">
+ <el-form-item label="开始导入">
+ <el-button style="margin-top: 3px;" size="small" type="el-button el-button--success" @click="impDev_inExcel">导入设备</el-button>
+ </el-form-item>
+ </el-col>
+
+ </el-row>
+
+ </el-form>
+
+ <el-alert
+ title="导入说明:"
+ type="warning"
+ :closable="false">
+ </el-alert>
+ <label style="margin-top: 5px">请先导入控制器再导入读头,导入excel格式为xls <el-button size="small" type="success" plain @click="impDev_downTemplate">模板下载</el-button></label><br>
+ <label>为提高效率,推荐一次性导入200条以内 </label><br>
+ <el-tag type="danger">导入控制器类型说明如下:</el-tag><br>
+ <label >1、终端物理编号、设备类型、设备名称为必填项,上级设备编号和读头号不可填写</label><br>
+ <label >2、终端物理编号和设备名称不可重复</label><br>
+ <label >3、设备类型填写"C"</label><br>
+ <label >4、终端物理编号必须为12位,不够前面补0</label><br>
+ <el-tag type="danger">导入读头类型说明如下:</el-tag><br>
+ <label >1、终端物理编号、设备类型、设备名称、上级设备编号、读头号都为必填项</label><br>
+ <label >2、终端物理编号和设备名称不可重复</label><br>
+ <label >3、设备类型填写"R"</label><br>
+ <label >4、上级设备编号请根据已导入的控制器信息到设备管理页面编号所在列查询</label><br>
+ <label >5、终端物理编号为所填上级设备终端物理编号加上0加上读头号,如:XXXXXXXXXXXX03</label><br>
+ <label >6、同一个控制器下读头号不可重复</label>
+ </div>
+
+
+ </div>
+</div>
+
+<script>
+ var impDev_vue = new Vue({
+ el:"#impDev",
+ data: {
+ devType:[{
+ value:'C',
+ label:'控制器'
+ },{
+ value:'R',
+ label:'读头'
+ }],
+ devTypeId:'',
+ textfield:'',
+ per_sheetname:'sheet1',
+ exceltable:[],
+ loading:false,
+ impDevForm:{
+
+ }
+ },
+ methods: {
+ impDev_downTemplate:function(val) {
+ console.log("下载模板");
+ var url ="[[@{/ncmgr/downNcDevExcelTemplate}]]";
+ window.location.href=url;
+ },
+ impDev_openExcel:function () {
+ $("#impDev_filePath").click();
+ this.textfield=$("#impDev_filePath").val();
+ },
+ impDev_inExcel:function () {
+ if (this.devTypeId==""){
+ layer.msg('请选择要导入的设备类型', {icon: 2, time: 1000});
+ return;
+ }
+ var path=JSON.parse(JSON.stringify(this.textfield));
+ var file=path.substring(path.lastIndexOf(".") + 1);
+ impDev_uploadExcel(path,file);
+ this.textfield='';
+ this.devTypeId='';
+ },
+
+ },
+ created: function () {
+
+ }
+
+ })
+
+ function impDev_uploadExcel(path,file) {
+ if (path.length == 0) {
+ layer.msg('请选择要上传的文件!', {icon: 2, time: 1000});
+ return;
+ }
+ if (path.length > 0){
+ fileIndex = 0;
+ fileName = path;
+ if ("xls"!=file){
+ layer.msg('请选择要上传的文件,格式只能为.xls的表格文件!',{icon: 2, time: 2000});
+ }else {
+ $("#fileNameId").text(path);
+ importIndex = 0;
+ var sheetName = JSON.parse(JSON.stringify(impDev_vue.per_sheetname));
+ if (sheetName == ""){
+ layer.msg('请写出表单的名字!', {icon: 2, time: 1000});
+ sheetIndex = 0;
+ return;
+ } else {
+ var token=$("meta[name='_csrf_token']").attr("value");
+ impDev_vue.loading = true;
+ var options = {
+ success: "",
+ type: 'post',
+ dataType: 'json',
+ headers: {
+ 'Accept': 'application/json',
+ 'X-CSRF-TOKEN': token,
+ },
+ processData:false,
+ contentType: false,
+ success:function (info) {
+ impDev_vue.loading = false;
+ if (info.flag == 0){
+ layer.alert(info.resultStr, {icon: 6});
+ } else {
+ layer.alert(info.impDev_succ, {icon: 5});
+ }
+ }
+ };
+ $('#impDev_uploadExcelId').ajaxSubmit(options);
+ }
+ }
+ }
+ }
+
+</script>
\ No newline at end of file