2021.3.5 18:18

dep_wangsr
Limy 4 years ago
parent e63e3c5a8b
commit 99b21729b6

@ -1,5 +1,6 @@
package com.ruoyi.web.controller.nanjing; package com.ruoyi.web.controller.nanjing;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.nanjing.domain.ReportData; import com.ruoyi.nanjing.domain.ReportData;
import com.ruoyi.nanjing.domain.TBdProductinfo; import com.ruoyi.nanjing.domain.TBdProductinfo;
@ -13,9 +14,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
import java.util.Map;
@Controller @Controller
@RequestMapping("/nanjing/reportData") @RequestMapping("/nanjing/reportData")
@ -28,19 +28,49 @@ public class ReportDataController extends BaseController {
@GetMapping() @GetMapping()
public String reportData(ModelMap map) public String reportData(ModelMap map)
{ {
// return prefix + "/Report"; return prefix + "/Report";
return "redirect:"+"http://127.0.0.1:18080/RDP-SERVER/rdppage/main/d354a3beb6dae7938155b3f9a962e479"; // return "redirect:"+"http://127.0.0.1:18080/RDP-SERVER/rdppage/main/d354a3beb6dae7938155b3f9a962e479";
} }
@PostMapping("/report") @PostMapping("/report")
@ResponseBody @ResponseBody
public List<ReportData> reportData(String begin,String end,String barcode) public String reportData(String begin,String end,String barcode)
{ {
Map map = new HashMap<String,Object>(); Map map = new HashMap<String,Object>();
map.put("begin",begin); map.put("begin",begin);
map.put("end",end); map.put("end",end);
map.put("barcode",barcode); map.put("barcode",barcode);
List<ReportData> reportDataList = producttypeService.selectReport(map); List<ReportData> reportDataList = producttypeService.selectReport(map);
return reportDataList;
List<String> paraName = new ArrayList<>();
List<String> barcodelist = new ArrayList<>();
//取出参数名
reportDataList.forEach(x->barcodelist.add(x.getBarcode()));
reportDataList.forEach(x->paraName.add(x.getParameaning()));
//去重
List<String> barcodeList = barcodelist.stream().distinct().collect(Collectors.toList());
List<String> paraNameList = paraName.stream().distinct().collect(Collectors.toList());
//定义结果集合
List<Map<String,Object>> list = new ArrayList<>();
//定义结果集map
Map<String,Object> map1 = new HashMap<>();
for(String item:barcodeList){
map1.put("barcode",item);
for (String param:paraNameList) {
for (ReportData rpd:reportDataList) {
if (rpd.getBarcode().equals(item)&&rpd.getParameaning().equals(param)){
map1.put(param,rpd.getParameaning());
map1.put(param+"value",rpd.getValue());
break;
}
}
}
//排序的作用
TreeMap<String,Object> treeMap = new TreeMap<>(map1);
list.add(treeMap);
}
String info = JSONArray.toJSONString(list);
// System.out.println(info);
return info;
} }
} }

@ -133,14 +133,21 @@ public class TBdSubstationController extends BaseController
@ResponseBody @ResponseBody
public AjaxResult addSave(TBdSubstation tBdSubstation) public AjaxResult addSave(TBdSubstation tBdSubstation)
{ {
String res = "";
Map map = new HashMap<String,Object>(); Map map = new HashMap<String,Object>();
map.put("tableName",tBdSubstation.getTableName()); map.put("tableName",tBdSubstation.getTableName());
map.put("ParaAmount",tBdSubstation.getParaCount()); map.put("ParaAmount",tBdSubstation.getParaCount());
tBdSubstationService.createTable(map); String msg = tBdSubstationService.createTable(map);
tBdSubstation.setUniteID(0L); tBdSubstation.setUniteID(0L);
tBdSubstation.setUserID(ShiroUtils.getUserId().toString()); tBdSubstation.setUserID(ShiroUtils.getUserId().toString());
return toAjax(tBdSubstationService.insertTBdSubstation(tBdSubstation)); int insertStation = tBdSubstationService.insertTBdSubstation(tBdSubstation);
if(insertStation>0){
res = "工位创建成功;"+msg;
}else {
res = "工位创建失败;"+msg;
}
return AjaxResult.success(res);
} }
/** /**

@ -21,7 +21,7 @@
<input type="text" id="barcode" name="barcode"/> <input type="text" id="barcode" name="barcode"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="searchAll()"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="searchpara()"><i class="fa fa-search"></i>&nbsp;搜索</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -34,44 +34,107 @@
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<script th:inline="javascript"> <script th:inline="javascript">
function searchAll(){ function searchpara(){
// console.log("点击查询按钮事件执行..."); // console.log("点击查询按钮事件执行...");
var url = ctx + "nanjing/reportData/report"; // //方式1行转列
$('#bootstrap-table').bootstrapTable('destroy'); var formData = new FormData();
$('#bootstrap-table').bootstrapTable({ formData.append("begin",$('#beginTime').val());
method:"post", formData.append("end",$('#endTime').val());
url: url, formData.append("barcode",$('#barcode').val());
$.ajax({
type: "post",
url: ctx + "nanjing/reportData/report",
data: formData,
contentType: "application/json;charset=utf-8",
dataType: "json",
json: 'callback',
processData: false,
contentType: false,
success: function (json) {
var coulmnsData = [];
var columnsArray = [];
columnsArray.push({field : "barcode",title : "产品条码",colspan: 1,rowspan: 2});
var columns = [];
if(json.length>0){
for (var i = 0; i < (Object.keys(json[0])).length; i++) {//Object.keys(obj) 获取key名称
var property = (Object.keys(json[0]))[i];//id username
if(property!='barcode'&&!(property.endsWith("value"))){
columns.push({
"title": property,
"field": property+'value',
switchable: true,
align:"center",
}
);
}
}
}
coulmnsData.push(columnsArray);
coulmnsData.push(columns);
// console.log(columnsArray);
$('#bootstrap-table').bootstrapTable('destroy').bootstrapTable({
id: "bootstrap-table",
data:json,
toolbar: "#toolbar",
singleSelect: false,
// clickToSelect: true,
sortName: "barcode",
sortOrder: "desc",
pageSize: 15,
pageNumber: 1,
pageList: "[10, 15,25, 50, 100, All]",
// showToggle: true,
showRefresh: true,
showColumns: true,
search: false,
pagination: true, pagination: true,
search: true, showExport: false,//工具栏上显示导出按钮
contentType : "application/x-www-form-urlencoded", fixedColumns: true,
queryParams: { fixedNumber: 4,
begin:$('#beginTime').val(), fixedLeftNumber: 4,
end:$('#endTime').val(), columns: coulmnsData
barcode:$('#barcode').val() });
}, // columnsArray.push();
modalName: "条码信息查询",
columns: [
{
field: 'id',
title: '序号'
},
{
field: 'barcode',
title: '系统条码'
}, },
{ error: function () {
field: 'parameaning', alert("错误");
title: '参数名' }
}, });
{ // 方式2 不进行行转列
field:'value', // var url = ctx + "nanjing/reportData/report";
title:'参数值' // $('#bootstrap-table').bootstrapTable('destroy');
}, // $('#bootstrap-table').bootstrapTable({
], // method:"post",
// onLoadSuccess:function(data){ // url: url,
// mergeTable(data,"table"); // pagination: true,
// search: true,
// contentType : "application/x-www-form-urlencoded",
// queryParams: {
// begin:$('#beginTime').val(),
// end:$('#endTime').val(),
// barcode:$('#barcode').val()
// },
// modalName: "条码信息查询",
// columns: [
// {
// field: 'id',
// title: '序号'
// },
// {
// field: 'barcode',
// title: '系统条码'
// },
// {
// field: 'parameaning',
// title: '参数名'
// },
// {
// field:'value',
// title:'参数值'
// }, // },
}) // ],
// })
} }
</script> </script>

@ -65,9 +65,6 @@
success: function (json) { success: function (json) {
console.log(json); console.log(json);
var columnsArray1 = []; var columnsArray1 = [];
columnsArray1.push({field : "系统条码",title : "系统条码",colspan: 1,rowspan: 1}); columnsArray1.push({field : "系统条码",title : "系统条码",colspan: 1,rowspan: 1});
columnsArray1.push({field : "semiBarcode" ,title : "产品码",colspan: 1,rowspan: 1}); columnsArray1.push({field : "semiBarcode" ,title : "产品码",colspan: 1,rowspan: 1});

@ -79,7 +79,26 @@
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-SubStation-add').serialize()); // $.operate.save(prefix + "/add", $('#form-SubStation-add').serialize());
$.ajax({
url: prefix + "/add",
type: "post",
dataType: "json",
data: $('#form-SubStation-add').serialize(),
beforeSend: function () {
$.modal.loading("正在处理中,请稍后...");
$.modal.disable();
},
success: function (result) {
// if (typeof callback == "function") {
// callback(result);
// }
console.log(result.msg);
alert(result.msg);
$.operate.successCallback(result);
}
});
} }
} }
function fillTableName() { function fillTableName() {

@ -65,7 +65,7 @@ public interface TBdSubstationMapper
List<TBdSubstation> selectOrderid(); List<TBdSubstation> selectOrderid();
void createTable(Map map); String createTable(Map map);
void updateTable(Map map); void updateTable(Map map);

@ -67,7 +67,7 @@ public interface ITBdSubstationService
List<TBdSubstation> selectOrderid(); List<TBdSubstation> selectOrderid();
void createTable(Map map); String createTable(Map map);
void updateTable(Map map); void updateTable(Map map);

@ -110,8 +110,8 @@ public class TBdSubstationServiceImpl implements ITBdSubstationService
} }
@Override @Override
public void createTable(Map map) { public String createTable(Map map) {
tBdSubstationMapper.createTable(map); return tBdSubstationMapper.createTable(map);
} }
@Override @Override

@ -64,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select top 1 * from T_BD_SubStation order by OrderID desc select top 1 * from T_BD_SubStation order by OrderID desc
</select> </select>
<select id="createTable" parameterType="map" statementType="CALLABLE" resultMap="TBdSubstationResult"> <select id="createTable" parameterType="map" statementType="CALLABLE" resultType="string">
{ {
call SP_SY_CreatStationTableByStationCode( call SP_SY_CreatStationTableByStationCode(
#{tableName,mode=IN,jdbcType=VARCHAR}, #{tableName,mode=IN,jdbcType=VARCHAR},

Loading…
Cancel
Save