需求 A表中有 设备的ID ,sbid ,以及设备名称 sbmcb 都是以字符串进行拼接。
sbid:sb123,sb567
sbmc:mc设备01,mc设备02,
B表有 dpt【代表拍摄的流程】字段,以及设备IDa,和设备名称 sbmch, 一个设备一张照片【一条数据】
dpt:朝阳东 sb123, mc设备01 ipath
dpt:朝阳西 sb567, mc设备02 ipath
给前端返回如下格式
[
{
"value": "48124", //设备的ID
"children": [ //dpt 字段
{
"value": "61",
"label": "现场"
},
{
"value": "60",
"label": "直线"
},
{
"value": "62",
"label": "寸"
},
{
"value": "63",
"label": "尺寸"
}
],
"label": "南槐接头01" //设备名称
},
{
"value": "48125",
"children": [
{
"value": "67",
"label": "w间距"
},
{
"value": "65",
"label": "绝缘"
},
{
"value": "64",
"label": "检查"
},
{
"value": "66",
"label": "间距"
}
],
"label": "南槐接头02"
},
{
"value": "0",
"label": "全部"
}
]
JdbcTemplate jdbcTemplate3 = (JdbcTemplate) ctx.getBean("CmJdbcTemplate");String sqlhwe = " select t.SBQDMC as LABELM, t.SBQD as VALUE from gw_jxjsy_jxjh t where t.id='" + rwid + "'";List<Map<String, java.lang.Object>> sqlhwelist = jdbcTemplate3.queryForList(sqlhwe);String sqlhwef = "select t.taskid from gw_jxjsy_ysrww t where t.pid='" + rwid + "'";List<Map<String, java.lang.Object>> sqlhwelistf = jdbcTemplate3.queryForList(sqlhwef);String taskid = "";for (Map<String, java.lang.Object> stringObjectMap : sqlhwelistf) {if (StringUtil.isNotEmpty((String) stringObjectMap.get("taskid"))) {taskid = (String) stringObjectMap.get("taskid");}}String sqlhw = "select t. EQUIPMENTID as sbid ,t.STEPTYPE as dpt ,t.EQUIPMENTNAME as sbmc from Gw_Dljt_Pic_Rw t where t.taskid='" + taskid + "' and t.filepath is not null and t.filepath not like '%dat%' group by t.EQUIPMENTID\n" +", STEPTYPE,EQUIPMENTNAME";List<Map<String, java.lang.Object>> listhw = jdbcTemplate3.queryForList(sqlhw);HashMap<String, java.lang.Object> quan = new HashMap<String, java.lang.Object>();List<Map<String, java.lang.Object>> list5 = new ArrayList<Map<String, java.lang.Object>>();String valuea = (String) sqlhwelist.get(0).get("VALUE");String[] split = valuea.split(",");for (int i = 0; i < split.length; i++) {HashMap<String, java.lang.Object> ma = new HashMap<String, java.lang.Object>();ArrayList<HashMap<String, java.lang.Object>> listw = new ArrayList<HashMap<String, java.lang.Object>>();for (Map<String, java.lang.Object> objectMap : listhw) {if (split[i].equals(objectMap.get("sbid"))) {HashMap<String, java.lang.Object> maw = new HashMap<String, java.lang.Object>();ma.put("value", split[i]);ma.put("label", objectMap.get("sbmc"));if ("1".equals(objectMap.get("dpt"))) {maw.put("value", "60");maw.put("label", "直线度");}if ("2".equals(objectMap.get("dpt"))) {maw.put("value", "61");maw.put("label", "现场");}if ("3".equals(objectMap.get("dpt"))) {maw.put("value", "62");maw.put("label", "尺寸");}if ("4".equals(objectMap.get("dpt"))) {maw.put("value", "63");maw.put("label", "半导电端口尺寸");}if ("5".equals(objectMap.get("dpt"))) {maw.put("value", "64");maw.put("label", "精细");}if ("6".equals(objectMap.get("dpt"))) {maw.put("value", "65");maw.put("label", "绝缘");}if ("7".equals(objectMap.get("dpt"))) {maw.put("value", "66");maw.put("label", "绝缘间距");}if ("8".equals(objectMap.get("dpt"))) {maw.put("value", "67");maw.put("label", "压接后");}if ("9".equals(objectMap.get("dpt"))) {maw.put("value", "68");maw.put("label", "压钳压模后");}if ("10".equals(objectMap.get("dpt"))) {maw.put("value", "69");maw.put("label", "应力锥");}if ("11".equals(objectMap.get("dpt"))) {maw.put("value", "70");maw.put("label", "电");}if ("12".equals(objectMap.get("dpt"))) {maw.put("value", "71");maw.put("label", "主体长度");}listw.add(maw);}ma.put("children", listw);}if (ma.size() > 0) {list5.add(ma);}}quan.put("value", "0");quan.put("label", "全部");list5.add(quan);return JSONArray.fromObject(list5).toString();