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

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

parent eb6d7fb2
...@@ -4,10 +4,15 @@ import java.util.Arrays; ...@@ -4,10 +4,15 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.core.domain.R; 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.AutomobileEnterpriseEditRequest;
import com.ruoyi.web.request.AutomobileEnterpriseGetInfoRequest; import com.ruoyi.web.request.AutomobileEnterpriseGetInfoRequest;
import com.ruoyi.web.request.AutomobileEnterpriseListRequest; import com.ruoyi.web.request.AutomobileEnterpriseListRequest;
import com.ruoyi.web.request.SampleManagementRequest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -39,6 +44,9 @@ public class AutomobileEnterpriseController extends BaseController ...@@ -39,6 +44,9 @@ public class AutomobileEnterpriseController extends BaseController
@Autowired @Autowired
private AutomobileEnterpriseService automobileEnterpriseService; private AutomobileEnterpriseService automobileEnterpriseService;
@Autowired
private SampleManagementService sampleManagementService;
/** /**
* 查询车企信息列表 * 查询车企信息列表
*/ */
...@@ -104,6 +112,16 @@ public class AutomobileEnterpriseController extends BaseController ...@@ -104,6 +112,16 @@ public class AutomobileEnterpriseController extends BaseController
@PostMapping("/remove") @PostMapping("/remove")
public R<Boolean> remove(@Validated @RequestBody AutomobileEnterpriseEditRequest request) 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()))); return R.ok(automobileEnterpriseService.removeBatchByIds(Arrays.asList(request.getIds())));
} }
} }
...@@ -25,4 +25,6 @@ public class SampleManagementRequest extends PageDomain { ...@@ -25,4 +25,6 @@ public class SampleManagementRequest extends PageDomain {
/** 0:整车样品 1:零部件样品 */ /** 0:整车样品 1:零部件样品 */
@ApiModelProperty("0:整车样品 1:零部件样品") @ApiModelProperty("0:整车样品 1:零部件样品")
private String flag; private String flag;
private Long manufacturingEnterpriseId;
} }
...@@ -162,6 +162,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -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="identificationCode != null and identificationCode != ''"> and sm.identification_code = #{identificationCode}</if>
<if test="sampleNumber != null and sampleNumber != ''"> and sm.sample_number = #{sampleNumber}</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="flag != null and flag != ''"> and sm.flag = #{flag} </if>
<if test="manufacturingEnterpriseId != null"> and sm.manufacturing_enterprise_id = #{manufacturingEnterpriseId} </if>
</where> </where>
</select> </select>
......
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