src/main/java/com/fgkj/controller/BattInfController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/fgkj/mapper/impl/BattInfMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/fgkj/services/BattInfServices.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/BattInfMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/fgkj/controller/BattInfController.java
@@ -5,6 +5,7 @@ import com.fgkj.util.ActionUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.sun.xml.internal.bind.v2.TODO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -12,6 +13,7 @@ import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; @RequestMapping("battInf") @@ -292,18 +294,32 @@ return service.serchBatt(binf); } //TODO 数据不足待测 //6.4.7按地域和标称电压分组统计蓄电池组服役超期的数量 /* * 区域层次放在stationid中 * battgroupnum 中存放统计方式:年度统计为0 季度统计为1 * moncount中存放统计季度:一季度为1 以此类推 * monnum 中存放年份*/ @GetMapping("beyondTime") * moncount中存放统计季度:一季度为1 以此类推 -3 * monnum 中存放年份 -2020*/ @PostMapping("beyondTime") @ApiOperation(notes = "区域层次放在stationid中 battgroupnum 中存放统计方式:年度统计为0 季度统计为1 moncount中存放统计季度:一季度为1 以此类推 monnum 中存放年份",value="按地域和标称电压分组统计蓄电池组服役超期的数量") public ServiceModel serchBeyondTime(@RequestBody BattInf bif){ // bif=ActionUtil.getGson("yyyy-MM-dd").fromJson(result,BattInf.class); return service.serchBeyondTime(bif); public ServiceModel serchBeyondTime(@ApiParam(value = "区域层次(字符串数字)",required = true) @RequestParam String stationId,@ApiParam(value = "统计方式:年度统计为0 季度统计为1",required = true) @RequestParam Integer battGroupNum,@ApiParam(value = "年份",required = true) @RequestParam Integer monNum,@ApiParam(value = "统计季度:一季度为1 以此类推",required = true) @RequestParam Integer monCount,@ApiParam(value = "",required = true) @RequestParam Date BattInUseDate,@ApiParam(value = "使用日期段 格式2021/02/01 08:16:35",required = true) @RequestParam Date BattInUseDate1) { ServiceModel model= new ServiceModel(); try { Integer.parseInt(stationId); } catch (NumberFormatException e) { e.printStackTrace(); model.setMsg("参数不合法"); return model; } BattInf binf = new BattInf(); binf.setStationId(stationId); binf.setBattGroupNum(battGroupNum); binf.setMonNum(monNum); binf.setMonCount(monCount); binf.setBattInUseDate(BattInUseDate); binf.setBattInUseDate1(BattInUseDate1); return service.serchBeyondTime(binf); } //6.4.8按地域和标称电压分组统计蓄电池组的数量(蓄电池组数量统计) src/main/java/com/fgkj/mapper/impl/BattInfMapper.java
@@ -838,17 +838,17 @@ public int serchByName(Object obj); //6.4数据统计报表查询(分地域查地域所在总电池数) public List serchBylevel(int level); public List<BattInf> serchBylevel(int level); //6.4.7按地域和标称电压分组统计蓄电池组服役超期的数量 /* * 区域层次放在stationid中*/ public List serchBeyondTime(Object obj); public List<BattInf> serchBeyondTime(BattInf obj); //6.4.8按地域和标称电压分组统计蓄电池组的数量(蓄电池组数量统计) /* * 区域层次放在stationid中*/ public List serchByMonVolStdGroup(Object obj); public List<BattInf> serchByMonVolStdGroup(BattInf obj); //6.4.9按地域和标称电压分组统计蓄电池组品牌的数量(蓄电池供应商信息统计) /* src/main/java/com/fgkj/services/BattInfServices.java
@@ -558,9 +558,9 @@ * battgroupnum 中存放统计方式:年度统计为0 季度统计为1 * moncount中存放统计季度:一季度为1 以此类推 * monnum 中存放年份*/ public ServiceModel serchBeyondTime(Object obj){ public ServiceModel serchBeyondTime(BattInf binf){ ServiceModel model = new ServiceModel(); System.out.println(1111111111); BattInf binf=(BattInf) obj; int year=binf.getMonNum();//获取年份 int firstMonth=0;//获取起始月份 int lastMonth=0;//获取结束月份 @@ -592,54 +592,103 @@ dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间 binf.setBattInUseDate1(DateUtil.sdf.parse(dateLast)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } int level = Integer.parseInt(binf.getStationId()); List<BattInf> listFalse=mapper.serchBylevel(level); //求总数 List<BattInf> list=mapper.serchByMonVolStdGroup(binf); List<BattInf> listB=BattinfGroupFactory.finishMonvol(list); List<BattInf> listL=BattinfGroupFactory.delMonvol(listB); //求超期服役的数量 List<BattInf> listB=null; try { year=(new Date()).getYear()+1900-3;//当前时间减去年限 //System.out.println(year); dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间 binf.setBattInUseDate(DateUtil.sdf.parse(dateFirst)); //System.out.println(binf.getBattInUseDate()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<BattInf> listY=mapper.serchBeyondTime(binf);//超期服役的电池组数 List<BattInf> listBY=BattinfGroupFactory.finishMonvol(listY); List<BattInf> listLY=BattinfGroupFactory.delMonvol(listBY); if (list!=null&&list.size()>0){ System.out.println("list.size() = " + list.size()); System.out.println("list = " + list); listB=BattinfGroupFactory.finishMonvol(list); }else{ model.setCode(0); model.setData(listFalse); model.setMsg("查询失败!"); return model; } List<BattInf> listL=null; if (listB!=null&&listB.size()>0){ listL=BattinfGroupFactory.delMonvol(listB); }else{ model.setCode(0); model.setData(listFalse); model.setMsg("查询失败!"); return model; } //求超期服役的数量 try { year=(new Date()).getYear()+1900-3;//当前时间减去年限 //System.out.println(year); dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间 binf.setBattInUseDate(DateUtil.sdf.parse(dateFirst)); //System.out.println(binf.getBattInUseDate()); } catch (ParseException e) { e.printStackTrace(); } List<BattInf> listY=mapper.serchBeyondTime(binf);//超期服役的电池组数 System.out.println("超期服役的电池组数 listY.get(0) = " + listY.get(0)); List<BattInf> listBY=null; if (listY!=null&&listY.size()>0){ listBY=BattinfGroupFactory.finishMonvol(listY); }else{ model.setCode(0); model.setData(listFalse); model.setMsg("查询失败!"); return model; } List<BattInf> listLY=null; if (listBY!=null&&listBY.size()>0){ listLY=BattinfGroupFactory.delMonvol(listBY); }else{ model.setCode(0); model.setData(listFalse); model.setMsg("查询失败!"); return model; } /*for (BattInf b : listBY) { System.out.println("0 "+b.getBattGroupNum()+" "+ "2v: "+b.getBattGroupId()+" "+ "6v: "+b.getMonCount()+" "+ "12v: "+b.getMonNum()); }*/ int level = Integer.parseInt(binf.getStationId()); List<BattInf> listFalse=mapper.serchBylevel(level); // int level = Integer.parseInt(binf.getStationId()); // List<BattInf> listFalse=mapper.serchBylevel(level); /* for (BattInf b : listL) { System.out.println("1 "+b.getBattGroupNum()+" "+ "2v: "+b.getBattGroupId()+" "+ "6v: "+b.getMonCount()+" "+ "12v: "+b.getMonNum()); }*/ List<BattInf> listEnd=BattinfGroupFactory.countAll(listL, listLY); for (BattInf b : listEnd) { System.out.println("2 "+b.getBattGroupNum()+" "+ "2v: "+b.getBattGroupId()+" 超过2v: "+b.getMonCapStd()+" "+ "6v: "+b.getMonCount()+" 超过6v: "+b.getMonResStd()+" "+ "12v: "+b.getMonNum()+" 超过12v: "+b.getMonSerStd()); if(listL!=null&&listL.size()>0) { List<BattInf> listEnd = BattinfGroupFactory.countAll(listL, listLY); for (BattInf b : listEnd) { System.out.println("2 " + b.getBattGroupNum() + " " + "2v: " + b.getBattGroupId() + " 超过2v: " + b.getMonCapStd() + " " + "6v: " + b.getMonCount() + " 超过6v: " + b.getMonResStd() + " " + "12v: " + b.getMonNum() + " 超过12v: " + b.getMonSerStd()); } model.setCode(1); model.setData(listEnd); model.setMsg("查询成功!"); }else{ model.setCode(0); model.setData(listFalse); System.out.println(listFalse.size()); model.setMsg("查询失败!"); } if(listL!=null&&listL.size()>0){ model.setCode(1); model.setData(listEnd); model.setMsg("查询成功!"); }else{ } catch (Exception e) { e.printStackTrace(); model.setCode(0); model.setData(listFalse); System.out.println(listFalse.size()); src/main/resources/mapper/BattInfMapper.xml
@@ -88,6 +88,14 @@ <result column="battProductDate" property="battProductDate"></result> <result column="battInUseDate" property="battInUseDate"></result> </resultMap> <resultMap id="BaseResultMapBattInf3" type="BattInf"> <result column="stationName1" property="stationName1"></result> <result column="stationName2" property="stationName2"></result> <result column="stationName3" property="stationName3"></result> <result column="stationName4" property="stationName4"></result> <result column="monVolStd" property="monVolStd"></result> <result column="num" property="num"></result> </resultMap> <!-- //添加新的电池组(多个) public boolean add(Object obj) { @@ -4582,9 +4590,71 @@ <select id="serchByInfo" resultType="java.util.List"></select> <!-- <select id="searchBattBybattgroupid" resultType="java.util.List"></select>--> <select id="serchByName" resultType="java.lang.Integer"></select> <select id="serchBylevel" resultType="java.util.List"></select> <select id="serchBeyondTime" resultType="java.util.List"></select> <select id="serchByMonVolStdGroup" resultType="java.util.List"></select> <select id="serchBylevel" resultMap="BaseResultMapBattInf3"> select stationname1, stationname2, stationname3, stationname4, moncount, count(distinct (db_battinf.tb_battinf.battgroupid)) as num from db_battinf.tb_battinf <if test="level==1"> group by stationname1 </if> <if test="level==2"> group by stationname2,stationname1 </if> <if test="level==3"> group by stationname3,stationname2,stationname1 </if> <if test="level==4"> group by stationname4,stationname3,stationname2,stationname1 </if> order by db_battinf.tb_battinf.battgroupid </select> <select id="serchBeyondTime" resultMap="BaseResultMapBattInf3"> select stationname1,stationname2,stationname3 ,stationname4,monvolstd,count(distinct(battgroupid)) as num from db_battinf.tb_battinf where battinusedate <![CDATA[<]]> #{battInUseDate} <if test="stationId==1"> group by stationname1,monvolstd order by stationname1,monvolstd </if> <if test="stationId==2"> group by stationname2,stationname1,monvolstd order by stationname2,stationname1,monvolstd </if> <if test="stationId==3"> group by stationname3,stationname2,stationname1,monvolstd order by stationname3,stationname2,stationname1,monvolstd </if> <if test="stationId==4"> group by stationname4,stationname3,stationname2,stationname1,monvolstd order by stationname4,stationname3,stationname2,stationname1,monvolstd </if> </select> <select id="serchByMonVolStdGroup" resultMap="BaseResultMapBattInf3"> select stationname1,stationname2,stationname3 ,stationname4,monvolstd,count(distinct(battgroupid)) as num from db_battinf.tb_battinf where to_days(battinusedate)>to_days(#{battInUseDate}) and to_days(battinusedate) <![CDATA[<]]> to_days(#{battInUseDate1}) <if test="stationId==1"> group by stationname1,monvolstd order by stationname1,monvolstd </if> <if test="stationId==2"> group by stationname2,stationname1,monvolstd order by stationname2,stationname1,monvolstd </if> <if test="stationId==3"> group by stationname3,stationname2,stationname1,monvolstd order by stationname3,stationname2,stationname1,monvolstd </if> <if test="stationId==4"> group by stationname4,stationname3,stationname2,stationname1,monvolstd order by stationname4,stationname3,stationname2,stationname1,monvolstd </if> </select> <select id="serchByIdLow" resultType="java.util.List"></select> <select id="serchByBattProducerGroup" resultType="java.util.List"></select> <select id="serchByBattInUseDateGroup" resultType="java.util.List"></select>