Prechádzať zdrojové kódy

限制取样材料只能关联一个委托单

DengLinLang 2 mesiacov pred
rodič
commit
d2af65fa2c

+ 17 - 11
blade-service/blade-business/src/main/java/org/springblade/business/controller/EntrustInfoController.java

@@ -17,31 +17,28 @@
 package org.springblade.business.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import lombok.AllArgsConstructor;
-import javax.validation.Valid;
-
-import org.springblade.business.entity.TrialSampleInfo;
+import org.springblade.business.entity.EntrustInfo;
+import org.springblade.business.service.IEntrustInfoService;
 import org.springblade.business.vo.EntrustDataInfoVO;
+import org.springblade.business.vo.EntrustInfoVO;
 import org.springblade.business.vo.LoadDataInfoVO;
 import org.springblade.business.vo.TrialSampleDataInfoVO;
+import org.springblade.business.wrapper.EntrustInfoWrapper;
+import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.bind.annotation.RequestParam;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import org.springblade.business.entity.EntrustInfo;
-import org.springblade.business.vo.EntrustInfoVO;
-import org.springblade.business.wrapper.EntrustInfoWrapper;
-import org.springblade.business.service.IEntrustInfoService;
-import org.springblade.core.boot.ctrl.BladeController;
 
+import javax.validation.Valid;
 import java.util.Date;
 
 /**
@@ -209,4 +206,13 @@ public class  EntrustInfoController extends BladeController {
 		LoadDataInfoVO pages = entrustInfoService.selectDataInfoById(id);
 		return R.data(pages);
 	}
+	/**
+	 * 生成委托单 校验该材料是否关联委托单
+	 */
+	@GetMapping("/checkSample")
+	@ApiOperationSupport(order = 10)
+	@ApiOperation(value = "校验材料", notes = "传入材料id")
+	public R checkSample(Long sampleId){
+		return  entrustInfoService.checkSample(sampleId);
+	}
 }

+ 2 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/EntrustInfoMapper.java

@@ -53,4 +53,6 @@ public interface EntrustInfoMapper extends BaseMapper<EntrustInfo> {
 	LoadDataInfoVO selectDataInfoById(@Param("id") String id);
 
 	int delEntrustInfo(@Param("ids") List<Long> ids);
+
+	Integer selectCountBySampleId(Long sampleId);
 }

+ 3 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/EntrustInfoMapper.xml

@@ -155,6 +155,9 @@
         select a.*,(SELECT dict_key from blade_dict_biz where id=(SELECT parent_id from blade_dict_biz where code='test_data_type' and dict_value=a.testTypeName)) as testTypePId
         from u_view_gather_data_info a  where a.id=#{id}
     </select>
+    <select id="selectCountBySampleId" resultType="java.lang.Integer">
+        select  count(*) from u_entrust_info where sample_id=#{sampleId} and is_deleted=0
+    </select>
 
 
     <delete id="delEntrustInfo" >

+ 3 - 3
blade-service/blade-business/src/main/java/org/springblade/business/service/IEntrustInfoService.java

@@ -17,17 +17,15 @@
 package org.springblade.business.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.business.entity.EntrustInfo;
 import org.springblade.business.vo.EntrustDataInfoVO;
 import org.springblade.business.vo.EntrustInfoVO;
 import org.springblade.business.vo.LoadDataInfoVO;
 import org.springblade.business.vo.TrialSampleDataInfoVO;
 import org.springblade.core.mp.base.BaseService;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.core.tool.api.R;
 
-import java.util.List;
-
 /**
  * 委托单信息表 服务类
  *
@@ -70,4 +68,6 @@ public interface IEntrustInfoService extends BaseService<EntrustInfo> {
 
 	//委托单删除
 	R delEntrustInfo(String ids);
+	//检查材料是否关联委托单
+	R checkSample(Long sampleId);
 }

+ 10 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/EntrustInfoServiceImpl.java

@@ -30,6 +30,7 @@ import org.springblade.business.vo.TrialSampleDataInfoVO;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.feign.ExcelTabClient;
 import org.springblade.manager.feign.WbsTreePrivateClient;
@@ -52,6 +53,7 @@ public class EntrustInfoServiceImpl extends BaseServiceImpl<EntrustInfoMapper, E
 	private final ExcelTabClient excelTabClient;
 	private final JdbcTemplate jdbcTemplate;
 	private final WbsTreePrivateClient wbsTreePrivateClient;
+	private final EntrustInfoMapper entrustInfoMapper;
 
 	@Override
 	public IPage<EntrustInfoVO> selectEntrustInfoPage(IPage<EntrustInfoVO> page, EntrustInfoVO entrustInfo) {
@@ -165,4 +167,12 @@ public class EntrustInfoServiceImpl extends BaseServiceImpl<EntrustInfoMapper, E
 		return R.success("");
 	}
 
+	@Override
+	public R checkSample(Long sampleId) {
+		Integer count = entrustInfoMapper.selectCountBySampleId(sampleId);
+		if (ObjectUtil.isNotEmpty(count) && count > 0){
+			return R.fail("当前材料已被委托");
+		}
+		return R.success("操作成功");
+	}
 }

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -2771,7 +2771,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         } else if (contractInfo.getContractType()==3 || contractInfo.getContractType()==8) { //业主
             pkeyId = treePrivate.getYzerTreeId()+"";
         }else{
-            return "该合同段没有委托单权限业务";
+            return R.fail("该合同段没有委托单权限业务");
         }
         Object excelHtml = getExcelHtml(pkeyId);
         return excelHtml;