Commit 39825f8c authored by 王飞's avatar 王飞

Merge branch 'gaoying' into 'dev'

Gaoying

See merge request !65
parents ab0810fd 0f14f512
package com.ruoyi.domain;
import java.util.Date;
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 com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 样品管理对象 t_sample_management
*
* @author ruoyi
* @date 2024-01-29
*/
@ApiModel
@TableName(value ="t_sample")
@Data
public class Sample extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
@ApiModelProperty("主键")
@TableId(type = IdType.ASSIGN_ID)
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;
/** 车企ID 与车企信息表的id关联 */
@JsonFormat(shape = JsonFormat.Shape.STRING)
@ApiModelProperty("关联车企的id")
private Long enterpriseId;
/** 车辆识别码 */
@ApiModelProperty("车辆识别码")
private String identificationCode;
/** 样品编号 */
@ApiModelProperty("样品编号")
private String sampleNumber;
/** 样品名称 */
@ApiModelProperty("样品名称")
private String sampleName;
/** 送样着 */
@ApiModelProperty("送样着")
private String sampleSender;
/** 样品数量 */
@ApiModelProperty("样品数量")
private String numberOfSamples;
/** 送样日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("送样日期")
private Date deliveryDate;
/** 生产日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("生产日期 ")
private Date manufactureDate;
/** 生产企业 */
@ApiModelProperty("生产企业")
private String manufacturingEnterprise;
/** 0:整车样品 1:零部件样品 */
@ApiModelProperty("0:整车样品 1:零部件样品")
private String flag;
/** 生产企业名称*/
@ApiModelProperty("生产企业名称")
private String enterpriseName;
/** 商标 */
@ApiModelProperty("商标")
private String trademark;
/** 备注 */
@ApiModelProperty("备注")
private String remark;
/** 样品照片 */
@ApiModelProperty("样品照片")
private String samplePhotos;
}
package com.ruoyi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.Sample;
import com.ruoyi.web.request.SampleManagementRequest;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SampleManagementMapper extends BaseMapper<Sample> {
/**
* 查询样品管理
*
* @param id 样品管理主键
* @return 样品管理
*/
public Sample selectSampleManagementById(Long id);
/**
* 查询样品管理列表
*
* @param sampleManagementRequest 样品管理
* @return 样品管理集合
*/
public List<Sample> selectSampleManagementList(SampleManagementRequest sampleManagementRequest);
/**
* 新增样品管理
*
* @param tSampleManagement 样品管理
* @return 结果
*/
public int insertSampleManagement(Sample tSampleManagement);
/**
* 修改样品管理
*
* @param tSampleManagement 样品管理
* @return 结果
*/
public int updateSampleManagement(Sample tSampleManagement);
/**
* 删除样品管理
*
* @param id 样品管理主键
* @return 结果
*/
public int deleteSampleManagementById(Long id);
/**
* 查询车辆识别码是否重复
* */
public int selectIdentificationCodeCount(Sample sampleManagement);
/**
* 查询样品编号是否重复
* */
public int selectSampleNumberCount(Sample sampleManagement);
}
package com.ruoyi.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.Sample;
import com.ruoyi.web.request.SampleManagementRequest;
/**
* 样品管理Service接口
*
* @author ruoyi
* @date 2024-01-29
*/
public interface SampleManagementService extends IService<Sample>
{
/**
* 查询样品管理
*
* @param id 样品管理主键
* @return 样品管理
*/
public Sample selectSampleManagementById(Long id);
/**
* 查询样品管理列表
*
* @param sampleManagementRequest 样品管理
* @return 样品管理集合
*/
public List<Sample> selectSampleManagementList(SampleManagementRequest sampleManagementRequest);
/**
* 新增样品管理
*
* @param tSampleManagement 样品管理
* @return 结果
*/
public int insertSampleManagement(Sample tSampleManagement);
/**
* 修改样品管理
*
* @param tSampleManagement 样品管理
* @return 结果
*/
public int updateSampleManagement(Sample tSampleManagement);
/**
* 删除样品管理信息
*
* @param id 样品管理主键
* @return 结果
*/
public int deleteSampleManagementById(Long id);
}
package com.ruoyi.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.domain.Sample;
import com.ruoyi.mapper.SampleManagementMapper;
import com.ruoyi.service.SampleManagementService;
import com.ruoyi.web.request.SampleManagementRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 样品管理Service业务层处理
*
* @author ruoyi
* @date 2024-01-29
*/
@Service
@Transactional
public class SampleManagementServiceImpl extends ServiceImpl<SampleManagementMapper, Sample> implements SampleManagementService
{
@Autowired
private SampleManagementMapper sampleManagementMapper;
/**
* 查询样品管理
*
* @param id 样品管理主键
* @return 样品管理
*/
@Override
public Sample selectSampleManagementById(Long id)
{
return sampleManagementMapper.selectSampleManagementById(id);
}
/**
* 查询样品管理列表
*
* @param sampleManagementRequest 样品管理
* @return 样品管理
*/
@Override
public List<Sample> selectSampleManagementList(SampleManagementRequest sampleManagementRequest)
{
return sampleManagementMapper.selectSampleManagementList(sampleManagementRequest);
}
/**
* 新增样品管理
*
* @param sampleManagement 样品管理
* @return 结果
*/
@Override
public int insertSampleManagement(Sample sampleManagement)
{
// 判断车辆识别码是否重复
int dentificationCode = sampleManagementMapper.selectIdentificationCodeCount(sampleManagement);
if(dentificationCode>0){
throw new ServiceException("车辆识别码已存在");
}
// 判断样品编号是否存在
int sampleNumber = sampleManagementMapper.selectSampleNumberCount(sampleManagement);
if(sampleNumber>0){
throw new ServiceException("样品编号已存在");
}
sampleManagement.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
sampleManagement.setCreateTime(DateUtils.getNowDate());
return sampleManagementMapper.insertSampleManagement(sampleManagement);
}
/**
* 修改样品管理
*
* @param sampleManagement 样品管理
* @return 结果
*/
@Override
public int updateSampleManagement(Sample sampleManagement)
{
// 判断车辆识别码是否重复
int dentificationCode = sampleManagementMapper.selectIdentificationCodeCount(sampleManagement);
if(dentificationCode>0){
throw new ServiceException("车辆识别码已存在");
}
// 判断样品编号是否存在
int sampleNumber = sampleManagementMapper.selectSampleNumberCount(sampleManagement);
if(sampleNumber>0){
throw new ServiceException("样品编号已存在");
}
sampleManagement.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
sampleManagement.setUpdateTime(DateUtils.getNowDate());
return sampleManagementMapper.updateSampleManagement(sampleManagement);
}
/**
* 删除样品管理信息
* @param id 样品管理主键
* @return 结果
*/
@Override
public int deleteSampleManagementById(Long id)
{
return sampleManagementMapper.deleteSampleManagementById(id);
}
}
package com.ruoyi.web;
import java.util.List;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.domain.Sample;
import com.ruoyi.service.SampleManagementService;
import com.ruoyi.web.request.SampleManagementGetInfoRequest;
import com.ruoyi.web.request.SampleManagementRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 样品管理Controller
*
* @author ruoyi
* @date 2024-01-29
*/
@Api(tags = "样品管理")
@RestController
@RequestMapping("/sample/Management")
public class SampleManagementController extends BaseController
{
@Autowired
private SampleManagementService sampleManagementService;
/**
* 查询样品管理列表
*/
@ApiOperation("查询样品管理列表")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/list")
public TableDataInfo list(@Validated @RequestBody SampleManagementRequest request)
{
startPage();
List<Sample> list = sampleManagementService.selectSampleManagementList(request);
return getDataTable(list);
}
/**
* 获取样品管理详细信息
*/
@ApiOperation("获取样品管理详细信息")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getInfo")
public R<Sample> getInfo(@Validated @RequestBody SampleManagementGetInfoRequest request)
{
return R.ok(sampleManagementService.selectSampleManagementById(request.getId()));
}
/**
* 新增样品管理
*/
@ApiOperation("新增样品管理")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "样品管理", businessType = BusinessType.INSERT)
@RequestMapping(method = RequestMethod.POST, value = "/add")
public R<Integer> add(@Validated @RequestBody Sample tSampleManagement)
{
return R.ok(sampleManagementService.insertSampleManagement(tSampleManagement));
}
/**
* 修改样品管理
*/
@ApiOperation("修改样品管理")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "样品管理", businessType = BusinessType.UPDATE)
@RequestMapping(method = RequestMethod.POST, value = "/edit")
public R<Integer> edit(@Validated @RequestBody Sample tSampleManagement)
{
return R.ok(sampleManagementService.updateSampleManagement(tSampleManagement));
}
/**
* 删除样品管理
*/
@ApiOperation(" 删除样品管理")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "样品管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@Validated @RequestBody SampleManagementGetInfoRequest request)
{
return toAjax(sampleManagementService.deleteSampleManagementById(request.getId()));
}
}
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel
public class SampleManagementGetInfoRequest {
@ApiModelProperty("ID")
private Long id;
}
package com.ruoyi.web.request;
import com.ruoyi.common.core.page.PageDomain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel
public class SampleManagementRequest extends PageDomain {
/** 车辆识别码 */
@ApiModelProperty("车辆识别码")
private String identificationCode;
/** 样品编号 */
@ApiModelProperty("样品编号")
private String sampleNumber;
/** 样品名称 */
@ApiModelProperty("样品名称")
private String sampleName;
/** 0:整车样品 1:零部件样品 */
@ApiModelProperty("0:整车样品 1:零部件样品")
private String flag;
}
<?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.SampleManagementMapper">
<resultMap type="com.ruoyi.domain.Sample" id="SampleManagementResult">
<result property="id" column="id" />
<result property="identificationCode" column="identification_code" />
<result property="sampleNumber" column="sample_number" />
<result property="sampleName" column="sample_name" />
<result property="sampleSender" column="sample_sender" />
<result property="numberOfSamples" column="number_of_samples" />
<result property="deliveryDate" column="delivery_date" />
<result property="manufactureDate" column="manufacture_date" />
<result property="manufacturingEnterprise" column="manufacturing_enterprise" />
<result property="flag" column="flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="deleted" column="deleted" />
<result property="enterpriseId" column="enterprise_id" />
<result property="enterpriseName" column="enterprise_name" />
<result property="remark" column="remark" />
<result property="trademark" column="trademark" />
<result property="samplePhotos" column="sample_photos" />
</resultMap>
<sql id="selectTSampleManagementVo">
select sm.id,
sm.identification_code,
sm.sample_number,
sm.sample_name,
sm.sample_sender,
sm.number_of_samples,
sm.delivery_date,
sm.manufacture_date,
sm.manufacturing_enterprise,
sm.flag,
sm.create_by,
sm.create_time,
sm.update_by,
sm.update_time,
sm.deleted,
sm.enterprise_id,
sm.remark,
sm.trademark,
sm.sample_photos,
ae.enterprise_name
from t_sample sm
left join t_automobile_enterprise ae on ae.id = sm.enterprise_id
</sql>
<select id="selectSampleManagementList" parameterType="com.ruoyi.domain.Sample" resultMap="SampleManagementResult">
<include refid="selectTSampleManagementVo"/>
<where>
sm.deleted = 0
<if test="identificationCode != null and identificationCode != ''"> and sm.identification_code like concat('%', #{identificationCode}, '%')</if>
<if test="sampleNumber != null and sampleNumber != ''"> and sm.sample_number like concat('%', #{sampleNumber}, '%')</if>
<if test="sampleName != null and sampleName != ''"> and sm.sample_name like concat('%', #{sampleName}, '%')</if>
<if test="flag != null and flag != ''"> sm.flag = #{flag} </if>
</where>
</select>
<select id="selectSampleManagementById" parameterType="Long" resultMap="SampleManagementResult">
<include refid="selectTSampleManagementVo"/>
where sm.id = #{id}
</select>
<insert id="insertSampleManagement" parameterType="com.ruoyi.domain.Sample" useGeneratedKeys="true" keyProperty="id">
insert into t_sample
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="identificationCode != null">identification_code,</if>
<if test="sampleNumber != null">sample_number,</if>
<if test="sampleName != null">sample_name,</if>
<if test="sampleSender != null">sample_sender,</if>
<if test="numberOfSamples != null">number_of_samples,</if>
<if test="deliveryDate != null">delivery_date,</if>
<if test="manufactureDate != null">manufacture_date,</if>
<if test="manufacturingEnterprise != null">manufacturing_enterprise,</if>
<if test="flag != null">flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="enterpriseId != null">enterprise_id,</if>
<if test="remark != null">remark,</if>
<if test="trademark != null">trademark,</if>
<if test="samplePhotos != null">sample_photos,</if>
<if test="deleted != null">deleted,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="identificationCode != null">#{identificationCode},</if>
<if test="sampleNumber != null">#{sampleNumber},</if>
<if test="sampleName != null">#{sampleName},</if>
<if test="sampleSender != null">#{sampleSender},</if>
<if test="numberOfSamples != null">#{numberOfSamples},</if>
<if test="deliveryDate != null">#{deliveryDate},</if>
<if test="manufactureDate != null">#{manufactureDate},</if>
<if test="manufacturingEnterprise != null">#{manufacturingEnterprise},</if>
<if test="flag != null">#{flag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="enterpriseId != null">#{enterpriseId}</if>
<if test="remark != null">#{remark},</if>
<if test="trademark != null">#{trademark},</if>
<if test="samplePhotos != null">#{samplePhotos},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<update id="updateSampleManagement" parameterType="com.ruoyi.domain.Sample">
update t_sample
<trim prefix="SET" suffixOverrides=",">
<if test="identificationCode != null">identification_code = #{identificationCode},</if>
<if test="sampleNumber != null">sample_number = #{sampleNumber},</if>
<if test="sampleName != null">sample_name = #{sampleName},</if>
<if test="sampleSender != null">sample_sender = #{sampleSender},</if>
<if test="numberOfSamples != null">number_of_samples = #{numberOfSamples},</if>
<if test="deliveryDate != null">delivery_date = #{deliveryDate},</if>
<if test="manufactureDate != null">manufacture_date = #{manufactureDate},</if>
<if test="manufacturingEnterprise != null">manufacturing_enterprise = #{manufacturingEnterprise},</if>
<if test="flag != null">flag = #{flag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="trademark != null">trademark = #{trademark},</if>
<if test="samplePhotos != null">sample_photos = #{samplePhotos},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSampleManagementById" parameterType="Long">
update t_sample set deleted = 1,
where id = #{id}
</delete>
<select id="selectIdentificationCodeCount" parameterType="com.ruoyi.domain.Sample" resultType="integer">
select count(id) from t_sample
<where>
deleted = 0
<if test="flag != null and flag != ''">and flag = #{flag}</if>
<if test="identificationCode != null and identificationCode != ''"> and identification_code = #{identificationCode}</if>
<if test="id != null and id != ''">and id != #{id}</if>
</where>
</select>
<select id="selectSampleNumberCount" parameterType="com.ruoyi.domain.Sample" resultType="integer">
select count(id) from t_sample
<where>
deleted = 0
<if test="flag != null and flag != ''">and flag = #{flag}</if>
<if test="sampleNumber != null and sampleNumber != ''"> and sample_number = #{sampleNumber}</if>
<if test="id != null and id != ''">and id != #{id}</if>
</where>
</select>
</mapper>
\ No newline at end of file
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