Commit 23c281f1 authored by 盖献康's avatar 盖献康

bug(70605) - 车企管理-当企业已经被样品关联时,需要限制不能删除

parent eb6d7fb2
......@@ -4,10 +4,15 @@ import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.Sample;
import com.ruoyi.service.SampleManagementService;
import com.ruoyi.web.request.AutomobileEnterpriseEditRequest;
import com.ruoyi.web.request.AutomobileEnterpriseGetInfoRequest;
import com.ruoyi.web.request.AutomobileEnterpriseListRequest;
import com.ruoyi.web.request.SampleManagementRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -39,6 +44,9 @@ public class AutomobileEnterpriseController extends BaseController
@Autowired
private AutomobileEnterpriseService automobileEnterpriseService;
@Autowired
private SampleManagementService sampleManagementService;
/**
* 查询车企信息列表
*/
......@@ -104,6 +112,16 @@ public class AutomobileEnterpriseController extends BaseController
@PostMapping("/remove")
public R<Boolean> remove(@Validated @RequestBody AutomobileEnterpriseEditRequest request)
{
Long[] ids = request.getIds();
for (Long id : ids) {
SampleManagementRequest sampleManagementRequest = new SampleManagementRequest();
sampleManagementRequest.setManufacturingEnterpriseId(id);
List<Sample> samples = sampleManagementService.selectSampleList(sampleManagementRequest);
if (CollUtil.isNotEmpty(samples)) {
throw new ServiceException("已被样品引用,不允许删除");
}
}
// 判断样品是否在此企业下
return R.ok(automobileEnterpriseService.removeBatchByIds(Arrays.asList(request.getIds())));
}
}
......@@ -25,4 +25,6 @@ public class SampleManagementRequest extends PageDomain {
/** 0:整车样品 1:零部件样品 */
@ApiModelProperty("0:整车样品 1:零部件样品")
private String flag;
private Long manufacturingEnterpriseId;
}
......@@ -3,7 +3,7 @@
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" />
......@@ -61,12 +61,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="flag != null and flag != ''"> and 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=",">
......@@ -162,6 +162,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="identificationCode != null and identificationCode != ''"> and sm.identification_code = #{identificationCode}</if>
<if test="sampleNumber != null and sampleNumber != ''"> and sm.sample_number = #{sampleNumber}</if>
<if test="flag != null and flag != ''"> and sm.flag = #{flag} </if>
<if test="manufacturingEnterpriseId != null"> and sm.manufacturing_enterprise_id = #{manufacturingEnterpriseId} </if>
</where>
</select>
......@@ -183,4 +184,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
ORDER BY ts.id
</select>
</mapper>
\ No newline at end of file
</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