add:新增设备导入功能
This commit is contained in:
@@ -7,12 +7,16 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.RedissonUtils;
|
||||
import org.nl.wms.device_manage.lubricate.service.DevicelubricateplanmstService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -86,4 +90,14 @@ public class DevicelubricateplanmstController {
|
||||
devicelubricateplanmstService.copyAdd(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入bom数据
|
||||
*/
|
||||
|
||||
@PostMapping("/excelImport")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
RedissonUtils.lock(() -> devicelubricateplanmstService.excelImport(file, request), "导入润滑计划", null);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.device_manage.lubricate.service.dto.DevicelubricateplanmstDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -108,4 +110,11 @@ public interface DevicelubricateplanmstService {
|
||||
* @param whereJson /
|
||||
*/
|
||||
void copyAdd(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 导入
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,13 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
@@ -25,11 +28,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
@@ -393,4 +397,102 @@ public class DevicelubricateplanmstServiceImpl implements Devicelubricateplanmst
|
||||
dtlTab.insert(jsonDtl);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@Transactional
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_DeviceLubricatePlanMst");
|
||||
WQLObject dtlTab = WQLObject.getWQLObject("EM_BI_DeviceLubricatePlanDtl");
|
||||
WQLObject fileTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 档案表
|
||||
|
||||
JSONArray allDevices = fileTab.query().getResultJSONArray(0);
|
||||
Map<String, List<String>> devicerecords = new HashMap<>();
|
||||
for (Object o : allDevices) {
|
||||
JSONObject item = (JSONObject) o;
|
||||
List<String> list = devicerecords.get(item.getString("material_type_id"));
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
List<String> childs = new ArrayList<>();
|
||||
childs.add(item.getString("devicerecord_id")+"@"+item.getString("device_model"));
|
||||
devicerecords.put(item.getString("material_type_id"),childs);
|
||||
}else {
|
||||
list.add(item.getString("devicerecord_id")+"@"+item.getString("device_model"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
|
||||
ExcelReader excelReader = ExcelUtil.getReader(file.getInputStream(), 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
||||
Map<Integer, Object> IndexValue = new HashMap<>();
|
||||
for (int i = 0; i < read.get(0).size(); i++) {
|
||||
IndexValue.put(i,read.get(0));
|
||||
}
|
||||
String now = DateUtil.now();
|
||||
String today = DateUtil.today();
|
||||
|
||||
List<JSONObject> ids = new ArrayList<>();
|
||||
for (int i = 1; i < read.size(); i++) {
|
||||
List<Object> objects = read.get(i);
|
||||
JSONObject item = new JSONObject();
|
||||
for (int i1 = 0; i1 < objects.size(); i1++) {
|
||||
item.put(String.valueOf(i1), objects.get(i1));
|
||||
}
|
||||
ids.add(item);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)){
|
||||
return;
|
||||
}
|
||||
//根据保养名称分类
|
||||
Map<String, List<JSONObject>> collect = ids.stream().collect(Collectors.groupingBy(a -> a.getString("2")));
|
||||
JSONArray dbs = new JSONArray();
|
||||
JSONArray dtls = new JSONArray();
|
||||
String maint_code = "RHJH0000000";
|
||||
int i = 1;
|
||||
for (List<JSONObject> devicePlan : collect.values()) {
|
||||
String maint_plan_name = devicePlan.get(0).getString("2");
|
||||
String maintenancecycle = devicePlan.get(0).getString("4");
|
||||
String remark = devicePlan.get(0).getString("9");
|
||||
String is_active = devicePlan.get(0).getString("12");
|
||||
String plan_start_date = StringUtils.isEmpty(devicePlan.get(0).getString("10"))?today:devicePlan.get(0).getString("10");
|
||||
Integer detail_count = devicePlan.size();
|
||||
List<String> devicerecord = devicerecords.get(devicePlan.get(0).getString("3"));
|
||||
for (String devicerecord_id : devicerecord) {
|
||||
String[] split = devicerecord_id.split("@");
|
||||
JSONObject db = new JSONObject();
|
||||
db.put("devicerecord_id",split[0]);
|
||||
db.put("maint_plan_name",maint_plan_name+split[1]);
|
||||
db.put("maint_plan_code",maint_code+i);
|
||||
db.put("maint_plan_id",i);
|
||||
db.put("maintenancecycle",maintenancecycle);
|
||||
db.put("plan_start_date",plan_start_date);
|
||||
db.put("detail_count",detail_count);
|
||||
db.put("is_delete","0");
|
||||
db.put("is_active",is_active);
|
||||
db.put("remark",remark);
|
||||
db.put("create_id",SecurityUtils.getCurrentUserId());
|
||||
db.put("create_name",SecurityUtils.getCurrentUsername());
|
||||
db.put("create_time",now);
|
||||
dbs.add(db);
|
||||
i++;
|
||||
for (JSONObject item : devicePlan) {
|
||||
JSONObject dtl = new JSONObject();
|
||||
dtl.put("maint_plan_dtl_id", org.nl.common.utils.IdUtil.getLongId());
|
||||
dtl.put("maint_plan_id", db.getString("maint_plan_id"));
|
||||
dtl.put("maint_item_id", item.getString("5"));
|
||||
dtl.put("dtl_remark", item.getString("8"));
|
||||
dtls.add(dtl);
|
||||
}
|
||||
}
|
||||
}
|
||||
mstTab.delete(" maint_plan_code like 'RHJH00000%'");
|
||||
dtlTab.delete("length(maint_plan_id)<10");
|
||||
for (Object db : dbs) {
|
||||
mstTab.insert((JSONObject)db);
|
||||
}
|
||||
for (Object dtl : dtls) {
|
||||
dtlTab.insert((JSONObject)dtl);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.RedissonUtils;
|
||||
import org.nl.wms.device_manage.repair.service.DevicerepairmstService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -193,5 +197,4 @@ public class DevicerepairmstController {
|
||||
devicerepairmstService.createExcel(whereJson,response);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.RedissonUtils;
|
||||
import org.nl.wms.device_manage.repair.service.DevicerepairplanmstService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -78,4 +82,13 @@ public class DevicerepairplanmstController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入bom数据
|
||||
*/
|
||||
@PostMapping("/excelImport")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
RedissonUtils.lock(() -> devicerepairplanmstService.excelImport(file, request), "导入维修计划", null);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.device_manage.repair.service.dto.DevicerepairmstDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.device_manage.repair.service.dto.DevicerepairplanmstDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -88,4 +90,11 @@ public interface DevicerepairplanmstService {
|
||||
* @param whereJson /
|
||||
*/
|
||||
void copyAdd(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 导入设备档案
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -19,6 +21,7 @@ import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.device_manage.ios.service.iostorInv.EmBiIostorinvOutService;
|
||||
import org.nl.wms.device_manage.repair.service.DevicerepairmstService;
|
||||
@@ -27,15 +30,20 @@ import org.nl.wms.masterdata_manage.storage.service.storage.IStIvtBsrealstorattr
|
||||
import org.nl.wms.masterdata_manage.storage.service.storage.dao.StIvtBsrealstorattr;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
import org.nl.wms.system_manage.service.dept.ISysDeptService;
|
||||
import org.nl.wms.system_manage.service.tableData.ColumnInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
|
||||
@@ -7,6 +7,8 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -16,18 +18,20 @@ import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.device_manage.repair.service.DevicerepairplanmstService;
|
||||
import org.nl.wms.device_manage.repair.service.dto.DevicerepairplanmstDto;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
import org.nl.wms.system_manage.service.tableData.ColumnInfoService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
@@ -328,4 +332,8 @@ public class DevicerepairplanmstServiceImpl implements DevicerepairplanmstServic
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.RedissonUtils;
|
||||
import org.nl.wms.device_manage.sportcheck.service.DevicesportcheckplanmstService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -86,4 +90,12 @@ public class DevicesportcheckplanmstController {
|
||||
devicesportcheckplanmstService.copyAdd(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
/**
|
||||
* 导入bom数据
|
||||
*/
|
||||
@PostMapping("/excelImport")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
RedissonUtils.lock(() -> devicesportcheckplanmstService.excelImport(file, request), "导入点检计划", null);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.device_manage.sportcheck.service.dto.DevicesportcheckplanmstDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -108,4 +110,11 @@ public interface DevicesportcheckplanmstService {
|
||||
* @param whereJson /
|
||||
*/
|
||||
void copyAdd(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 导入
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,13 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
@@ -25,11 +28,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
@@ -393,4 +397,103 @@ public class DevicesportcheckplanmstServiceImpl implements Devicesportcheckplanm
|
||||
dtlTab.insert(jsonDtl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_DeviceSportCheckPlanMst");
|
||||
WQLObject dtlTab = WQLObject.getWQLObject("EM_BI_DeviceSportCheckPlanDtl");
|
||||
WQLObject fileTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 档案表
|
||||
|
||||
JSONArray allDevices = fileTab.query().getResultJSONArray(0);
|
||||
Map<String, List<String>> devicerecords = new HashMap<>();
|
||||
for (Object o : allDevices) {
|
||||
JSONObject item = (JSONObject) o;
|
||||
List<String> list = devicerecords.get(item.getString("material_type_id"));
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
List<String> childs = new ArrayList<>();
|
||||
childs.add(item.getString("devicerecord_id")+"@"+item.getString("device_model"));
|
||||
devicerecords.put(item.getString("material_type_id"),childs);
|
||||
}else {
|
||||
list.add(item.getString("devicerecord_id")+"@"+item.getString("device_model"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
|
||||
ExcelReader excelReader = ExcelUtil.getReader(file.getInputStream(), 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
||||
Map<Integer, Object> IndexValue = new HashMap<>();
|
||||
for (int i = 0; i < read.get(0).size(); i++) {
|
||||
IndexValue.put(i,read.get(0));
|
||||
}
|
||||
String now = DateUtil.now();
|
||||
String today = DateUtil.today();
|
||||
|
||||
List<JSONObject> ids = new ArrayList<>();
|
||||
for (int i = 1; i < read.size(); i++) {
|
||||
List<Object> objects = read.get(i);
|
||||
JSONObject item = new JSONObject();
|
||||
for (int i1 = 0; i1 < objects.size(); i1++) {
|
||||
item.put(String.valueOf(i1), objects.get(i1));
|
||||
}
|
||||
ids.add(item);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)){
|
||||
return;
|
||||
}
|
||||
//根据保养名称分类
|
||||
Map<String, List<JSONObject>> collect = ids.stream().collect(Collectors.groupingBy(a -> a.getString("2")));
|
||||
JSONArray dbs = new JSONArray();
|
||||
JSONArray dtls = new JSONArray();
|
||||
String maint_code = "DJJH0000000";
|
||||
int i = 1;
|
||||
for (List<JSONObject> devicePlan : collect.values()) {
|
||||
String maint_plan_name = devicePlan.get(0).getString("2");
|
||||
String maintenancecycle = devicePlan.get(0).getString("4");
|
||||
String remark = devicePlan.get(0).getString("9");
|
||||
String is_active = devicePlan.get(0).getString("12");
|
||||
String plan_start_date = StringUtils.isEmpty(devicePlan.get(0).getString("10"))?today:devicePlan.get(0).getString("10");
|
||||
Integer detail_count = devicePlan.size();
|
||||
List<String> devicerecord = devicerecords.get(devicePlan.get(0).getString("3"));
|
||||
for (String devicerecord_id : devicerecord) {
|
||||
String[] split = devicerecord_id.split("@");
|
||||
JSONObject db = new JSONObject();
|
||||
db.put("devicerecord_id",split[0]);
|
||||
db.put("maint_plan_name",maint_plan_name+split[1]);
|
||||
db.put("maint_plan_code",maint_code+i);
|
||||
db.put("maint_plan_id",i);
|
||||
db.put("maintenancecycle",maintenancecycle);
|
||||
db.put("plan_start_date",plan_start_date);
|
||||
db.put("detail_count",detail_count);
|
||||
db.put("is_delete","0");
|
||||
db.put("is_active",is_active);
|
||||
db.put("remark",remark);
|
||||
db.put("create_id",SecurityUtils.getCurrentUserId());
|
||||
db.put("create_name",SecurityUtils.getCurrentUsername());
|
||||
db.put("create_time",now);
|
||||
dbs.add(db);
|
||||
i++;
|
||||
for (JSONObject item : devicePlan) {
|
||||
JSONObject dtl = new JSONObject();
|
||||
dtl.put("maint_plan_dtl_id", org.nl.common.utils.IdUtil.getLongId());
|
||||
dtl.put("maint_plan_id", db.getString("maint_plan_id"));
|
||||
dtl.put("maint_item_id", item.getString("5"));
|
||||
dtl.put("dtl_remark", item.getString("8"));
|
||||
dtls.add(dtl);
|
||||
}
|
||||
}
|
||||
}
|
||||
mstTab.delete(" maint_plan_code like 'DJJH00000%'");
|
||||
dtlTab.delete("length(maint_plan_id)<10");
|
||||
for (Object db : dbs) {
|
||||
mstTab.insert((JSONObject)db);
|
||||
}
|
||||
for (Object dtl : dtls) {
|
||||
dtlTab.insert((JSONObject)dtl);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.RedissonUtils;
|
||||
import org.nl.wms.device_manage.upkeep.service.DevicemaintenanceplanmstService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -86,4 +90,13 @@ public class DevicemaintenanceplanmstController {
|
||||
devicemaintenanceplanmstService.copyAdd(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入bom数据
|
||||
*/
|
||||
@PostMapping("/excelImport")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
RedissonUtils.lock(() -> devicemaintenanceplanmstService.excelImport(file, request), "导入保养计划", null);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.device_manage.upkeep.service.dto.DevicemaintenanceplanmstDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -108,4 +110,11 @@ public interface DevicemaintenanceplanmstService {
|
||||
* @param whereJson /
|
||||
*/
|
||||
void copyAdd(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 导入设备档案
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -7,29 +7,36 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.device_manage.upkeep.service.DevicemaintenanceplanmstService;
|
||||
import org.nl.wms.device_manage.upkeep.service.dto.DevicemaintenanceplanmstDto;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
import org.nl.wms.system_manage.service.dept.ISysDeptService;
|
||||
import org.nl.wms.system_manage.service.tableData.ColumnInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
@@ -379,4 +386,105 @@ public class DevicemaintenanceplanmstServiceImpl implements Devicemaintenancepla
|
||||
dtlTab.insert(jsonDtl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_DeviceMaintenancePlanMst");
|
||||
WQLObject dtlTab = WQLObject.getWQLObject("EM_BI_DeviceMaintenancePlanDtl");
|
||||
WQLObject fileTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 档案表
|
||||
|
||||
JSONArray allDevices = fileTab.query().getResultJSONArray(0);
|
||||
Map<String, List<String>> devicerecords = new HashMap<>();
|
||||
for (Object o : allDevices) {
|
||||
JSONObject item = (JSONObject) o;
|
||||
List<String> list = devicerecords.get(item.getString("material_type_id"));
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
List<String> childs = new ArrayList<>();
|
||||
childs.add(item.getString("devicerecord_id")+"@"+item.getString("device_model"));
|
||||
devicerecords.put(item.getString("material_type_id"),childs);
|
||||
}else {
|
||||
list.add(item.getString("devicerecord_id")+"@"+item.getString("device_model"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
|
||||
ExcelReader excelReader = ExcelUtil.getReader(file.getInputStream(), 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
||||
Map<Integer, Object> IndexValue = new HashMap<>();
|
||||
for (int i = 0; i < read.get(0).size(); i++) {
|
||||
IndexValue.put(i,read.get(0));
|
||||
}
|
||||
String now = DateUtil.now();
|
||||
String today = DateUtil.today();
|
||||
|
||||
List<JSONObject> ids = new ArrayList<>();
|
||||
for (int i = 1; i < read.size(); i++) {
|
||||
List<Object> objects = read.get(i);
|
||||
JSONObject item = new JSONObject();
|
||||
for (int i1 = 0; i1 < objects.size(); i1++) {
|
||||
item.put(String.valueOf(i1), objects.get(i1));
|
||||
}
|
||||
ids.add(item);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)){
|
||||
return;
|
||||
}
|
||||
//根据保养名称分类
|
||||
Map<String, List<JSONObject>> collect = ids.stream().collect(Collectors.groupingBy(a -> a.getString("2")));
|
||||
JSONArray dbs = new JSONArray();
|
||||
JSONArray dtls = new JSONArray();
|
||||
String maint_code = "BYJH0000000";
|
||||
int i = 1;
|
||||
for (List<JSONObject> devicePlan : collect.values()) {
|
||||
String maint_plan_name = devicePlan.get(0).getString("2");
|
||||
String maintenancecycle = devicePlan.get(0).getString("4");
|
||||
String remark = devicePlan.get(0).getString("9");
|
||||
String is_active = devicePlan.get(0).getString("12");
|
||||
String plan_start_date = StringUtils.isEmpty(devicePlan.get(0).getString("10"))?today:devicePlan.get(0).getString("10");
|
||||
Integer detail_count = devicePlan.size();
|
||||
List<String> devicerecord = devicerecords.get(devicePlan.get(0).getString("3"));
|
||||
for (String devicerecord_id : devicerecord) {
|
||||
String[] split = devicerecord_id.split("@");
|
||||
JSONObject db = new JSONObject();
|
||||
db.put("devicerecord_id",split[0]);
|
||||
db.put("maint_plan_name",maint_plan_name+split[1]);
|
||||
db.put("maint_plan_code",maint_code+i);
|
||||
db.put("maint_plan_id",i);
|
||||
db.put("maintenancecycle",maintenancecycle);
|
||||
db.put("plan_start_date",plan_start_date);
|
||||
db.put("detail_count",detail_count);
|
||||
db.put("is_delete","0");
|
||||
db.put("is_active",is_active);
|
||||
db.put("remark",remark);
|
||||
db.put("create_id",SecurityUtils.getCurrentUserId());
|
||||
db.put("create_name",SecurityUtils.getCurrentUsername());
|
||||
db.put("create_time",now);
|
||||
dbs.add(db);
|
||||
i++;
|
||||
for (JSONObject item : devicePlan) {
|
||||
JSONObject dtl = new JSONObject();
|
||||
dtl.put("maint_plan_dtl_id", org.nl.common.utils.IdUtil.getLongId());
|
||||
dtl.put("maint_plan_id", db.getString("maint_plan_id"));
|
||||
dtl.put("maint_item_id", item.getString("5"));
|
||||
dtl.put("dtl_remark", item.getString("8"));
|
||||
dtls.add(dtl);
|
||||
}
|
||||
}
|
||||
}
|
||||
mstTab.delete(" maint_plan_code like 'BYJH00000%'");
|
||||
dtlTab.delete("length(maint_plan_id)<10");
|
||||
for (Object db : dbs) {
|
||||
mstTab.insert((JSONObject)db);
|
||||
}
|
||||
for (Object dtl : dtls) {
|
||||
dtlTab.insert((JSONObject)dtl);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,13 +7,17 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.RedissonUtils;
|
||||
import org.nl.wms.masterdata_manage.em.service.DeviceLubricateitemsService;
|
||||
import org.nl.wms.masterdata_manage.em.service.DeviceSportCheckitemsService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -55,4 +59,15 @@ public class DeviceLubricateitemsController {
|
||||
deviceLubricateitemsService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入bom数据
|
||||
*/
|
||||
@Log("导入润滑项")
|
||||
@PostMapping("/excelImport")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
RedissonUtils.lock(() -> deviceLubricateitemsService.excelImport(file, request), "导入设备档案", null);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.RedissonUtils;
|
||||
import org.nl.wms.masterdata_manage.em.service.DeviceSportCheckitemsService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -54,4 +58,13 @@ public class DeviceSportCheckitemsController {
|
||||
deviceSportCheckitemsService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* 导入bom数据
|
||||
*/
|
||||
@Log("导入点检项")
|
||||
@PostMapping("/excelImport")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
RedissonUtils.lock(() -> deviceSportCheckitemsService.excelImport(file, request), "导入设备档案", null);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.utils.RedissonUtils;
|
||||
import org.nl.wms.masterdata_manage.em.service.DevicemaintenanceitemsService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -54,4 +58,16 @@ public class DevicemaintenanceitemsController {
|
||||
devicemaintenanceitemsService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入bom数据
|
||||
*/
|
||||
@Log("导入保养项")
|
||||
@PostMapping("/excelImport")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
RedissonUtils.lock(() -> devicemaintenanceitemsService.excelImport(file, request), "导入设备档案", null);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ package org.nl.wms.masterdata_manage.em.service;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.masterdata_manage.em.service.dto.DevicemaintenanceitemsDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -69,4 +71,11 @@ public interface DeviceLubricateitemsService {
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导入设备档案
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ package org.nl.wms.masterdata_manage.em.service;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.masterdata_manage.em.service.dto.DevicemaintenanceitemsDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -69,4 +71,11 @@ public interface DeviceSportCheckitemsService {
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导入设备档案
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ package org.nl.wms.masterdata_manage.em.service;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.masterdata_manage.em.service.dto.DevicemaintenanceitemsDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -69,4 +71,11 @@ public interface DevicemaintenanceitemsService {
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导入设备档案
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -7,25 +7,34 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.masterdata_manage.em.service.DeviceLubricateitemsService;
|
||||
import org.nl.wms.masterdata_manage.em.service.dto.DevicemaintenanceitemsDto;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
import org.nl.wms.system_manage.service.tableData.ColumnInfoService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
@@ -165,4 +174,52 @@ public class DeviceLubricateitemsServiceImpl implements DeviceLubricateitemsServ
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
try {
|
||||
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
|
||||
ExcelReader excelReader = ExcelUtil.getReader(file.getInputStream(), 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
ColumnInfoService columnInfoService = SpringContextHolder.getBean(ColumnInfoService.class);
|
||||
Map<String, String> tableColumn = columnInfoService.TableColumn2("em_bi_devicelubricateitems");
|
||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
||||
Map<Integer, String> IndexValue = new HashMap<>();
|
||||
for (int i = 0; i < read.get(0).size(); i++) {
|
||||
String label = String.valueOf(read.get(0).get(i));String value = tableColumn.get(label);
|
||||
if (value!=null){ IndexValue.put(i,value); }
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
JSONArray array = new JSONArray();
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (int i = 1; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
JSONObject item = new JSONObject();
|
||||
for (int i1 = 0; i1 < list.size(); i1++) {
|
||||
String s = IndexValue.get(i1);
|
||||
if (s!=null){
|
||||
item.put(s,list.get(i1));
|
||||
|
||||
}
|
||||
}
|
||||
item.put("create_id",currentUserId);
|
||||
item.put("create_name",currentUsername);
|
||||
item.put("create_time",now);
|
||||
array.add(item);
|
||||
ids.add(item.getString("maint_item_id"));
|
||||
}
|
||||
System.out.println(array.size());
|
||||
WQLObject mstTab = WQLObject.getWQLObject("em_bi_devicelubricateitems"); // 工艺路线主表
|
||||
mstTab.delete("maint_item_id in "+"('" + ids.stream().collect(Collectors.joining("','")) + "')");
|
||||
for (Object o : array) {
|
||||
mstTab.insert((JSONObject)o);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,25 +7,34 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.masterdata_manage.em.service.DeviceSportCheckitemsService;
|
||||
import org.nl.wms.masterdata_manage.em.service.dto.DevicemaintenanceitemsDto;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
import org.nl.wms.system_manage.service.tableData.ColumnInfoService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
@@ -165,4 +174,52 @@ public class DeviceSportCheckitemsServiceImpl implements DeviceSportCheckitemsSe
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
try {
|
||||
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
|
||||
ExcelReader excelReader = ExcelUtil.getReader(file.getInputStream(), 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
ColumnInfoService columnInfoService = SpringContextHolder.getBean(ColumnInfoService.class);
|
||||
Map<String, String> tableColumn = columnInfoService.TableColumn2("em_bi_devicesportcheckitems");
|
||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
||||
Map<Integer, String> IndexValue = new HashMap<>();
|
||||
for (int i = 0; i < read.get(0).size(); i++) {
|
||||
String label = String.valueOf(read.get(0).get(i));String value = tableColumn.get(label);
|
||||
if (value!=null){ IndexValue.put(i,value); }
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
JSONArray array = new JSONArray();
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (int i = 1; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
JSONObject item = new JSONObject();
|
||||
for (int i1 = 0; i1 < list.size(); i1++) {
|
||||
String s = IndexValue.get(i1);
|
||||
if (s!=null){
|
||||
item.put(s,list.get(i1));
|
||||
|
||||
}
|
||||
}
|
||||
item.put("create_id",currentUserId);
|
||||
item.put("create_name",currentUsername);
|
||||
item.put("create_time",now);
|
||||
array.add(item);
|
||||
ids.add(item.getString("maint_item_id"));
|
||||
}
|
||||
System.out.println(array.size());
|
||||
WQLObject mstTab = WQLObject.getWQLObject("em_bi_devicesportcheckitems"); // 工艺路线主表
|
||||
mstTab.delete("maint_item_id in "+"('" + ids.stream().collect(Collectors.joining("','")) + "')");
|
||||
for (Object o : array) {
|
||||
mstTab.insert((JSONObject)o);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,25 +7,37 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.masterdata_manage.em.service.DevicemaintenanceitemsService;
|
||||
import org.nl.wms.masterdata_manage.em.service.dto.DevicemaintenanceitemsDto;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
import org.nl.wms.system_manage.service.ql.IPdmQlOptionService;
|
||||
import org.nl.wms.system_manage.service.tableData.ColumnInfoService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
@@ -165,4 +177,56 @@ public class DevicemaintenanceitemsServiceImpl implements Devicemaintenanceitems
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
try {
|
||||
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
|
||||
ExcelReader excelReader = ExcelUtil.getReader(file.getInputStream(), 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
ColumnInfoService columnInfoService = SpringContextHolder.getBean(ColumnInfoService.class);
|
||||
Map<String, String> tableColumn = columnInfoService.TableColumn2("em_bi_devicemaintenanceitems");
|
||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
||||
Map<Integer, String> IndexValue = new HashMap<>();
|
||||
for (int i = 0; i < read.get(0).size(); i++) {
|
||||
String label = String.valueOf(read.get(0).get(i));
|
||||
String value = tableColumn.get(label);
|
||||
if (value != null) {
|
||||
IndexValue.put(i, value);
|
||||
}
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
JSONArray array = new JSONArray();
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (int i = 1; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
JSONObject item = new JSONObject();
|
||||
for (int i1 = 0; i1 < list.size(); i1++) {
|
||||
String s = IndexValue.get(i1);
|
||||
if (s != null) {
|
||||
item.put(s, list.get(i1));
|
||||
|
||||
}
|
||||
}
|
||||
item.put("create_id", currentUserId);
|
||||
item.put("create_name", currentUsername);
|
||||
item.put("create_time", now);
|
||||
array.add(item);
|
||||
ids.add(item.getString("maint_item_id"));
|
||||
}
|
||||
System.out.println(array.size());
|
||||
WQLObject mstTab = WQLObject.getWQLObject("em_bi_devicemaintenanceitems"); // 工艺路线主表
|
||||
mstTab.delete("maint_item_id in " + "('" + ids.stream().collect(Collectors.joining("','")) + "')");
|
||||
for (Object o : array) {
|
||||
mstTab.insert((JSONObject) o);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -143,6 +143,12 @@
|
||||
<if test="query.material_search != null and query.material_search != ''">
|
||||
and (mb.material_code = #{query.material_search} OR mb.material_name = #{query.material_search})
|
||||
</if>
|
||||
<if test="query.struct_search != null and query.struct_search.size>0">
|
||||
and sa.struct_code in
|
||||
<foreach collection="query.struct_search" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="query.sect_id != null and query.sect_id != ''">
|
||||
and sa.sect_id = #{query.sect_id}
|
||||
</if>
|
||||
|
||||
@@ -2,7 +2,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: prod
|
||||
active: dev3
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="导入Excel文件"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="400px"
|
||||
:show-close="true"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
class="upload-demo"
|
||||
action=""
|
||||
drag
|
||||
:on-exceed="is_one"
|
||||
:limit="1"
|
||||
:auto-upload="false"
|
||||
:multiple="false"
|
||||
:show-file-list="true"
|
||||
:on-change="uploadByJsqd"
|
||||
:file-list="fileList"
|
||||
accept=".xlsx,.xls"
|
||||
>
|
||||
<i class="el-icon-upload" />
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div slot="tip" class="el-upload__tip">只能上传Excel文件,且不超过10MB</div>
|
||||
</el-upload>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudEquipmentfile from '@/views/wms/device_manage/lubricate/devicelubricateplan/devicelubricateplanmst'
|
||||
import CRUD, { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'UploadDialog',
|
||||
mixins: [crud()],
|
||||
components: {},
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
openParam: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
fileList: [],
|
||||
file1: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue, oldValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
},
|
||||
openParam: {
|
||||
handler(newValue, oldValue) {
|
||||
this.opendtlParam = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
is_one() {
|
||||
this.crud.notify('只能上传一个excel文件!', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
},
|
||||
// 文件校验方法
|
||||
beforeAvatarUpload(file) {
|
||||
// 不能导入大小超过2Mb的文件
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 文件发生改变就会触发的事件
|
||||
uploadByJsqd(file) {
|
||||
this.file1 = file
|
||||
},
|
||||
submit() {
|
||||
if (this.beforeAvatarUpload(this.file1)) {
|
||||
this.fileList.name = this.file1.name
|
||||
this.fileList.url = ''
|
||||
var formdata = new FormData()
|
||||
formdata.append('file', this.file1.raw)
|
||||
crudEquipmentfile.excelImport(formdata).then((res) => {
|
||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.$emit('tableChanged3', '')
|
||||
this.$emit('update:dialogShow', false)
|
||||
}).catch(err => {
|
||||
// const list = err.response.data.message
|
||||
// download2('/api/produceWorkorder/download', list).then(result => {
|
||||
// downloadFile(result, '错误信息汇总', 'xlsx')
|
||||
// crud.downloadLoading = false
|
||||
// })
|
||||
})
|
||||
} else {
|
||||
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -48,4 +48,12 @@ export function copyAdd(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getDtl, changeActive, copyAdd }
|
||||
export function excelImport(data) {
|
||||
return request({
|
||||
url: 'api/crudDevicelubricateplanmst/excelImport',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getDtl, changeActive, copyAdd, excelImport }
|
||||
|
||||
@@ -96,6 +96,16 @@
|
||||
>
|
||||
复制新增
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="warning"
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="uploadShow = true"
|
||||
>
|
||||
导入
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
@@ -141,6 +151,7 @@
|
||||
</div>
|
||||
<AddDialog />
|
||||
<CopyAddDialog :dialog-show.sync="copyAddDialog" :open-param="openParam" />
|
||||
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -158,11 +169,13 @@ import crudMaterialbase from '@/api/wms/basedata/master/materialbase'
|
||||
import DateRangePicker from '@/components/DateRangePicker'
|
||||
import AddDialog from '@/views/wms/device_manage/lubricate/devicelubricateplan/AddDialog'
|
||||
import CopyAddDialog from '@/views/wms/device_manage/lubricate/devicelubricateplan/CopyAddDialog'
|
||||
import UploadDialog from '@/views/wms/device_manage/lubricate/devicelubricateplan/UploadDialog'
|
||||
|
||||
|
||||
export default {
|
||||
name: 'Devicelubricateplan',
|
||||
dicts: ['IS_OR_NOT', 'EM_DEVICE_BY_CYCLE'],
|
||||
components: { AddDialog, pagination, crudOperation, rrOperation, udOperation, Treeselect, DateRangePicker, CopyAddDialog },
|
||||
components: { UploadDialog, AddDialog, pagination, crudOperation, rrOperation, udOperation, Treeselect, DateRangePicker, CopyAddDialog },
|
||||
mixins: [presenter(), header(), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
@@ -182,6 +195,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadShow: false,
|
||||
classes: [],
|
||||
class_idStr: null,
|
||||
tabData: [],
|
||||
@@ -211,6 +225,9 @@ export default {
|
||||
hand(value) {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
tableChanged3() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
format_is_active(is_active) {
|
||||
return is_active === '1'
|
||||
},
|
||||
@@ -267,7 +284,7 @@ export default {
|
||||
},
|
||||
queryClassId() {
|
||||
const param = {
|
||||
'class_idStr': this.class_idStr
|
||||
'class_idStr': '2'
|
||||
}
|
||||
crudClassstandard.queryClassById(param).then(res => {
|
||||
this.classes = res.content.map(obj => {
|
||||
|
||||
@@ -271,9 +271,26 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
getSubTypes(id) {
|
||||
crudClassstandard.getClassSuperior2(id).then(res => {
|
||||
const date = res.content
|
||||
this.buildClass(date)
|
||||
this.classes = date
|
||||
})
|
||||
},
|
||||
buildClass(classes) {
|
||||
classes.forEach(data => {
|
||||
if (data.children) {
|
||||
this.buildClass(data.children)
|
||||
}
|
||||
if (data.hasChildren && !data.children) {
|
||||
data.children = null
|
||||
}
|
||||
})
|
||||
},
|
||||
queryClassId() {
|
||||
const param = {
|
||||
'class_idStr': this.class_idStr
|
||||
'class_idStr': '2'
|
||||
}
|
||||
crudClassstandard.queryClassById(param).then(res => {
|
||||
this.classes = res.content.map(obj => {
|
||||
|
||||
@@ -243,7 +243,7 @@ export default {
|
||||
},
|
||||
queryClassId() {
|
||||
const param = {
|
||||
'class_idStr': this.class_idStr
|
||||
'class_idStr': '2'
|
||||
}
|
||||
crudClassstandard.queryClassById(param).then(res => {
|
||||
this.classes = res.content.map(obj => {
|
||||
|
||||
@@ -204,7 +204,7 @@ export default {
|
||||
},
|
||||
queryClassId() {
|
||||
const param = {
|
||||
'class_idStr': this.class_idStr
|
||||
'class_idStr': '2'
|
||||
}
|
||||
crudClassstandard.queryClassById(param).then(res => {
|
||||
this.classes = res.content.map(obj => {
|
||||
|
||||
@@ -352,7 +352,7 @@ export default {
|
||||
},
|
||||
queryClassId() {
|
||||
const param = {
|
||||
'class_idStr': this.class_idStr
|
||||
'class_idStr': '2'
|
||||
}
|
||||
crudClassstandard.queryClassById(param).then(res => {
|
||||
this.classes = res.content.map(obj => {
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="导入Excel文件"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="400px"
|
||||
:show-close="true"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
class="upload-demo"
|
||||
action=""
|
||||
drag
|
||||
:on-exceed="is_one"
|
||||
:limit="1"
|
||||
:auto-upload="false"
|
||||
:multiple="false"
|
||||
:show-file-list="true"
|
||||
:on-change="uploadByJsqd"
|
||||
:file-list="fileList"
|
||||
accept=".xlsx,.xls"
|
||||
>
|
||||
<i class="el-icon-upload" />
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div slot="tip" class="el-upload__tip">只能上传Excel文件,且不超过10MB</div>
|
||||
</el-upload>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudEquipmentfile from '@/views/wms/device_manage/sportcheck/devicesportcheckplan/devicesportcheckplanmst'
|
||||
import CRUD, { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'UploadDialog',
|
||||
mixins: [crud()],
|
||||
components: {},
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
openParam: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
fileList: [],
|
||||
file1: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue, oldValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
},
|
||||
openParam: {
|
||||
handler(newValue, oldValue) {
|
||||
this.opendtlParam = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
is_one() {
|
||||
this.crud.notify('只能上传一个excel文件!', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
},
|
||||
// 文件校验方法
|
||||
beforeAvatarUpload(file) {
|
||||
// 不能导入大小超过2Mb的文件
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 文件发生改变就会触发的事件
|
||||
uploadByJsqd(file) {
|
||||
this.file1 = file
|
||||
},
|
||||
submit() {
|
||||
if (this.beforeAvatarUpload(this.file1)) {
|
||||
this.fileList.name = this.file1.name
|
||||
this.fileList.url = ''
|
||||
var formdata = new FormData()
|
||||
formdata.append('file', this.file1.raw)
|
||||
crudEquipmentfile.excelImport(formdata).then((res) => {
|
||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.$emit('tableChanged3', '')
|
||||
this.$emit('update:dialogShow', false)
|
||||
}).catch(err => {
|
||||
// const list = err.response.data.message
|
||||
// download2('/api/produceWorkorder/download', list).then(result => {
|
||||
// downloadFile(result, '错误信息汇总', 'xlsx')
|
||||
// crud.downloadLoading = false
|
||||
// })
|
||||
})
|
||||
} else {
|
||||
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -48,4 +48,13 @@ export function copyAdd(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getDtl, changeActive, copyAdd }
|
||||
|
||||
export function excelImport(data) {
|
||||
return request({
|
||||
url: 'api/devicesportcheckplanmst/excelImport',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getDtl, changeActive, copyAdd, excelImport }
|
||||
|
||||
@@ -96,6 +96,16 @@
|
||||
>
|
||||
复制新增
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="warning"
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="uploadShow = true"
|
||||
>
|
||||
导入
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
@@ -141,6 +151,7 @@
|
||||
</div>
|
||||
<AddDialog />
|
||||
<CopyAddDialog :dialog-show.sync="copyAddDialog" :open-param="openParam" />
|
||||
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -158,11 +169,13 @@ import crudMaterialbase from '@/api/wms/basedata/master/materialbase'
|
||||
import DateRangePicker from '@/components/DateRangePicker'
|
||||
import AddDialog from '@/views/wms/device_manage/sportcheck/devicesportcheckplan/AddDialog'
|
||||
import CopyAddDialog from '@/views/wms/device_manage/sportcheck/devicesportcheckplan/CopyAddDialog'
|
||||
import UploadDialog from '@/views/wms/device_manage/sportcheck/devicesportcheckplan/UploadDialog'
|
||||
|
||||
|
||||
export default {
|
||||
name: 'Devicesportcheckplanmst',
|
||||
dicts: ['IS_OR_NOT', 'EM_DEVICE_BY_CYCLE'],
|
||||
components: { AddDialog, pagination, crudOperation, rrOperation, udOperation, Treeselect, DateRangePicker, CopyAddDialog },
|
||||
components: {UploadDialog, AddDialog, pagination, crudOperation, rrOperation, udOperation, Treeselect, DateRangePicker, CopyAddDialog },
|
||||
mixins: [presenter(), header(), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
@@ -182,6 +195,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadShow: false,
|
||||
classes: [],
|
||||
class_idStr: null,
|
||||
tabData: [],
|
||||
@@ -236,6 +250,9 @@ export default {
|
||||
formatMainName(row, cloum) {
|
||||
return this.dict.label.EM_DEVICE_BY_CYCLE[row.maintenancecycle]
|
||||
},
|
||||
tableChanged3() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
copyAdd() {
|
||||
const _selectData = this.$refs.table.selection
|
||||
const data = {
|
||||
@@ -267,7 +284,7 @@ export default {
|
||||
},
|
||||
queryClassId() {
|
||||
const param = {
|
||||
'class_idStr': this.class_idStr
|
||||
'class_idStr': '2'
|
||||
}
|
||||
crudClassstandard.queryClassById(param).then(res => {
|
||||
this.classes = res.content.map(obj => {
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="导入Excel文件"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="400px"
|
||||
:show-close="true"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
class="upload-demo"
|
||||
action=""
|
||||
drag
|
||||
:on-exceed="is_one"
|
||||
:limit="1"
|
||||
:auto-upload="false"
|
||||
:multiple="false"
|
||||
:show-file-list="true"
|
||||
:on-change="uploadByJsqd"
|
||||
:file-list="fileList"
|
||||
accept=".xlsx,.xls"
|
||||
>
|
||||
<i class="el-icon-upload" />
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div slot="tip" class="el-upload__tip">只能上传Excel文件,且不超过10MB</div>
|
||||
</el-upload>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudEquipmentfile from '@/views/wms/device_manage/upkeep/devicemaintenanceplan/devicemaintenanceplanmst'
|
||||
import CRUD, { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'UploadDialog',
|
||||
mixins: [crud()],
|
||||
components: {},
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
openParam: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
fileList: [],
|
||||
file1: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue, oldValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
},
|
||||
openParam: {
|
||||
handler(newValue, oldValue) {
|
||||
this.opendtlParam = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
is_one() {
|
||||
this.crud.notify('只能上传一个excel文件!', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
},
|
||||
// 文件校验方法
|
||||
beforeAvatarUpload(file) {
|
||||
// 不能导入大小超过2Mb的文件
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 文件发生改变就会触发的事件
|
||||
uploadByJsqd(file) {
|
||||
this.file1 = file
|
||||
},
|
||||
submit() {
|
||||
if (this.beforeAvatarUpload(this.file1)) {
|
||||
this.fileList.name = this.file1.name
|
||||
this.fileList.url = ''
|
||||
var formdata = new FormData()
|
||||
formdata.append('file', this.file1.raw)
|
||||
crudEquipmentfile.excelImport(formdata).then((res) => {
|
||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.$emit('tableChanged3', '')
|
||||
this.$emit('update:dialogShow', false)
|
||||
}).catch(err => {
|
||||
// const list = err.response.data.message
|
||||
// download2('/api/produceWorkorder/download', list).then(result => {
|
||||
// downloadFile(result, '错误信息汇总', 'xlsx')
|
||||
// crud.downloadLoading = false
|
||||
// })
|
||||
})
|
||||
} else {
|
||||
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -48,4 +48,11 @@ export function copyAdd(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getDtl, changeActive, copyAdd }
|
||||
export function excelImport(data) {
|
||||
return request({
|
||||
url: 'api/devicemaintenanceplanmst/excelImport',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
export default { add, edit, del, getDtl, changeActive, copyAdd, excelImport }
|
||||
|
||||
@@ -96,6 +96,16 @@
|
||||
>
|
||||
复制新增
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="warning"
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="uploadShow = true"
|
||||
>
|
||||
导入
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
@@ -141,6 +151,7 @@
|
||||
</div>
|
||||
<AddDialog />
|
||||
<CopyAddDialog :dialog-show.sync="copyAddDialog" :open-param="openParam" />
|
||||
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -158,11 +169,13 @@ import crudMaterialbase from '@/api/wms/basedata/master/materialbase'
|
||||
import DateRangePicker from '@/components/DateRangePicker'
|
||||
import AddDialog from '@/views/wms/device_manage/upkeep/devicemaintenanceplan/AddDialog'
|
||||
import CopyAddDialog from '@/views/wms/device_manage/upkeep/devicemaintenanceplan/CopyAddDialog'
|
||||
import UploadDialog from '@/views/wms/device_manage/upkeep/devicemaintenanceplan/UploadDialog'
|
||||
|
||||
|
||||
export default {
|
||||
name: 'Devicemaintenanceplan',
|
||||
dicts: ['IS_OR_NOT', 'EM_DEVICE_BY_CYCLE'],
|
||||
components: { AddDialog, pagination, crudOperation, rrOperation, udOperation, Treeselect, DateRangePicker, CopyAddDialog },
|
||||
components: { UploadDialog, AddDialog, pagination, crudOperation, rrOperation, udOperation, Treeselect, DateRangePicker, CopyAddDialog },
|
||||
mixins: [presenter(), header(), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
@@ -182,6 +195,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadShow: false,
|
||||
classes: [],
|
||||
class_idStr: null,
|
||||
tabData: [],
|
||||
@@ -233,6 +247,9 @@ export default {
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
tableChanged3() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
formatMainName(row, cloum) {
|
||||
return this.dict.label.EM_DEVICE_BY_CYCLE[row.maintenancecycle]
|
||||
},
|
||||
@@ -267,7 +284,7 @@ export default {
|
||||
},
|
||||
queryClassId() {
|
||||
const param = {
|
||||
'class_idStr': this.class_idStr
|
||||
'class_idStr': '2'
|
||||
}
|
||||
crudClassstandard.queryClassById(param).then(res => {
|
||||
this.classes = res.content.map(obj => {
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="导入Excel文件"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="400px"
|
||||
:show-close="true"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
class="upload-demo"
|
||||
action=""
|
||||
drag
|
||||
:on-exceed="is_one"
|
||||
:limit="1"
|
||||
:auto-upload="false"
|
||||
:multiple="false"
|
||||
:show-file-list="true"
|
||||
:on-change="uploadByJsqd"
|
||||
:file-list="fileList"
|
||||
accept=".xlsx,.xls"
|
||||
>
|
||||
<i class="el-icon-upload" />
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div slot="tip" class="el-upload__tip">只能上传Excel文件,且不超过10MB</div>
|
||||
</el-upload>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudEquipmentfile from '@/views/wms/masterdata_manage/em/devicelubricateitems/devicelubricateitems'
|
||||
import CRUD, { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'UploadDialog',
|
||||
mixins: [crud()],
|
||||
components: {},
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
openParam: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
fileList: [],
|
||||
file1: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue, oldValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
},
|
||||
openParam: {
|
||||
handler(newValue, oldValue) {
|
||||
this.opendtlParam = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
is_one() {
|
||||
this.crud.notify('只能上传一个excel文件!', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
},
|
||||
// 文件校验方法
|
||||
beforeAvatarUpload(file) {
|
||||
// 不能导入大小超过2Mb的文件
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 文件发生改变就会触发的事件
|
||||
uploadByJsqd(file) {
|
||||
this.file1 = file
|
||||
},
|
||||
submit() {
|
||||
if (this.beforeAvatarUpload(this.file1)) {
|
||||
this.fileList.name = this.file1.name
|
||||
this.fileList.url = ''
|
||||
var formdata = new FormData()
|
||||
formdata.append('file', this.file1.raw)
|
||||
crudEquipmentfile.excelImport(formdata).then((res) => {
|
||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.$emit('tableChanged3', '')
|
||||
this.$emit('update:dialogShow', false)
|
||||
}).catch(err => {
|
||||
// const list = err.response.data.message
|
||||
// download2('/api/produceWorkorder/download', list).then(result => {
|
||||
// downloadFile(result, '错误信息汇总', 'xlsx')
|
||||
// crud.downloadLoading = false
|
||||
// })
|
||||
})
|
||||
} else {
|
||||
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -24,4 +24,12 @@ export function edit(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del }
|
||||
export function excelImport(data) {
|
||||
return request({
|
||||
url: 'api/devicelubricateitems/excelImport',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del,excelImport }
|
||||
|
||||
@@ -60,7 +60,18 @@
|
||||
</el-form>
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<crudOperation :permission="permission" >
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="warning"
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="uploadShow = true"
|
||||
>
|
||||
导入
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="850px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="120px">
|
||||
@@ -165,10 +176,12 @@
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UploadDialog from '@/views/wms/masterdata_manage/em/devicelubricateitems/UploadDialog'
|
||||
import crudDevicemaintenanceitems from '@/views/wms/masterdata_manage/em/devicelubricateitems/devicelubricateitems'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
@@ -183,7 +196,7 @@ import crudMaterialbase from '@/api/wms/basedata/master/materialbase'
|
||||
const defaultForm = { material_type_id: null, maint_item_id: null, maint_item_code: null, maint_item_name: null, item_level: null, contents: null, requirement: null, acceptancecriteria: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null, is_delete: null, remark: null }
|
||||
export default {
|
||||
name: 'Devicemaintain',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect },
|
||||
components: { UploadDialog, pagination, crudOperation, rrOperation, udOperation, Treeselect },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
@@ -202,6 +215,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadShow: false,
|
||||
classes: [],
|
||||
class_idStr: null,
|
||||
materOpt_code: '23',
|
||||
@@ -263,6 +277,9 @@ export default {
|
||||
changeQuery() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
tableChanged3() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
formatLevel(row, cloum) {
|
||||
if (row.item_level === '01') {
|
||||
return '日常'
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="导入Excel文件"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="400px"
|
||||
:show-close="true"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
class="upload-demo"
|
||||
action=""
|
||||
drag
|
||||
:on-exceed="is_one"
|
||||
:limit="1"
|
||||
:auto-upload="false"
|
||||
:multiple="false"
|
||||
:show-file-list="true"
|
||||
:on-change="uploadByJsqd"
|
||||
:file-list="fileList"
|
||||
accept=".xlsx,.xls"
|
||||
>
|
||||
<i class="el-icon-upload" />
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div slot="tip" class="el-upload__tip">只能上传Excel文件,且不超过10MB</div>
|
||||
</el-upload>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudEquipmentfile from '@/views/wms/masterdata_manage/em/devicemaintain/devicemaintenanceitems'
|
||||
import CRUD, { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'UploadDialog',
|
||||
mixins: [crud()],
|
||||
components: {},
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
openParam: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
fileList: [],
|
||||
file1: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue, oldValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
},
|
||||
openParam: {
|
||||
handler(newValue, oldValue) {
|
||||
this.opendtlParam = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
is_one() {
|
||||
this.crud.notify('只能上传一个excel文件!', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
},
|
||||
// 文件校验方法
|
||||
beforeAvatarUpload(file) {
|
||||
// 不能导入大小超过2Mb的文件
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 文件发生改变就会触发的事件
|
||||
uploadByJsqd(file) {
|
||||
this.file1 = file
|
||||
},
|
||||
submit() {
|
||||
if (this.beforeAvatarUpload(this.file1)) {
|
||||
this.fileList.name = this.file1.name
|
||||
this.fileList.url = ''
|
||||
var formdata = new FormData()
|
||||
formdata.append('file', this.file1.raw)
|
||||
crudEquipmentfile.excelImport(formdata).then((res) => {
|
||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.$emit('tableChanged3', '')
|
||||
this.$emit('update:dialogShow', false)
|
||||
}).catch(err => {
|
||||
// const list = err.response.data.message
|
||||
// download2('/api/produceWorkorder/download', list).then(result => {
|
||||
// downloadFile(result, '错误信息汇总', 'xlsx')
|
||||
// crud.downloadLoading = false
|
||||
// })
|
||||
})
|
||||
} else {
|
||||
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -24,4 +24,12 @@ export function edit(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del }
|
||||
export function excelImport(data) {
|
||||
return request({
|
||||
url: 'api/devicemaintenanceitems/excelImport',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, excelImport }
|
||||
|
||||
@@ -60,7 +60,18 @@
|
||||
</el-form>
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<crudOperation :permission="permission" >
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="warning"
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="uploadShow = true"
|
||||
>
|
||||
导入
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="850px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="120px">
|
||||
@@ -165,6 +176,7 @@
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -179,11 +191,13 @@ import crudClassstandard from '@/api/wms/basedata/master/classstandard'
|
||||
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import crudMaterialbase from '@/api/wms/basedata/master/materialbase'
|
||||
import UploadDialog from '@/views/wms/masterdata_manage/em/devicemaintain/UploadDialog'
|
||||
|
||||
|
||||
const defaultForm = { material_type_id: null, maint_item_id: null, maint_item_code: null, maint_item_name: null, item_level: null, contents: null, requirement: null, acceptancecriteria: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null, is_delete: null, remark: null }
|
||||
export default {
|
||||
name: 'Devicemaintain',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect },
|
||||
components: { UploadDialog, pagination, crudOperation, rrOperation, udOperation, Treeselect },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
@@ -202,6 +216,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadShow: false,
|
||||
classes: [],
|
||||
class_idStr: '2',
|
||||
materOpt_code: '23',
|
||||
@@ -260,6 +275,9 @@ export default {
|
||||
this.getSubTypes(data)
|
||||
}
|
||||
},
|
||||
tableChanged3() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
changeQuery() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="导入Excel文件"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="400px"
|
||||
:show-close="true"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
class="upload-demo"
|
||||
action=""
|
||||
drag
|
||||
:on-exceed="is_one"
|
||||
:limit="1"
|
||||
:auto-upload="false"
|
||||
:multiple="false"
|
||||
:show-file-list="true"
|
||||
:on-change="uploadByJsqd"
|
||||
:file-list="fileList"
|
||||
accept=".xlsx,.xls"
|
||||
>
|
||||
<i class="el-icon-upload" />
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div slot="tip" class="el-upload__tip">只能上传Excel文件,且不超过10MB</div>
|
||||
</el-upload>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudEquipmentfile from '@/views/wms/masterdata_manage/em/devicesportcheckitems/devicesportcheckitems'
|
||||
import CRUD, { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'UploadDialog',
|
||||
mixins: [crud()],
|
||||
components: {},
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
openParam: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
fileList: [],
|
||||
file1: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue, oldValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
},
|
||||
openParam: {
|
||||
handler(newValue, oldValue) {
|
||||
this.opendtlParam = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
is_one() {
|
||||
this.crud.notify('只能上传一个excel文件!', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
},
|
||||
// 文件校验方法
|
||||
beforeAvatarUpload(file) {
|
||||
// 不能导入大小超过2Mb的文件
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 文件发生改变就会触发的事件
|
||||
uploadByJsqd(file) {
|
||||
this.file1 = file
|
||||
},
|
||||
submit() {
|
||||
if (this.beforeAvatarUpload(this.file1)) {
|
||||
this.fileList.name = this.file1.name
|
||||
this.fileList.url = ''
|
||||
var formdata = new FormData()
|
||||
formdata.append('file', this.file1.raw)
|
||||
crudEquipmentfile.excelImport(formdata).then((res) => {
|
||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.$emit('tableChanged3', '')
|
||||
this.$emit('update:dialogShow', false)
|
||||
}).catch(err => {
|
||||
// const list = err.response.data.message
|
||||
// download2('/api/produceWorkorder/download', list).then(result => {
|
||||
// downloadFile(result, '错误信息汇总', 'xlsx')
|
||||
// crud.downloadLoading = false
|
||||
// })
|
||||
})
|
||||
} else {
|
||||
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -23,5 +23,12 @@ export function edit(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
export function excelImport(data) {
|
||||
return request({
|
||||
url: 'api/devicesportcheckitems/excelImport',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del }
|
||||
export default { add, edit, del, excelImport }
|
||||
|
||||
@@ -60,7 +60,18 @@
|
||||
</el-form>
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<crudOperation :permission="permission" >
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="warning"
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="uploadShow = true"
|
||||
>
|
||||
导入
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="850px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="120px">
|
||||
@@ -165,6 +176,7 @@
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -179,11 +191,13 @@ import crudClassstandard from '@/api/wms/basedata/master/classstandard'
|
||||
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import crudMaterialbase from '@/api/wms/basedata/master/materialbase'
|
||||
import UploadDialog from '@/views/wms/masterdata_manage/em/devicesportcheckitems/UploadDialog'
|
||||
|
||||
|
||||
const defaultForm = { material_type_id: null, maint_item_id: null, maint_item_code: null, maint_item_name: null, item_level: null, contents: null, requirement: null, acceptancecriteria: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null, is_delete: null, remark: null }
|
||||
export default {
|
||||
name: 'Devicemaintain',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect },
|
||||
components: { UploadDialog, pagination, crudOperation, rrOperation, udOperation, Treeselect },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
@@ -202,6 +216,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadShow: false,
|
||||
classes: [],
|
||||
class_idStr: null,
|
||||
materOpt_code: '23',
|
||||
@@ -260,6 +275,9 @@ export default {
|
||||
this.getSubTypes(data)
|
||||
}
|
||||
},
|
||||
tableChanged3() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
changeQuery() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user