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
Reference in New Issue
Block a user