1.口门门禁-检查部门初始化-新增部门修改,删除
parent
30403abd28
commit
fd8e03cabb
|
|
@ -2,10 +2,17 @@ package com.zcloud.primeport.command;
|
|||
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.primeport.domain.gateway.InspectionDeptGateway;
|
||||
import com.zcloud.primeport.domain.gateway.InspectionVehicleGateway;
|
||||
import com.zcloud.primeport.domain.gateway.VehicleMessageGateway;
|
||||
import com.zcloud.primeport.persistence.dataobject.InspectionVehicleDO;
|
||||
import com.zcloud.primeport.persistence.repository.InspectionVehicleRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* web-app
|
||||
|
|
@ -17,10 +24,18 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@AllArgsConstructor
|
||||
public class InspectionDeptRemoveExe {
|
||||
private final InspectionDeptGateway inspectionDeptGateway;
|
||||
|
||||
private final InspectionVehicleRepository inspectionVehicleRepository;
|
||||
private final InspectionVehicleGateway inspectionVehicleGateway;
|
||||
private final VehicleMessageGateway vehicleMessageGateway;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(Long id) {
|
||||
boolean res = inspectionDeptGateway.deletedInspectionDeptById(id);
|
||||
List<InspectionVehicleDO> vehicleDOS = inspectionVehicleRepository.queryInspectionVehicleByDeptId(id); //获取这个部门下的车辆信息
|
||||
Map<Long, InspectionVehicleDO> vehicleMap = vehicleDOS.stream().collect(java.util.stream.Collectors.toMap(InspectionVehicleDO::getId, InspectionVehicleDO -> InspectionVehicleDO)); //循环一下
|
||||
for (InspectionVehicleDO vehicleDO : vehicleMap.values()){ ///删除车辆 删除关系
|
||||
inspectionVehicleGateway.deletedInspectionVehicleById(vehicleDO.getId());
|
||||
vehicleMessageGateway.deletedVehicleMessageById(vehicleDO.getVehicleMessageId());
|
||||
}
|
||||
if (!res) {
|
||||
throw new BizException("删除失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,23 @@ package com.zcloud.primeport.command;
|
|||
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.primeport.domain.gateway.InspectionDeptGateway;
|
||||
import com.zcloud.primeport.domain.gateway.InspectionVehicleGateway;
|
||||
import com.zcloud.primeport.domain.gateway.VehicleMessageGateway;
|
||||
import com.zcloud.primeport.domain.model.InspectionDeptE;
|
||||
import com.zcloud.primeport.domain.model.InspectionVehicleE;
|
||||
import com.zcloud.primeport.domain.model.VehicleMessageE;
|
||||
import com.zcloud.primeport.dto.InspectionDeptUpdateCmd;
|
||||
import com.zcloud.primeport.dto.VehicleInspectionUpdateCmd;
|
||||
import com.zcloud.primeport.persistence.dataobject.InspectionVehicleDO;
|
||||
import com.zcloud.primeport.persistence.repository.InspectionVehicleRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* web-app
|
||||
|
|
@ -20,12 +30,42 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@AllArgsConstructor
|
||||
public class InspectionDeptUpdateExe {
|
||||
private final InspectionDeptGateway inspectionDeptGateway;
|
||||
private final InspectionVehicleGateway inspectionVehicleGateway;
|
||||
private final VehicleMessageGateway vehicleMessageGateway;
|
||||
|
||||
private final InspectionVehicleRepository inspectionVehicleRepository;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void execute(InspectionDeptUpdateCmd inspectionDeptUpdateCmd) {
|
||||
InspectionDeptE inspectionDeptE = new InspectionDeptE();
|
||||
BeanUtils.copyProperties(inspectionDeptUpdateCmd, inspectionDeptE);
|
||||
boolean res = inspectionDeptGateway.update(inspectionDeptE);
|
||||
List<InspectionVehicleDO> vehicleDOS = inspectionVehicleRepository.queryInspectionVehicleByDeptId(inspectionDeptE.getId()); //获取这个部门下的车辆信息
|
||||
Map<Long, InspectionVehicleDO> vehicleMap = vehicleDOS.stream().collect(java.util.stream.Collectors.toMap(InspectionVehicleDO::getId, InspectionVehicleDO -> InspectionVehicleDO)); //循环一下
|
||||
for (VehicleInspectionUpdateCmd vehicleInspectionAddCmd : inspectionDeptUpdateCmd.getVehicleMessageAddCmd()) {
|
||||
if (vehicleInspectionAddCmd.getId() == null){ //新增
|
||||
VehicleMessageE vehicleMessageE = new VehicleMessageE();
|
||||
BeanUtils.copyProperties(vehicleInspectionAddCmd, vehicleMessageE);
|
||||
vehicleMessageE.VehicleMessageForInspection(vehicleMessageE);
|
||||
VehicleMessageE vehicleAdd = vehicleMessageGateway.add(vehicleMessageE);// 添加车辆信息
|
||||
InspectionVehicleE inspectionVehicleE = new InspectionVehicleE();
|
||||
inspectionVehicleE.addDeptInspection(inspectionDeptUpdateCmd.getId(),vehicleAdd.getId()); //车辆和部门之间的关系
|
||||
res = inspectionVehicleGateway.add(inspectionVehicleE);
|
||||
}else{
|
||||
//修改
|
||||
VehicleMessageE vehicleMessageE = new VehicleMessageE();
|
||||
BeanUtils.copyProperties(vehicleInspectionAddCmd, vehicleMessageE);
|
||||
vehicleMessageE.VehicleMessageForInspection(vehicleMessageE);
|
||||
vehicleMessageGateway.update(vehicleMessageE);// 添加车辆信息
|
||||
}
|
||||
if (vehicleMap.containsKey(vehicleInspectionAddCmd.getId())){
|
||||
vehicleMap.remove(vehicleInspectionAddCmd.getId());
|
||||
}
|
||||
}
|
||||
for (InspectionVehicleDO vehicleDO : vehicleMap.values()){ ///如果没返回回来,就删除车辆 删除关系
|
||||
inspectionVehicleGateway.deletedInspectionVehicleById(vehicleDO.getId());
|
||||
vehicleMessageGateway.deletedVehicleMessageById(vehicleDO.getVehicleMessageId());
|
||||
}
|
||||
if (!res) {
|
||||
throw new BizException("修改失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.zcloud.primeport.command.convertor;
|
||||
|
||||
import com.zcloud.primeport.domain.model.InspectionVehicleE;
|
||||
import com.zcloud.primeport.dto.clientobject.InspectionVehicleCO;
|
||||
import com.zcloud.primeport.persistence.dataobject.InspectionVehicleDO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
|
@ -20,5 +21,12 @@ public interface InspectionVehicleCoConvertor {
|
|||
* @return
|
||||
*/
|
||||
List<InspectionVehicleCO> converDOsToCOs(List<InspectionVehicleDO> inspectionVehicleDOs);
|
||||
|
||||
|
||||
/**
|
||||
* @param inspectionVehicleDO
|
||||
* @return
|
||||
*/
|
||||
InspectionVehicleE converDOToE( InspectionVehicleDO inspectionVehicleDO);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import java.util.List;
|
|||
@AllArgsConstructor
|
||||
public class InspectionDeptAddCmd extends Command {
|
||||
|
||||
@ApiModelProperty(value = "主键", name = "id", required = true)
|
||||
@NotEmpty(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "名称", name = "name", required = true)
|
||||
@NotEmpty(message = "名称不能为空")
|
||||
private String name;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* web-client
|
||||
|
|
@ -28,5 +29,9 @@ public class InspectionDeptUpdateCmd extends Command {
|
|||
@NotEmpty(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "单位车辆信息部门为空", name = "VehicleMessageAddCmd", required = true)
|
||||
@NotEmpty(message = "单位车辆信息部门为空")
|
||||
List<VehicleInspectionUpdateCmd> VehicleMessageAddCmd;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
package com.zcloud.primeport.dto;
|
||||
|
||||
|
||||
import com.alibaba.cola.dto.Command;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* web-client
|
||||
*
|
||||
* @Author guoyuepeng
|
||||
* @Date 2025-11-15 11:41:21
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VehicleInspectionUpdateCmd extends Command {
|
||||
@ApiModelProperty(value = "车辆id", name = "id")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "车牌类型 0-白牌 1- 蓝牌 2-黄牌 3-绿牌 4-黑牌", name = "licenceType", required = true)
|
||||
@NotNull(message = "车牌类型 0-白牌 1- 蓝牌 2-黄牌 3-绿牌 4-黑牌不能为空")
|
||||
private Integer licenceType;
|
||||
@ApiModelProperty(value = "车牌号", name = "licenceNo", required = true)
|
||||
@NotEmpty(message = "车牌号不能为空")
|
||||
private String licenceNo;
|
||||
@ApiModelProperty(value = "车辆类型", name = "vehicleType", required = true)
|
||||
@NotEmpty(message = "车辆类型不能为空")
|
||||
private String vehicleType;
|
||||
@ApiModelProperty(value = "访问起始时间", name = "visitStartTime", required = true)
|
||||
@NotEmpty(message = "访问起始时间不能为空")
|
||||
private Date visitStartTime;
|
||||
@ApiModelProperty(value = "访问结束时间", name = "visitEndTime", required = true)
|
||||
@NotEmpty(message = "访问结束时间不能为空")
|
||||
private Date visitEndTime;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -21,5 +21,7 @@ public class InspectionDeptCO extends ClientObject {
|
|||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.zcloud.primeport.domain.gateway;
|
|||
|
||||
import com.zcloud.primeport.domain.model.InspectionVehicleE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* web-domain
|
||||
*
|
||||
|
|
@ -27,5 +29,6 @@ public interface InspectionVehicleGateway {
|
|||
Boolean deletedInspectionVehicleById(Long id);
|
||||
|
||||
Boolean deletedInspectionVehicleByIds(Long[] id);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.zcloud.primeport.gatewayimpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
||||
import com.zcloud.primeport.domain.gateway.InspectionVehicleGateway;
|
||||
import com.zcloud.primeport.domain.model.InspectionVehicleE;
|
||||
import com.zcloud.primeport.persistence.dataobject.InspectionVehicleDO;
|
||||
|
|
@ -9,6 +12,7 @@ import org.springframework.beans.BeanUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* web-infrastructure
|
||||
|
|
@ -46,5 +50,6 @@ public class InspectionVehicleGatewayImpl implements InspectionVehicleGateway {
|
|||
public Boolean deletedInspectionVehicleByIds(Long[] ids) {
|
||||
return inspectionVehicleRepository.removeByIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ public class InspectionDeptDO extends BaseDO {
|
|||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "检查部门下的车辆数量")
|
||||
@TableField(exist = false)
|
||||
private Integer vehicleCount;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.zcloud.primeport.persistence.repository;
|
|||
import com.alibaba.cola.dto.PageResponse;
|
||||
import com.jjb.saas.framework.repository.repo.BaseRepository;
|
||||
import com.zcloud.primeport.persistence.dataobject.InspectionVehicleDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -13,5 +15,7 @@ import java.util.Map;
|
|||
*/
|
||||
public interface InspectionVehicleRepository extends BaseRepository<InspectionVehicleDO> {
|
||||
PageResponse<InspectionVehicleDO> listPage(Map<String, Object> parmas);
|
||||
|
||||
List<InspectionVehicleDO> queryInspectionVehicleByDeptId(Long deptId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ public class InspectionDeptRepositoryImpl extends BaseRepositoryImpl<InspectionD
|
|||
IPage<InspectionDeptDO> iPage = new Query<InspectionDeptDO>().getPage(parmas);
|
||||
QueryWrapper<InspectionDeptDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper = PageQueryHelper.createPageQueryWrapper(queryWrapper, parmas);
|
||||
queryWrapper.select("inspection_dept.*",
|
||||
"(SELECT COUNT(*) FROM inspection_vehicle WHERE inspection_vehicle.inspection_dept_id = inspection_dept.id)" +
|
||||
" AS vehicle_count");
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
IPage<InspectionDeptDO> result = inspectionDeptMapper.selectPage(iPage, queryWrapper);
|
||||
return PageHelper.pageToResponse(result, result.getRecords());
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.zcloud.primeport.persistence.repository.InspectionVehicleRepository;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -35,5 +36,16 @@ public class InspectionVehicleRepositoryImpl extends BaseRepositoryImpl<Inspecti
|
|||
IPage<InspectionVehicleDO> result = inspectionVehicleMapper.selectPage(iPage, queryWrapper);
|
||||
return PageHelper.pageToResponse(result, result.getRecords());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InspectionVehicleDO> queryInspectionVehicleByDeptId(Long deptId) {
|
||||
QueryWrapper<InspectionVehicleDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("inspection_dept_id", deptId);
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
List<InspectionVehicleDO> list = inspectionVehicleMapper.selectList(queryWrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue