Commit 3c1532be authored by chenhao's avatar chenhao

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents d0559eb4 9f4b6165
......@@ -28,25 +28,24 @@ GROUP BY
<select id ="getNoInLinkUnit" resultType="com.yeejoin.amos.boot.biz.common.entity.DataDictionary">
SELECT
CONCAT(cbb.`name`,' (',elink.count,')') as `name`,
cbb.*,
elink.count as count
FROM
cb_data_dictionary cbb
LEFT JOIN (
SELECT
CONCAT(cbb.`name`,' (',IFNULL(elink.count, 0),')') as `name`,
cbb.*,
elink.count as count
FROM
cb_data_dictionary cbb
LEFT JOIN (
SELECT
emergency_linkage_unit_code,
COUNT(1) count
FROM
FROM
cb_linkage_unit
WHERE is_delete = 0
GROUP BY
WHERE is_delete = 0
GROUP BY
emergency_linkage_unit_code
) elink ON elink.emergency_linkage_unit_code = cbb.`code`
WHERE
cbb.type = 'YJLDDW' and cbb.is_delete = 0
AND elink.count IS NOT NULL
) elink ON elink.emergency_linkage_unit_code = cbb.`code`
WHERE
cbb.type = 'YJLDDW' and cbb.is_delete = 0
</select>
<select id ="getByCode" resultType="com.yeejoin.amos.boot.biz.common.entity.DataDictionary">
......
......@@ -38,8 +38,14 @@ public class RequestData {
private String address;
@ApiModelProperty(value = "灾情状态")
private int status =0;
private Integer status ;
@ApiModelProperty(value = "灾情ID")
private Long alertId ;
@ApiModelProperty(value = "类型code")
private String alertTypeCode;
@ApiModelProperty(value = "排序")
private String orderTime;
}
......@@ -56,6 +56,8 @@ public class AlertCalledZhDto {
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "标题")
private String alertTypeName;
@ApiModelProperty(value = "响应级别字典code 为了过滤用(只有航空器故障有)")
private String responseLevelCode;
......
......@@ -39,4 +39,7 @@ public class PowerTransferCompanyResources extends BaseEntity {
@ApiModelProperty(value = "资源编号(如车牌号)")
private String resourcesNum;
@ApiModelProperty(value = "任务状态")
private String status;
}
......@@ -14,16 +14,16 @@ import java.util.Map;
@Getter
@AllArgsConstructor
public enum FireCarStatusEnum {
// 执勤状态
执勤("ZW", "1", "执勤"),
// 出动状态
出动("ZQ", "2", "出动"),
// 维修状态
维修("WX","3", "维修"),
// 退役状态
退役("TY","6", "退役"),
// 报废状态
报废("BF","7", "报废");
执勤("ZW","1", "执勤"),
出动("ZQ","2", "出动"),
途中("TZ","3", "途中"),
到场("DC","4", "到场"),
出水("CS","5", "出水"),
停水("TS","6", "停水"),
驻防("ZF","7", "驻防"),
返队("FD","8", "返队");
// 完成("WC","9", "完成");
private String key;
private String code;
......
......@@ -25,10 +25,7 @@
a.alert_stage alertStage,
a.call_time callTime,
a.rescue_grid rescueGrid,
-- a.alert_type alertType,
CONCAT('【',a.alert_type,'】',IFNULL((select field_value from jc_alert_form_value where jc_alert_form_value.alert_called_id =a.sequence_nbr and jc_alert_form_value.field_code='remark'),"")) alertType,
CONCAT(a.alert_type,' ',IFNULL((select field_value from jc_alert_form_value where jc_alert_form_value.alert_called_id =a.sequence_nbr and jc_alert_form_value.field_code='remark'),"")) alertType,
a.alert_type_code alarmTypeCode,
a.unit_involved unitInvolved,
a.trapped_num trappedNum,
......@@ -55,10 +52,25 @@
and a.address like CONCAT('%',#{par.address},'%') || a.alert_type like CONCAT('%',#{par.address},'%')
</if>
<if test='par.alertTypeCode!=null and par.alertTypeCode!="" '>
and a.alert_type_code = #{par.alertTypeCode}
</if>
<if test='par.whether24!=false'>
and a.call_time &gt;= (NOW() - interval 24 hour)
</if>
ORDER BY a.call_time DESC
<if test='par.orderTime=="1"'>
ORDER BY a.call_time DESC
</if>
<if test='par.orderTime=="2"'>
ORDER BY a.call_time
</if>
<if test='par.orderTime==null'>
ORDER BY a.call_time DESC
</if>
<if test='pageNum!=null and pageSize !=null'>
limit #{pageNum},#{pageSize}
</if>
......@@ -81,6 +93,9 @@
<if test='par.address!=null and par.address!="" '>
and a.address like CONCAT('%',#{par.address},'%')
</if>
<if test='par.alertTypeCode!=null and par.alertTypeCode!="" '>
and a.alert_type_code = #{par.alertTypeCode}
</if>
<if test='par.whether24!=false'>
and a.call_time &gt;= (NOW() - interval 24 hour)
</if>
......
......@@ -63,4 +63,7 @@ public class AlertPaperInfoDto {
@ApiModelProperty(value = "电梯设备编码")
private String elevatorCode;
@ApiModelProperty(value = "警情结束时间")
private Date finishTime;
}
package com.yeejoin.amos.boot.module.tzs.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
......@@ -33,6 +34,12 @@ public class ElevatorAlarmDto extends BaseDto {
@ApiModelProperty(value = "故障类型")
private String type;
/**
* 故障类型名称
*/
@ApiModelProperty(value = "故障类型名称")
private String typeName;
@ApiModelProperty(value = "处置状态。0:处置完成。1:故障发生 2:发出通知 3:处置响应 4:处置到场 5:误报")
private Integer dealStatus;
......
......@@ -47,6 +47,12 @@ public class ElevatorAlarm extends BaseEntity {
private String type;
/**
* 故障类型名称
*/
@TableField("type_name")
private String typeName;
/**
* 处置状态。0:处置完成。1:故障发生 2:发出通知 3:处置响应 4:处置到场 5:误报
*/
@TableField("deal_status")
......
......@@ -35,4 +35,11 @@ public interface IWechatService {
*/
JSONObject sendWechatModelMessage(String openId, WechatMessageDto wechatMessageDto);
/**
* 根据多媒体id 获取微信图片
* @param mediaId
* @return
*/
String getWechatPicByMediaId(String mediaId);
}
......@@ -51,13 +51,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.exception.BaseException;
......@@ -176,7 +170,10 @@ public class CommandController extends BaseController {
@GetMapping(value = "history/list")
@ApiOperation(httpMethod = "GET", value = "警情列表查询", notes = "警情列表查询")
public ResponseModel<Page<AlertCalledZhDto>> listhistoryPage(Integer pageNum, Integer pageSize,RequestData par) {
par.setStatus(1);
if(par.getStatus()==null){
par.setStatus(1);
}
if (null == pageNum || null == pageSize) {
pageNum = 1;
pageSize = Integer.MAX_VALUE;
......@@ -1199,11 +1196,11 @@ public class CommandController extends BaseController {
//获取用户已绑定车辆id、
UserCar userCar=userCarService.selectByAmosUserId(Long.valueOf(agencyUserModel.getUserId()));
if(isNo!=null&&isNo){
id =userCar!=null?userCar.getAmosUserId():null;
id =userCar!=null?userCar.getCarId():null;
}
ResponseModel<Object> data= equipFeignClient.equipmentCarList(teamId,name,code , pageNum,pageSize,id);
Map map =new HashMap();
map.put("select",userCar!=null?userCar.getAmosUserId():null);
map.put("select",userCar!=null?userCar.getCarId():null);
map.put("data",data!=null?data.getResult():null);
return ResponseHelper.buildResponse(map);
}
......@@ -1222,22 +1219,30 @@ public class CommandController extends BaseController {
@TycloudOperation( needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "adduserCar/{type}", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "增加绑定", notes = "增加绑定")
public ResponseModel<Object> adduserCar(@PathVariable String type,UserCar userCar ) {
public ResponseModel<Object> adduserCar(@PathVariable String type, @RequestBody UserCar userCar ) {
AgencyUserModel agencyUserModel= getUserInfo();
userCar.setAmosUserId(Long.valueOf(agencyUserModel.getUserId()));
userCar.setAmosUserName(agencyUserModel.getUserName());
if("1".equals(type)){
userCarService.add(userCar);
}else{
userCarService.delete(userCar);
}
return ResponseHelper.buildResponse(true);
}
return ResponseHelper.buildResponse(null);
}
@TycloudOperation( needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "getAlertCalledId", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "增加绑定", notes = "增加绑定")
public ResponseModel<Object> getAlertCalledId() {
AgencyUserModel agencyUserModel= getUserInfo();
Long id =null;
//获取用户已绑定车辆id、
UserCar userCar=userCarService.selectByAmosUserId(Long.valueOf(agencyUserModel.getUserId()));
id =userCar!=null?userCar.getCarId():null;
return ResponseHelper.buildResponse(id);
}
}
\ No newline at end of file
......@@ -148,16 +148,18 @@ public class AlertCalledController extends BaseController {
String alertSourceCode,
String callTimeStart,
String callTimeEnd){
//Page<AlertCalled> pageBean;
// IPage<AlertCalled> page;
/* Page<AlertCalled> pageBean;
IPage<AlertCalled> page;
QueryWrapper<AlertCalled> alertCalledQueryWrapper = new QueryWrapper<>();
/* page = iAlertCalledService.page(pageBean, alertCalledQueryWrapper);
return ResponseHelper.buildResponse(page);*/
setQueryWrapper(alertCalledQueryWrapper, alertCalled,sort);
page = iAlertCalledService.page(pageBean, alertCalledQueryWrapper);
return ResponseHelper.buildResponse(page);
setQueryWrapper(alertCalledQueryWrapper, alertCalled,sort); */
/*分页存在问题 修改分页参数 陈召 2021-09-22 开始*/
Page<AlertCalled> page = new Page<>();
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
page = new Page<>(0, Long.MAX_VALUE);
page = new Page<>();
page.setCurrent(0L);
page.setSize(10L);
} else {
page.setCurrent( (Long.parseLong(pageNum) - 1) * Long.parseLong(pageSize));
page.setSize(Long.parseLong(pageSize));
......@@ -168,7 +170,7 @@ public class AlertCalledController extends BaseController {
/* bug2408 筛选参数解析异常 修改筛选条件方法 修改入参分离筛选条件
alertStatus 警情状态 alertTypeCode 报警类型code alertSourceCode 警情来源code
陈召 2021-08-21 开始*/
IPage<AlertCalled> alertCalledIPage = iAlertCalledService.queryForCalledList(page, alertStatus,alertTypeCode, alertSourceCode, callTimeStart, callTimeEnd,sort);
IPage<AlertCalled> alertCalledIPage = iAlertCalledService.queryForCalledList(page, alertStatus,alertTypeCode, alertSourceCode, callTimeStart, callTimeEnd,sort);
/* bug 2406 接警记录,列表缺少警情状态字段 by litw start*/
alertCalledIPage.getRecords().stream().forEach(e->{
if(e.getAlertStatus()) {
......
......@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
......@@ -80,16 +81,18 @@ public class OrgUsrSafeReportController extends BaseController {
}
/**
* 根据sequenceNbr删除
* 根据ids删除
*
* @param sequenceNbr 主键
* @param ids 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@DeleteMapping(value = "/{ids}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除机场单位消防安全报告", notes = "根据sequenceNbr删除机场单位消防安全报告")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
return ResponseHelper.buildResponse(orgUsrSafeReportServiceImpl.removeById(sequenceNbr));
public ResponseModel deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "ids") String ids){
List<Long> seqs = StringUtil.String2LongList(ids);
orgUsrSafeReportServiceImpl.deleteBatchSeq(seqs);
return ResponseHelper.buildResponse(seqs);
}
/**
......@@ -124,7 +127,7 @@ public class OrgUsrSafeReportController extends BaseController {
page.setSize(size);
return ResponseHelper.buildResponse(orgUsrSafeReportServiceImpl.queryForOrgUsrSafeReportPage(page,
orgUsrSafeReportDto.getName(),
orgUsrSafeReportDto.getType(),
orgUsrSafeReportDto.getTypeCode(),
orgUsrSafeReportDto.getTakeEffectYear(),
orgUsrSafeReportDto.getCompanyId()));
}
......
......@@ -2,6 +2,11 @@ package com.yeejoin.amos.boot.module.jcs.biz.controller;
import java.util.Arrays;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yeejoin.amos.boot.module.common.api.entity.FirefightersJacket;
import com.yeejoin.amos.boot.module.jcs.api.entity.UserCar;
import com.yeejoin.amos.boot.module.jcs.api.service.IUserCarService;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -37,7 +42,8 @@ public class PowerTransferCompanyResourcesController extends BaseController {
@Autowired
PowerTransferCompanyResourcesServiceImpl powerTransferCompanyResourcesService;
@Autowired
IUserCarService userCarService;
/**
* 新增调派单位资源
*
......@@ -77,6 +83,31 @@ public class PowerTransferCompanyResourcesController extends BaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/updateById/{code}", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "修改调派单位资源", notes = "修改调派单位资源")
public boolean updateByResourcesIdPowerTransferCompanyResources(@PathVariable String code) {
//获取用户所属单位id
AgencyUserModel agencyUserModel= getUserInfo();
Long id =null;
//获取用户已绑定车辆id、
UserCar userCar=userCarService.selectByAmosUserId(Long.valueOf(agencyUserModel.getUserId()));
id =userCar!=null?userCar.getCarId():null;
UpdateWrapper<PowerTransferCompanyResources> up=new UpdateWrapper<>();
return powerTransferCompanyResourcesService.update(new UpdateWrapper<PowerTransferCompanyResources>().eq("resources_id", id).set("status", code));
}
/**
* 根据id查询
*
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
......@@ -10,6 +11,7 @@ import com.yeejoin.amos.boot.biz.common.utils.EnumsUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.FormValue;
import com.yeejoin.amos.boot.module.common.api.entity.FirefightersPost;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledObjsDto;
......@@ -25,11 +27,7 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyZHDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.SchedulingReportingDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateExtendDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmitted;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmittedObject;
import com.yeejoin.amos.boot.module.jcs.api.entity.Template;
import com.yeejoin.amos.boot.module.jcs.api.entity.*;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertBusinessTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSchedulingTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSubmitTypeEnum;
......@@ -99,7 +97,8 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
@Autowired
EquipFeignClient equipFeignClient;
@Autowired
PowerTransferCompanyResourcesServiceImpl powerTransferCompanyResourcesService;
@Autowired
AlertSubmittedMapper alertSubmittedMapper;
......@@ -360,6 +359,8 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
}
// 更新所有车辆状态为执勤
equipFeignClient.updateCarStatus(carStatusInfoDtoList);
//跟车辆状态
powerTransferCompanyResourcesService.update(new UpdateWrapper<PowerTransferCompanyResources>().eq("resources_id", transferCarIdList).set("status", FireCarStatusEnum.返队.getCode()));
}
// 4.发送任务消息
......
......@@ -26,10 +26,10 @@ public class OrgUsrSafeReportServiceImpl extends BaseService<OrgUsrSafeReportDto
*/
public Page<OrgUsrSafeReportDto> queryForOrgUsrSafeReportPage(Page<OrgUsrSafeReportDto> page,
@Condition(Operator.like) String name,
String type,
String typeCode,
Date takeEffectYear,
Long companyId) {
return this.queryForPage(page, "rec_date", false, name,type,takeEffectYear,companyId);
return this.queryForPage(page, "rec_date", false, name,typeCode,takeEffectYear,companyId);
}
/**
......
......@@ -20,12 +20,7 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferSimpleDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ResourceStatisticsDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransfer;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransferCompany;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransferCompanyResources;
import com.yeejoin.amos.boot.module.jcs.api.entity.Template;
import com.yeejoin.amos.boot.module.jcs.api.entity.*;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertFeedbackStatusEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.DutyInfoEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.FireBrigadeTypeEnum;
......@@ -170,32 +165,61 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
// 1.调用装备服务接口查询车辆列表
List<FireBrigadeResourceDto> fireCarDtoList = Lists.newArrayList();
ResponseModel<Object> result = equipFeignService.getFireCarListAll();
// if (!ObjectUtils.isEmpty(result)) {
// List<Map<String, Object>> fireCarListMapList = (List<Map<String, Object>>) result.getResult();
// if (!ValidationUtil.isEmpty(fireCarListMapList)) {
// fireCarListMapList.stream().filter(car -> ObjectUtils.isNotEmpty(car.get("teamId"))).filter(car ->
// FireCarStatusEnum.执勤.getCode().equals(car.get("carState")) //TODO 后续如果需要多个状态需要删掉这个过滤条件
// || FireCarStatusEnum.出动.getCode().equals(car.get("carState"))).forEach(car -> {
//
// FireBrigadeResourceDto fireCarDto = (FireBrigadeResourceDto) Bean.mapToBean(car, FireBrigadeResourceDto.class);
// // TODO 后期根据车物联状态来返回,现在为"(装备)在位=执勤","(装备)执勤=出动"
// if (FireCarStatusEnum.执勤.getCode().equals(fireCarDto.getCarState())) {
// fireCarDto.setCarStateDesc(FireCarStatusEnum.执勤.getName());
// } else {
// fireCarDto.setCarState(FireCarStatusEnum.出动.getCode());
// fireCarDto.setCarStateDesc(FireCarStatusEnum.出动.getName());
// }
// fireCarDtoList.add(fireCarDto);
// });
// }
// }
//查询车辆当前任务状态
QueryWrapper<PowerTransferCompanyResources> queryWrapper = new QueryWrapper<>();
queryWrapper.ne("status", FireCarStatusEnum.返队.getCode());
List<PowerTransferCompanyResources> alertFormValue = powerTransferCompanyResourcesService.list(queryWrapper);
Map<String, String> appleMap = alertFormValue!=null&&alertFormValue.size()>0?alertFormValue.stream().collect(Collectors.toMap(PowerTransferCompanyResources::getResourcesId, PowerTransferCompanyResources::getStatus)):null;
if (!ObjectUtils.isEmpty(result)) {
List<Map<String, Object>> fireCarListMapList = (List<Map<String, Object>>) result.getResult();
if (!ValidationUtil.isEmpty(fireCarListMapList)) {
fireCarListMapList.stream().filter(car -> ObjectUtils.isNotEmpty(car.get("teamId"))).filter(car ->
FireCarStatusEnum.执勤.getCode().equals(car.get("carState")) //TODO 后续如果需要多个状态需要删掉这个过滤条件
|| FireCarStatusEnum.出动.getCode().equals(car.get("carState"))).forEach(car -> {
FireBrigadeResourceDto fireCarDto = (FireBrigadeResourceDto) Bean.mapToBean(car,
FireBrigadeResourceDto.class);
fireCarListMapList.stream().filter(car -> ObjectUtils.isNotEmpty(car.get("teamId"))).forEach(car -> {
FireBrigadeResourceDto fireCarDto = (FireBrigadeResourceDto) Bean.mapToBean(car, FireBrigadeResourceDto.class);
// TODO 后期根据车物联状态来返回,现在为"(装备)在位=执勤","(装备)执勤=出动"
if (FireCarStatusEnum.执勤.getCode().equals(fireCarDto.getCarState())) {
fireCarDto.setCarStateDesc(FireCarStatusEnum.执勤.getName());
} else {
fireCarDto.setCarState(FireCarStatusEnum.出动.getCode());
fireCarDto.setCarStateDesc(FireCarStatusEnum.出动.getName());
}
if(appleMap!=null){
String state= appleMap.containsKey(car.get("id"))?appleMap.get(car.get("id")):null;
fireCarDto.setCarState(state);
fireCarDto.setCarStateDesc(state!=null?FireCarStatusEnum.getEnum(state).getName():null);
}else{
fireCarDto.setCarState(null);
fireCarDto.setCarStateDesc(null);
}
}
fireCarDtoList.add(fireCarDto);
});
}
}
// 2.查询消防队伍列表
List<FireTeam> fullTimeFireBrigadeList = fireTeamService.list(new QueryWrapper<FireTeam>().eq("type_code",
FireBrigadeTypeEnum.专职消防队.getCode()).eq("is_delete", 0));
List<FireTeam> fullTimeFireBrigadeList = fireTeamService.list(new QueryWrapper<FireTeam>().eq("type_code", FireBrigadeTypeEnum.专职消防队.getCode()).eq("is_delete", 0));
if (!CollectionUtils.isEmpty(fullTimeFireBrigadeList)) {
Map<String, List<FireBrigadeResourceDto>> resultMap =
fireCarDtoList.stream().collect(Collectors.groupingBy(FireBrigadeResourceDto::getTeamId));
Map<String, List<FireBrigadeResourceDto>> resultMap = fireCarDtoList.stream().collect(Collectors.groupingBy(FireBrigadeResourceDto::getTeamId));
if (!ValidationUtil.isEmpty(fullTimeFireBrigadeList)) {
fullTimeFireBrigadeList.forEach(brigade -> {
if (!CollectionUtils.isEmpty(resultMap.get(brigade.getSequenceNbr().toString()))) {
......@@ -221,18 +245,18 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
List<FireBrigadeResourceDto> monitorFireBrigadeList = fireTeamService.listMonitorFireBrigade(FireBrigadeTypeEnum.监控大队.getCode());
// List<FireBrigadeResourceDto> monitorFireBrigadeList = fireTeamService.listMonitorFireBrigade();
/*bug 2403 队伍未显示图片 2021-09-23 陈召开始 */
for (FireBrigadeResourceDto fireBrigadeResourceDto : monitorFireBrigadeList) {
if (fireBrigadeResourceDto.getPic() != null) {
String[] split = fireBrigadeResourceDto.getPic().split(",");
if (split.length > 1) {
fireBrigadeResourceDto.setImage(Arrays.asList(split));
} else {
List<String> objects = new ArrayList<>();
objects.add(fireBrigadeResourceDto.getPic());
fireBrigadeResourceDto.setImage(objects);
}
}
}
// for (FireBrigadeResourceDto fireBrigadeResourceDto : monitorFireBrigadeList) {
// if (fireBrigadeResourceDto.getPic() != null) {
// String[] split = fireBrigadeResourceDto.getPic().split(",");
// if (split.length > 1) {
// fireBrigadeResourceDto.setImage(Arrays.asList(split));
// } else {
// List<String> objects = new ArrayList<>();
// objects.add(fireBrigadeResourceDto.getPic());
// fireBrigadeResourceDto.setImage(objects);
// }
// }
// }
/*bug 2403 队伍未显示图片 2021-09-23 陈召结束 */
FireBrigadeResourceDto monitorResourceDto = new FireBrigadeResourceDto();
monitorResourceDto.setId("0");
......@@ -258,6 +282,8 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
powerTransferCompanyResources = new PowerTransferCompanyResources();
BeanUtils.copyProperties(powerTransferCompanyResourcesDto, powerTransferCompanyResources);
powerTransferCompanyResources.setPowerTransferCompanyId(powerTransferCompanySequenceNbr);
//资源状态
powerTransferCompanyResources.setStatus(FireCarStatusEnum.出动.getCode());
powerTransferCompanyResourcesList.add(powerTransferCompanyResources);
}
return powerTransferCompanyResourcesList;
......
......@@ -20,6 +20,10 @@
<artifactId>amos-boot-module-common-biz</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
</dependency>
</dependencies>
</project>
......@@ -24,6 +24,7 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledRequestDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchPaper;
import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator;
import com.yeejoin.amos.boot.module.tzs.api.entity.WechatRelation;
import com.yeejoin.amos.boot.module.tzs.api.enums.AlertStageEnums;
......@@ -195,7 +196,10 @@ public class AlertCalledController extends BaseController {
alertCalledDto.setUseStatus(elevator.getUseStatus());
alertCalledDto.setUseSiteCategory(elevator.getUseSiteCategory());
alertCalledDto.setAlarmType(AlertStageEnums.getEnumById(alertCalledDto.getAlarmTypeCode()).getValue());
alertCalledDto.setEquipmentClassification("电梯");
alertCalledDto.setEquipmentClassificationCode("3000");
alertCalledDto.setCity(elevator.getCity());
alertCalledDto.setDistrict(elevator.getDistrict());
AlertCalledDto alertCalledDtoReturn = iAlertCalledService.createAlertCalled(alertCalledDto);
return ResponseHelper.buildResponse(alertCalledDtoReturn);
}
......@@ -232,6 +236,11 @@ public class AlertCalledController extends BaseController {
alertPaperInfoDto.setAlertStatus(alertCalled.getAlertStage());
alertPaperInfoDto.setElevatorId(elevator.getSequenceNbr() +"");
alertPaperInfoDto.setElevatorCode(elevator.getRegisterCode());
DispatchPaper paper = dispatchPaperServiceImpl.getOne(new LambdaQueryWrapper<DispatchPaper>().eq(DispatchPaper::getIsDelete,false).eq(DispatchPaper::getAlertId,alertId));
if(paper != null) {
alertPaperInfoDto.setFinishTime(paper.getFeedbackFinishTime());
}
return ResponseHelper.buildResponse(alertPaperInfoDto);
}
......
......@@ -45,6 +45,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -509,13 +510,24 @@ public class WechatController extends BaseController {
return ResponseHelper.buildResponse(urlString);
}
/**
* 微信端图片上传
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/downloadWechatPic/{mediaId}")
@ApiOperation(httpMethod = "GET", value = "微信公众号从微信服务器下载图片到自己服务器", notes = "微信公众号从微信服务器下载图片到自己服务器")
public ResponseModel<String> uploadImage(@PathVariable String mediaId) {
if (ValidationUtil.isEmpty(mediaId)){
throw new BadRequest("参数校验失败.");
}
String urlString = wechatService.getWechatPicByMediaId(mediaId);
return ResponseHelper.buildResponse(urlString);
}
private WechatMyBussinessDto getBussinessDtoById(Long alertId) {
WechatMyBussinessDto temp = iAlertCalledService.getBussinessInfoById(alertId);
List<AlertFormValue> paperList = null;
Map<String, List<AttachmentDto>> imgMap = null;
List<AttachmentDto> imgDtos = null;
......@@ -635,4 +647,22 @@ public class WechatController extends BaseController {
}
return temp;
}
/**
* 微信端图片上传
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/testWechatFile")
@ApiOperation(httpMethod = "POST", value = "微信公众号上传图片", notes = "微信公众号上传图片")
public ResponseModel<String> testWechatFile(@ApiParam(value = "图片", required = true)@RequestParam MultipartFile file) {
if (ValidationUtil.isEmpty(file)){
throw new BadRequest("参数校验失败.");
}
String accessToken = wechatService.getAccessToken();
String getPicUrl = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + accessToken + "&type=image";
String url = HttpUtils.doPostWithFile(getPicUrl,file,"media",accessToken,"image");
return ResponseHelper.buildResponse(url);
}
}
......@@ -387,7 +387,8 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
// 警情基本信息
AlertCalled alertCalled = BeanDtoVoUtils.convert(alertCalledObjsDto.getAlertCalledDto(),AlertCalled.class);
alertCalled.setEquipmentClassification("电梯");
alertCalled.setEquipmentClassificationCode("3000");
alertCalled.setCallTime(DateUtils.longStr2Date(alertCalled.getCallTimeStr()));
// 判断是否归并警情
......@@ -425,6 +426,8 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
queryWrapper.eq(Elevator::getRescueCode,alertCalled.getDeviceId());
Elevator elevator = iElevatorService.getOne(queryWrapper);
alertCalled.setEquipmentId(elevator.getSequenceNbr());
alertCalled.setCity(elevator.getCity());
alertCalled.setDistrict(elevator.getDistrict());
this.save(alertCalled);
// 动态表单
......
......@@ -116,6 +116,7 @@ public class ESAlertCalledService {
esAlertCalled.setAlertStatus(alertCalled.getAlertStatus());
esAlertCalled.setEmergencyCall(alertCalled.getEmergencyCall());
esAlertCalled.setDeviceId(alertCalled.getDeviceId());
esAlertCalled.setUseUnit(alertCalled.getUseUnit());
if (alertCalled.getAlertStatus())
{
esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode());
......@@ -141,13 +142,11 @@ public class ESAlertCalledService {
public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size)
{
Page<ESAlertCalledDto> result = new Page<ESAlertCalledDto>(current, size);
String[] alertStatus = alertCalledVo.getAlertStatus();
if (ValidationUtil.isEmpty(alertStatus))
{
return result;
}
AlertCalled alertCalled = BeanDtoVoUtils.convert(alertCalledVo.getAlertCalledDto(),AlertCalled.class);
if (ValidationUtil.isEmpty(alertCalled))
{
......@@ -157,54 +156,92 @@ public class ESAlertCalledService {
* 通用匹配规则,条件构建
*/
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//警情状态
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
for (String status : alertStatus)
//警情状态
BoolQueryBuilder qbstatus = QueryBuilders.boolQuery();
for (String status : alertStatus)
{
AlertStatusEnum alertStatusEnum = AlertStatusEnum.getEnum(status);
if (!ValidationUtil.isEmpty(alertStatusEnum))
AlertStatusEnum alertStatusEnum = AlertStatusEnum.getEnum(status);
if (!ValidationUtil.isEmpty(alertStatusEnum))
{
qb0.should(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getCode()));
qbstatus.should(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getCode()));
}
}
boolMust.must(qb0);
//接警时间,距离当前时间不超过两个小时的
long currentTime = System.currentTimeMillis() ;
currentTime = currentTime - 120*60*1000;
BoolQueryBuilder qb1 = QueryBuilders.boolQuery()
.filter(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime));
boolMust.must(qb1);
//报警电话一致
if (!ValidationUtil.isEmpty(alertCalled.getEmergencyCall()) && !ValidationUtil.isEmpty(alertCalled.getContactPhone()))
boolMust.must(qbstatus);
// 如果没有搜索条件不搜索
boolean flag = true;
// ①事发地点一致,或相距不超过200米的;&& ②警情类别一致;&& ③报警时间:距离当前时间不超过两小时的
if (!ValidationUtil.isEmpty(alertCalled.getAddress()) && !ValidationUtil.isEmpty(alertCalled.getAlarmTypeCode()) && !ValidationUtil.isEmpty(alertCalled.getAlarmTypeCode()))
{
BoolQueryBuilder qb2 = QueryBuilders.boolQuery()
.should(QueryBuilders.termQuery("emergencyCall.keyword", alertCalled.getEmergencyCall()))
.should(QueryBuilders.termQuery("contactPhone.keyword", alertCalled.getContactPhone()));
boolMust.must(qb2);
flag = false;
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
BoolQueryBuilder temp1 = QueryBuilders.boolQuery()
.filter(QueryBuilders.matchQuery("address", alertCalled.getAddress()));
qb0.must(temp1);
BoolQueryBuilder temp2 = QueryBuilders.boolQuery()
.filter(QueryBuilders.matchQuery("alarmTypeCode", alertCalled.getAlarmTypeCode()));
qb0.must(temp2);
//接警时间,距离当前时间不超过两个小时的
long currentTime = System.currentTimeMillis() ;
currentTime = currentTime - 120*60*1000;
BoolQueryBuilder temp3 = QueryBuilders.boolQuery()
.filter(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime));
qb0.must(temp3);
boolMust.should(qb0);
}
//事发地点一致,或相距不超过200米的
if (!ValidationUtil.isEmpty(alertCalled.getAddress()))
{
BoolQueryBuilder qb3 = QueryBuilders.boolQuery()
.filter(QueryBuilders.matchQuery("address", alertCalled.getAddress()));
boolMust.should(qb3);
// 报警电话一致;
if (!ValidationUtil.isEmpty(alertCalled.getEmergencyCall())) {
flag = false;
BoolQueryBuilder tempQb = QueryBuilders.boolQuery();
BoolQueryBuilder tempQb1 = QueryBuilders.boolQuery()
.filter(QueryBuilders.termQuery("emergencyCall.keyword", alertCalled.getEmergencyCall()));
tempQb.must(tempQb1);
boolMust.should(tempQb);
}
//警情类型一致
BoolQueryBuilder qb4 = QueryBuilders.boolQuery()
.filter(QueryBuilders.termQuery("alarmTypeCode", alertCalled.getAlarmTypeCode()));
boolMust.must(qb4);
//使用单位名称一致
if (!ValidationUtil.isEmpty(alertCalled.getUseUnit()))
{
BoolQueryBuilder qb5 = QueryBuilders.boolQuery()
.filter(QueryBuilders.termQuery("useUnit.keyword", alertCalled.getUseUnit()));
boolMust.must(qb5);
// 使用单位名称一致;&& ②警情类别一致;&& ③报警时间:距离当前时间不超过两小时的
if (!ValidationUtil.isEmpty(alertCalled.getUseUnit()) && !ValidationUtil.isEmpty(alertCalled.getAlarmTypeCode()) ) {
flag = false;
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
BoolQueryBuilder temp1 = QueryBuilders.boolQuery()
.filter(QueryBuilders.termQuery("useUnit.keyword", alertCalled.getUseUnit()));
qb0.must(temp1);
BoolQueryBuilder temp2 = QueryBuilders.boolQuery()
.filter(QueryBuilders.termQuery("alarmTypeCode.keyword", alertCalled.getAlarmTypeCode()));
qb0.must(temp2);
//接警时间,距离当前时间不超过两个小时的
long currentTime = System.currentTimeMillis() ;
currentTime = currentTime - 120*60*1000;
BoolQueryBuilder temp3 = QueryBuilders.boolQuery()
.filter(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime));
qb0.must(temp3);
boolMust.should(qb0);
}
//电梯识别码一致
if(!ValidationUtil.isEmpty(alertCalled.getDeviceId())) {
BoolQueryBuilder qb6 = QueryBuilders.boolQuery()
// 电梯识别码一致;&& ③报警时间:距离当前时间不超过两小时的
if (!ValidationUtil.isEmpty(alertCalled.getDeviceId())) {
flag = false;
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
BoolQueryBuilder temp = QueryBuilders.boolQuery()
.filter(QueryBuilders.termQuery("deviceId.keyword", alertCalled.getDeviceId()));
boolMust.must(qb6);
qb0.must(temp);
//接警时间,距离当前时间不超过两个小时的
long currentTime = System.currentTimeMillis() ;
currentTime = currentTime - 120*60*1000;
BoolQueryBuilder temp2 = QueryBuilders.boolQuery()
.filter(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime));
qb0.must(temp2);
boolMust.should(qb0);
}
boolMust.minimumShouldMatch(1);//至少满足一个
if(flag) { // 不搜素
return result;
}
/**
......
......@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledFormDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.DispatchPaperFormDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.RepairConsultDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.RescueProcessDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchPaper;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchTask;
......@@ -275,6 +276,12 @@ public class RepairConsultServiceImpl extends BaseService<RepairConsultDto,Repai
// 警情伤亡消息 矩阵 消息
JSONObject jsonObject = new JSONObject();
jsonObject.put("alertId",String.valueOf(alertCalledVo.getSequenceNbr()));
// KRJY 的 repaired complainantBack 和 reportorBack 警情完成
if(CZHJ == DispatchPaperEnums.reportorBack || CZHJ == DispatchPaperEnums.complainantBack) {
jsonObject.put("finished",true);
} else if(CZHJ == DispatchPaperEnums.repaired && alertCalledVo.getAlarmTypeCode().equals(AlertStageEnums.KRJY.getId())) {
jsonObject.put("finished",true);
}
try {
emqKeeper.getMqttClient().publish(alertHeartpushTopic, jsonObject.toString().getBytes("UTF-8"), 1, false);
emqKeeper.getMqttClient().publish(alertMatrixpushTopic, jsonObject.toString().getBytes("UTF-8"), 1, false);
......
......@@ -7,12 +7,19 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.WechatMessageDto;
import com.yeejoin.amos.boot.module.tzs.api.service.IWechatService;
import com.yeejoin.amos.boot.module.tzs.biz.utils.HttpUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
......@@ -146,5 +153,28 @@ public class WechatServiceImpl implements IWechatService {
return response;
}
@Override
public String getWechatPicByMediaId(String mediaId) {
String accessToken = this.getAccessToken();
String getPicUrl = wechatUrl + "/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
Map<String, Object> result = HttpUtils.doGetDownload(getPicUrl);
if(result.get("bytes") == null) {
throw new BadRequest("获取附件失败");
}
byte[] bytes = (byte[]) result.get("bytes");
String fileName = (String) result.get("filename");
String urlString="";
MultipartFile file = new MockMultipartFile(fileName,fileName,"application/octet-stream" ,bytes);
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFile(file);
if (date != null) {
Map<String, String> map = date.getResult();
Iterator<String> it = map.keySet().iterator();
while (it.hasNext()) {
urlString=it.next();
}
}
return urlString;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.biz.utils;
import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
......@@ -12,7 +14,11 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
......@@ -21,11 +27,15 @@ import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
......@@ -358,6 +368,114 @@ public class HttpUtils {
}
/**
* 发送get请求并且获取下载字节流
* @param apiUrl
* @return
*/
public static Map<String, Object> doGetDownload(String apiUrl) {
Map<String, Object> result = new HashMap<>();
InputStream inputStream = null;
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()).setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
HttpGet httpGet = new HttpGet(apiUrl);
CloseableHttpResponse response = null;
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
try {
response = httpClient.execute(httpGet);
Header[] heads = response.getHeaders("Content-disposition");
HeaderElement[] elements = heads[0].getElements();
for (HeaderElement el : elements) {
NameValuePair pair = el.getParameterByName("filename");
result.put("filename",pair.getValue());
}
HttpEntity entity = response.getEntity();
inputStream = entity.getContent();
byte[] buff = new byte[1024];
int rc = 0;
while ((rc = inputStream.read(buff, 0, buff.length)) > 0) {
swapStream.write(buff, 0, rc);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
result.put("bytes",swapStream.toByteArray());
return result;
}
/**
* 发送上传post 文件
* @param apiUrl
* @param file
* @return
*/
public static String doPostWithFile(String apiUrl, MultipartFile file, String fileParam, String token , String type) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
try {
httpPost.addHeader("Connection", "keep-alive");
httpPost.addHeader("Accept", "*/*");
httpPost.addHeader("Content-Type", "multipart/form-data;boundary=------------7da2e536604c8");
httpPost.addHeader("User-Agent",
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setBoundary("------------7da2e536604c8")
.setCharset(Charset.forName("UTF-8"))
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addTextBody("type", type);
// 设置access_token,
builder.addTextBody("access_token", token);
String fileName = null;
fileName = file.getOriginalFilename();
builder.addBinaryBody(fileParam, file.getBytes(), ContentType.APPLICATION_OCTET_STREAM, fileName);// 文件流
//解决中文乱码
// for (Map.Entry<String, Object> entry : params.entrySet()) {
// if(entry.getValue() == null) {
// continue;
// }
// // 类似浏览器表单提交,对应input的name和value
// builder.addTextBody(entry.getKey(), entry.getValue().toString());
// }
HttpEntity entity = builder.build();
httpPost.setEntity(entity);
response = httpClient.execute(httpPost);// 执行提交
HttpEntity result = response.getEntity();
httpStr = EntityUtils.toString(result, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 创建SSL安全连接
*
* @return
......
......@@ -1795,7 +1795,6 @@
</sql>
</changeSet>
<changeSet id="2021-10-14" author="cz">
<preConditions onFail="MARK_RAN">
<tableExists tableName="cb_org_usr_safe_report"/>
</preConditions>
......@@ -1805,4 +1804,28 @@
ALTER TABLE cb_org_usr_safe_report MODIFY COLUMN duty_person_id bigint(20);
</sql>
</changeSet>
<changeSet author="tw" id="2021-10-15-1">
<preConditions onFail="MARK_RAN">
<tableExists tableName="cb_data_dictionary" />
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions>
<comment>add data cb_data_dictionary</comment>
<sql>
INSERT INTO `amos-jcs-biz`.`cb_data_dictionary`(`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES (1330, '2', '出动', 'CARSTATE', NULL, NULL, NULL, NULL, NULL, b'0', 2);
INSERT INTO `amos-jcs-biz`.`cb_data_dictionary`(`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES (1331, '3', '途中', 'CARSTATE', NULL, NULL, NULL, NULL, NULL, b'0', 3);
INSERT INTO `amos-jcs-biz`.`cb_data_dictionary`(`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES (1332, '4', '到场', 'CARSTATE', NULL, NULL, NULL, NULL, NULL, b'0', 4);
INSERT INTO `amos-jcs-biz`.`cb_data_dictionary`(`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES (1333, '5', '出水', 'CARSTATE', NULL, NULL, NULL, NULL, NULL, b'0', 5);
INSERT INTO `amos-jcs-biz`.`cb_data_dictionary`(`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES (1334, '6', '停水', 'CARSTATE', NULL, NULL, NULL, NULL, NULL, b'0', 6);
INSERT INTO `amos-jcs-biz`.`cb_data_dictionary`(`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES (1335, '7', '驻防', 'CARSTATE', NULL, NULL, NULL, NULL, NULL, b'0', 7);
INSERT INTO `amos-jcs-biz`.`cb_data_dictionary`(`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES (1336, '8', '返队', 'CARSTATE', NULL, NULL, NULL, NULL, NULL, b'0', 8);
</sql>
</changeSet>
</databaseChangeLog>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment