|
|
|
|
@@ -17,6 +17,7 @@ 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.modules.system.util.MapOf;
|
|
|
|
|
import org.nl.pda.exception.PdaRequestException;
|
|
|
|
|
import org.nl.utils.FileUtil;
|
|
|
|
|
import org.nl.utils.SecurityUtils;
|
|
|
|
|
@@ -29,11 +30,20 @@ import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.function.ToDoubleFunction;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@@ -340,7 +350,7 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
|
|
|
|
|
// JSONObject num_jo = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject num_jo = WQL.getWO("QL_ERP").addParamMap(map).setDbname("dataSource1").process().uniqueResult(0);
|
|
|
|
|
JSONObject num_jo = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//合同在途
|
|
|
|
|
@@ -654,6 +664,91 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
public void download2(HttpServletResponse response, Map whereJson,String type) {
|
|
|
|
|
if (type ==null){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Map<String, String> headers = new LinkedHashMap<>();
|
|
|
|
|
List<Map<String, Object>> excelData = new ArrayList<>();
|
|
|
|
|
JSONArray list = handleData(headers,type,whereJson);
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)){
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
Map<String, Object> dtl_map = new LinkedHashMap<>();
|
|
|
|
|
dtl_map.put("序号",i+1==list.size()?"合计":i+1);
|
|
|
|
|
JSONObject row = list.getJSONObject(i);
|
|
|
|
|
for (String item : headers.keySet()) {
|
|
|
|
|
String header = headers.get(item);
|
|
|
|
|
dtl_map.put(header, row.getString(item));
|
|
|
|
|
}
|
|
|
|
|
excelData.add(dtl_map);
|
|
|
|
|
}
|
|
|
|
|
FileUtil.downloadExcel(excelData, response);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
private JSONArray handleData(Map<String, String> headers, String type, Map whereJson){
|
|
|
|
|
JSONArray list = null;
|
|
|
|
|
switch (type){
|
|
|
|
|
case "1":
|
|
|
|
|
list = query1(whereJson);
|
|
|
|
|
list.forEach(o -> {
|
|
|
|
|
JSONObject item = (JSONObject) o;
|
|
|
|
|
String halfUp = new BigDecimal(item.getDoubleValue("qty")).setScale(3, RoundingMode.HALF_UP).toString();
|
|
|
|
|
item.put("qty",halfUp);
|
|
|
|
|
});
|
|
|
|
|
headers.putAll(MapOf.of("material_code", "物料编码","material_name","物料名称","pcsn","批次","qty","可用重量"));
|
|
|
|
|
double qty = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("qty")).sum();
|
|
|
|
|
String halfUp = new BigDecimal(qty).setScale(3, RoundingMode.HALF_UP).toString();
|
|
|
|
|
list.add(MapOf.ofJ("material_code", " ","material_name"," ","pcsn"," ","qty",halfUp));
|
|
|
|
|
break;
|
|
|
|
|
case "2":
|
|
|
|
|
list = query2(whereJson);
|
|
|
|
|
list.forEach(o -> {
|
|
|
|
|
JSONObject item = (JSONObject) o;
|
|
|
|
|
String rHalfUp = new BigDecimal(item.getDoubleValue("receive_qty")).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
String nHalfUp = new BigDecimal(item.getDoubleValue("noin_qty")).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
item.put("receive_qty",rHalfUp);
|
|
|
|
|
item.put("noin_qty",nHalfUp);
|
|
|
|
|
});
|
|
|
|
|
headers.putAll(MapOf.of("receive_code", "到货单号","material_code","物料编码", "material_name","物料名称","pcsn","批次","receive_qty","订单重量","noin_qty","剩余重量","source_name","供应商"));
|
|
|
|
|
double receiveQty = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("receive_qty")).sum();
|
|
|
|
|
double noinQty = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("noin_qty")).sum();
|
|
|
|
|
String rHalfUp = new BigDecimal(receiveQty).setScale(3, RoundingMode.HALF_UP).toString();
|
|
|
|
|
String nHalfUp = new BigDecimal(noinQty).setScale(3, RoundingMode.HALF_UP).toString();
|
|
|
|
|
list.add(MapOf.ofJ("receive_code", " ","material_code"," ", "material_name"," ","pcsn"," ","receive_qty",rHalfUp,"noin_qty",nHalfUp ,"source_name"," "));
|
|
|
|
|
break;
|
|
|
|
|
case "3":
|
|
|
|
|
headers.putAll(MapOf.of("receive_code", "合同号","material_code","物料编码","material_name","物料名称","sumqty","合同重量","notqty","在途重量","norigtaxprice","含税单价","norigtaxmny","金额","name","供应商"));
|
|
|
|
|
list = query3(whereJson);
|
|
|
|
|
// byte[] bytes = Files.readAllBytes(Paths.get("/Users/mima0000/Desktop/data.txt"));
|
|
|
|
|
// String s = new String(bytes);
|
|
|
|
|
// list = JSONArray.parseArray(s);
|
|
|
|
|
list.forEach(o -> {
|
|
|
|
|
JSONObject item = (JSONObject) o;
|
|
|
|
|
String sumqty = new BigDecimal(item.getDoubleValue("sumqty")).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
String notqty = new BigDecimal(item.getDoubleValue("notqty")).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
String norigtaxprice = new BigDecimal(item.getDoubleValue("norigtaxprice")).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
String norigtaxmny = new BigDecimal(item.getDoubleValue("norigtaxmny")).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
item.put("sumqty",sumqty);
|
|
|
|
|
item.put("notqty",notqty);
|
|
|
|
|
item.put("norigtaxprice",norigtaxprice);
|
|
|
|
|
item.put("norigtaxmny",norigtaxmny);
|
|
|
|
|
});
|
|
|
|
|
double sumqtyD = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("sumqty")).sum();
|
|
|
|
|
double notqtyD = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("notqty")).sum();
|
|
|
|
|
double norigtaxmnyD = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("norigtaxmny")).sum();
|
|
|
|
|
String sumqtySum = new BigDecimal(sumqtyD).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
String notqtySum = new BigDecimal(notqtyD).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
String norigtaxmnySum = new BigDecimal(norigtaxmnyD).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
list.add(MapOf.ofJ("receive_code", " ","material_code"," ","material_name"," ","sumqty",sumqtySum,"notqty",notqtySum,"norigtaxprice"," ","norigtaxmny",norigtaxmnySum,"name"," "));
|
|
|
|
|
break;
|
|
|
|
|
default: ;
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> bucketQuery(Map whereJson, Pageable page) {
|
|
|
|
|
// 仓位属性表【ST_IVT_StructAttr】
|
|
|
|
|
|