115 lines
4.5 KiB
Plaintext
115 lines
4.5 KiB
Plaintext
|
|
package com.jysoft.trrafficVis.service;
|
||
|
|
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
import java.util.UUID;
|
||
|
|
|
||
|
|
import org.apache.commons.collections.CollectionUtils;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
import org.springframework.transaction.annotation.Transactional;
|
||
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||
|
|
|
||
|
|
import com.jysoft.trrafficVis.dto.TrrafficVisUserDto;
|
||
|
|
import com.jysoft.trrafficVis.vo.TrrafficVisUserVo;
|
||
|
|
import com.nationalelectirc.Constant.Constant;
|
||
|
|
import com.nationalelectirc.utils.RestResult;
|
||
|
|
import com.nationalelectric.greenH5.bizc.BaseServiceImpl;
|
||
|
|
import com.sgcc.uap.persistence.IHibernateDao;
|
||
|
|
import com.sgcc.uap.service.validator.ServiceValidatorBaseException;
|
||
|
|
import com.sgcc.uap.service.validator.ServiceValidatorUtil;
|
||
|
|
|
||
|
|
@Service
|
||
|
|
public class trrafficVisService {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private IHibernateDao iHibernateDao;
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private BaseServiceImpl baseService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param vo
|
||
|
|
* @return
|
||
|
|
* 新增通行可视化人员数据
|
||
|
|
*/
|
||
|
|
@Transactional(rollbackFor = Exception.class)
|
||
|
|
public RestResult addUserData(TrrafficVisUserVo vo) {
|
||
|
|
try {
|
||
|
|
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||
|
|
vo.setId(uuid);
|
||
|
|
ServiceValidatorUtil.validatorJavaBean(vo);
|
||
|
|
String addSql = "INSERT INTO TRRAFFIC_VIS_USER (ID, USER_NAME, USER_PHONE, USER_PHOTO, USER_ID_NUMBER,USER_DEPT,CREATE_USER_ID,CREATE_USER_NAME,CREATE_ORG_ID,CREATE_ORG_NAME,CREATE_USER_PHONE,REMARK,IS_DELETE,CREATE_TIME,UPDATE_TIME,APPLY_TIME,IS_AUTH)"
|
||
|
|
+ " VALUES (?, ?, ?, ?, ?,?,?,?, ?, ?, ?, ?,?,?,?,?,?)";
|
||
|
|
iHibernateDao.executeSqlUpdate(addSql,
|
||
|
|
new Object[] { vo.getId(), vo.getUserName(), vo.getUserPhone(), vo.getUserPhoto(),vo.getUserIdNumber(), vo.getUserDept(),vo.getCreateUserId(),
|
||
|
|
vo.getCreateUserName(),vo.getCreateOrgId(),vo.getCreateOrgName(),vo.getCreateUserPhone(),vo.getRemark(),'N',vo.getCreateTime(),vo.getUpdateTime(),vo.getApplyTime(),'0'});
|
||
|
|
return new RestResult(Constant.SUCCESS, "操作成功");
|
||
|
|
} catch (ServiceValidatorBaseException e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
return new RestResult(Constant.FAILED, e.getMessage());
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
// 手动回滚异常
|
||
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
|
|
return new RestResult(Constant.FAILED, "操作失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param vo
|
||
|
|
* @return
|
||
|
|
* 获取通行可视化人员数据-登录人
|
||
|
|
*/
|
||
|
|
public RestResult getUserLists(TrrafficVisUserDto dto) {
|
||
|
|
String sql = "SELECT * FROM (SELECT ROWNUM num ,A.* FROM (SELECT ID AS \"id\",USER_NAME AS \"userName\",USER_PHONE AS \"userPhone\","
|
||
|
|
+ " USER_DEPT AS \"userDept\",to_char(APPLY_TIME,'YYYY-MM-DD HH24:MI:SS') AS \"applyTime\",IS_AUTH AS \"isAuth\" "
|
||
|
|
+ " FROM TRRAFFIC_VIS_USER WHERE CREATE_USER_ID = ?) A WHERE ROWNUM<=?) WHERE num > ?";
|
||
|
|
try {
|
||
|
|
Integer pageSize = dto.getPageSize();
|
||
|
|
Integer pageNum = dto.getPageNum();
|
||
|
|
Integer page = (pageNum - 1) * pageSize;
|
||
|
|
Integer limit = pageNum * pageSize;
|
||
|
|
List<Map<String, Object>> list = iHibernateDao.queryForListWithSql(sql,
|
||
|
|
new Object[] { dto.getUserId(), limit, page });
|
||
|
|
return new RestResult(Constant.SUCCESS, "查询成功", list);
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
System.err.println(e.getMessage());
|
||
|
|
return new RestResult(Constant.FAILED, "查询失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param dto
|
||
|
|
* @return
|
||
|
|
* 获取通行可视化人员详情数据
|
||
|
|
*/
|
||
|
|
public RestResult getUserInfo(TrrafficVisUserDto dto) {
|
||
|
|
try {
|
||
|
|
String sql = "SELECT ID AS \"id\",USER_NAME AS \"userName\",USER_PHONE AS \"userPhone\",USER_PHOTO AS \"userPhoto\","
|
||
|
|
+ " USER_DEPT AS \"userDept\",REMARK AS \"remark\",to_char(APPLY_TIME,'YYYY-MM-DD HH24:MI:SS') AS \"applyTime\",IS_AUTH AS \"isAuth\""
|
||
|
|
+ " FROM TRRAFFIC_VIS_USER WHERE ID = ? AND IS_DELETE = 'N'";
|
||
|
|
ArrayList<Object> paramList = new ArrayList<Object>();
|
||
|
|
paramList.add(dto.getId());
|
||
|
|
List<Map<String, Object>> list = iHibernateDao.queryForListWithSql(sql, paramList.toArray());
|
||
|
|
if(CollectionUtils.isNotEmpty(list)){
|
||
|
|
Map<String, Object> mapData = list.get(0);
|
||
|
|
if(mapData.get("userPhoto") != null){
|
||
|
|
// 人脸照片
|
||
|
|
String imageBase64 = baseService.getImageBase64(String.valueOf(mapData.get("userPhoto")));
|
||
|
|
list.get(0).put("userPhoto", imageBase64);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return new RestResult(Constant.SUCCESS, "查询成功", list);
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
System.err.println(e.getMessage());
|
||
|
|
return new RestResult(Constant.FAILED, "查询失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|