mysql 数据库切片_Mysql切片保存数据

1 packagecom.cn.elec.service.impl;2 importjava.util.HashMap;3 importjava.util.List;4 importjava.util.Map;5

6 importjavax.annotation.Resource;7 importorg.springframework.stereotype.Service;8

9

10 importcom.cn.elec.dao.ElecRunCommonMsgDao;11 importcom.cn.elec.dao.IElecRunSituationDao;12 importcom.cn.elec.domain.ElecRunCommonMsg;13 importcom.cn.elec.domain.ElecRunSituation;14 importcom.cn.elec.service.ElecRunSituationService;15 importcom.cn.elec.utils.StringUtils;16

17 @Service(ElecRunSituationService.SERVICE_NAME)18 public class ElecRunSituationServiceImpl implementsElecRunSituationService {19 @Resource(name=IElecRunSituationDao.DAO_NAME)20 privateIElecRunSituationDao dao;21

22 @Resource(name=ElecRunCommonMsgDao.DAO_NAME)23 privateElecRunCommonMsgDao msg_dao;24

25

26 public voidsaveRunMeseage(ElecRunSituation entity) {27 //1. 清空碎片表里面所有的数据

28 List list=msg_dao.findCollectionByConditionNoPage("", null, null);29 msg_dao.deleteByCollection(list);30

31 //2. 将站点运行情况和设备运行情况切片

32 String station=entity.getSituationRun();33 String devRun=entity.getDevRun();34 List station_list=StringUtils.getContentByList(station, 20);35 List devRun_list=StringUtils.getContentByList(devRun, 20);36 //3. 保存切片的数据37 //保存站点的运行情况

38 for (int i = 0; i

41 msgg.setContent(station_list.get(i));42 msgg.setType("1");43 msgg.setOrderby(i+1);44 msg_dao.save(msgg);45 }46

47 //3. 保存切片的数据48 //保存站点的运行情况

49 for (int i = 0; i

52 msge.setContent(devRun_list.get(i));53 msge.setType("2");54 msge.setOrderby(i+1);55 msg_dao.save(msge);56 }57 //4. 更新或者保存ElecCommonMsg

58 dao.saveRunMeseage(entity);59 }60

61 publicElecRunSituation findRunMesage() {62 //return dao.findRunMesage();63 //1. 查询所有的切片数据(分类型查询)

64

65 String condition = " and o.type = ?";66 Object[] params = new Object[]{"1"};67 Map orderby = new HashMap();68 orderby.put("o.orderby", "asc");69 List list =

70 msg_dao.findCollectionByConditionNoPage(condition, params, orderby);71

72 String station_content = ""; //站点的运行情况

73 for(ElecRunCommonMsg content : list)74 {75 station_content = station_content +content.getContent();76 }77

78 //查询设备的运行情况

79 condition = " and o.type = ?";80 params = new Object[]{"2"};81 orderby = new HashMap();82 orderby.put("o.orderby", "asc");83 list =

84 msg_dao.findCollectionByConditionNoPage(condition, params, orderby);85

86 String dev_content = ""; //设备的运行情况

87 for(ElecRunCommonMsg content : list)88 {89 dev_content = dev_content +content.getContent();90 }91

92

93 ElecRunSituation msg =dao.findRunMesage();94 if(null !=msg)95 {96 //3. 设置站点的运行情况和设备的运行情况

97 msg.setDevRun(dev_content);98 msg.setSituationRun(station_content);99

100 returnmsg;101 }102

103 return null;104 }105 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值