// // Created by lloyd on 2020/11/16. // #include "gtselectstandardgt.h" #include "DataMapping/gtdgnsdao.h" #include "DataMapping/dgns_gtstandard.h" #include "gtcvcore.h" #include "gtrunconf.h" #include "time.h" bool gtselectstandardgt::cal_std_sgt(dgns_gtstandard gt_pre_standard) { if(gt_pre_standard.sgtcharacters==NULL) return false; /*std::cout<<"当前功图特征("<0) std::cout<<";"; std::cout< gts = gtdgnsdao::get_dgns_gtstandard_list(); bool cal_sus = false; gt_pre_standard.appearcounter = 1; gt_pre_standard.maxsemblance = 100; gt_pre_standard.minsemblance = 100; time_t t = time(NULL); //获取目前秒时间 tm *local = localtime(&t); //转为本地时间 //当前时间 char tm_s[128]; strftime(tm_s, 64, "%Y-%m-%d %H:%M:%S", local); gt_pre_standard.latestupdatedtime = tm_s; if (gts.empty()) { return gtdgnsdao::addDgns_gtstandardContent(gt_pre_standard); } gtcvcore::calgray ocalgray; int i = 0; for (; i < gts.size(); ++i) { //TODO:未考虑生产参数变化的情况 未考虑生产参数变化的情况, 后期添加 //if(abs(std_gt.l-pre_gt.l)0) std::cout<<";"; std::cout<= standard_gt_minest_semblance) { if (gray_si*100 < gts[i].minsemblance) gts[i].minsemblance = gray_si*100; if (gray_si*100 > gts[i].maxsemblance) gts[i].maxsemblance = gray_si*100; gts[i].appearcounter += gt_pre_standard.appearcounter; gts[i].latestupdatedtime = gt_pre_standard.latestupdatedtime; cal_sus = gtdgnsdao::alterDgns_gtstandardContent(gts[i]); break; } } if (i >= gts.size()) { if (gts.size() + 1 > standard_gt_groups_max_num) { tm d_tm_; strptime(gts[0].createtime.c_str(), "%Y-%m-%d %H:%M:%S", &d_tm_); time_t d_t_ = mktime(&d_tm_); int d_i = 0; for (int j = 1; j < gts.size(); ++j) { tm tm_; strptime(gts[j].createtime.c_str(), "%Y-%m-%d %H:%M:%S", &tm_); time_t t_ = mktime(&tm_); if (t_ < d_t_) { d_t_ = t_; d_i = j; } } if (!gtdgnsdao::deleteDgns_gtstandardContent(gts[d_i].id)) { std::cout << "Warning: delete dgns_gtstandard row fault:id=" << gts[d_i].id << std::endl; } } cal_sus = gtdgnsdao::addDgns_gtstandardContent(gt_pre_standard); } return cal_sus; } bool gtselectstandardgt::select_bzt_from_db(dgns_gtstandard >_data_std) { std::string conditionsql = " where date_part('day',latestupdatedtime-createtime)>"+std::to_string(standard_gt_effect_days)+" and appearcounter= (select max(appearcounter) from dgns_gtstandard where date_part('day',latestupdatedtime-createtime)>"+std::to_string(standard_gt_effect_days)+" )"; std::vector ls = gtdgnsdao::get_dgns_gtstandard_list(conditionsql); if (ls.empty() || ls.size() == 0) return false; gt_data_std=ls[0]; return true; }