产品吗查询

master
yangwl 4 years ago
parent 40df46158c
commit c672b87441

@ -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);
// }
}

@ -18,9 +18,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Controller
@RequestMapping("/nanjing/selectStationPara")
@ -31,6 +29,7 @@ public class StationParaInfoController extends BaseController {
@Autowired
private ITBdSubstationService substationService;
@RequiresPermissions("nanjing:StationPara:view")
@GetMapping()
public String ProRpList(ModelMap map) {
@ -55,7 +54,14 @@ public class StationParaInfoController extends BaseController {
map.put("Barcode", "");
map.put("SemiBarcode", semiBarcode);
map.put("StateID", "");
List<Map<String, Object>> list = tracestateService.selectStationPara(map);
List<Map<String,Object>> list=tracestateService.selectStationPara(map);
// List<Map<String, Object>> list = tracestateService.selectStationPara(map);
// Map newMAP=new HashMap();
// for(Map map1 : list){
// if (map1.containsKey("产品码")){
// newMAP.put("产品码",map1.get("产品码"));
// }
// }
for (int i = 0; i < list.size(); i++) {
if (list.get(i).containsKey("产品码")) {
continue;
@ -66,6 +72,27 @@ public class StationParaInfoController extends BaseController {
return getDataTable(list);
}
// public static void main(String[] args) {
// List<Map<String,Object>> maps=new ArrayList<>();
// Map map=new HashMap();
// map.put("测试","1552");
// map.put("测试2","58146");
// map.put("产品码","58533");
// maps.add(map);
// Map newMAP=new HashMap();
// List<Map<String,Object>> newListMap=new ArrayList<>();
// for (Map map1 : maps){
// if (map1.containsKey("产品码")){
// newMAP.put("产品码",map1.get("产品码"));
// }else {
// newMAP.put();
// }
// newListMap.add(newMAP);
// }
// System.out.println(maps);
// }
// @RequiresPermissions("nanjing:StationPara:export")
// @Log(title = "产品码查询", businessType = BusinessType.EXPORT)

@ -1,80 +1,84 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('组合表头')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 select-table table-bordered">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var prefix = ctx + "demo/table";
var datas = [[${@dict.getType('sys_normal_disable')}]];
$(function() {
var options = {
url: prefix + "/list",
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
columns : [
[{
title : '基本信息',
align : 'center',
colspan : 6
}, {
title : '其他信息',
align : 'center',
colspan : 3
}
],
[{
checkbox : true
}, {
field : 'userId',
title : '用户ID'
}, {
field : 'userCode',
title : '用户编号'
}, {
field : 'userName',
title : '用户姓名'
}, {
field : 'userPhone',
title : '用户手机'
}, {
field : 'userEmail',
title : '用户邮箱'
}, {
field : 'userBalance',
title : '用户余额'
}, {
field : 'status',
title : '用户状态',
formatter : function (value, row, index) {
return $.table.selectDictLabel(datas, value);
}
}, {
title : '操作',
align : 'center',
formatter : function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}
]
]
};
$.table.init(options);
});
</script>
</body>
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('组合表头')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 select-table table-bordered">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var prefix = ctx + "demo/table";
var datas = [[${@dict.getType('sys_normal_disable')}]];
$(function() {
var options = {
url: prefix + "/list",
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
onLoadSuccess: function (data) {
$('#bootstrap-table').bootstrapTable('mergeCells', {index: 1, field: 'userId', rowspan:3});
},
columns : [
// [{
// title : '基本信息',
// align : 'center',
// colspan : 6
// }, {
// title : '其他信息',
// align : 'center',
// colspan : 3
// }
// ],
[{
checkbox : true
}, {
field : 'userId',
title : '用户ID'
}, {
field : 'userCode',
title : '用户编号'
}, {
field : 'userName',
title : '用户姓名'
}, {
field : 'userPhone',
title : '用户手机'
}, {
field : 'userEmail',
title : '用户邮箱'
}, {
field : 'userBalance',
title : '用户余额'
}, {
field : 'status',
title : '用户状态',
formatter : function (value, row, index) {
return $.table.selectDictLabel(datas, value);
}
}, {
title : '操作',
align : 'center',
formatter : function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}
]
]
};
$.table.init(options);
});
</script>
</body>
</html>

@ -30,6 +30,7 @@
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</table>
</div>
</div>
</div>
@ -56,24 +57,13 @@
contentType: false,
success: function (json) {
console.log(json)
// var coulmnsData = [];
var columnsArray = [];
columnsArray.push({field : "序号",title : "序号",colspan: 1,rowspan: 1});
columnsArray.push({field : "产品条码",title : "产品条码",colspan: 1,rowspan: 1});
columnsArray.push({field : "状态",title : "状态",colspan: 1,rowspan: 1,
formatter: function (value, row, index) {
return $.table.selectDictLabel(stateDatas, value);
}
});
columnsArray.push({field : "时间",title : "开始时间",colspan: 1,rowspan: 1});
// columnsArray.push({field : "barCode",title : "产品条码",colspan: 1,rowspan: 1});
// var columns = [];
console.log(json.total)
columnsArray.push({field : "Barcode",title : "产品条码",colspan: 1,rowspan: 1});
if(json.total>0){
for (var i = 0; i < (Object.keys(json.rows[0])).length; i++) {//Object.keys(obj) 获取key名称
var property = (Object.keys(json.rows[0]))[i];
if(property!='产品条码'&&property!='时间'&&property!='序号'&&property!='状态'){
console.log(property)
if(property!='Barcode'){
columnsArray.push({
"title": property,
"field": property,
@ -81,37 +71,13 @@
align:"center",
}
);
}
}
// for (var i = 0;i<json.rows.length;i++){
// // console.log(json.rows[i].map)
// console.log(Object.keys(json.rows[i].map))
//
// // columnsArray.push(
// // [{
// //
// // }]
// // )
// }
// console.log(Object.keys(json[0]).length);
// for (var i = 0; i < (Object.keys(json[0])).length; i++) {//Object.keys(obj) 获取key名称
// var property = (Object.keys(json[0]))[i];
// if(property!='barcode'){
// columnsArray.push({
// "title": property,
// "field": property,
// switchable: true,
// align:"center",
// }
// );
// }
//
// }
}
}
// coulmnsData.push(columnsArray);
// coulmnsData.push(columns);
// console.log(columnsArray);
console.log(columnsArray);
$('#bootstrap-table').bootstrapTable('destroy').bootstrapTable({
id: "bootstrap-table",
data:json,

@ -12,7 +12,7 @@ public class ReportData extends BaseEntity {
private String parameaning;
private String value;
private long id;
private String beginTime;
private Date beginTime;
private String endTime;
private String stationName;
private String state;
@ -65,11 +65,11 @@ public class ReportData extends BaseEntity {
this.id = id;
}
public String getBeginTime() {
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(String beginTime) {
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}

@ -36,5 +36,5 @@ public interface TBdProducttypeMapper
List<QsStation> selectAllQs(Map map);
List<ReportData> selectReport(Map map);
List<Map<String,Object>> selectReport(Map map);
}

@ -40,5 +40,5 @@ public interface ITBdProducttypeService
List<QsStation> selectNodeQs(Map map);
List<ReportData> selectReport(Map map);
List<Map<String,Object>> selectReport(Map map);
}

@ -83,7 +83,7 @@ public class TBdProducttypeServiceImpl implements ITBdProducttypeService
}
@Override
public List<ReportData> selectReport(Map map) {
public List<Map<String,Object>> selectReport(Map map) {
return tBdProducttypeMapper.selectReport(map);
}
}

@ -151,7 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
}
</select>
<select id="selectReport" parameterType="map" statementType="CALLABLE" resultMap="repo">
<select id="selectReport" parameterType="map" statementType="CALLABLE" resultType="java.util.LinkedHashMap">
{
call begin_date5
(

@ -121,7 +121,7 @@
)
}
</select>
<select id="selectStationPara" statementType="CALLABLE" parameterType="map" resultType="map" >
<select id="selectStationPara" statementType="CALLABLE" parameterType="map" resultType="java.util.LinkedHashMap" >
{
call pro_SelectSemiStationParaData
(

Loading…
Cancel
Save