Browse Source

添加下载功能

lwx_dev
erdanergou 3 years ago
parent
commit
8b08cc857a
  1. 57
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

57
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

@ -547,7 +547,7 @@ public class DepositoryRecordController {
Map<String, Object> insert = new HashMap<>();
insert.put("applicantId", userToken.getId());
insert.put("mid", map.get("mid" + temp));
insert.put("quantity",(int)(ObjectFormatUtil.toDouble(map.get("quantity" + temp)) * 100));
insert.put("quantity", (int) (ObjectFormatUtil.toDouble(map.get("quantity" + temp)) * 100));
insert.put("applyRemark", map.get("applyRemark" + temp));
insert.put("code", map.get("code"));
insert.put("placeId", map.get("placeId"));
@ -734,7 +734,7 @@ public class DepositoryRecordController {
// 获取申请的物料信息
Inventory materialById = materialService.findInventoryById(applicationOutMinById.getMid());
if ("-1".equals(applicationOutMinById.getUnit())) {
simpleApplicationOutMinRecordP.setShowQuantity(materialById.getUnit() + ":" + (applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut()));
simpleApplicationOutMinRecordP.setShowQuantity(materialById.getUnit() + ":" + (applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut()));
} else {
simpleApplicationOutMinRecordP.setShowQuantity(applicationOutMinById.getUnit() + ":" + (applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut()));
}
@ -761,7 +761,7 @@ public class DepositoryRecordController {
simpleApplicationOutMinRecordP.setCheckerName(checker.getName());
simpleApplicationOutMinRecordP.setPcode(placeByDid.getCode());
// 当已经完成出库时设置数量为出库数
simpleApplicationOutMinRecordP.setQuantity(applicationOutMinById.getQuantity() );
simpleApplicationOutMinRecordP.setQuantity(applicationOutMinById.getQuantity());
}
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialService.findMaterialAndProducedDateByMid(materialById.getId());
if (materialAndProducedDateByMid.size() > 0) {
@ -835,14 +835,14 @@ public class DepositoryRecordController {
depositoryName.append(depository.getDname()).append(",");
sumQuantity += applicationOutRecordMin.getQuantity();
String unit = applicationOutRecordMin.getUnit();
if("-1".equals(unit)){
if ("-1".equals(unit)) {
sumPrice += (inventory.getPrice() * applicationOutRecordMin.getQuantity());
}else{
sumPrice += (inventory.getPrice() * applicationOutRecordMin.getQuantity());
} else {
// 获取当前对应的拆单记录
Map<String,Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("mid",inventory.getMid());
paramForSplitInfo.put("newUnit",unit);
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("mid", inventory.getMid());
paramForSplitInfo.put("newUnit", unit);
SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取当前拆单记录与基础单位进制
int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
@ -1428,7 +1428,7 @@ public class DepositoryRecordController {
Double integer = ObjectFormatUtil.toDouble(quantitys.get(i));
// 获取当前仓库编号
Integer depositoryId = depositoryIds.get(i);
String quantity = String.valueOf((int)(integer * 100));
String quantity = String.valueOf((int) (integer * 100));
// 获取库位
String placeCode = placeCodes.get(i);
@ -1478,7 +1478,7 @@ public class DepositoryRecordController {
outRecord.put("placeId", place);
outRecord.put("unit", unit);
outRecord.put("applyRemark", applyRemark);
outRecord.put("adminorgId",userToken.getMaindeparment());
outRecord.put("adminorgId", userToken.getMaindeparment());
success += depositoryRecordService.insertApplicationOutMin(outRecord);
} else {
// 获取失败的物料信息
@ -1562,13 +1562,13 @@ public class DepositoryRecordController {
// 用于下载待打印出库订单
@GetMapping("/downloadOutRecord")
public void downloadOutRecord(@RequestParam Map<String,Object> map, HttpServletRequest request, HttpServletResponse response){
public void downloadOutRecord(@RequestParam Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) {
String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
if(map.containsKey("id")){
if (map.containsKey("id")) {
Integer id = ObjectFormatUtil.toInteger(map.get("id"));
List<String> strings = excelService.writeExcelForPrint(id, 4, userToken);
List<File> files = new ArrayList<>();
@ -1576,36 +1576,9 @@ public class DepositoryRecordController {
File file = new File(string);
files.add(file);
}
ZipMultiFileUtil.zipDownload(response,"出库订单.zip",files);
ZipMultiFileUtil.zipDownload(response, "出库订单.zip", files);
ZipMultiFileUtil.deleteFile(files);
/*try {
String path = "static/upload/materialTypeImport.xlsx";
String fileName = "materialTypeImport.xlsx";
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.setContentType("content-type:octet-stream");
*//* .getClassLoader() 方法是在静态文件路径添加一个/ *//*
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(path);
OutputStream outputStream = response.getOutputStream();
try {
byte[] buffer = new byte[1024];
int len;
assert inputStream != null;
while ((len = inputStream.read(buffer)) != -1) { *//* 将流中内容写出去 .*//*
outputStream.write(buffer, 0, len);
}
}catch (IOException e){
e.printStackTrace();
}finally {
assert inputStream != null;
inputStream.close();
outputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}*/
}else{
} else {
throw new MyException("缺少必要参数");
}
}

Loading…
Cancel
Save