pom.xml
@@ -41,14 +41,19 @@ <version>2.1.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <!--<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>3.1.2</version> </dependency> <!--<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>2.2.0</version> </dependency>--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <!--连接池--> <dependency> <groupId>com.alibaba</groupId> @@ -56,27 +61,10 @@ <version>1.1.10</version> </dependency> <!--swagger--> <!--<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency>--> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>2.0.2</version> <!--<version>2.0.6</version>--> <!--<exclusions> <exclusion> <groupId>org.springframework.plugin</groupId> <artifactId>spring-plugin-core</artifactId> </exclusion> </exclusions>--> </dependency> <!--pageHelper分页--> <dependency> src/main/java/com/fgkj/controller/BattPower_offController.java
@@ -1,15 +1,10 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.BattPower_off; import com.fgkj.dto.Batt_Maint_Dealarm; import com.fgkj.dto.ServiceModel; import com.fgkj.dto.User_inf; import com.fgkj.dto.*; import com.fgkj.services.BattPower_offService; import com.fgkj.util.ActionUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -23,9 +18,8 @@ private BattPower_offService service; @PostMapping("/") @ApiOperation(notes = "",value="新增") @ApiOperation(value="新增") public ServiceModel add(@RequestBody BattPower_off bpo) { // BattPower_off bpo = getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, BattPower_off.class); ServiceModel model = service.add(bpo); return model; @@ -33,32 +27,42 @@ } @PutMapping("/") @ApiOperation(notes = "",value="修改") @ApiOperation(value="修改") public ServiceModel update(@RequestBody BattPower_off bpo) { // BattPower_off bpo = getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, BattPower_off.class); ServiceModel model = service.update(bpo); return model; } @DeleteMapping("/") @ApiOperation(notes = "",value="删除") public ServiceModel delete(@RequestBody BattPower_off bpo) { @ApiOperation(value="删除") public ServiceModel delete(@RequestParam int devId) { // BattPower_off bpo = getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, BattPower_off.class); ServiceModel model = service.delete(bpo); ServiceModel model = service.delete(devId); return model; } //机房断电统计查询 /* * 时间段选择放在:binf的battproductdate*/ @GetMapping("byCondition") @ApiOperation(notes = "时间段选择放在:binf的battproductdate",value="机房断电统计查询") public ServiceModel serchByCondition(@RequestBody Batt_Maint_Dealarm bmd){ // Batt_Maint_Dealarm bmd = getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, Batt_Maint_Dealarm.class); /** * 时间段选择放在:binf的battproductdate * 传入参数:poweroff_starttime两个->binf.BattProductDate和BattProductDate1 * power_state->binf.num数值 历史或者实时 * stationName->binf.stationName * stationName1->binf.stationName1 * page * * */ @PostMapping("byCondition") @ApiOperation(notes = "传入参数:battProductDate(查询时间1),battProductDate1(查询时间2),num(实时为1,历史为0),stationName,stationName1, " + "pageNum,pageSize," + "其中pageNum和pageSize放在url上,其他参数放在body里",value="机房断电统计查询") public ServiceModel serchByCondition(@RequestBody BattInf battInf,@RequestParam int pageNum,@RequestParam int pageSize){ User_inf uinf=(User_inf) ActionUtil.getUser(); bmd.setUinf(uinf); ServiceModel model = service.serchByCondition(bmd); battInf.setMonNum(uinf.getuId()); PageBean pageBean = new PageBean(); pageBean.setPageNum(pageNum); pageBean.setPageSize(pageSize); ServiceModel model = service.getByCondition(battInf,pageBean); return model; } @@ -72,13 +76,14 @@ return model; } @GetMapping("all") /*@GetMapping("all") @ApiOperation(notes = "",value="all") public ServiceModel searchAll(){ ServiceModel model = service.searchAll(); return model; } }*/ src/main/java/com/fgkj/controller/BattTest_ResController.java
@@ -16,6 +16,7 @@ @RequestMapping("battTestRes") @RestController @Api(tags = "battTestRes接口") //Perry TODO public class BattTest_ResController{ @Resource @@ -33,12 +34,12 @@ List list=service.serchByCondition(bmd); return list; } //TODO //电池充放电数据管理(删除操作) @DeleteMapping("/") @ApiOperation(notes = "",value="电池充放电数据管理(删除操作)") public ServiceModel delete(@RequestBody List<BattInf> list){ // List<BattInf> list=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, new TypeToken<List<BattInf>>(){}.getType()); ServiceModel model=service.delete(list); return model; } src/main/java/com/fgkj/controller/BattresdataController.java
@@ -1,14 +1,11 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.BattInf; import com.fgkj.dto.Battresdata; import com.fgkj.dto.ServiceModel; import com.fgkj.services.BattresdataService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -16,6 +13,7 @@ @RequestMapping("battResData") @RestController @Api(tags = "battResData接口") //Perry TODO public class BattresdataController { @Resource src/main/java/com/fgkj/controller/Battresdata_infController.java
@@ -1,13 +1,10 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.Battresdata_inf; import com.fgkj.dto.ServiceModel; import com.fgkj.services.Battresdata_infService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -20,67 +17,67 @@ @Resource private Battresdata_infService service; ServiceModel model = new ServiceModel(); // private Battresdata_inf brdi; @PostMapping("/") @ApiOperation(notes = "",value="新增") public ServiceModel add(@RequestBody Battresdata_inf brdi) { model = service.add(brdi); @ApiOperation(value="新增") public ServiceModel add(@RequestBody Battresdata_inf dataInf) { ServiceModel model = service.add(dataInf); return model; } @PutMapping("/") @ApiOperation(notes = "",value="修改") public ServiceModel update(@RequestBody Battresdata_inf brdi) { model = service.update(brdi); //System.out.println(result); @ApiOperation(value="修改") public ServiceModel update(@RequestBody Battresdata_inf dataInf) { ServiceModel model = service.update(dataInf); return model; } @DeleteMapping("/") @ApiOperation(notes = "",value="删除") public ServiceModel delete(@RequestBody Battresdata_inf brdi) { model = service.delete(brdi); //System.out.println(result); @ApiOperation(value="删除") public ServiceModel delete(@RequestParam int num) { ServiceModel model = service.delete(num); return model; } @GetMapping("byCondition") @ApiOperation(notes = "",value="筛选存在battresdata_inf表中的数据") public ServiceModel serchByCondition(@RequestBody Battresdata_inf brdi) { model = service.serchByCondition(brdi); //System.out.println(result); @ApiOperation(value="筛选存在battresdata_inf表中的数据") public ServiceModel serchByCondition(@RequestBody Battresdata_inf dataInf) { ServiceModel model = service.serchByCondition(dataInf); return model; } @GetMapping("all") @ApiOperation(notes = "",value="all") @ApiOperation(value="all") public ServiceModel searchAll() { model = service.searchAll(); //System.out.println(result); ServiceModel model = service.searchAll(); return model; } //6.4.1根据条件查询符合条件的测试完成的电池组(蓄电池电导测试完成率) @GetMapping("complete") @ApiOperation(notes = "",value="条件查询符合条件的测试完成的电池组(蓄电池电导测试完成率)") public ServiceModel serchComplete(@RequestBody Battresdata_inf b){ @ApiOperation(value="条件查询符合条件的测试完成的电池组(蓄电池电导测试完成率)") public ServiceModel serchComplete(@RequestBody Battresdata_inf dataInf){ // Battresdata_inf b=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, Battresdata_inf.class); ServiceModel model=service.serchComplete(b); ServiceModel model=service.serchComplete(dataInf); return model; } //6.4.3根据条件查询符合条件的测试完成的电池组(蓄电池电导合格率) @GetMapping("serRate") @ApiOperation(notes = "",value="条件查询符合条件的测试完成的电池组(蓄电池电导合格率)") public ServiceModel serchSer(@RequestBody Battresdata_inf b){ public ServiceModel serchSer(@RequestBody Battresdata_inf dataInf){ // Battresdata_inf b=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, Battresdata_inf.class); ServiceModel model=service.serchSer(b); ServiceModel model=service.serchSer(dataInf); return model; } //6.4.3根据条件查询符合条件的测试完成的电池组(蓄电池电导合格率) @GetMapping("judge") @ApiOperation(value="judge调试") public ServiceModel judge(@RequestParam int battGroupId){ // Battresdata_inf b=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, Battresdata_inf.class); Battresdata_inf battresdata_inf = new Battresdata_inf(); battresdata_inf.setBattGroupId(battGroupId); ServiceModel model=service.judge(battresdata_inf); return model; } src/main/java/com/fgkj/controller/BatttestdataController.java
@@ -1,13 +1,10 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.Batttestdata; import com.fgkj.dto.ServiceModel; import com.fgkj.services.BatttestdataService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -18,6 +15,7 @@ @RequestMapping("battTestData") @RestController @Api(tags = "battTestData接口") //Perry TODO public class BatttestdataController{ @Resource src/main/java/com/fgkj/controller/Batttestdata_infController.java
@@ -1,7 +1,5 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.BattInf; import com.fgkj.dto.Batt_Maint_Dealarm; import com.fgkj.dto.Batttestdata_inf; @@ -9,19 +7,18 @@ import com.fgkj.services.Batttestdata_infService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.text.ParseException; import javax.annotation.Resource; import java.text.ParseException; @RequestMapping("battTestDataInf") @RestController @Api(tags = "battTestDataInf接口") //Perry TODO public class Batttestdata_infController{ ServiceModel model = new ServiceModel(); src/main/java/com/fgkj/controller/BatttestdatastopController.java
@@ -1,14 +1,11 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.Batt_Maint_Dealarm; import com.fgkj.dto.Batttestdatastop; import com.fgkj.dto.ServiceModel; import com.fgkj.services.BatttestdatastopService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -19,6 +16,7 @@ @RequestMapping("battTestDataStop") @RestController @Api(tags = "battTestDataStop接口") //Perry TODO public class BatttestdatastopController{ @Resource src/main/java/com/fgkj/controller/Cmcc_Power_DataController.java
@@ -1,14 +1,11 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.BattInf; import com.fgkj.dto.Cmcc_Power_Data; import com.fgkj.dto.ServiceModel; import com.fgkj.services.Cmcc_Power_DataService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -16,6 +13,7 @@ @RequestMapping("cmccPowerData") @RestController @Api(tags = "cmccPowerData接口") //Perry TODO public class Cmcc_Power_DataController{ @Resource src/main/java/com/fgkj/controller/Fbsdev_Statechange_infController.java
@@ -1,13 +1,10 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.Fbsdev_Statechange_inf; import com.fgkj.dto.ServiceModel; import com.fgkj.services.Fbsdev_Statechange_infService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -18,6 +15,7 @@ @RequestMapping("fbsDevStateChangeInf") @RestController @Api(tags = "fbsDevStateChangeInf接口") //Perry TODO public class Fbsdev_Statechange_infController{ @Resource src/main/java/com/fgkj/controller/PageParamController.java
@@ -1,23 +1,22 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.PageParam; import com.fgkj.dto.ServiceModel; import com.fgkj.services.PageParamService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; /** * 页面参数状态类 */ import javax.annotation.Resource; @RequestMapping("pageParam") @RestController @Api(tags = "pageParam接口") //Perry TODO public class PageParamController{ @Resource src/main/java/com/fgkj/controller/PositionMapUsrController.java
@@ -1,7 +1,5 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.Positiomap_usr; import com.fgkj.dto.ServiceModel; import com.fgkj.dto.User_inf; @@ -9,9 +7,9 @@ import com.fgkj.mapper.UinfDaoFactory; import com.fgkj.services.Positiomap_usrService; import com.fgkj.services.User_logService; import com.fgkj.util.ActionUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -19,6 +17,7 @@ @RequestMapping("positionMapUsr") @RestController @Api(tags = "positionMapUsr接口") //Perry TODO public class PositionMapUsrController{ @Resource src/main/java/com/fgkj/controller/ResDataUploadController.java
@@ -4,13 +4,13 @@ import com.fgkj.dto.ServiceModel; import com.fgkj.dto.User_inf; import com.fgkj.services.ResDataUploadService; import com.fgkj.util.*; import com.fgkj.util.ActionUtil; import com.google.gson.Gson; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpSession; import java.io.File; import java.io.FileInputStream; @@ -18,11 +18,10 @@ import java.io.IOException; import java.util.Date; import javax.annotation.Resource; @RequestMapping("resDataUpload") @RestController @Api(tags = "resDataUpload接口") //Perry TODO public class ResDataUploadController{ /*private String tableRowData; src/main/java/com/fgkj/controller/UserController.java
@@ -1,13 +1,10 @@ package com.fgkj.controller; import com.fgkj.util.*; import com.fgkj.dto.ServiceModel; import com.fgkj.dto.User; import com.fgkj.services.UserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -15,6 +12,7 @@ @RequestMapping("user") @RestController @Api(tags = "user接口") //Perry TODO public class UserController { @Resource src/main/java/com/fgkj/dto/PageBean.java
@@ -6,12 +6,12 @@ import java.util.List; @Alias("Page") public class PageBean implements Serializable{ public class PageBean<T> implements Serializable{ private Integer pageSize=6; //每页的行数 private Integer pageNum; //当前页数 private Integer totalSize; //总记录数 private Integer totalPages; //总页数 private List<Object> data; //记录列表 private List<T> data; //记录列表 private Integer pageCurr=1; //当前页码数 private Integer pageAll; //总记录数 @@ -67,11 +67,11 @@ this.pageAll = pageAll; } public List<Object> getData() { public List<T> getData() { return data; } public void setData(List<Object> data) { public void setData(List<T> data) { this.data = data; } src/main/java/com/fgkj/dto/User_inf.java
@@ -1,10 +1,10 @@ package com.fgkj.dto; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.ibatis.type.Alias; import java.io.Serializable; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; @Alias("User_inf") public class User_inf implements Serializable { private Integer uId; //主键 src/main/java/com/fgkj/mapper/impl/BattPowerOffMapper.java
New file @@ -0,0 +1,25 @@ package com.fgkj.mapper.impl; import com.fgkj.dto.BattInf; import com.fgkj.dto.BattPower_off; import com.fgkj.dto.User_inf; import java.util.List; public interface BattPowerOffMapper { /** * 机房断电统计(首页上的饼状图) * 以电池组分组 */ public int serchPowerOff(User_inf userInf); /**机房断电统计查询*/ List<BattPower_off> getByCondition(BattInf battInf); int insert(BattPower_off battPowerOff); int updateById(BattPower_off battPowerOff); int deleteById(int id); } src/main/java/com/fgkj/mapper/impl/BattPower_offMapper.java
File was deleted src/main/java/com/fgkj/mapper/impl/Battresdata_infMapper.java
@@ -1,57 +1,46 @@ package com.fgkj.mapper.impl; import java.util.List; import com.fgkj.dto.Battresdata_inf; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; import java.util.List; public interface Battresdata_infMapper{ public boolean add(Object obj); public boolean add(Battresdata_inf dataInf); public boolean update(Object obj); public boolean update(Battresdata_inf dataInf); //6.1电池充放电删除操作 public boolean del(Object obj); @Delete("delete from db_batt_testdata.tb_battresdata_inf where num=?") public boolean del(int num); //电池充/放电数据管理删除 public String delPro(Object obj); //public String delPro(Object obj); public List searchAll() ; @Select("select * from db_batt_testdata.tb_battresdata_inf") public List<Battresdata_inf> searchAll(); //1.1测试battgroupid在battresdata_inf中是否存在 public List judge(Object obj); public List<String> judge(Battresdata_inf dataInf); //battgroupid是不是存在battresdata_inf中 public List serchByCondition(Object obj); public List<Battresdata_inf> serchByCondition(Battresdata_inf dataInf); //6.2根据battgroupi和test_starttime查test_record_count public List serchTest_record_count(Object obj); public List<Battresdata_inf> serchTest_record_count(Object obj); //6.4.1根据条件查询符合条件的测试完成的电池组(蓄电池电导测试完成率) /* * data_available 中存放层次 */ public List serchComplete(Object obj); public List<Integer> serchComplete(Battresdata_inf dataInf); //6.4.3根据条件查询符合条件的测试完成的电池组(蓄电池电导合格率) /* * data_available 中存放层次 */ public List serchSer(Object obj); /*public static void main(String[] args) { Battresdata_infDAOImpl bstd=new Battresdata_infDAOImpl(); Battresdata_inf bst=new Battresdata_inf(); bst.setTest_record_count(1); List<Battresdata_inf> list=bstd.serchByCondition(bst); System.out.println(list.size()); for(Battresdata_inf b:list){ System.out.println(b); } // List<Battresdata_inf> list=bstd.searchAll(); // for(Battresdata_inf b:list){ // System.out.println(b); // } }*/ public List<Battresdata_inf> serchSer(Battresdata_inf dataInf); } src/main/java/com/fgkj/services/BattPower_offService.java
@@ -1,99 +1,82 @@ package com.fgkj.services; import com.fgkj.dto.Batt_Maint_Dealarm; import com.fgkj.dto.ServiceModel; import com.fgkj.dto.*; import com.fgkj.mapper.impl.BattInfMapper; import com.fgkj.mapper.impl.BattPower_offMapper; import org.springframework.beans.factory.annotation.Autowired; import com.fgkj.mapper.impl.BattPowerOffMapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.HashMap; import java.util.List; import javax.annotation.Resource; @Service public class BattPower_offService { ServiceModel model = new ServiceModel(); @Resource private BattPowerOffMapper mapper; @Resource private BattInfMapper battInfMapper; @Resource private BattPower_offMapper mapper; @Resource private BattInfMapper battInfMapper; public ServiceModel add(BattPower_off battPowerOff) { ServiceModel model = new ServiceModel(); int flag = mapper.insert(battPowerOff); if (flag > 0) { model.setCode(1); model.setMsg("添加成功!"); } else { model.setMsg("添加失败!"); } return model; public ServiceModel add(Object obj) { Boolean bl=mapper.add(obj); if(bl){ model.setCode(1); model.setMsg("添加成功!"); } else{ model.setMsg("添加失败!"); } return model; } public ServiceModel update(Object obj) { Boolean bl=mapper.update(obj); if(bl){ model.setCode(1); model.setMsg("修改成功!"); } else{ model.setMsg("修改失败!"); } return model; } public ServiceModel delete(Object obj) { Boolean bl=mapper.del(obj); if(bl){ model.setCode(1); model.setMsg("删除成功!"); } else{ model.setMsg("删除失败!"); } return model; } //机房断电统计查询 /* * 时间段选择放在:binf的battproductdate*/ public ServiceModel serchByCondition(Batt_Maint_Dealarm obj){ List list=mapper.serchByCondition(obj); if(list!=null && list.size()>0){ model.setCode(1); model.setData(list); model.setMsg("查询成功!"); }else{ model.setCode(0); model.setMsg("查询失败!"); } return model; } //机房断电统计(首页上的饼状图) public ServiceModel serchPowerOff(Object obj){ int powerNum=mapper.serchPowerOff(obj); //断电实时数 int devNum=battInfMapper.serchByDeviceId(obj); //总设备数 //TODO perry // model.setSum(powerNum); // model.setNewsum(devNum); return model; } public ServiceModel searchAll(){ List list=mapper.searchAll(); for (Object object : list) { System.out.println(object); } //System.out.println(list); if(list!=null && list.size()>0){ model.setCode(1); model.setData(list); } System.out.println(model); return model; } public ServiceModel update(BattPower_off battPowerOff) { ServiceModel model = new ServiceModel(); int flag = mapper.updateById(battPowerOff); if (flag > 0) { model.setCode(1); model.setMsg("修改成功!"); } else { model.setMsg("修改失败!"); } return model; } public ServiceModel delete(int id) { ServiceModel model = new ServiceModel(); int flag = mapper.deleteById(id); if (flag > 0) { model.setCode(1); model.setMsg("删除成功!"); } else { model.setMsg("删除失败!"); } return model; } //机房断电统计查询 public ServiceModel getByCondition(BattInf battInf, PageBean page) { PageHelper.startPage(page.getPageNum(), page.getPageSize(), true); List<BattPower_off> powerOffs = mapper.getByCondition(battInf); PageInfo<BattPower_off> pageInfo = new PageInfo<>(powerOffs); return new ServiceModel().set(1,pageInfo); } //机房断电统计(首页上的饼状图) public ServiceModel serchPowerOff(User_inf userInf) { int powerNum = mapper.serchPowerOff(userInf); //断电实时数 int devNum = battInfMapper.serchByDeviceId(userInf); //总设备数 //TODO perry // model.setSum(powerNum); // model.setNewsum(devNum); HashMap<String, Integer> map = new HashMap<>(); map.put("powerNum",powerNum); map.put("devNum",devNum); return new ServiceModel().set(1,map); } } src/main/java/com/fgkj/services/BattTest_ResService.java
@@ -3,7 +3,6 @@ import com.fgkj.dto.*; import com.fgkj.mapper.AlarmDaoFactory; import com.fgkj.mapper.TestDaoFactory; import com.fgkj.mapper.UinfDaoFactory; import com.fgkj.mapper.impl.*; import com.fgkj.util.ActionUtil; import org.springframework.stereotype.Service; @@ -135,9 +134,12 @@ //System.out.println(listall.size()); return listall; } //6.1电池充放电删除操作 /** * 6.1电池充放电删除操作 * 暂时不做,后续对接前端再沟通实现 */ public ServiceModel delete(Object obj){ List<BattInf> list=(List<BattInf>) obj; /*List<BattInf> list=(List<BattInf>) obj; ArrayList<String> sql_str = new ArrayList<String>();//存放所有的sql语句 List<User_log> listU=new ArrayList();//存放user_log if(list!=null&&list.size()>0){ @@ -191,7 +193,6 @@ } } // Boolean bl=DateUtil.makeManualCommit(DBUtil.getConn(), sql_str); //TODO perry待做 Boolean bl=true; new User_logService().addPro(listU);//将用户的操作记录下来 @@ -203,7 +204,8 @@ model.setCode(0); model.setMsg("删除失败!"); } return model; return model;*/ return null; } public static void main(String[] args) throws ParseException { src/main/java/com/fgkj/services/Battresdata_infService.java
@@ -7,14 +7,13 @@ import com.fgkj.mapper.impl.BattInfMapper; import com.fgkj.mapper.impl.BattresdataMapper; import com.fgkj.mapper.impl.Battresdata_infMapper; import com.fgkj.util.*; import org.springframework.beans.factory.annotation.Autowired; import com.fgkj.util.ActionUtil; import com.fgkj.util.DateUtil; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.text.ParseException; import java.util.List; import javax.annotation.Resource; @Service public class Battresdata_infService { @@ -28,8 +27,8 @@ private BattresdataMapper battResDataMapper; public ServiceModel add(Object obj) { Boolean bl = mapper.add(obj); public ServiceModel add(Battresdata_inf dataInf) { Boolean bl = mapper.add(dataInf); if (bl) { model.setCode(1); model.setMsg("添加成功!"); @@ -40,8 +39,8 @@ } public ServiceModel update(Object obj) { Boolean bl = mapper.update(obj); public ServiceModel update(Battresdata_inf dataInf) { Boolean bl = mapper.update(dataInf); if (bl) { model.setCode(1); model.setMsg("修改成功!"); @@ -51,8 +50,8 @@ return model; } public ServiceModel delete(Object obj) { Boolean bl = mapper.del(obj); public ServiceModel delete(int num) { Boolean bl = mapper.del(num); if (bl) { model.setCode(1); model.setMsg("删除成功!"); @@ -63,9 +62,9 @@ } //筛选存在battresdata_inf表中的数据 public ServiceModel serchByCondition(Object obj){ public ServiceModel serchByCondition(Battresdata_inf dataInf){ model=new ServiceModel(); List list=mapper.serchByCondition(obj); List list=mapper.serchByCondition(dataInf); if(list!=null && list.size()>0){ model.setCode(1); model.setData(list); @@ -77,9 +76,9 @@ return model; } //测试battgroupid在battresdata_inf中是否存在 public ServiceModel judge(Object obj){ public ServiceModel judge(Battresdata_inf dataInf){ model=new ServiceModel(); List<String> list=mapper.judge(obj); List<String> list=mapper.judge(dataInf); if(list!=null && list.size()>0){ model.setCode(1); model.setData(list); @@ -92,10 +91,6 @@ //查询所有 public ServiceModel searchAll() { List<Battresdata_inf> list = mapper.searchAll(); // for (Battresdata_inf u : list) { // System.out.println(u); // } // System.out.println(list); if (list != null && list.size() > 0) { model.setCode(1); model.setData(list); @@ -109,71 +104,65 @@ * test_record_count_ex中存放统计季度:一季度为1 以此类推 * test_type 中存放年份 * upload_usr_id 中存上传方式 100:全部 0:自动上传 用户ID对应手动上传*/ public ServiceModel serchComplete(Object obj){ Battresdata_inf rinf=(Battresdata_inf) obj; int level=rinf.getData_available(); int year=rinf.getTest_type();//获取年份 public ServiceModel serchComplete(Battresdata_inf dataInf){ int level=dataInf.getData_available(); int year=dataInf.getTest_type();//获取年份 int firstMonth=0;//获取起始月份 int lastMonth=0;//获取结束月份 String dateFirst=""; //起始时间 String dateLast=""; //结束时间 //做时间判断 if(rinf.getTest_record_count()==0){ if(dataInf.getTest_record_count()==0){ firstMonth=0;//获取起始月份 lastMonth=11;//获取结束月份 }else if(rinf.getTest_record_count()==1){ if(rinf.getTest_record_count_ex()==1){ }else if(dataInf.getTest_record_count()==1){ if(dataInf.getTest_record_count_ex()==1){ firstMonth=0;//获取起始月份 lastMonth=2;//获取结束月份 }else if(rinf.getTest_record_count_ex()==2){ }else if(dataInf.getTest_record_count_ex()==2){ firstMonth=3;//获取起始月份 lastMonth=5;//获取结束月份 }else if(rinf.getTest_record_count_ex()==3){ }else if(dataInf.getTest_record_count_ex()==3){ firstMonth=6;//获取起始月份 lastMonth=8;//获取结束月份 }else if(rinf.getTest_record_count_ex()==4){ }else if(dataInf.getTest_record_count_ex()==4){ firstMonth=9;//获取起始月份 lastMonth=11;//获取结束月份 } } dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间 try { rinf.setTest_starttime(DateUtil.sdf.parse(dateFirst)); //System.out.println(dateFirst.substring(0,10)); dataInf.setTest_starttime(DateUtil.sdf.parse(dateFirst)); dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间 rinf.setTest_starttime_ex(DateUtil.sdf.parse(dateLast)); dataInf.setTest_starttime_ex(DateUtil.sdf.parse(dateLast)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } //System.out.println(dateLast.substring(0,10)); //System.out.println(dateFirst.substring(0,11).concat(dateLast.substring(0,10))); List<BattInf> listB=battInfMapper.serchBylevel(level); if(listB!=null&&listB.size()>0){ for(int i=0;i<listB.size();i++){ if(level==1){ rinf.setStationname1(listB.get(i).getStationName1()); rinf.setStationname2(""); rinf.setStationname3(""); rinf.setStationname4(""); dataInf.setStationname1(listB.get(i).getStationName1()); dataInf.setStationname2(""); dataInf.setStationname3(""); dataInf.setStationname4(""); }else if(level==2){ rinf.setStationname1(listB.get(i).getStationName1()); rinf.setStationname2(listB.get(i).getStationName2()); rinf.setStationname3(""); rinf.setStationname4(""); dataInf.setStationname1(listB.get(i).getStationName1()); dataInf.setStationname2(listB.get(i).getStationName2()); dataInf.setStationname3(""); dataInf.setStationname4(""); }else if(level==3){ rinf.setStationname1(listB.get(i).getStationName1()); rinf.setStationname2(listB.get(i).getStationName2()); rinf.setStationname3(listB.get(i).getStationName3()); rinf.setStationname4(""); dataInf.setStationname1(listB.get(i).getStationName1()); dataInf.setStationname2(listB.get(i).getStationName2()); dataInf.setStationname3(listB.get(i).getStationName3()); dataInf.setStationname4(""); }else if(level==4){ rinf.setStationname1(listB.get(i).getStationName1()); rinf.setStationname2(listB.get(i).getStationName2()); rinf.setStationname3(listB.get(i).getStationName3()); rinf.setStationname4(listB.get(i).getStationName4()); dataInf.setStationname1(listB.get(i).getStationName1()); dataInf.setStationname2(listB.get(i).getStationName2()); dataInf.setStationname3(listB.get(i).getStationName3()); dataInf.setStationname4(listB.get(i).getStationName4()); } List<Battresdata_inf> list=mapper.serchComplete(rinf); List<Integer> list=mapper.serchComplete(dataInf); listB.get(i).setMonCount(list.size());//完成数 listB.get(i).setStationName9(dateFirst.substring(0,11).concat(dateLast.substring(0,10))); if(listB.get(i).getMonNum()!=0){ @@ -202,39 +191,38 @@ * test_record_count 中存放统计方式:年度统计为0 季度统计为1 * test_record_count_ex中存放统计季度:一季度为1 以此类推 * test_type 中存放年份*/ public ServiceModel serchSer(Object obj) { Battresdata_inf rinf=(Battresdata_inf) obj; int level=rinf.getData_available(); int year=rinf.getTest_type();//获取年份 public ServiceModel serchSer(Battresdata_inf dataInf) { int level=dataInf.getData_available(); int year=dataInf.getTest_type();//获取年份 int firstMonth=0;//获取起始月份 int lastMonth=0;//获取结束月份 String dateFirst=""; //起始时间 String dateLast=""; //结束时间 //做时间判断 if(rinf.getTest_record_count()==0){ if(dataInf.getTest_record_count()==0){ firstMonth=0;//获取起始月份 lastMonth=11;//获取结束月份 }else if(rinf.getTest_record_count()==1){ if(rinf.getTest_record_count_ex()==1){ }else if(dataInf.getTest_record_count()==1){ if(dataInf.getTest_record_count_ex()==1){ firstMonth=0;//获取起始月份 lastMonth=2;//获取结束月份 }else if(rinf.getTest_record_count_ex()==2){ }else if(dataInf.getTest_record_count_ex()==2){ firstMonth=3;//获取起始月份 lastMonth=5;//获取结束月份 }else if(rinf.getTest_record_count_ex()==3){ }else if(dataInf.getTest_record_count_ex()==3){ firstMonth=6;//获取起始月份 lastMonth=8;//获取结束月份 }else if(rinf.getTest_record_count_ex()==4){ }else if(dataInf.getTest_record_count_ex()==4){ firstMonth=9;//获取起始月份 lastMonth=11;//获取结束月份 } } dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间 try { rinf.setTest_starttime(DateUtil.sdf.parse(dateFirst)); dataInf.setTest_starttime(DateUtil.sdf.parse(dateFirst)); //System.out.println(dateFirst.substring(0,10)); dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间 rinf.setTest_starttime_ex(DateUtil.sdf.parse(dateLast)); dataInf.setTest_starttime_ex(DateUtil.sdf.parse(dateLast)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -244,29 +232,29 @@ if(listB!=null&&listB.size()>0){ for(int i=0;i<listB.size();i++){ if(level==1){ rinf.setStationname1(listB.get(i).getStationName1()); rinf.setStationname2(""); rinf.setStationname3(""); rinf.setStationname4(""); dataInf.setStationname1(listB.get(i).getStationName1()); dataInf.setStationname2(""); dataInf.setStationname3(""); dataInf.setStationname4(""); }else if(level==2){ rinf.setStationname1(listB.get(i).getStationName1()); rinf.setStationname2(listB.get(i).getStationName2()); rinf.setStationname3(""); rinf.setStationname4(""); dataInf.setStationname1(listB.get(i).getStationName1()); dataInf.setStationname2(listB.get(i).getStationName2()); dataInf.setStationname3(""); dataInf.setStationname4(""); }else if(level==3){ rinf.setStationname1(listB.get(i).getStationName1()); rinf.setStationname2(listB.get(i).getStationName2()); rinf.setStationname3(listB.get(i).getStationName3()); rinf.setStationname4(""); dataInf.setStationname1(listB.get(i).getStationName1()); dataInf.setStationname2(listB.get(i).getStationName2()); dataInf.setStationname3(listB.get(i).getStationName3()); dataInf.setStationname4(""); }else if(level==4){ rinf.setStationname1(listB.get(i).getStationName1()); rinf.setStationname2(listB.get(i).getStationName2()); rinf.setStationname3(listB.get(i).getStationName3()); rinf.setStationname4(listB.get(i).getStationName4()); dataInf.setStationname1(listB.get(i).getStationName1()); dataInf.setStationname2(listB.get(i).getStationName2()); dataInf.setStationname3(listB.get(i).getStationName3()); dataInf.setStationname4(listB.get(i).getStationName4()); } listB.get(i).setStationName9(dateFirst.substring(0,11).concat(dateLast.substring(0,10))); Float monSerStd=0f;//标存电导 List<Battresdata_inf> list=mapper.serchSer(rinf); List<Battresdata_inf> list=mapper.serchSer(dataInf); int numC=0;//已完成个数总数 int numQ=0;//80%合格个数总数 if(list!=null&&list.size()>0){ @@ -308,15 +296,4 @@ return model; } public static void main(String[] args) { Battresdata_infService brids = new Battresdata_infService(); Battresdata_inf brid = new Battresdata_inf(); brid.setTest_record_count(1); // brids.serchByCondition(brid); //brids.searchAll(); Battresdata_inf brsdata=new Battresdata_inf(); brsdata.setBattGroupId(1002561); brids.serchByCondition(brsdata); } } src/main/resources/application.yml
@@ -1,6 +1,6 @@ #服务端口号 server: port: 8080 port: 8090 #数据库 spring: @@ -8,8 +8,8 @@ type: com.alibaba.druid.pool.DruidDataSource # driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://localhost:3360/db_user?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true url: jdbc:mysql://192.168.10.222:3360/db_user?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&useSSL=false url: jdbc:mysql://localhost:3360/db_user?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true # url: jdbc:mysql://192.168.10.222:3360/db_user?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&useSSL=false # url: jdbc:mysql://118.89.139.230:3360/db_user?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true username: root password: lmx8688139 @@ -21,8 +21,8 @@ mybatis: #mybatis-plus: type-aliases-package: com.fgkj.dto # mapper-locations: classpath:mapper/**/*Mapper.xml,classpath:mapper/*Mapper.xml mapper-locations: classpath:mapper/**/*Mapper.xml mapper-locations: classpath:mapper/**/*Mapper.xml,classpath:mapper/*Mapper.xml #mapper-locations: classpath:mapper/**/*Mapper.xml configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #pageHelper src/main/resources/mapper/BattInfMapper.xml
@@ -4442,7 +4442,13 @@ <!-- <select id="serchByMonVolStd" resultType="java.util.List"></select>--> <!-- <select id="serchByMonCapStd" resultType="java.util.List"></select>--> <select id="serchByBattGroupName1" resultType="java.util.List"></select> <select id="serchByDeviceId" resultType="java.lang.Integer"></select> <select id="serchByDeviceId" resultType="java.lang.Integer"> SELECT COUNT(DISTINCT fbsdeviceid) number FROM db_battinf.tb_battinf left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId left outer join db_user.tb_user_battgroup_baojigroup_usr on db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id left outer join db_user.tb_user_inf on tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid where db_user.tb_user_inf.uid=#{uId} limit 1 </select> <!-- <select id="serchByMonNum" resultType="java.util.List"></select>--> <!-- <select id="serchByBattgroupId" resultType="java.util.List"></select>--> <!-- <select id="serchByCondition" resultType="java.util.List"></select>--> src/main/resources/mapper/BattPowerOffMapper.xml
@@ -1,163 +1,46 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.fgkj.mapper.impl.BattPower_offMapper" > <resultMap id="BaseResultMap" type="Batt_Maint_Dealarm"> <association property="mainf"> <mapper namespace="com.fgkj.mapper.impl.BattPowerOffMapper"> <insert id="insert"> insert into web_site.tb_battpower_off values(#{num},#{dev_id},#{record_count},#{poweroff_starttime},#{poweroff_stoptime},#{timelong},#{power_state},#{note},#{stationName},#{stationName1}) </insert> <update id="updateById"> update web_site.tb_battpower_off set num=#{num},record_count=#{record_count},poweroff_starttime=#{poweroff_starttime},poweroff_stoptime=#{poweroff_stoptime},timelong=#{timelong}, power_state=#{power_state},note=#{note},stationName=#{stationName},stationName1=#{stationName1} where dev_id=#{dev_id} </update> <delete id="deleteById"> delete from web_site.tb_battpower_off where dev_id=#{id} </delete> </association> <association property="binf"> </association> <!-- 参数名不一致--> <association property="pageBean"> </association> <association property="uinf"> </association> </resultMap> <!-- public boolean add(Object obj) { return false; } public boolean update(Object obj) { return false; } public boolean del(Object obj) { return false; } public List searchAll() { return null; } //机房断电统计查询 /* * 时间段选择放在:binf的battproductdate * 状态:binf的num中*/ public List serchByCondition(Object obj) { Batt_Maint_Dealarm bmd=(Batt_Maint_Dealarm) obj; BattInf binf=bmd.getBinf(); Page pageBean=bmd.getPage(); User_inf uinf=bmd.getUinf(); Connection conn=DBUtil.getConn(); String numberSql=" SELECT FOUND_ROWS() number"; String sql=" SELECT SQL_CALC_FOUND_ROWS DISTINCT tb_battpower_off.dev_id,poweroff_starttime,poweroff_stoptime,timelong,power_state,note" + ",db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.StationName1 " + " FROM web_site.tb_battpower_off,db_battinf.tb_battinf " + " WHERE tb_battpower_off.dev_id=db_battinf.tb_battinf.FBSDeviceId " + " AND db_battinf.tb_battinf.StationName LIKE ? " + " AND poweroff_starttime>=? " + " AND poweroff_starttime<=? "; //实时还是历史 String stateSqlT=" AND power_state=? "; String stateSqlF=" AND power_state!=? "; if(binf.getNum()==100){ sql+=stateSqlF; }else{ sql+=stateSqlT; } //判断是否为管理的机房 String stationSql=" and db_battinf.tb_battinf.StationId in(select distinct db_battinf.tb_battinf.stationId " + " from db_battinf.tb_battinf " + " left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.stationid=db_battinf.tb_battinf.stationid " + " left outer join db_user.tb_user_battgroup_baojigroup_usr on db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id " + " left outer join db_user.tb_user_inf on tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid " + " where db_user.tb_user_inf.uid=? and db_battinf.tb_battinf.stationname1 like ? ) "; sql+=stationSql; //分页 String limitSql=" limit ?,?"; sql+=limitSql; List<BattPower_off> list = DateUtil.executeQueryLimit(sql, conn, new Object[]{"%"+binf.getStationName()+"%",binf.getBattProductDate(),binf.getBattProductDate1() ,binf.getNum(),uinf.getuId(),"%"+binf.getStationName1()+"%",(pageBean.getPageCurr() - 1)*pageBean.getPageSize(), pageBean.getPageSize()}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ BattPower_off bpoff=new BattPower_off(); bpoff.setDev_id(rs.getInt("dev_id")); bpoff.setPoweroff_starttime(rs.getTimestamp("poweroff_starttime")); bpoff.setPoweroff_stoptime(rs.getTimestamp("poweroff_stoptime")); bpoff.setPower_state(rs.getInt("power_state")); bpoff.setTimelong(rs.getInt("timelong")); bpoff.setStationName(rs.getString("stationName")); bpoff.setStationName1(rs.getString("stationName1")); bpoff.setNote(rs.getString("note")); list.add(bpoff); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } }); //去掉limit条件后的总数 int number=LimitNumberFactory.GetLimtitNumber(conn, numberSql); if(list!=null && list.size() > 0){ list.get(list.size()-1).setNum(number); } return list; } //机房断电统计(首页上的饼状图) /*以电池组分组*/ public int serchPowerOff(Object obj){ User_inf uinf=(User_inf) obj; String sql=""; String baseSql=" SELECT COUNT(DISTINCT dev_id) AS number FROM web_site.tb_battpower_off " + " WHERE dev_id in( " + " select distinct db_battinf.tb_battinf.fbsdeviceid " + " from db_battinf.tb_battinf,db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr,db_user.tb_user_inf " + " where db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId " + " and db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id " + " and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid " + " and db_user.tb_user_inf.uid=? ) "; //电池断电状态:实时 String stateSql=" AND power_state=0 limit 1"; sql=baseSql+stateSql; List<BattPower_off> list=DateUtil.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getuId()}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ BattPower_off bpoff=new BattPower_off(); bpoff.setNum(rs.getInt("number")); list.add(bpoff); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } }); int number=0;//存放总数 if(list!=null&&list.size()>0){ number=list.get(list.size()-1).getNum(); } return number; } --> <insert id="add"></insert> <update id="update"></update> <delete id="del"></delete> <select id="searchAll" resultType="java.util.List"></select> <select id="serchByCondition" resultMap="BaseResultMap"> <select id="serchPowerOff" resultType="java.lang.Integer"> SELECT COUNT(DISTINCT dev_id) AS number FROM web_site.tb_battpower_off WHERE dev_id in( select distinct db_battinf.tb_battinf.fbsdeviceid from db_battinf.tb_battinf,db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr,db_user.tb_user_inf where db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId and db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid and db_user.tb_user_inf.uid=#{uId} ) AND power_state=0 limit 1 </select> <select id="serchPowerOff" resultType="java.lang.Integer"></select> <!--<select id="getByCondition" resultMap="Map_BattPowerOff">--> <select id="getByCondition" resultType="BattPower_off"> SELECT DISTINCT tb_battpower_off.dev_id,poweroff_starttime,poweroff_stoptime,timelong,power_state,note ,db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.StationName1 FROM web_site.tb_battpower_off,db_battinf.tb_battinf WHERE tb_battpower_off.dev_id=db_battinf.tb_battinf.FBSDeviceId AND db_battinf.tb_battinf.StationName LIKE concat('%',#{stationName},'%') AND poweroff_starttime <![CDATA[>=]]> #{battProductDate} AND poweroff_starttime <![CDATA[<=]]> #{battProductDate1} AND power_state=#{num} and db_battinf.tb_battinf.StationId in(select distinct db_battinf.tb_battinf.stationId from db_battinf.tb_battinf left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.stationid=db_battinf.tb_battinf.stationid left outer join db_user.tb_user_battgroup_baojigroup_usr on db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id left outer join db_user.tb_user_inf on tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid where db_user.tb_user_inf.uid=#{monNum} and db_battinf.tb_battinf.stationname1 like concat('%',#{stationName1},'%') ) </select> </mapper> src/main/resources/mapper/BattResDataInfMapper.xml
@@ -2,247 +2,45 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.fgkj.mapper.impl.Battresdata_infMapper" > <!-- public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ Battresdata_inf b=new Battresdata_inf(); b.setNum(rs.getInt("num")); b.setBattGroupId(rs.getInt("BattGroupId")); b.setTest_record_count(rs.getInt("test_record_count")); b.setTest_record_count_ex(rs.getInt("test_record_count_ex")); b.setTest_type(rs.getInt("test_type")); b.setData_new(rs.getFloat("data_new")); b.setData_available(rs.getInt("data_available")); b.setTest_starttime(rs.getTimestamp("test_starttime")); b.setTest_starttime_ex(rs.getTimestamp("test_starttime_ex")); b.setTest_devtype(rs.getInt("test_devtype")); b.setRecord_time(rs.getTimestamp("record_time")); b.setGroup_vol(rs.getFloat("group_vol")); b.setTest_curr(rs.getFloat("test_curr")); b.setUpload_usr_id(rs.getInt("upload_usr_id")); list.add(b); //System.out.println(b); } } catch (SQLException e) { e.printStackTrace(); } return list; } public boolean add(Object obj) { Battresdata_inf binf=(Battresdata_inf) obj; String sql="insert into db_batt_testdata.tb_battresdata_inf(BattGroupId,test_record_count,test_record_count_ex,test_type,data_new,data_available,test_starttime,test_starttime_ex,test_devtype,record_time,group_vol," + "test_curr,upload_usr_id) values(?,?,?,?,?,?,?,?,?,?,?,?,?)"; Boolean bl=DateUtil.executeUpdate(DBUtil.getConn(), sql, new Object[]{binf.getBattGroupId(),binf.getTest_record_count(),binf.getTest_record_count_ex(), binf.getTest_type(),binf.getData_new(),binf.getData_available(),binf.getTest_starttime(),binf.getTest_starttime_ex(),binf.getTest_devtype(),binf.getRecord_time(),binf.getGroup_vol(), binf.getTest_curr(),binf.getUpload_usr_id()}); return bl; } public boolean update(Object obj) { Battresdata_inf binf=(Battresdata_inf) obj; String sql="update db_batt_testdata.tb_battresdata_inf set BattGroupId=?,test_record_count=?,test_record_count_ex=?,test_type=?,data_new=?,data_available=?,test_starttime=?,test_starttime_ex=?,test_devtype=?,record_time=?,group_vol=?," + "test_curr=?,upload_usr_id=? where num=?"; Boolean bl=DateUtil.executeUpdate(DBUtil.getConn(), sql, new Object[]{binf.getBattGroupId(),binf.getTest_record_count(),binf.getTest_record_count_ex(), binf.getTest_type(),binf.getData_new(),binf.getData_available(),binf.getTest_starttime(),binf.getTest_starttime_ex(),binf.getTest_devtype(),binf.getRecord_time(),binf.getGroup_vol(), binf.getTest_curr(),binf.getUpload_usr_id(),binf.getNum()}); return bl; } //6.1电池充放电删除操作 public boolean del(Object obj) { Battresdata_inf rinf=(Battresdata_inf) obj; String sql="delete from db_batt_testdata.tb_battresdata_inf where num=?"; Boolean bl=DateUtil.executeUpdate(DBUtil.getConn(), sql, new Object[]{rinf.getNum()}); return bl; } //电池充/放电数据管理删除 public String delPro(Object obj) { Battresdata_inf rinf=(Battresdata_inf) obj; String sql="delete from db_batt_testdata.tb_battresdata_inf where num="+rinf.getNum(); return sql; } public List searchAll() { String sql="select * from db_batt_testdata.tb_battresdata_inf"; // System.out.println(sql); List list=DateUtil.executeQuery(sql, DBUtil.getConn(), null, new Battresdata_infDAOImpl()); return list; } //1.1测试battgroupid在battresdata_inf中是否存在 public List judge(Object obj){ Battresdata_inf bti=(Battresdata_inf)obj; String sql="select table_name from `INFORMATION_SCHEMA`.`TABLES` " + "where table_name ='tb_battresdata_"+bti.getBattGroupId()+"'and TABLE_SCHEMA='db_batt_testdata'"; return DateUtil.executeQuery(sql, DBUtil.getConn(), null, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ String name=rs.getString("table_name"); list.add(name); //System.out.println(binf); } } catch (SQLException e) { e.printStackTrace(); } return list; } }); } //battgroupid是不是存在battresdata_inf中 public List serchByCondition(Object obj) { Battresdata_inf btd=(Battresdata_inf)obj; String sql="select num,BattGroupId,test_record_count,test_record_count_ex,test_type,data_new,data_available,test_starttime,test_starttime_ex,test_devtype,record_time,group_vol,test_curr,upload_usr_id from db_batt_testdata.tb_battresdata_inf" + " where battgroupid=?"; // System.out.println(sql); return DateUtil.executeQuery(sql, DBUtil.getConn(), new Object[]{btd.getBattGroupId()}, new Battresdata_infDAOImpl()); } //6.2根据battgroupi和test_starttime查test_record_count public List serchTest_record_count(Object obj) { Battresdata_inf rinf=(Battresdata_inf)obj; String sql="select test_record_count " + "from db_batt_testdata.tb_battresdata_inf where BattGroupId=? and (test_starttime)=(?) "; return DateUtil.executeQuery(sql, DBUtil.getConn(), new Object[]{rinf.getBattGroupId(),rinf.getTest_starttime()}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ Battresdata_inf rinf=new Battresdata_inf(); rinf.setTest_record_count(rs.getInt("test_record_count")); list.add(rinf); //System.out.println(rinf); } } catch (SQLException e) { e.printStackTrace(); } return list; } }); } //6.4.1根据条件查询符合条件的测试完成的电池组(蓄电池电导测试完成率) /* * data_available 中存放层次 */ public List serchComplete(Object obj){ Battresdata_inf rinf=(Battresdata_inf) obj; String sql=""; String baseSql="select distinct(tb_battresdata_inf.battgroupid) from db_batt_testdata.tb_battresdata_inf,db_battinf.tb_battinf " + "where tb_battresdata_inf.BattGroupId=db_battinf.tb_battinf.BattGroupId " + "and (test_starttime)>=(?) and (test_starttime)<=(?) "; //上传方式 String usrSqlT="and upload_usr_id!=? " ; String usrSqlU="and upload_usr_id!=0 and upload_usr_id!=? " ; String usrSqlF="and upload_usr_id=? " ; if(rinf.getUpload_usr_id()==100){//全部 baseSql+=usrSqlT; }else{ if(rinf.getUpload_usr_id()==0){ baseSql+=usrSqlF; }else{ baseSql+=usrSqlU; } } String levelSql=" and db_battinf.tb_battinf.stationname4 like ? and db_battinf.tb_battinf.stationname3 like ? and db_battinf.tb_battinf.stationname2 like ? and db_battinf.tb_battinf.stationname1 like ? ";//分组层次 sql=baseSql+levelSql; //System.out.println(sql); List list=DateUtil.executeQuery(sql, DBUtil.getConn(), new Object[]{rinf.getTest_starttime(),rinf.getTest_starttime_ex(),rinf.getUpload_usr_id(),"%"+rinf.getStationname4()+"%","%"+rinf.getStationname3()+"%","%"+rinf.getStationname2()+"%","%"+rinf.getStationname1()+"%"}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ Battresdata_inf rinf=new Battresdata_inf(); rinf.setBattGroupId(rs.getInt("battGroupId")); list.add(rinf); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } }); return list; } //6.4.3根据条件查询符合条件的测试完成的电池组(蓄电池电导合格率) /* * data_available 中存放层次 */ public List serchSer(Object obj){ Battresdata_inf rinf=(Battresdata_inf) obj; String sql=""; String baseSql="select distinct(tb_battresdata_inf.battgroupid),test_starttime,test_record_count from db_batt_testdata.tb_battresdata_inf,db_battinf.tb_battinf " + "where tb_battresdata_inf.BattGroupId=db_battinf.tb_battinf.BattGroupId " + //"and upload_usr_id=? "+ "and (test_starttime)>=(?) and (test_starttime)<=(?) "; //上传方式 String usrSqlT=" and upload_usr_id!=? " ; String usrSqlU=" and upload_usr_id!=0 and upload_usr_id!=? " ; String usrSqlF=" and upload_usr_id=? " ; if(rinf.getUpload_usr_id()==100){//全部 baseSql+=usrSqlT; }else{ if(rinf.getUpload_usr_id()==0){ baseSql+=usrSqlF; }else{ baseSql+=usrSqlU; } } String levelSql=" and db_battinf.tb_battinf.stationname4 like ? and db_battinf.tb_battinf.stationname3 like ? and db_battinf.tb_battinf.stationname2 like ? and db_battinf.tb_battinf.stationname1 like ? ";//分组层次 sql=baseSql+levelSql; String endSql=" order by tb_battresdata_inf.battgroupid asc,test_starttime desc "; sql=sql+=endSql; //System.out.println(sql); List list=DateUtil.executeQuery(sql, DBUtil.getConn(), new Object[]{rinf.getTest_starttime(),rinf.getTest_starttime_ex(),rinf.getUpload_usr_id(),"%"+rinf.getStationname4()+"%","%"+rinf.getStationname3()+"%","%"+rinf.getStationname2()+"%","%"+rinf.getStationname1()+"%"}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); int id=0; try { while(rs.next()){ Battresdata_inf rinf=new Battresdata_inf(); if(id==rs.getInt("battGroupId")){ //时间倒序取最近的一次 continue; }else{ rinf.setBattGroupId(rs.getInt("battGroupId")); id=rs.getInt("battGroupId"); } rinf.setTest_record_count(rs.getInt("test_record_count")); rinf.setTest_starttime(rs.getTimestamp("test_starttime")); list.add(rinf); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } }); return list; } --> <insert id="add"></insert> <update id="update"></update> <delete id="del"></delete> <delete id="delPro"></delete> <select id="searchAll" resultType="java.util.List"></select> <select id="judge" resultType="java.util.List"></select> <select id="serchByCondition" resultType="java.util.List"></select> <select id="serchTest_record_count" resultType="java.util.List"></select> <select id="serchComplete" resultType="java.util.List"></select> <select id="serchSer" resultType="java.util.List"></select> <insert id="add"> insert into db_batt_testdata.tb_battresdata_inf(BattGroupId,test_record_count,test_record_count_ex,test_type,data_new,data_available,test_starttime,test_starttime_ex,test_devtype,record_time,group_vol,test_curr,upload_usr_id) values( #{BattGroupId},#{test_record_count},#{test_record_count_ex},#{test_type},#{data_new},#{data_available},#{test_starttime},#{test_starttime_ex},#{test_devtype},#{record_time},#{group_vol},#{test_curr},#{upload_usr_id} ) </insert> <update id="update"> update db_batt_testdata.tb_battresdata_inf set BattGroupId=#{BattGroupId},test_record_count=#{test_record_count},test_record_count_ex=#{test_record_count_ex}, test_type=#{test_type},data_new=#{data_new},data_available=#{data_available},test_starttime=#{test_starttime},test_starttime_ex=#{test_starttime_ex}, test_devtype=#{test_devtype},record_time=#{record_time},group_vol=#{group_vol},test_curr=#{test_curr},upload_usr_id=#{upload_usr_id} where num=#{num} </update> <select id="judge" resultType="java.lang.String"> select table_name from `INFORMATION_SCHEMA`.`TABLES` where table_name = concat('tb_battresdata_',#{battGroupId}) and TABLE_SCHEMA='db_batt_testdata' </select> <select id="serchByCondition" resultType="Battresdata_inf"> select num,battGroupId,test_record_count,test_record_count_ex,test_type,data_new,data_available,test_starttime,test_starttime_ex,test_devtype,record_time,group_vol,test_curr,upload_usr_id from db_batt_testdata.tb_battresdata_inf where battgroupid=#{battGroupId} </select> <select id="serchTest_record_count" resultType="Battresdata_inf"> select test_record_count from db_batt_testdata.tb_battresdata_inf where BattGroupId=#{battGroupId} and test_starttime=#{test_starttime} </select> <select id="serchComplete" resultType="java.lang.Integer"> select distinct tb_battresdata_inf.battgroupid from db_batt_testdata.tb_battresdata_inf,db_battinf.tb_battinf where tb_battresdata_inf.BattGroupId=db_battinf.tb_battinf.BattGroupId and test_starttime <![CDATA[>=]]> #{test_starttime} and test_starttime<![CDATA[<=]]> #{test_starttime_ex} and upload_usr_id=#{upload_usr_id} and db_battinf.tb_battinf.stationname4 like concat('%',#{stationname4},'%') and db_battinf.tb_battinf.stationname3 like concat('%',#{stationname3},'%') and db_battinf.tb_battinf.stationname2 like concat('%',#{stationname2},'%') and db_battinf.tb_battinf.stationname1 like concat('%',#{stationname1},'%') </select> <select id="serchSer" resultType="Battresdata_inf"> select * from(select tb_battresdata_inf.battgroupid,test_starttime,test_record_count from db_batt_testdata.tb_battresdata_inf,db_battinf.tb_battinf where tb_battresdata_inf.BattGroupId=db_battinf.tb_battinf.BattGroupId and test_starttime <![CDATA[>=]]> #{test_starttime} and test_starttime<![CDATA[<=]]> #{test_starttime_ex} and upload_usr_id=#{upload_usr_id} and db_battinf.tb_battinf.stationname4 like concat('%',#{stationname4},'%') and db_battinf.tb_battinf.stationname3 like concat('%',#{stationname3},'%') and db_battinf.tb_battinf.stationname2 like concat('%',#{stationname2},'%') and db_battinf.tb_battinf.stationname1 like concat('%',#{stationname1},'%') order by tb_battresdata_inf.battgroupid asc,test_starttime desc)temp GROUP BY battgroupid </select> </mapper> src/main/resources/mapper/ram/Fbs9100StateMapper.xml
@@ -164,7 +164,9 @@ and db_user.tb_user_inf.uid=#{num}) GROUP BY tb_fbs9100_state.dev_id </select> <select id="judgeSatationInState" resultType="java.lang.Integer"></select> <select id="judgeSatationInState" resultType="java.lang.Integer"> select 0 </select> <select id="serchByInfo" resultMap="Map_Gplot"> select fbs_rt.BattGroupId,