yang_shj
6 months ago
26 changed files with 733 additions and 65 deletions
@ -0,0 +1,25 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.dto; |
||||||
|
|
||||||
|
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @date 2024-05-30 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "车检记录模板DTO类") |
||||||
|
public class CarCheckTemplateDTO { |
||||||
|
|
||||||
|
@ApiModelProperty("模板id") |
||||||
|
private Long id; |
||||||
|
|
||||||
|
@ApiModelProperty("模板名称") |
||||||
|
private String templateName; |
||||||
|
|
||||||
|
@ApiModelProperty("模板详情列表") |
||||||
|
private List<CarCheckTemplateDetailEntity> detailList; |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull; |
||||||
|
import javax.validation.constraints.Size; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检模板详情服务类 |
||||||
|
* |
||||||
|
* @date 2024-05-30 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
@TableName("hzims_car_check_template_detail") |
||||||
|
@ApiModel(value = "车检模板详情实体类") |
||||||
|
public class CarCheckTemplateDetailEntity extends BaseEntity { |
||||||
|
|
||||||
|
@ApiModelProperty("车检记录id") |
||||||
|
private Long templateId; |
||||||
|
|
||||||
|
@NotNull |
||||||
|
@Size(max = 500, message = "检查项目长度不能超过50") |
||||||
|
@ApiModelProperty("检查项目") |
||||||
|
private String checkItem; |
||||||
|
|
||||||
|
@NotNull |
||||||
|
@ApiModelProperty("检查内容") |
||||||
|
private String checkContent; |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* @date 2024-05-28 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
@TableName("hzims_car_check_template") |
||||||
|
@ApiModel(value = "车检模板实体类") |
||||||
|
public class CarCheckTemplateEntity extends BaseEntity { |
||||||
|
|
||||||
|
@ApiModelProperty("模板名称") |
||||||
|
private String templateName; |
||||||
|
|
||||||
|
@TableField(exist = false) |
||||||
|
@ApiModelProperty("创建机构名称") |
||||||
|
private String createDeptName; |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.vo; |
||||||
|
|
||||||
|
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @date 2024-05-30 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "车检模板详情VO类") |
||||||
|
public class CarCheckTemplateDetailVO { |
||||||
|
|
||||||
|
@ApiModelProperty("模板id") |
||||||
|
private Long id; |
||||||
|
|
||||||
|
@ApiModelProperty("模板名称") |
||||||
|
private String templateName; |
||||||
|
|
||||||
|
@ApiModelProperty("模板详情列表") |
||||||
|
private List<CarCheckTemplateDetailEntity> templateDetailList; |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检模板详情Mapper类 |
||||||
|
* |
||||||
|
* @date 2024-05-30 |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface CarCheckTemplateDetailMapper extends BaseMapper<CarCheckTemplateDetailEntity> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.hnac.hzims.safeproduct.mapper.CarCheckTemplateDetailMapper"> |
||||||
|
|
||||||
|
</mapper> |
@ -0,0 +1,20 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Mapper |
||||||
|
public interface CarCheckTemplateMapper extends BaseMapper<CarCheckTemplateEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检分页 |
||||||
|
* @param page 分页类 |
||||||
|
* @param param 参数 |
||||||
|
* @return 分页 |
||||||
|
*/ |
||||||
|
IPage<CarCheckTemplateEntity> getCarCheckTemplatePage(IPage<CarCheckTemplateEntity> page, Map<String, Object> param); |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.hnac.hzims.safeproduct.mapper.CarCheckTemplateMapper"> |
||||||
|
|
||||||
|
<select id="getCarCheckTemplatePage" resultType="com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity"> |
||||||
|
SELECT |
||||||
|
* |
||||||
|
FROM |
||||||
|
hzims_car_check_template |
||||||
|
WHERE |
||||||
|
is_deleted = 0 |
||||||
|
<if test="param.templateName != null and param.templateName != ''"> |
||||||
|
AND template_name like concat('%', #{param.templateName}, '%') |
||||||
|
</if> |
||||||
|
ORDER BY |
||||||
|
create_time DESC |
||||||
|
</select> |
||||||
|
</mapper> |
@ -0,0 +1,61 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.hnac.hzims.safeproduct.dto.CarCheckTemplateDTO; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity; |
||||||
|
import com.hnac.hzims.safeproduct.vo.CarCheckTemplateDetailVO; |
||||||
|
import org.springblade.core.mp.support.Query; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检模板服务类 |
||||||
|
* |
||||||
|
* @date 2024-05-28 |
||||||
|
*/ |
||||||
|
public interface ICarCheckTemplateService extends IService<CarCheckTemplateEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增车检模板 |
||||||
|
* @param dto 车检模板dto类 |
||||||
|
* @return true-成功,false-失败 |
||||||
|
*/ |
||||||
|
boolean saveCarCheckTemplate(CarCheckTemplateDTO dto); |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据名称获取车检模板 |
||||||
|
* @param name 模板名称 |
||||||
|
* @return 车检模板实体类 |
||||||
|
*/ |
||||||
|
CarCheckTemplateEntity getCarCheckTemplateByName(String name); |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改车检模板 |
||||||
|
* @param dto 车检模板dto类 |
||||||
|
* @return true-成功,false-失败 |
||||||
|
*/ |
||||||
|
boolean updateCarCheckTemplate(CarCheckTemplateDTO dto); |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除车检模板 |
||||||
|
* @param id 模板id |
||||||
|
* @return true-成功,false-失败 |
||||||
|
*/ |
||||||
|
boolean removeCarCheckTemplate(Long id); |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检模板详情 |
||||||
|
* @param id 模板id |
||||||
|
* @return 模板详情VO类 |
||||||
|
*/ |
||||||
|
CarCheckTemplateDetailVO getCarCheckTemplateDetail(Long id); |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检分页 |
||||||
|
* @param query 分页类 |
||||||
|
* @param param 参数 |
||||||
|
* @return 分页 |
||||||
|
*/ |
||||||
|
IPage<CarCheckTemplateEntity> getCarCheckTemplatePage(Query query, Map<String, Object> param); |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity; |
||||||
|
import com.hnac.hzims.safeproduct.mapper.CarCheckTemplateDetailMapper; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检模板详情服务实现类 |
||||||
|
* |
||||||
|
* @date 2024-05-30 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class CarCheckTemplateDetailServiceImpl extends ServiceImpl<CarCheckTemplateDetailMapper, CarCheckTemplateDetailEntity> |
||||||
|
implements ICarCheckTemplateDetailService { |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除关联的模板详情数据 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public boolean removeReferenceDetail(Long templateId) { |
||||||
|
List<CarCheckTemplateDetailEntity> list = this.getReferenceDetail(templateId); |
||||||
|
List<Long> ids = list.stream().map(CarCheckTemplateDetailEntity::getId).collect(Collectors.toList()); |
||||||
|
return this.removeByIds(ids); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<CarCheckTemplateDetailEntity> getReferenceDetail(Long templateId) { |
||||||
|
QueryWrapper<CarCheckTemplateDetailEntity> queryWrapper = new QueryWrapper<>(); |
||||||
|
queryWrapper.lambda().eq(CarCheckTemplateDetailEntity::getTemplateId, templateId); |
||||||
|
return this.list(queryWrapper); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,161 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.hnac.hzims.safeproduct.dto.CarCheckTemplateDTO; |
||||||
|
import com.hnac.hzims.safeproduct.entity.*; |
||||||
|
import com.hnac.hzims.safeproduct.mapper.CarCheckTemplateMapper; |
||||||
|
import com.hnac.hzims.safeproduct.service.ICarCheckTemplateService; |
||||||
|
import com.hnac.hzims.safeproduct.vo.CarCheckTemplateDetailVO; |
||||||
|
import org.springblade.core.log.exception.ServiceException; |
||||||
|
import org.springblade.core.mp.support.Query; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.system.feign.ISysClient; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检模板服务实现类 |
||||||
|
* |
||||||
|
* @date 2024-05-28 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class CarCheckTemplateServiceImpl extends ServiceImpl<CarCheckTemplateMapper, CarCheckTemplateEntity> implements ICarCheckTemplateService { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
ICarCheckTemplateDetailService carCheckTemplateDetailService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
CarCheckTemplateMapper carCheckTemplateMapper; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
ISysClient sysClient; |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增车检模板 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
@Transactional(rollbackFor = Exception.class) |
||||||
|
public boolean saveCarCheckTemplate(CarCheckTemplateDTO dto) { |
||||||
|
String templateName = dto.getTemplateName(); |
||||||
|
// 重名校验
|
||||||
|
CarCheckTemplateEntity template = getCarCheckTemplateByName(templateName); |
||||||
|
if (template != null) { |
||||||
|
throw new ServiceException("模板名不可重复"); |
||||||
|
} |
||||||
|
// 新增车检模板
|
||||||
|
CarCheckTemplateEntity templateEntity = new CarCheckTemplateEntity(); |
||||||
|
templateEntity.setTemplateName(templateName); |
||||||
|
boolean saveTemplate = this.save(templateEntity); |
||||||
|
if (!saveTemplate) { |
||||||
|
throw new ServiceException("车检模板新增失败"); |
||||||
|
} |
||||||
|
// 新增模板详情
|
||||||
|
template = getCarCheckTemplateByName(templateName); |
||||||
|
List<CarCheckTemplateDetailEntity> details = dto.getDetailList(); |
||||||
|
for (CarCheckTemplateDetailEntity detail : details) { |
||||||
|
detail.setTemplateId(template.getId()); |
||||||
|
} |
||||||
|
return carCheckTemplateDetailService.saveBatch(details); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据名称获取车检模板 |
||||||
|
*/ |
||||||
|
public CarCheckTemplateEntity getCarCheckTemplateByName(String name) { |
||||||
|
QueryWrapper<CarCheckTemplateEntity> queryWrapper = new QueryWrapper<>(); |
||||||
|
queryWrapper.lambda().eq(CarCheckTemplateEntity::getTemplateName, name); |
||||||
|
return this.getOne(queryWrapper); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改车检模板 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
@Transactional(rollbackFor = Exception.class) |
||||||
|
public boolean updateCarCheckTemplate(CarCheckTemplateDTO dto) { |
||||||
|
String templateName = dto.getTemplateName(); |
||||||
|
Long templateId = dto.getId(); |
||||||
|
// 重名校验
|
||||||
|
QueryWrapper<CarCheckTemplateEntity> queryWrapper = new QueryWrapper<>(); |
||||||
|
queryWrapper.lambda().eq(CarCheckTemplateEntity::getTemplateName, templateName); |
||||||
|
queryWrapper.lambda().ne(CarCheckTemplateEntity::getId, templateId); |
||||||
|
CarCheckTemplateEntity template = this.getOne(queryWrapper); |
||||||
|
if (template != null) { |
||||||
|
throw new ServiceException("模板名不可重复"); |
||||||
|
} |
||||||
|
// 更新模板
|
||||||
|
CarCheckTemplateEntity templateEntity = new CarCheckTemplateEntity(); |
||||||
|
templateEntity.setId(templateId); |
||||||
|
templateEntity.setTemplateName(templateName); |
||||||
|
boolean updateTemplate = this.updateById(templateEntity); |
||||||
|
if (!updateTemplate) { |
||||||
|
throw new ServiceException("车检模板更新失败"); |
||||||
|
} |
||||||
|
// 更新模板详情
|
||||||
|
// 删除旧的模板详情数据
|
||||||
|
boolean removeDetail = carCheckTemplateDetailService.removeReferenceDetail(templateId); |
||||||
|
if (!removeDetail) { |
||||||
|
throw new ServiceException("车检模板详情数据删除失败"); |
||||||
|
} |
||||||
|
// 新增新的模板详情数据
|
||||||
|
List<CarCheckTemplateDetailEntity> detailList = dto.getDetailList(); |
||||||
|
for (CarCheckTemplateDetailEntity detail : detailList) { |
||||||
|
detail.setTemplateId(templateId); |
||||||
|
} |
||||||
|
return carCheckTemplateDetailService.saveBatch(detailList); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除车检模板 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
@Transactional(rollbackFor = Exception.class) |
||||||
|
public boolean removeCarCheckTemplate(Long id) { |
||||||
|
boolean removeTemplate = this.removeById(id); |
||||||
|
if (!removeTemplate) { |
||||||
|
throw new ServiceException("车检模板删除失败"); |
||||||
|
} |
||||||
|
return carCheckTemplateDetailService.removeReferenceDetail(id); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检模板详情 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public CarCheckTemplateDetailVO getCarCheckTemplateDetail(Long id) { |
||||||
|
CarCheckTemplateEntity templateEntity = this.getById(id); |
||||||
|
CarCheckTemplateDetailVO vo = new CarCheckTemplateDetailVO(); |
||||||
|
vo.setId(templateEntity.getId()); |
||||||
|
vo.setTemplateName(templateEntity.getTemplateName()); |
||||||
|
List<CarCheckTemplateDetailEntity> list = carCheckTemplateDetailService.getReferenceDetail(id); |
||||||
|
vo.setTemplateDetailList(list); |
||||||
|
return vo; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检分页 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public IPage<CarCheckTemplateEntity> getCarCheckTemplatePage(Query query, Map<String, Object> param) { |
||||||
|
IPage<CarCheckTemplateEntity> page = new Page<>(query.getCurrent(), query.getSize()); |
||||||
|
IPage<CarCheckTemplateEntity> templatePage = carCheckTemplateMapper.getCarCheckTemplatePage(page, param); |
||||||
|
List<CarCheckTemplateEntity> templateList = templatePage.getRecords(); |
||||||
|
// 获取机构名
|
||||||
|
templateList.forEach(template -> { |
||||||
|
R<String> deptName = sysClient.getDeptName(template.getCreateDept()); |
||||||
|
if (deptName.isSuccess()) { |
||||||
|
template.setCreateDeptName(deptName.getData()); |
||||||
|
} |
||||||
|
}); |
||||||
|
templatePage.setRecords(templateList); |
||||||
|
return templatePage; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
package com.hnac.hzims.safeproduct.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 车检模板详情服务类 |
||||||
|
* |
||||||
|
* @date 2024-05-30 |
||||||
|
*/ |
||||||
|
public interface ICarCheckTemplateDetailService extends IService<CarCheckTemplateDetailEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除关联的模板详情数据 |
||||||
|
* @param templateId 模板id |
||||||
|
* @return true-成功,false-失败 |
||||||
|
*/ |
||||||
|
boolean removeReferenceDetail(Long templateId); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询关联的模板详情列表 |
||||||
|
* @param templateId 模板id |
||||||
|
* @return 模板详情列表 |
||||||
|
*/ |
||||||
|
List<CarCheckTemplateDetailEntity> getReferenceDetail(Long templateId); |
||||||
|
} |
Loading…
Reference in new issue