|
|
|
@ -539,74 +539,12 @@ public class HuiYaModel {
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static List<Record> wxGetCostTimeList = new ArrayList<>();
|
|
|
|
|
public static DateTime wxGetCostTimeListBeginTime = DateTime.now();
|
|
|
|
|
public static Map<Integer, Long> wxGetCostMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
public void wxGetCostTimeMap() {
|
|
|
|
|
long between = wxGetCostTimeListBeginTime.between(DateTime.now(), DateUnit.MINUTE);//计算相差时长
|
|
|
|
|
if (between > 60) {
|
|
|
|
|
wxGetCostTimeList.clear();
|
|
|
|
|
wxGetCostTimeListBeginTime = DateTime.now();
|
|
|
|
|
}
|
|
|
|
|
if (wxGetCostTimeList.size() == 0) {
|
|
|
|
|
SqlPara sqlPara = Db.getSqlPara("HuiYa.wxGetCostTime");
|
|
|
|
|
wxGetCostTimeList = Db.find(sqlPara);
|
|
|
|
|
wxGetCostTimeListBeginTime = DateTime.now();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < wxGetCostTimeList.size(); i++) {
|
|
|
|
|
Record record = wxGetCostTimeList.get(i);
|
|
|
|
|
int model_id = record.getInt("model_id");
|
|
|
|
|
long seconds_difference = record.getLong("seconds_difference");
|
|
|
|
|
wxGetCostMap.put(model_id, seconds_difference);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String wxGetCostTime(int task_id) {
|
|
|
|
|
//调用生成Map
|
|
|
|
|
wxGetCostTimeMap();
|
|
|
|
|
|
|
|
|
|
//当前任务的model_id
|
|
|
|
|
Record r = Db.findById("t_hy_task", "task_id", task_id);
|
|
|
|
|
int model_id = r.getInt("model_id");
|
|
|
|
|
|
|
|
|
|
String sql = "select model_id from t_hy_task where task_id<? and finish_flag=0";
|
|
|
|
|
List<Record> list = Db.find(sql, task_id);
|
|
|
|
|
String res;
|
|
|
|
|
int secondsToAdd = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
Record record = list.get(i);
|
|
|
|
|
model_id = record.getInt("model_id");
|
|
|
|
|
long seconds_difference = 60;//如果前面的某个模型没有最后一次的执行耗时,那么默认是1分钟
|
|
|
|
|
if (wxGetCostMap.containsKey(model_id)) {
|
|
|
|
|
seconds_difference = wxGetCostMap.get(model_id);
|
|
|
|
|
}
|
|
|
|
|
secondsToAdd += seconds_difference;
|
|
|
|
|
}
|
|
|
|
|
//再加上当前任务的生成时间
|
|
|
|
|
long current_task_seconds = 60;
|
|
|
|
|
if (wxGetCostMap.containsKey(model_id)) {
|
|
|
|
|
current_task_seconds = wxGetCostMap.get(model_id);
|
|
|
|
|
}
|
|
|
|
|
long m = (secondsToAdd + current_task_seconds) / 60;
|
|
|
|
|
long s = (secondsToAdd + current_task_seconds) % 60;
|
|
|
|
|
|
|
|
|
|
if (m == 0) {
|
|
|
|
|
if (s == 0) {
|
|
|
|
|
res = "约1分钟后到作品中查看。";
|
|
|
|
|
} else {
|
|
|
|
|
res = "约" + s + "秒后到作品中查看。";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (s > 0) {
|
|
|
|
|
res = "约" + m + "分" + s + "秒后到作品中查看。";
|
|
|
|
|
} else {
|
|
|
|
|
res = "约" + m + "分钟后到作品中查看。";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
String sql = "select count(1) from t_hy_task where task_id<=? and finish_flag=0";
|
|
|
|
|
int count = Db.queryInt(sql, task_id);
|
|
|
|
|
int x = (int) (1.0 * count / 2 + 0.5);
|
|
|
|
|
return "约" + x + "分钟后“作品”中查看结果。";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|