控制器
@Controller
@RequestMapping("/planQueryController")
public class PlanQeruyController extends BaseController {private static final Logger logger = LoggerFactory.getLogger(PlanQeruyController.class);@Autowiredprivate DbThekeyStationScanLogServiceI dbThekeyStationScanLogService;/*** 系统参数列表页面*/@RequestMapping(params = "list")public ModelAndView workStart(HttpServletRequest request) {return new ModelAndView("com/jeecg/planquery/planQuery");}/*** easyui AJAX请求数据* @param clockin* @param request* @param response* @param dataGrid*/@RequestMapping(params = "datagrid")public void datagrid(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();boolean flag = false;StringBuffer sql = new StringBuffer("SELECT list_id as id,ufjhdh,ufscdd_hh,zch,cxh,a.chmc,a.hgzcxmc,t.cdefine6,t.lrrq FROM [xx_tm_scgl_cyc].[dbo].[t_c_zplck] t left join [xx_tm_scgl_cyc].[dbo].[t_ch_cp_dy] a on a.chbh = t.cxh where 1=1 ");//整码String zch = request.getParameter("zch");if(StringUtils.isNotBlank(zch)) {sql.append(" and t.zch = '" + zch + "'");flag = true;}//车码String cxh = request.getParameter("cxh");if(StringUtils.isNotBlank(cxh)) {sql.append(" and cxh = '" + cxh + "'");flag = true;}//日期String sj_begin = request.getParameter("sj_begin");if(StringUtils.isNotBlank(sj_begin)) {sql.append(" and t.lrrq >= '" + sj_begin + " 00:00:00'");flag = true;}String sj_end = request.getParameter("sj_end");if(StringUtils.isNotBlank(sj_end)) {sql.append(" and t.lrrq <= '" + sj_end + " 23:59:59'");flag = true;}//排序if(StringUtils.isNotBlank(dataGrid.getSort())) {if("cdefine6".equals(dataGrid.getSort())) {sql.append(" order by t.cdefine6 "+dataGrid.getOrder());}else {sql.append(" order by "+ dataGrid.getSort() +" "+dataGrid.getOrder());}}else {sql.append(" order by t.lrrq DESC");}//有条件 就查询if(flag) {data = DynamicDBUtil.findList("sql-server2008-tm",sql.toString());}//List<Map<String, Object>> showList = null;//要显示的数据int showLen = dataGrid.getRows();//动态得到前端需要显示多少条int totlePage = data.size()%showLen == 0 ? data.size()/showLen : data.size()/showLen + 1;if(dataGrid.getPage() == 1 ) {if(showLen > data.size()) {showLen = data.size();}showList = data.subList(0, showLen);}else {if(dataGrid.getPage() == totlePage) {showList = data.subList(((dataGrid.getPage()-1)*showLen),data.size());}else {showList = data.subList(((dataGrid.getPage()-1)*showLen),((dataGrid.getPage()-1)*showLen)+showLen);}}dataGrid.setResults(showList);dataGrid.setTotal(data.size());//总条数TagUtil.datagrid(response, dataGrid);}/*** 关重件明细* @param zch* @param ufjhdh* @param ufscdd_hh* @param cxh* @param request* @param response* @param dataGrid*/@RequestMapping(params = "planQueryLineDatagrid")public void planQueryLineDatagrid(String zch,String ufjhdh,String ufscdd_hh,String cxh,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {String sql = "select mm_pickm.cpickmid, " + //备料计划订单号 "mm_pickm.vsourcebillcode, " + "mm_pickm.vsourcemorowcode " + "from jpncdb1.mm_pickm mm_pickm " + "where (mm_pickm.pk_org = '00014910000000009CH2' " + //XX公司00014910000000009CH2"AND mm_pickm.vsourcebillcode = '"+ufjhdh+"' " + //订单号 "AND mm_pickm.vsourcemorowcode = '"+ufscdd_hh+"') "+ //行号"and mm_pickm.dr = 0 ";List<Map<String, Object>> materialList = DynamicDBUtil.findList(ConstantUtil.NC_DB,sql);if(materialList.size() > 0) {Map<String, Object> material = materialList.get(0);String cpickmid = material.get("cpickmid").toString();//备料计划订单号//关重件List<Map<String, Object>> data = Lists.newArrayList();String sql2 = "select bd_material.code, " + //零部件编号"bd_material.name," + //零部件名称 "mm_pickm_b.nunituseastnum ," + //装配数量"bd_defdoc.code as work_station_code," + //工位编码 "bd_defdoc.name as work_station_name, " + //工位名称"bd_material.def1 as is_thekey " + //是否是关重件 Y 是N 不是 空 不是"from jpncdb1.mm_pickm_b mm_pickm_b " + "left join jpncdb1.bd_defdoc bd_defdoc on mm_pickm_b.vbdef1=bd_defdoc.pk_defdoc " + "left join jpncdb1.bd_material bd_material on mm_pickm_b.cbmaterialvid = bd_material.pk_material " + "where (mm_pickm_b.cpickmid = '"+cpickmid+"') " + //备料计划订单号"and mm_pickm_b.dr = 0 " ;//nc备料计划List<Map<String, Object>> partsList = DynamicDBUtil.findList(ConstantUtil.NC_DB,sql2);for (Map<String, Object> map2 : partsList) {if(map2.get("IS_THEKEY") != null && "Y".equals(map2.get("IS_THEKEY").toString()) ) {//已安装的关重件List<DbThekeyStationScanLogEntity> tsslSize = dbThekeyStationScanLogService.findHql("from DbThekeyStationScanLogEntity "+ "where vinCode=? and carTypeCode=? and thekeyCode=? ",zch,cxh,map2.get("CODE").toString());if(tsslSize !=null && tsslSize.size() > 0) {map2.put("INSTALL_COUNT",tsslSize.size());//已安装的数量}else {map2.put("INSTALL_COUNT",0);//已安装的数量}data.add(map2);}}//分页主体List<Map<String, Object>> showList = null;//要显示的数据int showLen = dataGrid.getRows();//动态得到前端需要显示多少条int totlePage = data.size()%showLen == 0 ? data.size()/showLen : data.size()/showLen + 1;if(dataGrid.getPage() == 1 ) {if(showLen > data.size()) {showLen = data.size();}showList = data.subList(0, showLen);}else {if(dataGrid.getPage() == totlePage) {showList = data.subList(((dataGrid.getPage()-1)*showLen),data.size());}else {showList = data.subList(((dataGrid.getPage()-1)*showLen),((dataGrid.getPage()-1)*showLen)+showLen);}}dataGrid.setResults(showList);dataGrid.setTotal(data.size());//总条数}TagUtil.datagrid(response, dataGrid);}}
jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true"> <div region="center" style="padding:0px;border:0px"><t:datagrid name="planQueryList" checkbox="true" pagination="true" fitColumns="true" title="生产计划" sortName="lrrq" extendParams="view: detailview,detailFormatter:detailFormatterFun,onExpandRow: onExpandRowFun" actionUrl="planQueryController.do?datagrid" idField="id" fit="true" queryMode="group"><t:dgCol title="id" field="id" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="整车号" field="zch" query="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="计划订单号" field="ufjhdh" queryMode="single" width="120"></t:dgCol><t:dgCol title="计划订单行号" field="ufscdd_hh" queryMode="single" width="120"></t:dgCol><t:dgCol title="车型号" field="cxh" queryMode="single" width="120"></t:dgCol><t:dgCol title="车型名称" field="chmc" queryMode="single" width="120"></t:dgCol><t:dgCol title="车型名称(全)" field="hgzcxmc" queryMode="single" width="120"></t:dgCol><t:dgCol title="合格证打印情况" field="cdefine6" queryMode="single" width="120"></t:dgCol> <t:dgCol title="日期" field="lrrq" formatter="yyyy-MM-dd" query="true" queryMode="group" width="120"></t:dgCol><%-- <t:dgCol title="操作" field="opt" width="100"></t:dgCol> --%><!-- 自定义查询 --><div id="planQueryListtb" style="padding: 3px; height: 25px"><div style="float: left;"><label for="zch" class="col-sm-2 control-label">整车号: </label><input type="text" id="zch" name="zch" class="ac_input"><label for="cxh" class="col-sm-2 control-label">车型号: </label><input type="text" id="cxh" name="cxh" class="ac_input"><label for="sj" class="col-sm-2 control-label">日期: </label><input id="sj_begin" name="sj_begin" autocomplete="off" type="text" style="width: 150px" class="Wdate" onClick="WdatePicker()" datatype="*" ignore="checked" value='<fmt:formatDate value='${sj_begin}' type="date" pattern="yyyy-MM-dd"/>' />~<input id="sj_end" name="sj_end" autocomplete="off" type="text" style="width: 150px" class="Wdate" onClick="WdatePicker()" datatype="*" ignore="checked" value='<fmt:formatDate value='${sj_end}' type="date" pattern="yyyy-MM-dd"/>' /></div><div align="right" class="searchColums"><a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="f_listsearch();">查询</a><a href="#" class="easyui-linkbutton" iconCls="icon-reload" onclick="searchReset('planQueryList');initjfoInfo();">重置</a></div></div></t:datagrid></div></div>//这里要引入的js 库
<script src="plug-in/easyui/extends/datagrid-detailview.js"></script><script type="text/javascript">//查询function f_listsearch(){//判断日期不能为空var sj_begin = $("#sj_begin").val();var sj_end = $("#sj_end").val();planQueryListsearch();}//返回行明细内容的格式化函数。function detailFormatterFun() {var s = '<div class="orderInfoHidden" style="padding:2px;">' + ' <div class="easyui-tabs" style="height:230px;width:850px;">' + ' <div title="关重件" style="padding:2px;">' + ' <table class="plan_query_linetablelines" ></table>' + ' </div>' + ' </div>' + ' </div>';return s;}//当展开一行时触发 function onExpandRowFun(index, row) {//把加上的子表tabs和datagrid初始化var tabs = $(this).datagrid('getRowDetail', index).find('div.easyui-tabs');tabs.tabs();var plan_query_linetablelines = $(this).datagrid('getRowDetail', index).find('table.plan_query_linetablelines');var plan_query_linedurl = 'planQueryController.do?planQueryLineDatagrid&field=code,name,nunituseastnum,INSTALL_COUNT,work_station_code,work_station_name,is_thekey&zch='+ row.zch+'&ufjhdh=' + row.ufjhdh+'&ufscdd_hh='+ row.ufscdd_hh+'&cxh='+row.cxh;plan_query_linetablelines.datagrid({singleSelect: true,loadMsg: '正在加载',fitColumns: true,height: '200',pageSize: 50,pageList: [50, 150, 200, 250, 300],border: false,url: plan_query_linedurl,idField: 'code',rownumbers: true,pagination: true,columns: [[{title: '零部件编号',field: 'code',align: 'left',width: 60},{title: '零部件名称',field: 'name',align: 'left',width: 180},{title: '应装数量',field: 'nunituseastnum',align: 'left',width: 50},{title: '装配数量',field: 'INSTALL_COUNT',align: 'left',width: 50,/* formatter:function(value,row,index){return "<a href='javascript:void(0);' onclick='ann();'>用户权限</a>";}, */styler:function(value,row,index){var s1 = 'background-color:#ecb908';//橙//应装数量不等于装配数量颜色改变if (row.nunituseastnum != value ) {return s1;}}},{title: '工位编码',field: 'work_station_code',align: 'left',width: 50},{title: '工位名称',field: 'work_station_name',align: 'left',width: 50},{title: '是否是关重件',field: 'is_thekey',align: 'left',width: 60}]]});}</script>
效果