对数据库中某字段的数据进行截取

2022/4/18 19:12:42

本文主要是介绍对数据库中某字段的数据进行截取,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1、Controller:

@GetMapping("/pisplanstatus")
public Result pisPlanStatus(String queryType) {
    Station station = getStation();
    List<GuideScreenTest> pisplanstatus = (List<GuideScreenTest>) planBriService.pisplanstatus(queryType, station.getStationName());
    for (GuideScreenTest guideScreenTest : pisplanstatus) {
        String ledName = guideScreenTest.getLedName();
        int indx = ledName.indexOf("台");
        String substring = ledName.substring(0,indx+1);
        guideScreenTest.setRegion(substring);
    }
    return Result.ok(pisplanstatus);
}

2、service:
Object pisplanstatus(String queryType, String stationName);

3、serviceImpl:

@Override
    public Object pisplanstatus(String queryType, String stationName) {
//        String sql = "SELECT device_name,ip,station,`status`,fault_state_code,device_address as region,modify_time "+
//                "FROM `guide_screen_monitoring` WHERE station=:stationName ORDER BY modify_time DESC  ";
        String sql = "SELECT gsm.device_name,gsm.ip,gsm.station,gsm.`status`,gsm.fault_state_code,gsm.device_address AS region,gsm.modify_time,rd.s_device_id "+
                " FROM guide_screen_monitoring gsm LEFT JOIN rec_device rd on gsm.ip = rd.s_ip WHERE station=:stationName ORDER BY modify_time DESC  ";
        Map<String, Object> param = new HashMap<>();
        param.put("stationName", stationName);
        List<GuideScreenTest> listBySql = planBrightnessDao.findListBySql(GuideScreenTest.class, sql, param);
    return listBySql;
}














 


这篇关于对数据库中某字段的数据进行截取的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程