| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.BattTestData; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.paramter.POIWord; |
| | | import com.whyc.dto.paramter.TestDataInfDoc; |
| | | import com.whyc.mapper.BatttestdataInfMapper; |
| | | import com.whyc.mapper.BatttestdataMapper; |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.pojo.BattalarmData; |
| | | import com.whyc.pojo.BatttestdataClear; |
| | | import com.whyc.pojo.BatttestdataId; |
| | | import com.whyc.pojo.BatttestdataInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class BatttestdataService { |
| | | @Resource |
| | | private BatttestdataMapper mapper; |
| | | |
| | | @Resource |
| | | private SubTablePageInfoService subService; |
| | | |
| | | @Resource |
| | | private BatttestdataInfMapper tinfMapper; |
| | | |
| | | @Resource |
| | | private CommonMapper commonMapper; |
| | | |
| | | //查询历史数据 |
| | | public Response findhistory(int battGroupId, int testRecordCount, int dataNew) { |
| | |
| | | return new Response().set(1, pageInfo); |
| | | } |
| | | |
| | | //word导出 |
| | | public List<TestDataInfDoc> searchWordExport(POIWord poiWord) { |
| | | poiWord.setRecordNumList(Arrays.asList(poiWord.getRecordNums().split(","))); |
| | | List<TestDataInfDoc> list = mapper.searchWordExport(poiWord); |
| | | return list; |
| | | } |
| | | |
| | | //测试清洗放电数据 |
| | | public Response clearTdata(int battGroupId, int testRecordCount) { |
| | | //获取总的放电电流的总值 |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("battGroupId",battGroupId); |
| | | wrapper.eq("test_record_count",testRecordCount); |
| | | wrapper.last("limit 1"); |
| | | BatttestdataInf tinf=tinfMapper.selectOne(wrapper); |
| | | //平均值 |
| | | float avgCurr= (float) (((tinf.getTestCap()*3600)/tinf.getTestTimelong())*0.8); |
| | | //获取总的放电记录 |
| | | List<BatttestdataId> list=subService.getAllTdata(battGroupId,testRecordCount); |
| | | int recordNum=tinf.getRecordNum(); |
| | | for (BatttestdataId tdata:list){ |
| | | float testCurr=tdata.getTestCurr(); |
| | | if(Math.abs(avgCurr)<=Math.abs(testCurr)){ |
| | | recordNum= tdata.getRecordNum(); |
| | | break; |
| | | } |
| | | } |
| | | //查询表是否存在,不存在需要先创建表 |
| | | String tableName = commonMapper.existTable("db_batt_testdata", "tb_batttestdata_clear_"+battGroupId); |
| | | if(tableName==null){ |
| | | subService.creatClear(battGroupId); |
| | | } |
| | | //存入clear表 |
| | | subService.insertClear(battGroupId,testRecordCount,recordNum); |
| | | //删除记录(超过这个recordNum的数据) |
| | | subService.deleteData(battGroupId,testRecordCount,recordNum); |
| | | //inf表recordNum更改 |
| | | UpdateWrapper updateWrapper=new UpdateWrapper(); |
| | | updateWrapper.eq("battGroupId",battGroupId); |
| | | updateWrapper.set("record_num",recordNum); |
| | | tinfMapper.update((BatttestdataInf) ActionUtil.objeNull,updateWrapper); |
| | | return new Response().set(1,true); |
| | | } |
| | | //测试恢复放电数据 |
| | | public Response recoverTdata(int battGroupId, int testRecordCount) { |
| | | //查询表是否存在,不存在需要先创建表 |
| | | String tableName = commonMapper.existTable("db_batt_testdata", "tb_batttestdata_clear_"+battGroupId); |
| | | if(tableName==null){ |
| | | subService.creatClear(battGroupId); |
| | | }else{ |
| | | //先查询出所有的clear记录 |
| | | List<BatttestdataClear> list=subService.getRecoveInf(battGroupId,testRecordCount); |
| | | //恢复至testdata |
| | | subService.insertRecover(battGroupId,testRecordCount); |
| | | //恢复inf |
| | | if(list!=null){ |
| | | for (BatttestdataClear clear:list) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.set("record_num",clear.getRecordNum()); |
| | | wrapper.eq("battGroupId",battGroupId); |
| | | wrapper.eq("test_record_count",testRecordCount); |
| | | tinfMapper.update((BatttestdataInf) ActionUtil.objeNull,wrapper); |
| | | } |
| | | } |
| | | //删除记录(超过这个recordNum的数据) |
| | | subService.deleteRecover(battGroupId,testRecordCount); |
| | | } |
| | | return new Response().set(1,true); |
| | | } |
| | | } |