rev:超期信息导入
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.nl.wms.basedata.st.rest;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -12,7 +13,9 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@@ -98,10 +101,16 @@ public class StructivtController {
|
||||
|
||||
@PostMapping("/save")
|
||||
@Log("保存")
|
||||
|
||||
public ResponseEntity<Object> save(@RequestBody JSONObject whereJson) {
|
||||
structivtService.save(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/importExcel")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> importExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
structivtService.importExcel(file, request);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.basedata.st.service.dto.StructivtDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -81,4 +83,6 @@ public interface StructivtService {
|
||||
void download(Map map, HttpServletResponse response, String[] product_area, String[] ivt_flag) throws IOException;
|
||||
|
||||
void save(JSONObject whereJson);
|
||||
|
||||
void importExcel(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ 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.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -23,9 +26,12 @@ import org.nl.wms.basedata.st.service.dto.StructivtDto;
|
||||
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.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -329,4 +335,34 @@ public class StructivtServiceImpl implements StructivtService {
|
||||
WQLObject.getWQLObject("st_ivt_structivt").update(jsonObject, "stockrecord_id = '" + whereJson.getString("stockrecord_id") + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importExcel(MultipartFile file, HttpServletRequest request) {
|
||||
// 1.获取上传文件输入流
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
|
||||
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
|
||||
// 循环获取的数据
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List list = read.get(i);
|
||||
String container_name = list.get(0).toString();
|
||||
String remark = list.get(1).toString();
|
||||
|
||||
if (StrUtil.isEmpty(container_name) || StrUtil.isEmpty(remark)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONObject ivt_jo = WQLObject.getWQLObject("st_ivt_structivt").query("pcsn = '" + container_name + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(ivt_jo)) {
|
||||
continue;
|
||||
}
|
||||
ivt_jo.put("remark", remark);
|
||||
WQLObject.getWQLObject("st_ivt_structivt").update(ivt_jo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user