|
@@ -64,129 +64,127 @@ public class PersonDeviceLogController {
|
|
|
private CompanyPositionService companyPositionService;
|
|
|
|
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
- @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
+ @RequestMapping(value = "pageList", method = RequestMethod.POST)
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "companyId",value = "所属单位编号", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "subordinate",value = "会否保护下级单位", required = false, paramType = "query",dataType = "String"),
|
|
|
- @ApiImplicitParam(name = "deviceNo",value = "设备编号", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "aliasName",value = "设备别名", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "personName",value = "人员姓名", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "timeRanges",value = "时间范围", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "temperatureRanges",value = "温度范围", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "matchMsg",value = "匹配状态", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "distinct",value = "是否去重", paramType = "query")
|
|
|
+ @ApiImplicitParam(name = "companyId", value = "所属单位编号", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "subordinate", value = "会否保护下级单位", required = false, paramType = "query", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "deviceNo", value = "设备编号", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "aliasName", value = "设备别名", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "personName", value = "人员姓名", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "timeRanges", value = "时间范围", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "temperatureRanges", value = "温度范围", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "matchMsg", value = "匹配状态", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "distinct", value = "是否去重", paramType = "query")
|
|
|
})
|
|
|
public MessageResult<Map> pageList(
|
|
|
String companyId,
|
|
|
- @RequestParam(value="subordinate",defaultValue="false") Boolean subordinate,
|
|
|
- String deviceNo,String aliasName,String personName,
|
|
|
- String timeRanges,String temperatureRanges,String matchMsg,
|
|
|
- @RequestParam(value="distinct",defaultValue="false") Boolean distinct,
|
|
|
- @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
- @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
- @RequestAttribute String subject){
|
|
|
+ @RequestParam(value = "subordinate", defaultValue = "false") Boolean subordinate,
|
|
|
+ String deviceNo, String aliasName, String personName,
|
|
|
+ String timeRanges, String temperatureRanges, String matchMsg,
|
|
|
+ @RequestParam(value = "distinct", defaultValue = "false") Boolean distinct,
|
|
|
+ @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
|
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
|
|
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
|
|
- Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(companyId)){
|
|
|
+ if (StringUtils.isNotEmpty(companyId)) {
|
|
|
searchParams.put("companyId", companyId);
|
|
|
|
|
|
CompanyInfo companyInfo = companyInfoService.get(companyId);
|
|
|
|
|
|
- if(subordinate){
|
|
|
+ if (subordinate) {
|
|
|
searchParams.put("companyCode", companyInfo.getCode() + "%");
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
searchParams.put("companyCode", companyInfo.getCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (distinct!=null){
|
|
|
- searchParams.put("distinct",distinct);
|
|
|
+ if (distinct != null) {
|
|
|
+ searchParams.put("distinct", distinct);
|
|
|
}
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("a.record_time","desc"));
|
|
|
+ sortList.add(new Sort("a.record_time", "desc"));
|
|
|
|
|
|
//为公司管理员
|
|
|
- boolean isSysAdmin = userService.hasRole(subject,"SYSADMIN");
|
|
|
+ boolean isSysAdmin = userService.hasRole(subject, "SYSADMIN");
|
|
|
|
|
|
- if(!isSysAdmin){
|
|
|
+ if (!isSysAdmin) {
|
|
|
User user = userService.get(subject);
|
|
|
String userCompanyId = user.getCompanyId();
|
|
|
|
|
|
List<DeviceInfo> deviceInfoList = deviceInfoService.findByCompanyId(userCompanyId);
|
|
|
List<String> deviceIdList = new ArrayList<String>();
|
|
|
|
|
|
- for (DeviceInfo deviceInfo:deviceInfoList) {
|
|
|
+ for (DeviceInfo deviceInfo : deviceInfoList) {
|
|
|
deviceIdList.add(deviceInfo.getId());
|
|
|
}
|
|
|
|
|
|
- if (deviceIdList.size()==0) {
|
|
|
+ if (deviceIdList.size() == 0) {
|
|
|
deviceIdList.add("-1");
|
|
|
}
|
|
|
|
|
|
searchParams.put("deviceIdList", deviceIdList);
|
|
|
}
|
|
|
- if(StringUtil.isNotEmpty(deviceNo)){
|
|
|
- searchParams.put("deviceNo","%"+deviceNo+"%");
|
|
|
+ if (StringUtil.isNotEmpty(deviceNo)) {
|
|
|
+ searchParams.put("deviceNo", "%" + deviceNo + "%");
|
|
|
}
|
|
|
- if(StringUtil.isNotEmpty(aliasName)){
|
|
|
- searchParams.put("aliasName","%"+aliasName+"%");
|
|
|
+ if (StringUtil.isNotEmpty(aliasName)) {
|
|
|
+ searchParams.put("aliasName", "%" + aliasName + "%");
|
|
|
}
|
|
|
- if(StringUtil.isNotEmpty(personName)){
|
|
|
- searchParams.put("personName","%"+personName+"%");
|
|
|
+ if (StringUtil.isNotEmpty(personName)) {
|
|
|
+ searchParams.put("personName", "%" + personName + "%");
|
|
|
}
|
|
|
|
|
|
- if(StringUtil.isNotEmpty(matchMsg)){
|
|
|
- searchParams.put("matchMsg","%"+matchMsg+"%");
|
|
|
+ if (StringUtil.isNotEmpty(matchMsg)) {
|
|
|
+ searchParams.put("matchMsg", "%" + matchMsg + "%");
|
|
|
}
|
|
|
|
|
|
- if(StringUtil.isNotEmpty(timeRanges)){
|
|
|
+ if (StringUtil.isNotEmpty(timeRanges)) {
|
|
|
String[] timeRangeArray = timeRanges.split(",");
|
|
|
String beginTime = "";
|
|
|
String endTime = "";
|
|
|
- if(timeRangeArray.length==1){
|
|
|
+ if (timeRangeArray.length == 1) {
|
|
|
beginTime = timeRangeArray[0];
|
|
|
- }
|
|
|
- else if(timeRangeArray.length==2){
|
|
|
+ } else if (timeRangeArray.length == 2) {
|
|
|
beginTime = timeRangeArray[0];
|
|
|
endTime = timeRangeArray[1];
|
|
|
}
|
|
|
|
|
|
- searchParams.put("beginTime",beginTime);
|
|
|
- searchParams.put("endTime",endTime);
|
|
|
+ searchParams.put("beginTime", beginTime);
|
|
|
+ searchParams.put("endTime", endTime);
|
|
|
}
|
|
|
|
|
|
- if(StringUtil.isNotEmpty(temperatureRanges)){
|
|
|
+ if (StringUtil.isNotEmpty(temperatureRanges)) {
|
|
|
String[] temperatureRangeArray = temperatureRanges.split(",");
|
|
|
|
|
|
String minTemperature = "";
|
|
|
String maxTemperature = "";
|
|
|
|
|
|
- if(temperatureRangeArray.length == 1){
|
|
|
+ if (temperatureRangeArray.length == 1) {
|
|
|
minTemperature = temperatureRangeArray[0];
|
|
|
}
|
|
|
- if(temperatureRangeArray.length == 2){
|
|
|
+ if (temperatureRangeArray.length == 2) {
|
|
|
minTemperature = temperatureRangeArray[0];
|
|
|
maxTemperature = temperatureRangeArray[1];
|
|
|
}
|
|
|
|
|
|
- if(StringUtil.isNotEmpty(minTemperature)){
|
|
|
- searchParams.put("minTemperature",minTemperature);
|
|
|
+ if (StringUtil.isNotEmpty(minTemperature)) {
|
|
|
+ searchParams.put("minTemperature", minTemperature);
|
|
|
}
|
|
|
- if(StringUtil.isNotEmpty(maxTemperature)){
|
|
|
- searchParams.put("maxTemperature",maxTemperature);
|
|
|
+ if (StringUtil.isNotEmpty(maxTemperature)) {
|
|
|
+ searchParams.put("maxTemperature", maxTemperature);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Page<PersonDeviceLog> page = personDeviceLogService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+ Page<PersonDeviceLog> page = personDeviceLogService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(PojoUtils.pageWrapper(page));
|
|
@@ -195,23 +193,30 @@ public class PersonDeviceLogController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @ApiOperation(value="导出日志台账")
|
|
|
+ @ApiOperation(value = "导出日志台账")
|
|
|
@PostMapping("exportXls")
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "deviceNo",value = "设备编号", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "aliasName",value = "设备别名", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "personName",value = "人员姓名", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "timeRanges",value = "时间范围", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "temperatureRanges",value = "温度范围", paramType = "query")
|
|
|
+ @ApiImplicitParam(name = "companyId", value = "所属单位编号", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "subordinate", value = "会否保护下级单位", required = false, paramType = "query", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "deviceNo", value = "设备编号", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "aliasName", value = "设备别名", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "personName", value = "人员姓名", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "timeRanges", value = "时间范围", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "temperatureRanges", value = "温度范围", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "matchMsg", value = "匹配状态", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "distinct", value = "是否去重", paramType = "query")
|
|
|
})
|
|
|
public MessageResult<String> exportXls(
|
|
|
- String deviceNo,String aliasName,String personName,
|
|
|
- String timeRanges,String temperatureRanges,
|
|
|
- @RequestAttribute String subject) {
|
|
|
+ String companyId,
|
|
|
+ @RequestParam(value = "subordinate", defaultValue = "false") Boolean subordinate,
|
|
|
+ String deviceNo, String aliasName, String personName,
|
|
|
+ String timeRanges, String temperatureRanges, String matchMsg,
|
|
|
+ @RequestParam(value = "distinct", defaultValue = "false") Boolean distinct,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
MessageResult<String> msgResult = new MessageResult<>();
|
|
|
try {
|
|
|
User user = userService.get(subject);
|
|
|
- String companyId = user.getCompanyId();
|
|
|
+ String userCompanyId = user.getCompanyId();
|
|
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
HSSFSheet sheet = workbook.createSheet();
|
|
@@ -237,7 +242,7 @@ public class PersonDeviceLogController {
|
|
|
//获取公司
|
|
|
//五级位置
|
|
|
//CompanyInfo companyInfo = companyInfoService.get(companyId);
|
|
|
- List<CompanyPosition> companyPositionList = companyPositionService.findByCompanyId(companyId);
|
|
|
+ List<CompanyPosition> companyPositionList = companyPositionService.findByCompanyId(userCompanyId);
|
|
|
CompanyPosition companyPosition = null;
|
|
|
if (companyPositionList.size() > 0) {
|
|
|
companyPosition = companyPositionList.get(0);
|
|
@@ -260,15 +265,16 @@ public class PersonDeviceLogController {
|
|
|
sortList.add(new Sort("a.record_time", "desc"));
|
|
|
|
|
|
//为公司管理员
|
|
|
- boolean is_admin = userService.hasRole(subject, "ADMIN");
|
|
|
- if (is_admin) {
|
|
|
- List<DeviceInfo> deviceInfoList = deviceInfoService.findByCompanyId(companyId);
|
|
|
+ boolean isSysAdmin = userService.hasRole(subject, "SYSADMIN");
|
|
|
+ if (!isSysAdmin) {
|
|
|
+ List<DeviceInfo> deviceInfoList = deviceInfoService.findByCompanyId(userCompanyId);
|
|
|
List<String> deviceIdList = new ArrayList<String>();
|
|
|
- if (deviceInfoList.size() > 0) {
|
|
|
- for (DeviceInfo deviceInfo : deviceInfoList) {
|
|
|
- deviceIdList.add(deviceInfo.getId());
|
|
|
- }
|
|
|
- } else {
|
|
|
+
|
|
|
+ for (DeviceInfo deviceInfo : deviceInfoList) {
|
|
|
+ deviceIdList.add(deviceInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deviceIdList.size() == 0) {
|
|
|
deviceIdList.add("-1");
|
|
|
}
|
|
|
|
|
@@ -285,6 +291,22 @@ public class PersonDeviceLogController {
|
|
|
searchParams.put("personName", "%" + personName + "%");
|
|
|
}
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(companyId)) {
|
|
|
+ searchParams.put("companyId", companyId);
|
|
|
+
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(companyId);
|
|
|
+
|
|
|
+ if (subordinate) {
|
|
|
+ searchParams.put("companyCode", companyInfo.getCode() + "%");
|
|
|
+ } else {
|
|
|
+ searchParams.put("companyCode", companyInfo.getCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (distinct != null) {
|
|
|
+ searchParams.put("distinct", distinct);
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtil.isNotEmpty(timeRanges)) {
|
|
|
String[] timeRangeArray = timeRanges.split(",");
|
|
|
String beginTime = "";
|
|
@@ -350,7 +372,9 @@ public class PersonDeviceLogController {
|
|
|
HSSFCell cellContent5 = rowContent.createCell(4);
|
|
|
cellContent5.setCellValue(personDeviceLog.getDeviceNo());
|
|
|
HSSFCell cellContent6 = rowContent.createCell(5);
|
|
|
- cellContent6.setCellValue(personDeviceLog.getDevice().getAliasName());
|
|
|
+ if(personDeviceLog.getDevice() != null) {
|
|
|
+ cellContent6.setCellValue(personDeviceLog.getDevice().getAliasName());
|
|
|
+ }
|
|
|
HSSFCell cellContent7 = rowContent.createCell(6);
|
|
|
cellContent7.setCellValue(personDeviceLog.getFaceImage());
|
|
|
|
|
@@ -358,7 +382,7 @@ public class PersonDeviceLogController {
|
|
|
//判断 如果公司没有五级位置 就不做展示
|
|
|
if (companyPositionList.size() > 0) {
|
|
|
PersonInfo person = personDeviceLog.getPerson();
|
|
|
- if(person != null){
|
|
|
+ if (person != null) {
|
|
|
HSSFCell cellContent8 = rowContent.createCell(7);
|
|
|
if (person.getPosition1() != null) {
|
|
|
cellContent8.setCellValue(person.getPosition1());
|
|
@@ -393,7 +417,7 @@ public class PersonDeviceLogController {
|
|
|
byte[] buffer = output.toByteArray();
|
|
|
ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
|
|
|
- String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig, "import", "error.xls", input);
|
|
|
|
|
|
//todo 返回导入失败报表下载链接
|
|
|
msgResult.setData(downloadUrl);
|
|
@@ -410,9 +434,8 @@ public class PersonDeviceLogController {
|
|
|
// response.getOutputStream().write(out.toByteArray());
|
|
|
// response.getOutputStream().flush();
|
|
|
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|