lxw
2022-12-21 108da8c66924e7fc4015a0598f79b606f7436ad5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.whyc.service;
 
import com.whyc.dto.Response;
import com.whyc.mapper.BattmonStandardcurveMapper;
import com.whyc.mapper.BattmonTestcapMapper;
import com.whyc.pojo.BattmonStandardcurve;
import com.whyc.pojo.BattmonTestcap;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service
public class BattmonTestcapService {
    @Resource
    private BattmonTestcapMapper mapper;
    @Resource
    private BattmonStandardcurveMapper standatmapper;
 
    //添加标准曲线
    public Response add(BattmonTestcap btcp) {
        BattmonStandardcurve bsd=new BattmonStandardcurve();
        bsd.setMonvolstd(btcp.getMonvolstd());
        bsd.setMoncapstd(btcp.getMoncapstd());
        bsd.setBattproducer(btcp.getBattproducer());
        bsd.setBattmodel(btcp.getBattmodel());
        bsd.setNote(btcp.getNote());
        if(Integer.valueOf(btcp.getNote())<=0){
            return  new Response().set(1,false,"小时率小于等于0,无法添加小时率");
        }
        //查询前先创建数据库
        standatmapper.create_standard_curve();
        //先判断是否存在曲线记录库
        int number=standatmapper.serchRecord(bsd);
        if(number<=0){
            standatmapper.add(bsd);
        }
        String table_name="tb_battmon_testcap_"+(int)btcp.getMonvolstd()+"_"+(int)btcp.getMoncapstd()+"_"+btcp.getNote();
        mapper.create_standard_curve(table_name);
        //每次增加标准曲线库前要清理曲线库
        btcp.setTableName(table_name);
        mapper.del(btcp);
            //增加曲线
        int flag=mapper.add(btcp);
 
        return new Response().set(flag>0?1:0);
    }
 
    public List<BattmonTestcap> getTestCapList(BattmonStandardcurve curve) {
        return mapper.getTestCapList(curve);
    }
}