Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
ty 11 months ago
parent
commit
44e0995337
  1. 5
      hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java
  2. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java
  3. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java
  4. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java
  5. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java
  6. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMaintenanceMapper.xml
  7. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml
  8. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarUsedRecordMapper.xml
  9. 102
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/scheduled/ToolsPushMsgSchedule.java
  10. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckRecordService.java
  11. 14
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java
  12. 22
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java
  13. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarUsedRecordService.java
  14. 24
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java
  15. 29
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java
  16. 73
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java
  17. 17
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java

5
hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java

@ -49,4 +49,9 @@ public interface CommonConstant {
*/
String DEFAULT_PASSWORD = "123456";
/**
* 租户ID
*/
String TENANT_ID = "200000";
}

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java

@ -305,10 +305,11 @@ public class StationVideoTypeController extends BladeController {
@ApiOperationSupport(order = 140)
@ApiOperation(value = "根据摄像头设备编码获取ws地址", notes = "根据摄像头设备编码获取ws地址")
public R<Map<String,Object>> getWsUrlByPointCode(@RequestParam(value = "pointCodes",required = false) String pointCodes,
@RequestParam(value = "streamType",required = false) Integer streamType,
@RequestParam(value = "host",required = false) String host,
@RequestParam(value = "appKey",required = false) String appKey,
@RequestParam(value = "appSecret",required = false) String appSecret) {
return R.data(stationVideoTypeService.getWsUrlByPointCode(pointCodes,host,appKey,appSecret));
return R.data(stationVideoTypeService.getWsUrlByPointCode(pointCodes,host,appKey,appSecret,streamType));
}
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java

@ -74,6 +74,6 @@ public interface IStationVideoTypeService extends BaseService<StationVideoTypeEn
* @param pointCodes 摄像头设备编码
* @return ws地址
*/
Map<String,Object> getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret);
Map<String,Object> getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret,Integer streamType);
}

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java

@ -198,14 +198,14 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
}
@Override
public Map<String, Object> getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret) {
public Map<String, Object> getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret,Integer streamType) {
Map<String,Object> result = new HashMap<>();
pointCodes = StringUtil.isNotBlank(pointCodes) ? pointCodes : "7eaf556c7d3e429d89cd622256898776,43ee17dafde94c4ba40ad313ebefe6d2,98f51c998acf4dd2951e0484d265710e,6bb1f8ad552444309b68677b8ac3fbaf";
final String finalHost = StringUtil.isNotBlank(host) ? host : videoHost;
final String finalAppKey = StringUtil.isNotBlank(appKey) ? appKey : videoAppKey;
final String finalAppSecret = StringUtil.isNotBlank(appSecret) ? appSecret : videoAppSecret;
Map<String,Object> param = new HashMap<String,Object>(6){{
put("streamType",0);
put("streamType",Func.isNotEmpty(streamType) ? streamType : 0);
put("protocol","ws");
put("transmode",1);
put("expand","transcode=0");

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java

@ -53,21 +53,21 @@ public class CarController extends BladeController {
@ApiOperation(value = "新增车辆")
@ApiOperationSupport(order = 1)
public R saveCar(@Valid @RequestBody CarEntity carEntity) {
return R.status(carService.save(carEntity));
return carService.saveCar(carEntity);
}
@PostMapping("/updateCar")
@ApiOperation(value = "修改车辆")
@ApiOperationSupport(order = 2)
public R updateCar(@Valid @RequestBody CarEntity carEntity) {
return R.status(carService.updateById(carEntity));
return carService.updateCar(carEntity);
}
@PostMapping("/removeCar")
@ApiOperation(value = "删除车辆")
@ApiOperationSupport(order = 3)
public R removeCar(@RequestParam Long id) {
return R.status(carService.removeById(id));
return R.status(carService.removeCar(id));
}
@GetMapping("/carDetail")
@ -101,7 +101,7 @@ public class CarController extends BladeController {
@ApiOperation(value = "修改车辆维保记录")
@ApiOperationSupport(order = 7)
public R updateCarMaintenance(@Valid @RequestBody CarMaintenanceEntity carMaintenanceEntity) {
return R.status(carMaintenanceService.updateById(carMaintenanceEntity));
return carMaintenanceService.updateCarMaintenance(carMaintenanceEntity);
}
@PostMapping("/removeCarMaintenance")

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMaintenanceMapper.xml

@ -26,13 +26,13 @@
WHERE
t1.is_deleted = 0
<if test="param.unit != null and param.unit != ''">
AND t2.unit = #{param.unit}
AND t2.unit like concat('%', #{param.unit}, '%')
</if>
<if test="param.startTime != null and param.startTime != ''">
AND t1.start_time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
AND t1.end_time &lt; #{param.endTime}
AND t1.end_time &lt;= #{param.endTime}
</if>
<if test="param.carId != null and param.carId != ''">
AND t1.car_id = #{param.carId}

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml

@ -4,7 +4,7 @@
<select id="selectCarByYear" resultType="com.hnac.hzims.safeproduct.vo.CarMilesYearVO">
SELECT
t1.unit, t1.car_brand, t1.plate_number
DISTINCT t1.unit, t1.car_brand, t1.plate_number
FROM
hzims_car t1
LEFT JOIN hzims_car_used_record t2 ON t1.id = t2.car_id

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarUsedRecordMapper.xml

@ -26,7 +26,7 @@
WHERE
t1.is_deleted = 0
<if test="param.unit != null and param.unit != ''">
AND t1.unit = #{param.unit}
AND t1.unit like concat('%', #{param.unit}, '%')
</if>
<if test="param.carId != null and param.carId != ''">
AND t1.car_id = #{param.carId}

102
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/scheduled/ToolsPushMsgSchedule.java

@ -0,0 +1,102 @@
package com.hnac.hzims.safeproduct.scheduled;
import com.alibaba.fastjson.JSON;
import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.dto.SmsImmediatelyPushDTO;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.safeproduct.constants.RedisConstants;
import com.hnac.hzims.safeproduct.entity.SafetyToolEntity;
import com.hnac.hzims.safeproduct.service.ISafetyToolService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Set;
@Component
@Slf4j
@RequiredArgsConstructor
public class ToolsPushMsgSchedule {
private final ISafetyToolService toolService;
private final RedisTemplate redisTemplate;
private final IMessageClient messageClient;
@Value("${hzims.safeProduct.safeTool.sms-code}")
private String smsCode;
@XxlJob("toolsPushMessage")
public ReturnT execute(String params) {
Set<String> keys = redisTemplate.keys(RedisConstants.TOOLS_REMIND_MSG + "*");
XxlJobLogger.log("===========安全工器具key值为:"+ JSON.toJSONString(keys) +"===========");
keys.forEach(key -> {
Set<SafetyToolEntity> toolList = redisTemplate.opsForZSet().reverseRangeByScore(key, 0, new Date().getTime());
toolList.forEach(tool -> {
SafetyToolEntity safetyTool = toolService.getById(tool.getId());
// 安全工器具推送消息
this.pushMessageByTool(safetyTool);
});
redisTemplate.opsForZSet().remove(key,toolList.toArray());
});
return ReturnT.SUCCESS;
}
/**
* 推送安全工器具消息
* @param safetyTool 安全工器具实体类
*/
private void pushMessageByTool(SafetyToolEntity safetyTool) {
String alert = "工器具检查提醒:工器具("+safetyTool.getToolName()+")将于"+ DateUtil.format(safetyTool.getNextCheckTime(),DateUtil.PATTERN_DATE)+"到检查时间,请安排时间复核!";
// APP推送
if(SafeToolTypePushUserTask.JG_PUSH == safetyTool.getSendType()) {
BusinessMessageDTO request = new BusinessMessageDTO();
request.setTenantId(CommonConstant.TENANT_ID);
request.setDeptId(safetyTool.getCreateDept());
request.setBusinessKey("安全工器具提醒");
request.setBusinessClassify(MessageConstants.BusinessClassifyEnum.SAFE_PRODUCT.getKey());
request.setTaskId(safetyTool.getId());
request.setContent(alert);
request.setSubject("安全工器具复核时间到期提醒");
request.setUserIds(safetyTool.getNoticeUsers());
request.setCreateUser(safetyTool.getCreateUser());
R<Boolean> messageResult = messageClient.sendAppAndWsMsgByUsers(request);
if(!messageResult.isSuccess()) {
XxlJobLogger.log(safetyTool.getToolCode() + "推送消息失败!");
}
}
// 短信推送
else if(SafeToolTypePushUserTask.APP_PUSH == safetyTool.getSendType()) {
SmsImmediatelyPushDTO smsPush = SmsImmediatelyPushDTO.builder()
.deptId(safetyTool.getCreateDept())
.taskId(safetyTool.getId())
.businessKey("安全工器具提醒")
.businessClassify(MessageConstants.BusinessClassifyEnum.SAFE_PRODUCT.getKey())
.content(alert)
.subject("安全工器具复核时间到期提醒")
.pusher(safetyTool.getNoticeUsers())
.createUser(safetyTool.getCreateUser())
.tenantId(CommonConstant.TENANT_ID)
.resourceCode(smsCode)
.params(new HashMap<String,String>(){{
put("one",safetyTool.getToolName());
put("two",DateUtil.format(safetyTool.getNextCheckTime(),DateUtil.PATTERN_DATE));
}}).build();
R<Boolean> messageResult = messageClient.sendSmsImmediatelyMsg(smsPush);
if(!messageResult.isSuccess()) {
XxlJobLogger.log(safetyTool.getToolCode() + "推送消息失败!");
}
}
}
}

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckRecordService.java

@ -68,4 +68,11 @@ public interface ICarCheckRecordService extends IService<CarCheckRecordEntity> {
* @param response 响应类
*/
void exportCarCheckRecordData(Long id, HttpServletResponse response);
/**
* 删除关联车检记录
* @param carId 车辆id
* @return true-成功false-失败
*/
boolean removeRelativeCarCheckRecord(Long carId);
}

14
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java

@ -65,4 +65,18 @@ public interface ICarMaintenanceService extends IService<CarMaintenanceEntity> {
* @return 车辆维保记录列表
*/
List<CarMaintenanceEntity> getCarMaintenanceByCarIdAndTime(Long carId, String lastTime, String nextTime);
/**
* 更新车辆维保记录
* @param carMaintenanceEntity 车辆维保记录实体类
* @return 结果封装类
*/
R updateCarMaintenance(CarMaintenanceEntity carMaintenanceEntity);
/**
* 删除关联车辆维保记录
* @param carId 车辆id
* @return true-成功false-失败
*/
boolean removeRelativeCarMaintenance(Long carId);
}

22
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.safeproduct.entity.CarEntity;
import com.hnac.hzims.safeproduct.vo.CarMilesYearVO;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import java.util.List;
@ -40,4 +41,25 @@ public interface ICarService extends IService<CarEntity> {
* @return 车辆列表数据
*/
List<CarEntity> getCarListByMaintenanceTime(String today, String yesterday);
/**
* 新增车辆
* @param carEntity 车辆实体类
* @return 结果封装类
*/
R saveCar(CarEntity carEntity);
/**
* 更新车辆
* @param carEntity 车辆实体类
* @return 结果封装类
*/
R updateCar(CarEntity carEntity);
/**
* 删除车辆
* @param id 车辆id
* @return true-成功false-失败
*/
boolean removeCar(Long id);
}

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarUsedRecordService.java

@ -62,4 +62,11 @@ public interface ICarUsedRecordService extends IService<CarUsedRecordEntity> {
* @param response 响应类
*/
void exportCarUsedRecordData(Long id, HttpServletResponse response);
/**
* 删除关联用车记录
* @param carId 车辆id
* @return true-成功false-失败
*/
boolean removeRelativeCarUsedRecord(Long carId);
}

24
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java

@ -30,6 +30,7 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 车检记录服务实现类
@ -193,4 +194,27 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
String pdfPath = savePath + "/车检记录单.pdf";
BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, response);
}
/**
* 删除关联车检记录
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean removeRelativeCarCheckRecord(Long carId) {
QueryWrapper<CarCheckRecordEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CarCheckRecordEntity::getCarId, carId);
List<CarCheckRecordEntity> list = this.list(queryWrapper);
// 若无关联车检记录,返回true
if (CollectionUtils.isEmpty(list)) {
return true;
}
List<Long> ids = list.stream().map(CarCheckRecordEntity::getId).collect(Collectors.toList());
for (Long id : ids) {
boolean removeCarCheckRecord = removeCarCheckRecord(id);
if (!removeCarCheckRecord) {
return false;
}
}
return true;
}
}

29
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java

@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 车辆维保记录服务实现类
@ -133,6 +134,34 @@ public class CarMaintenanceServiceImpl extends ServiceImpl<CarMaintenanceMapper,
}
/**
* 更新车辆维保记录
*/
@Override
public R updateCarMaintenance(CarMaintenanceEntity carMaintenanceEntity) {
String maintenanceStatus = carMaintenanceEntity.getMaintenanceStatus();
if (maintenanceStatus.equals(CarMaintenanceStatusEnum.MAINTAINED.getValue())) {
return R.fail("已确认的维保记录无法被修改");
}
return R.status(this.updateById(carMaintenanceEntity));
}
/**
* 删除关联车辆维保记录
*/
@Override
public boolean removeRelativeCarMaintenance(Long carId) {
QueryWrapper<CarMaintenanceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CarMaintenanceEntity::getCarId, carId);
List<CarMaintenanceEntity> list = this.list(queryWrapper);
// 若无关联车辆维保记录,返回true
if (CollectionUtils.isEmpty(list)) {
return true;
}
List<Long> ids = list.stream().map(CarMaintenanceEntity::getId).collect(Collectors.toList());
return this.removeByIds(ids);
}
/**
* 查询是否存在同月编号
* @param currentMonth 当月
* @return 存在则返回上一编号否则返回null

73
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java

@ -7,10 +7,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.dto.CarMilesYearDTO;
import com.hnac.hzims.safeproduct.entity.CarEntity;
import com.hnac.hzims.safeproduct.mapper.CarMapper;
import com.hnac.hzims.safeproduct.service.ICarCheckRecordService;
import com.hnac.hzims.safeproduct.service.ICarMaintenanceService;
import com.hnac.hzims.safeproduct.service.ICarService;
import com.hnac.hzims.safeproduct.service.ICarUsedRecordService;
import com.hnac.hzims.safeproduct.vo.CarMilesYearVO;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
@ -27,6 +33,15 @@ import java.util.stream.Collectors;
@Service
public class CarServiceImpl extends ServiceImpl<CarMapper, CarEntity> implements ICarService {
@Autowired
ICarMaintenanceService carMaintenanceService;
@Autowired
ICarUsedRecordService carUsedRecordService;
@Autowired
ICarCheckRecordService carCheckRecordService;
/**
* 年度里程数页面
*/
@ -100,8 +115,9 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, CarEntity> implements
res.add(carMilesYearVO);
}
});
carPage.setRecords(res);
return carPage;
page.setRecords(res);
page.setTotal(res.size());
return page;
}
/**
@ -125,4 +141,57 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, CarEntity> implements
.ge(CarEntity::getMaintenanceNextTime, yesterday);
return this.list(queryWrapper);
}
/**
* 新增车辆
*/
@Override
public R saveCar(CarEntity carEntity) {
QueryWrapper<CarEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CarEntity::getPlateNumber, carEntity.getPlateNumber());
CarEntity car = this.getOne(queryWrapper);
if (car == null) {
return R.status(this.save(carEntity));
}
return R.fail("车牌号已存在");
}
/**
* 更新车辆
*/
@Override
public R updateCar(CarEntity carEntity) {
QueryWrapper<CarEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CarEntity::getPlateNumber, carEntity.getPlateNumber())
.ne(CarEntity::getId, carEntity.getId());
CarEntity car = this.getOne(queryWrapper);
if (car == null) {
return R.status(this.updateById(carEntity));
}
return R.fail("车牌号已存在");
}
/**
* 删除车辆
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean removeCar(Long id) {
boolean remove = this.removeById(id);
if (remove) {
// 删除关联维保记录
boolean removeCarMaintenance = carMaintenanceService.removeRelativeCarMaintenance(id);
if (!removeCarMaintenance) {
return false;
}
// 删除关联用车记录
boolean removeCarUsedRecord = carUsedRecordService.removeRelativeCarUsedRecord(id);
if (!removeCarUsedRecord) {
return false;
}
// 删除关联车检记录
return carCheckRecordService.removeRelativeCarCheckRecord(id);
}
return false;
}
}

17
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java

@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 用车记录服务实现类
@ -119,6 +120,22 @@ public class CarUsedRecordServiceImpl extends ServiceImpl<CarUsedRecordMapper, C
}
/**
* 删除关联用车记录
*/
@Override
public boolean removeRelativeCarUsedRecord(Long carId) {
QueryWrapper<CarUsedRecordEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CarUsedRecordEntity::getCarId, carId);
List<CarUsedRecordEntity> list = this.list(queryWrapper);
// 若无关联用车记录,返回true
if (CollectionUtils.isEmpty(list)) {
return true;
}
List<Long> ids = list.stream().map(CarUsedRecordEntity::getId).collect(Collectors.toList());
return this.removeByIds(ids);
}
/**
* 查询是否存在同月编号
* @param currentMonth 当月
* @return 存在则返回上一编号否则返回null

Loading…
Cancel
Save