whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/service/BatttestdataService.java
@@ -9,6 +9,7 @@
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;
@@ -31,6 +32,9 @@
    @Resource
    private BatttestdataInfMapper tinfMapper;
    @Resource
    private CommonMapper commonMapper;
    //查询历史数据
    public Response findhistory(int battGroupId, int testRecordCount, int dataNew) {
@@ -82,6 +86,11 @@
                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的数据)
@@ -95,21 +104,28 @@
    }
    //测试恢复放电数据
    public Response recoverTdata(int battGroupId, int testRecordCount) {
        //先查询出所有的记录
        List<BatttestdataClear> list=subService.getRecoveInf(battGroupId,testRecordCount);
        //先存入clear表
        subService.insertRecover(battGroupId,testRecordCount);
        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);
        //查询表是否存在,不存在需要先创建表
        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);
        }
        //删除记录(超过这个recordNum的数据)
        subService.deleteRecover(battGroupId,testRecordCount);
        return  new Response().set(1,true);
    }
}