Commit 9f8adfff authored by wdy's avatar wdy

查看标准详情&编辑标准

parent 625c2463
package com.ruoyi.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@ApiModel(value = "StandardInspectionItemRelation", description = "标准-检验项关系")
@TableName(value ="t_standard_inspection_item_relation", autoResultMap = true)
@Accessors(chain = true)
@Data
public class StandardInspectionItemRelation {
@ApiModelProperty("主键")
@TableId(type = IdType.ASSIGN_ID)
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;
/**
* 标准id
*/
@ApiModelProperty("标准id")
private Long standardId;
/**
* 检验项id
*/
@ApiModelProperty("检验项id")
private Long dictCode;
}
package com.ruoyi.domain.vo;
import lombok.Data;
@Data
public class DictDataVO {
private Long dictCode;
}
package com.ruoyi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.StandardInspectionItemRelation;
import com.ruoyi.domain.vo.DictDataVO;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface StandardInspectionItemRelationMapper extends BaseMapper<StandardInspectionItemRelation> {
List<DictDataVO> getListByStandardId(Long standardId);
/**
* 根据标准id获取列表
* @param standardId
* @return
*/
List<StandardInspectionItemRelation> getListByStandard(Long standardId);
}
package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.StandardInspectionItemRelation;
public interface StandardInspectionItemRelationService extends IService<StandardInspectionItemRelation> {
}
......@@ -5,6 +5,7 @@ import com.ruoyi.domain.Standard;
import com.ruoyi.web.request.StandardEditRequest;
import com.ruoyi.web.request.StandardGetInfoRequest;
import com.ruoyi.web.request.StandardListRequest;
import com.ruoyi.web.response.StandardResponse;
import java.util.List;
......@@ -21,5 +22,5 @@ public interface StandardService extends IService<Standard> {
void editStandard(StandardEditRequest request);
Standard getInfo(StandardGetInfoRequest request);
StandardResponse getInfo(StandardGetInfoRequest request);
}
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.StandardInspectionItemRelation;
import com.ruoyi.mapper.StandardInspectionItemRelationMapper;
import com.ruoyi.service.StandardInspectionItemRelationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Transactional
@Service
public class StandardInspectionItemRelationServiceImpl extends ServiceImpl<StandardInspectionItemRelationMapper, StandardInspectionItemRelation> implements StandardInspectionItemRelationService {
}
......@@ -3,13 +3,18 @@ package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.domain.Standard;
import com.ruoyi.domain.StandardInspectionItemRelation;
import com.ruoyi.domain.vo.DictDataVO;
import com.ruoyi.mapper.StandardInspectionItemRelationMapper;
import com.ruoyi.mapper.StandardMapper;
import com.ruoyi.service.StandardInspectionItemRelationService;
import com.ruoyi.service.StandardService;
import com.ruoyi.web.request.StandardEditRequest;
import com.ruoyi.web.request.StandardGetInfoRequest;
import com.ruoyi.web.request.StandardListRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.response.StandardResponse;
import java.util.List;
......@@ -22,6 +27,12 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i
@Autowired
private StandardService standardService;
@Autowired
private StandardInspectionItemRelationMapper standardInspectionItemRelationMapper;
@Autowired
private StandardInspectionItemRelationService standardInspectionItemRelationService;
/**
* 分页查询
* @param
......@@ -47,11 +58,29 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i
Standard standard = new Standard();
BeanUtils.copyBeanProp(standard, request);
List<StandardInspectionItemRelation> list = standardInspectionItemRelationMapper.getListByStandard(request.getId());
if (list != null && list.size() != 0) {
standardInspectionItemRelationMapper.deleteBatchIds(list);
}
List<StandardInspectionItemRelation> relations = request.getDictList();
if (relations != null && relations.size() != 0) {
standardInspectionItemRelationService.saveBatch(relations);
}
standardService.updateById(standard);
}
@Override
public Standard getInfo(StandardGetInfoRequest request) {
return standardMapper.selectById(request.getId());
public StandardResponse getInfo(StandardGetInfoRequest request) {
StandardResponse response = new StandardResponse();
Standard standard = standardMapper.selectById(request.getId());
List<DictDataVO> list = standardInspectionItemRelationMapper.getListByStandardId(request.getId());
BeanUtils.copyBeanProp(response, standard);
response.setDictList(list);
return response;
}
}
......@@ -9,8 +9,7 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.Standard;
import com.ruoyi.service.StandardService;
import com.ruoyi.web.request.*;
import com.ruoyi.web.response.ReviewSceneChangeTaskResponse;
import com.ruoyi.web.response.TaskGetInfoResponse;
import com.ruoyi.web.response.StandardResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.skywalking.apm.toolkit.trace.Tag;
......@@ -58,9 +57,9 @@ public class StandardController extends BaseController {
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getById")
public R<Standard> getInfo(@Validated @RequestBody StandardGetInfoRequest request) {
public R<StandardResponse> getInfo(@Validated @RequestBody StandardGetInfoRequest request) {
Standard standard = standardService.getInfo(request);
return R.ok(standard);
StandardResponse response = standardService.getInfo(request);
return R.ok(response);
}
}
package com.ruoyi.web.request;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.domain.StandardInspectionItemRelation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -38,6 +38,6 @@ public class StandardEditRequest {
@ApiModelProperty("实施日期")
private Date implementationDate;
@ApiModelProperty("实施日期")
List<Long> dictList;
@ApiModelProperty("检验项id")
List<StandardInspectionItemRelation> dictList;
}
package com.ruoyi.web.response;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.domain.vo.DictDataVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@ApiModel(value = "StandardResponse", description = "标准库详情")
@Data
public class StandardResponse {
@ApiModelProperty("主键")
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;
@ApiModelProperty("标准名称")
private String name;
@ApiModelProperty("标准号")
private String standardNo;
@ApiModelProperty("文件路径")
private String file;
@ApiModelProperty("标准分类")
private String standardType;
@ApiModelProperty("标准状态")
private String standardStatus;
@ApiModelProperty("发布日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date releaseDate;
@ApiModelProperty("实施日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date implementationDate;
@ApiModelProperty("检验项")
private List<DictDataVO> dictList;
}
<?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.ruoyi.mapper.StandardInspectionItemRelationMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.domain.StandardInspectionItemRelation">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="standardId" column="standard_id" jdbcType="BIGINT"/>
<result property="dictCode" column="dict_code" jdbcType="BIGINT"/>
</resultMap>
<select id="getListByStandardId" resultType="com.ruoyi.domain.vo.DictDataVO">
SELECT dict_code FROM t_standard_inspection_item_relation
WHERE standard_id = #{standardId}
</select>
<select id="getListByStandard" resultType="com.ruoyi.domain.StandardInspectionItemRelation">
SELECT id, standard_id, dict_code FROM t_standard_inspection_item_relation
WHERE standard_id = #{standardId}
</select>
</mapper>
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