阅览数据插入
This commit is contained in:
parent
de99c3fa7c
commit
4903c86729
@ -0,0 +1,102 @@
|
||||
package com.awspaas.user.apps.browsing_data.service;
|
||||
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.RequestParams;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.exception.AWSAPIException;
|
||||
import com.actionsoft.exception.AWSDataAccessException;
|
||||
import com.actionsoft.exception.BPMNError;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class InsertReadingLogService extends ActionWeb
|
||||
{
|
||||
UserContext _uc;
|
||||
|
||||
public InsertReadingLogService(UserContext uc) {
|
||||
super(uc);
|
||||
this._uc = uc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 插入浏览记录数据
|
||||
* @param uc
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public String insertReadingLog(UserContext uc, RequestParams params) {
|
||||
ResponseObject ro = null;
|
||||
try {
|
||||
ro = ResponseObject.newOkResponse();
|
||||
|
||||
Long begintime=Long.valueOf(params.get("intervalStartTime"));
|
||||
Long endtime=Long.valueOf(params.get("currentTime"));
|
||||
|
||||
long time =endtime - begintime;
|
||||
long diffSeconds = time / 1000 % 60;
|
||||
long diffMinutes = time / (60 * 1000) % 60;
|
||||
long diffHours = time / (60 * 60 * 1000) % 24;
|
||||
long diffDays = time / (24 * 60 * 60 * 1000);
|
||||
String remainTime = "";
|
||||
if (diffDays != 0 && diffHours != 0) {
|
||||
remainTime = diffDays + "天" + diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒";
|
||||
} else if (diffDays == 0 && diffHours != 0 && diffMinutes != 0) {
|
||||
remainTime = diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒";
|
||||
} else if (diffDays == 0 && diffHours == 0 && diffMinutes != 0) {
|
||||
remainTime = diffMinutes + "分钟" + diffSeconds + "秒";
|
||||
} else if (diffDays == 0 && diffHours == 0 && diffMinutes == 0) {
|
||||
remainTime = diffSeconds + "秒";
|
||||
}
|
||||
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String beginDate = sdf.format(begintime);
|
||||
String endDate = sdf.format(endtime);
|
||||
|
||||
|
||||
BO insertReadingLog=SDK.getBOAPI().query("BO_EU_READING_DURATION").addQuery("BROWSERID=",params.get("browserId")).addQuery("ISACTIVE=","true").detail();
|
||||
if(insertReadingLog==null){
|
||||
BO bo=new BO();
|
||||
bo.set("USERID",params.get("userId"));
|
||||
bo.set("USERNAME",params.get("userName"));
|
||||
bo.set("MODELID",params.get("ruuid"));
|
||||
bo.set("MODELNAME", params.get("fileName"));
|
||||
bo.set("READING_START_TIME",beginDate);
|
||||
bo.set("READING_END_TIME",endDate);
|
||||
bo.set("CUMULATIVE_DURATION_STAY",remainTime);
|
||||
bo.set("BROWSERID",params.get("browserId"));
|
||||
bo.set("ISACTIVE",params.get("isActive"));
|
||||
ProcessInstance processInstance = SDK.getProcessAPI()
|
||||
.createBOProcessInstance("obj_9af2004d87b3472da210b43dc1ca32ab", uc.getUID(), "OA任务状态记录");
|
||||
SDK.getBOAPI().create("BO_EU_READING_DURATION",bo,processInstance.getId(),uc.getUID());
|
||||
|
||||
}else{
|
||||
insertReadingLog.set("USERID",params.get("userId"));
|
||||
insertReadingLog.set("USERNAME",params.get("userName"));
|
||||
insertReadingLog.set("READING_START_TIME",beginDate);
|
||||
insertReadingLog.set("READING_END_TIME",endDate);
|
||||
insertReadingLog.set("CUMULATIVE_DURATION_STAY",remainTime);
|
||||
insertReadingLog.set("BROWSERID",params.get("browserId"));
|
||||
SDK.getBOAPI().update("BO_EU_READING_DURATION",insertReadingLog);
|
||||
}
|
||||
ro.put("result", "ok");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ro.put("result", "error");
|
||||
}
|
||||
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user