add:外协发货功能修改

This commit is contained in:
zhangzhiqiang
2023-01-11 17:19:03 +08:00
parent 310a5931d2
commit 10348780b4
6 changed files with 231 additions and 6 deletions

View File

@@ -13,6 +13,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
@@ -116,4 +117,10 @@ public class StatisticalReportController {
query4(whereJson),HttpStatus.OK);
}
@ApiOperation("导出数据")
@GetMapping(value = "/download")
public void download(HttpServletResponse response, @RequestParam Map whereJson){
statisticalReportService.download(response, whereJson);
}
}

View File

@@ -3,6 +3,7 @@ package org.nl.wms.statistics.service;
import com.alibaba.fastjson.JSONArray;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
@@ -57,4 +58,11 @@ public interface StatisticalReportService {
* @return Map<String, Object>
*/
Map<String, Object> confirmOutStore(JSONArray jsonObject);
/**
* 导出外协数据
* @param response
* @param whereJson
*/
void download(HttpServletResponse response,Map whereJson);
}

View File

@@ -8,21 +8,29 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.exception.BadRequestException;
import org.nl.modules.system.domain.Dept;
import org.nl.modules.system.repository.DeptRepository;
import org.nl.modules.system.service.DeptService;
import org.nl.modules.system.service.UserService;
import org.nl.modules.system.service.dto.UserDto;
import org.nl.pda.exception.PdaRequestException;
import org.nl.utils.FileUtil;
import org.nl.utils.SecurityUtils;
import org.nl.wms.common.util.DataAuthUtil;
import org.nl.wms.statistics.service.StatisticalReportService;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.util.WqlUtil;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
@@ -32,6 +40,7 @@ import java.util.stream.Collectors;
public class StatisticalReportServiceImpl implements StatisticalReportService {
private final UserService userService;
private final DeptRepository deptService;
@Override
public Map<String, Object> sendOutQuery(Map whereJson, Pageable page) {
@@ -70,7 +79,7 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
map.put("is_send0", "0");
}
}else if (StrUtil.isEmpty(is_send)) {
map.put("is_send0", "0");
// map.put("is_send0", "0");
}
map.put("flag", "5");
JSONObject jo = WQL.getWO("statistical_report_query_02").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "send_date,material_code,pcsn");
@@ -603,4 +612,36 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
returnjo.put("desc", "操作成功!");
return returnjo;
}
@Override
@SneakyThrows
public void download(HttpServletResponse response, Map whereJson) {
Map<String, Object> result = this.sendOutQuery(new HashMap(), PageRequest.of(0,99999));
Object content = result.get("content");
if (content !=null){
List<Dept> depts = deptService.findAll();
Map<Long, String> deptInfo = depts.stream().collect(Collectors.toMap(Dept::getId, Dept::getName));
JSONArray list = (JSONArray) content;
List<Map<String, Object>> excelData = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
Map<String, Object> dtl_map = new LinkedHashMap<>();
JSONObject row = (JSONObject)list.get(i);
dtl_map.put("序号", i+1);
dtl_map.put("物料编码", row.getString("material_code"));
dtl_map.put("批次号", row.getString("pcsn"));
dtl_map.put("重量", row.getString("total_qty"));
dtl_map.put("桶数", row.getString("num_bucket"));
dtl_map.put("计划发货时间", row.getString("send_date"));
String clientName = "";
if (!StringUtils.isEmpty(row.getString("org_id"))){
clientName = deptInfo.get(row.getLong("org_id"));
}
dtl_map.put("客户名称", clientName);
dtl_map.put("备注", "");
excelData.add(dtl_map);
}
FileUtil.downloadExcel(excelData, response);
}
}
}

View File

@@ -195,7 +195,6 @@
SELECT
procedureoffline2.num_bucket,
procedureoffline2.total_qty,
procedureoffline.diskrecord_id,
procedureoffline.storagevehicle_code,
procedureoffline.is_send AS is_send,
procedureoffline.send_name AS send_name,
@@ -258,6 +257,7 @@
OPTION 输入.is_send12 <> ""
(procedureoffline.is_send = 输入.is_send12)
ENDOPTION
GROUP BY workorder.workorder_id,workorder.pcsn,procedureoffline.storagevehicle_code
ENDSELECT
ENDPAGEQUERY
ENDIF