|
|
|
@ -59,7 +59,8 @@ public class ReportDataController extends BaseController {
|
|
|
|
|
map.put("begin", begin);
|
|
|
|
|
map.put("end", end);
|
|
|
|
|
map.put("barcode", barcode);
|
|
|
|
|
List<ReportData> reportDataList = producttypeService.selectReport(map);
|
|
|
|
|
// List<Map<String,Object>> mapList=producttypeService.selectReport(map);
|
|
|
|
|
List<Map<String,Object>> reportDataList = producttypeService.selectReport(map);
|
|
|
|
|
|
|
|
|
|
// List<DemoData> list = new ArrayList<>();
|
|
|
|
|
// for (ReportData data : reportDataList) {
|
|
|
|
@ -101,47 +102,101 @@ public class ReportDataController extends BaseController {
|
|
|
|
|
// }
|
|
|
|
|
// JSONObject jsonObject=new JSONObject();
|
|
|
|
|
// System.out.println(jsonObject.toJSONString(list));
|
|
|
|
|
List<String> paraName = new ArrayList<>();
|
|
|
|
|
List<String> barcodes = new ArrayList<>();
|
|
|
|
|
List<String> stations = new ArrayList<>();
|
|
|
|
|
//取出参数名
|
|
|
|
|
reportDataList.forEach(x->barcodes.add(x.getBarcode()));
|
|
|
|
|
reportDataList.forEach(x->paraName.add(x.getParameaning()));
|
|
|
|
|
reportDataList.forEach(x->stations.add(x.getStationName()));
|
|
|
|
|
//去重
|
|
|
|
|
//条码List
|
|
|
|
|
List<String> barcodeList = barcodes.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
//参数List
|
|
|
|
|
List<String> paraNameList = paraName.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
//工位名集合
|
|
|
|
|
List<String> stationList = stations.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
// List<String> paraName = new ArrayList<>();
|
|
|
|
|
// List<String> barcodes = new ArrayList<>();
|
|
|
|
|
// List<String> stations = new ArrayList<>();
|
|
|
|
|
// //取出参数名
|
|
|
|
|
// for (int i = 0; i < mapList.size(); i++) {
|
|
|
|
|
// barcodes.add((String) mapList.get(i).get("Barcode"));
|
|
|
|
|
//// mapList.forEach(x->barcodes.add());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// for (int i = 0; i < mapList.size(); i++) {
|
|
|
|
|
// paraName.add((String) mapList.get(i).get("parameaning"));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// for (int i = 0; i < mapList.size(); i++) {
|
|
|
|
|
// stations.add((String) mapList.get(i).get("stationname"));
|
|
|
|
|
// }
|
|
|
|
|
//// reportDataList.forEach(x->paraName.add(x.getParameaning()));
|
|
|
|
|
//// reportDataList.forEach(x->stations.add(x.getStationName()));
|
|
|
|
|
// //去重
|
|
|
|
|
// //条码List
|
|
|
|
|
// List<String> barcodeList = barcodes.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
// //参数List
|
|
|
|
|
// List<String> paraNameList = paraName.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
// //工位名集合
|
|
|
|
|
// List<String> stationList = stations.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
////
|
|
|
|
|
//// //定义结果集合
|
|
|
|
|
// List<Map<String,Object>> list = new ArrayList<>();
|
|
|
|
|
//// //定义结果集map
|
|
|
|
|
// Map<String,Object> map1 = new HashMap<>();
|
|
|
|
|
// System.out.println(barcodeList);
|
|
|
|
|
// int number=0;
|
|
|
|
|
//
|
|
|
|
|
// for (String item:barcodeList) {
|
|
|
|
|
// for (String station : stationList) {
|
|
|
|
|
// for (String param : paraNameList) {
|
|
|
|
|
// for (Map map2:mapList){
|
|
|
|
|
// System.out.println(map2.get("Barcode"));
|
|
|
|
|
//// if (map2.get("Barcode").equals(item) && map2.get("stationname").equals(station)&& map2.get("parameaning").equals(param)){
|
|
|
|
|
//// String paramName = map2.get("stationname") + "-" + map2.get("parameaning");
|
|
|
|
|
//// map1.put(paramName, map2.get("value"));
|
|
|
|
|
//// break;
|
|
|
|
|
//// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// for(String item:barcodeList) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//定义结果集合
|
|
|
|
|
List<Map<String,Object>> list = new ArrayList<>();
|
|
|
|
|
//定义结果集map
|
|
|
|
|
Map<String,Object> map1 = new HashMap<>();
|
|
|
|
|
int number=0;
|
|
|
|
|
for(String item:barcodeList){
|
|
|
|
|
number=number+1;
|
|
|
|
|
map1.put("产品条码",item);
|
|
|
|
|
map1.put("序号",number);
|
|
|
|
|
for (String station:stationList) {
|
|
|
|
|
for(String param:paraNameList){
|
|
|
|
|
for (ReportData rpd:reportDataList) {
|
|
|
|
|
map1.put("时间",rpd.getBeginTime());
|
|
|
|
|
map1.put("状态",rpd.getState());
|
|
|
|
|
if (rpd.getBarcode().equals(item)&&rpd.getStationName().equals(station)&&rpd.getParameaning().equals(param)){
|
|
|
|
|
if(rpd.getValue()==null){
|
|
|
|
|
rpd.setValue("-");
|
|
|
|
|
}
|
|
|
|
|
String paramName = rpd.getStationName()+"-"+rpd.getParameaning();
|
|
|
|
|
// map1.put(station,param);
|
|
|
|
|
map1.put(paramName,rpd.getValue());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// number = number + 1;
|
|
|
|
|
// map1.put("产品条码", item);
|
|
|
|
|
// map1.put("序号", number);
|
|
|
|
|
// for (String station : stationList) {
|
|
|
|
|
// for (String param : paraNameList) {
|
|
|
|
|
// for (Map map2 : mapList) {
|
|
|
|
|
// map1.put("时间", map2.get("begintime"));
|
|
|
|
|
// map1.put("状态", map2.get("stationname"));
|
|
|
|
|
// if (map2.get("Barcode").equals(item) && map2.get("stationname").equals(station) && map2.get("parameaning").equals(param)) {
|
|
|
|
|
// if (map2.get("value") == null) {
|
|
|
|
|
// map2.put("value", "-");
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// String paramName = map2.get("stationname") + "-" + map2.get("parameaning");
|
|
|
|
|
// map1.put(paramName, map2.get("value"));
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// int number=0;
|
|
|
|
|
// for(String item:barcodeList){
|
|
|
|
|
// number=number+1;
|
|
|
|
|
// map1.put("产品条码",item);
|
|
|
|
|
// map1.put("序号",number);
|
|
|
|
|
// for (String station:stationList) {
|
|
|
|
|
// for(String param:paraNameList){
|
|
|
|
|
// for (ReportData rpd:reportDataList) {
|
|
|
|
|
// map1.put("时间",rpd.getBeginTime());
|
|
|
|
|
// map1.put("状态",rpd.getState());
|
|
|
|
|
// if (rpd.getBarcode().equals(item)&&rpd.getStationName().equals(station)&&rpd.getParameaning().equals(param)){
|
|
|
|
|
// if(rpd.getValue()==null){
|
|
|
|
|
// rpd.setValue("-");
|
|
|
|
|
// }
|
|
|
|
|
// String paramName = rpd.getStationName()+"-"+rpd.getParameaning();
|
|
|
|
|
//// map1.put(station,param);
|
|
|
|
|
// map1.put(paramName,rpd.getValue());
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// for (String param:paraNameList) {
|
|
|
|
|
// for (ReportData rpd:reportDataList) {
|
|
|
|
|
// if (rpd.getBarcode().equals(item)&&rpd.getParameaning().equals(param)){
|
|
|
|
@ -155,126 +210,126 @@ public class ReportDataController extends BaseController {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//排序的作用
|
|
|
|
|
TreeMap<String,Object> treeMap = new TreeMap<>(map1);
|
|
|
|
|
list.add(treeMap);
|
|
|
|
|
}
|
|
|
|
|
String info = JSONArray.toJSONString(list);
|
|
|
|
|
// System.out.println(info);
|
|
|
|
|
System.out.println("条码信息查询Json格式:"+info);
|
|
|
|
|
return getDataTable(list);
|
|
|
|
|
// TreeMap<String,Object> treeMap = new TreeMap<>(map1);
|
|
|
|
|
// list.add(treeMap);
|
|
|
|
|
// }
|
|
|
|
|
// String info = JSONArray.toJSONString(list);
|
|
|
|
|
//// System.out.println(info);
|
|
|
|
|
// System.out.println("条码信息查询Json格式:"+info);
|
|
|
|
|
return getDataTable(reportDataList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult export(String begin, String end, String barcode){
|
|
|
|
|
Map map = new HashMap<String, Object>();
|
|
|
|
|
map.put("begin", begin);
|
|
|
|
|
map.put("end", end);
|
|
|
|
|
map.put("barcode", barcode);
|
|
|
|
|
AjaxResult ajaxResult=new AjaxResult();
|
|
|
|
|
List<ReportData> reportDataList = producttypeService.selectReport(map);
|
|
|
|
|
List<String> paraName = new ArrayList<>();
|
|
|
|
|
List<String> barcodes = new ArrayList<>();
|
|
|
|
|
List<String> stations = new ArrayList<>();
|
|
|
|
|
//取出参数名
|
|
|
|
|
reportDataList.forEach(x->barcodes.add(x.getBarcode()));
|
|
|
|
|
reportDataList.forEach(x->paraName.add(x.getParameaning()));
|
|
|
|
|
reportDataList.forEach(x->stations.add(x.getStationName()));
|
|
|
|
|
//去重
|
|
|
|
|
//条码List
|
|
|
|
|
List<String> barcodeList = barcodes.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
//参数List
|
|
|
|
|
List<String> paraNameList = paraName.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
//工位名集合
|
|
|
|
|
List<String> stationList = stations.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
//定义结果集合
|
|
|
|
|
List<Map<String,Object>> list = new ArrayList<>();
|
|
|
|
|
//定义结果集map
|
|
|
|
|
Map<String,Object> map1 = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
int number=0;
|
|
|
|
|
for(String item:barcodeList){
|
|
|
|
|
number=number+1;
|
|
|
|
|
map1.put("序号",String.valueOf(number));
|
|
|
|
|
map1.put("产品条码",item);
|
|
|
|
|
for (String station:stationList) {
|
|
|
|
|
for(String param:paraNameList){
|
|
|
|
|
for (ReportData rpd:reportDataList) {
|
|
|
|
|
map1.put("时间",rpd.getBeginTime());
|
|
|
|
|
if (rpd.getBarcode().equals(item)&&rpd.getStationName().equals(station)&&rpd.getParameaning().equals(param)){
|
|
|
|
|
if(rpd.getValue()==null){
|
|
|
|
|
rpd.setValue("-");
|
|
|
|
|
}
|
|
|
|
|
String paramName = rpd.getStationName()+"-"+rpd.getParameaning();
|
|
|
|
|
// map1.put(station,param);
|
|
|
|
|
map1.put(paramName,rpd.getValue());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//排序的作用
|
|
|
|
|
TreeMap<String,Object> treeMap = new TreeMap<>(map1);
|
|
|
|
|
list.add(treeMap);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<String> arrayList=new ArrayList();
|
|
|
|
|
if (list!=null) {
|
|
|
|
|
Set<String> k = list.get(0).keySet();
|
|
|
|
|
Iterator<String> it = k.iterator();
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
String key = it.next();
|
|
|
|
|
|
|
|
|
|
//有了键,就可以通过map集合的get方法获取对应的值
|
|
|
|
|
// if (key=="barcode"){
|
|
|
|
|
// key="产品条码";
|
|
|
|
|
// }if (key=="beginTime"){
|
|
|
|
|
// key="时间";
|
|
|
|
|
// @PostMapping("/export")
|
|
|
|
|
// @ResponseBody
|
|
|
|
|
// public AjaxResult export(String begin, String end, String barcode){
|
|
|
|
|
// Map map = new HashMap<String, Object>();
|
|
|
|
|
// map.put("begin", begin);
|
|
|
|
|
// map.put("end", end);
|
|
|
|
|
// map.put("barcode", barcode);
|
|
|
|
|
// AjaxResult ajaxResult=new AjaxResult();
|
|
|
|
|
// List<ReportData> reportDataList = producttypeService.selectReport(map);
|
|
|
|
|
// List<String> paraName = new ArrayList<>();
|
|
|
|
|
// List<String> barcodes = new ArrayList<>();
|
|
|
|
|
// List<String> stations = new ArrayList<>();
|
|
|
|
|
// //取出参数名
|
|
|
|
|
// reportDataList.forEach(x->barcodes.add(x.getBarcode()));
|
|
|
|
|
// reportDataList.forEach(x->paraName.add(x.getParameaning()));
|
|
|
|
|
// reportDataList.forEach(x->stations.add(x.getStationName()));
|
|
|
|
|
// //去重
|
|
|
|
|
// //条码List
|
|
|
|
|
// List<String> barcodeList = barcodes.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
// //参数List
|
|
|
|
|
// List<String> paraNameList = paraName.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
// //工位名集合
|
|
|
|
|
// List<String> stationList = stations.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
//
|
|
|
|
|
// //定义结果集合
|
|
|
|
|
// List<Map<String,Object>> list = new ArrayList<>();
|
|
|
|
|
// //定义结果集map
|
|
|
|
|
// Map<String,Object> map1 = new HashMap<>();
|
|
|
|
|
//
|
|
|
|
|
// int number=0;
|
|
|
|
|
// for(String item:barcodeList){
|
|
|
|
|
// number=number+1;
|
|
|
|
|
// map1.put("序号",String.valueOf(number));
|
|
|
|
|
// map1.put("产品条码",item);
|
|
|
|
|
// for (String station:stationList) {
|
|
|
|
|
// for(String param:paraNameList){
|
|
|
|
|
// for (ReportData rpd:reportDataList) {
|
|
|
|
|
// map1.put("时间",rpd.getBeginTime());
|
|
|
|
|
// if (rpd.getBarcode().equals(item)&&rpd.getStationName().equals(station)&&rpd.getParameaning().equals(param)){
|
|
|
|
|
// if(rpd.getValue()==null){
|
|
|
|
|
// rpd.setValue("-");
|
|
|
|
|
// }
|
|
|
|
|
// String paramName = rpd.getStationName()+"-"+rpd.getParameaning();
|
|
|
|
|
//// map1.put(station,param);
|
|
|
|
|
// map1.put(paramName,rpd.getValue());
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
arrayList.add(key);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// ExcelUtil.createWorkBook(list,list1);
|
|
|
|
|
XSSFWorkbook wb = new XSSFWorkbook();
|
|
|
|
|
XSSFSheet sheet = wb.createSheet("First sheet");
|
|
|
|
|
sheet.setDefaultRowHeight((short) (2 * 256));
|
|
|
|
|
XSSFFont font = wb.createFont();
|
|
|
|
|
font.setFontName("宋体");
|
|
|
|
|
font.setFontHeightInPoints((short) 16);
|
|
|
|
|
XSSFRow row = sheet.createRow(0);
|
|
|
|
|
String targetFile=null;
|
|
|
|
|
for (int s=0;s<arrayList.size();s++){
|
|
|
|
|
row.createCell(s);
|
|
|
|
|
XSSFCell cell = row.createCell(s);
|
|
|
|
|
cell.setCellValue(arrayList.get(s));
|
|
|
|
|
sheet.setColumnWidth(s, 4000);
|
|
|
|
|
}
|
|
|
|
|
XSSFRow rows ;
|
|
|
|
|
XSSFCell cells;
|
|
|
|
|
for (int i=0;i<list.size();i++){
|
|
|
|
|
rows = sheet.createRow(i + 1);
|
|
|
|
|
for (int j = 0; j < arrayList.size(); j++) {
|
|
|
|
|
cells = rows.createCell(j);
|
|
|
|
|
String value = (String) list.get(i).get(arrayList.get(j));
|
|
|
|
|
cells.setCellValue(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
targetFile="条码信息"+ new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".xlsx";
|
|
|
|
|
// File file = new File();
|
|
|
|
|
FileOutputStream fileOutputStream = new FileOutputStream(ExcelUtil.getAbsoluteFilew(targetFile));
|
|
|
|
|
wb.write(fileOutputStream);
|
|
|
|
|
wb.close();
|
|
|
|
|
fileOutputStream.close();
|
|
|
|
|
}catch (IOException e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ajaxResult.success(targetFile);
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
// //排序的作用
|
|
|
|
|
// TreeMap<String,Object> treeMap = new TreeMap<>(map1);
|
|
|
|
|
// list.add(treeMap);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// List<String> arrayList=new ArrayList();
|
|
|
|
|
// if (list!=null) {
|
|
|
|
|
// Set<String> k = list.get(0).keySet();
|
|
|
|
|
// Iterator<String> it = k.iterator();
|
|
|
|
|
// while (it.hasNext()) {
|
|
|
|
|
// String key = it.next();
|
|
|
|
|
//
|
|
|
|
|
// //有了键,就可以通过map集合的get方法获取对应的值
|
|
|
|
|
//// if (key=="barcode"){
|
|
|
|
|
//// key="产品条码";
|
|
|
|
|
//// }if (key=="beginTime"){
|
|
|
|
|
//// key="时间";
|
|
|
|
|
//// }
|
|
|
|
|
// arrayList.add(key);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//// ExcelUtil.createWorkBook(list,list1);
|
|
|
|
|
// XSSFWorkbook wb = new XSSFWorkbook();
|
|
|
|
|
// XSSFSheet sheet = wb.createSheet("First sheet");
|
|
|
|
|
// sheet.setDefaultRowHeight((short) (2 * 256));
|
|
|
|
|
// XSSFFont font = wb.createFont();
|
|
|
|
|
// font.setFontName("宋体");
|
|
|
|
|
// font.setFontHeightInPoints((short) 16);
|
|
|
|
|
// XSSFRow row = sheet.createRow(0);
|
|
|
|
|
// String targetFile=null;
|
|
|
|
|
// for (int s=0;s<arrayList.size();s++){
|
|
|
|
|
// row.createCell(s);
|
|
|
|
|
// XSSFCell cell = row.createCell(s);
|
|
|
|
|
// cell.setCellValue(arrayList.get(s));
|
|
|
|
|
// sheet.setColumnWidth(s, 4000);
|
|
|
|
|
// }
|
|
|
|
|
// XSSFRow rows ;
|
|
|
|
|
// XSSFCell cells;
|
|
|
|
|
// for (int i=0;i<list.size();i++){
|
|
|
|
|
// rows = sheet.createRow(i + 1);
|
|
|
|
|
// for (int j = 0; j < arrayList.size(); j++) {
|
|
|
|
|
// cells = rows.createCell(j);
|
|
|
|
|
// String value = (String) list.get(i).get(arrayList.get(j));
|
|
|
|
|
// cells.setCellValue(value);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// try {
|
|
|
|
|
//
|
|
|
|
|
// targetFile="条码信息"+ new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".xlsx";
|
|
|
|
|
//// File file = new File();
|
|
|
|
|
// FileOutputStream fileOutputStream = new FileOutputStream(ExcelUtil.getAbsoluteFilew(targetFile));
|
|
|
|
|
// wb.write(fileOutputStream);
|
|
|
|
|
// wb.close();
|
|
|
|
|
// fileOutputStream.close();
|
|
|
|
|
// }catch (IOException e){
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return ajaxResult.success(targetFile);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|