add:添加档案导入/故障分类;rev:分类分类显示异常
This commit is contained in:
@@ -75,6 +75,7 @@ public interface ClassstandardService {
|
||||
JSONObject loadClass(Map whereJson);
|
||||
|
||||
JSONArray getSuperior(JSONObject jo, JSONArray ja);
|
||||
JSONArray getSuperiorLimit(JSONObject jo, JSONArray ja,String parent_id);
|
||||
|
||||
JSONObject buildTree(JSONArray ja);
|
||||
|
||||
|
||||
@@ -255,6 +255,33 @@ public class ClassstandardServiceImpl implements ClassstandardService {
|
||||
return getSuperior(id_row, ja);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONArray getSuperiorLimit(JSONObject jo, JSONArray ja, String parent_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard");
|
||||
if (StrUtil.isEmpty(jo.getString("parent_class_id")) || jo.getString("parent_class_id").equals("0")) {
|
||||
JSONArray null_pids = new JSONArray();
|
||||
null_pids = wo.query("(parent_class_id = '0' OR parent_class_id is null) and is_delete = '0'").getResultJSONArray(0);
|
||||
|
||||
for (int m = 0; m < null_pids.size(); m++) {
|
||||
JSONObject null_pid = null_pids.getJSONObject(m);
|
||||
ja.add(null_pid);
|
||||
}
|
||||
return ja;
|
||||
}
|
||||
JSONArray pid_rows = wo.query("parent_class_id = '" + jo.getString("parent_class_id") + "'").getResultJSONArray(0);
|
||||
for (int n = 0; n < pid_rows.size(); n++) {
|
||||
JSONObject pid_row = pid_rows.getJSONObject(n);
|
||||
ja.add(pid_row);
|
||||
}
|
||||
JSONObject id_row = wo.query("class_id = '" + jo.getString("parent_class_id") + "'").uniqueResult(0);
|
||||
if (id_row.getString("class_id").equals(parent_id)){
|
||||
ja.add(id_row);
|
||||
return ja;
|
||||
}
|
||||
return getSuperiorLimit(id_row, ja,parent_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject buildTree(JSONArray ja) {
|
||||
Set<JSONObject> trees = new LinkedHashSet<>();
|
||||
|
||||
@@ -12,7 +12,9 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -50,12 +52,17 @@ public class DevicefaultclassController {
|
||||
devicefaultclassService.update(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("删除设备故障分类维护")
|
||||
//@PreAuthorize("@el.check('devicefaultclass:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
devicefaultclassService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/excelImport")
|
||||
@ApiOperation("故障分类导入")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
devicefaultclassService.excelImport(file,request);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.DevicefaultclassDto;
|
||||
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 DevicefaultclassService {
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导入
|
||||
* @param file
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,14 @@ 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;
|
||||
@@ -19,13 +22,19 @@ import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.masterdata_manage.em.service.DevicefaultclassService;
|
||||
import org.nl.wms.masterdata_manage.em.service.dto.DevicefaultclassDto;
|
||||
import org.nl.wms.masterdata_manage.bfmaster.service.ClassstandardService;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
@@ -33,10 +42,13 @@ import java.util.Map;
|
||||
* @date 2022-06-16
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DevicefaultclassServiceImpl implements DevicefaultclassService {
|
||||
private final ClassstandardService classstandardService;
|
||||
|
||||
@Autowired
|
||||
private ClassstandardService classstandardService;
|
||||
@Autowired
|
||||
private ColumnInfoService columnInfoService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
@@ -148,4 +160,48 @@ public class DevicefaultclassServiceImpl implements DevicefaultclassService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||
try {
|
||||
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
|
||||
ExcelReader excelReader = ExcelUtil.getReader(file.getInputStream(), 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
Map<String, String> tableColumn = columnInfoService.TableColumn2("em_bi_devicefaultclass");
|
||||
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("device_faultclass_id"));
|
||||
}
|
||||
System.out.println(array.size());
|
||||
WQLObject mstTab = WQLObject.getWQLObject("em_bi_devicefaultclass"); // 工艺路线主表
|
||||
mstTab.delete("device_faultclass_id in "+"('" + ids.stream().collect(Collectors.joining("','")) + "')");
|
||||
for (Object o : array) {
|
||||
mstTab.insert((JSONObject)o);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,12 +116,21 @@ public class ClassstandardController {
|
||||
//("查询类别:根据ID获取同级与上级数据")
|
||||
@PostMapping("/superior")
|
||||
//@PreAuthorize("@el.check('user:list','dept:list')")
|
||||
public ResponseEntity<Object> getSuperior(@RequestBody Long id) {
|
||||
public ResponseEntity<Object> getSuperior(@RequestBody String id) {
|
||||
JSONObject jo = WQLObject.getWQLObject("MD_PB_ClassStandard").query("class_id = '" + id + "'").uniqueResult(0);
|
||||
JSONArray maters = ClassstandardService.getSuperior(jo, new JSONArray());
|
||||
return new ResponseEntity<>(ClassstandardService.buildTree(maters), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/superior2")
|
||||
public ResponseEntity<Object> getSuperior2(@RequestBody String param) {
|
||||
JSONArray arr = JSONArray.parseArray(param);
|
||||
JSONObject parse = arr.getJSONObject(0);
|
||||
JSONObject jo = WQLObject.getWQLObject("MD_PB_ClassStandard").query("class_id = '" + parse.getString("id") + "'").uniqueResult(0);
|
||||
JSONArray maters = ClassstandardService.getSuperiorLimit(jo, new JSONArray(),parse.getString("parent_id"));
|
||||
return new ResponseEntity<>(ClassstandardService.buildTree(maters), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getType")
|
||||
@Log("获取分类类型")
|
||||
//("获取分类类型")
|
||||
|
||||
Reference in New Issue
Block a user