|
@@ -8,8 +8,10 @@ import javax.persistence.criteria.Predicate;
|
|
|
|
|
|
import cn.com.qmth.examcloud.web.jpa.PageUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.dao.DuplicateKeyException;
|
|
|
+import org.springframework.dao.DataIntegrityViolationException;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Sort;
|
|
@@ -33,29 +35,36 @@ import cn.com.qmth.examcloud.reports.commons.bean.OperateReport;
|
|
|
|
|
|
@Service
|
|
|
public class OperateServiceImpl implements OperateService {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(OperateServiceImpl.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private OperateRepo operateRepo;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void saveOperate(OperateReport r, String msgId) {
|
|
|
- OperateEntity e=new OperateEntity();
|
|
|
- e.setMsgId(msgId);
|
|
|
- e.setRootOrgId(r.getRootOrgId());
|
|
|
- e.setStudentId(r.getStudentId());
|
|
|
- e.setOperateUserId(r.getOperateUserId());
|
|
|
- e.setOperateUserType(r.getOperateUserType());
|
|
|
- e.setOperateTime(r.getReportTime());
|
|
|
- e.setOperateIp(r.getRemoteHost());
|
|
|
- e.setOperate(r.getOperate());
|
|
|
- e.setExamStudentId(r.getExamStudentId());
|
|
|
- e.setCreationTime(new Date());
|
|
|
- try {
|
|
|
- operateRepo.save(e);
|
|
|
- } catch (DuplicateKeyException e1) {
|
|
|
- //忽略;
|
|
|
- }
|
|
|
+ OperateEntity e = operateRepo.findByMsgId(msgId);
|
|
|
+ if (e != null) {
|
|
|
+ log.warn("msgId:{} 跳过重复!", msgId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ e = new OperateEntity();
|
|
|
+ e.setMsgId(msgId);
|
|
|
+ e.setRootOrgId(r.getRootOrgId());
|
|
|
+ e.setStudentId(r.getStudentId());
|
|
|
+ e.setOperateUserId(r.getOperateUserId());
|
|
|
+ e.setOperateUserType(r.getOperateUserType());
|
|
|
+ e.setOperateTime(r.getReportTime());
|
|
|
+ e.setOperateIp(r.getRemoteHost());
|
|
|
+ e.setOperate(r.getOperate());
|
|
|
+ e.setExamStudentId(r.getExamStudentId());
|
|
|
+ e.setCreationTime(new Date());
|
|
|
+ try {
|
|
|
+ operateRepo.save(e);
|
|
|
+ } catch (DataIntegrityViolationException ee) {
|
|
|
+ log.warn("msgId:{} uid:{} operate:{} err:{}", msgId, r.getStudentId(), r.getOperate(), ee.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|