|
@@ -35,6 +35,7 @@ import com.jeeplus.test.cw.workClientInfo.service.CwWorkClientContactService;
|
|
import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
|
|
import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
|
|
import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
import com.jeeplus.test.oss.service.OssService;
|
|
import com.jeeplus.test.oss.service.OssService;
|
|
|
|
+import com.mchange.lang.IntegerUtils;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -296,7 +297,40 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public ResponseEntity deleteByIds(String ids) {
|
|
public ResponseEntity deleteByIds(String ids) {
|
|
|
|
+ // 查询项目是否被引用(报告、报销、发票)
|
|
String idArray[] =ids.split(",");
|
|
String idArray[] =ids.split(",");
|
|
|
|
+ List<String> useProjects = new ArrayList<>();
|
|
|
|
+ // 查询项目是否被引用(报告)
|
|
|
|
+ List<String> useByReport = cwProjectRecordsMapper.isUseByReport(idArray);
|
|
|
|
+ if (CollectionUtil.isNotEmpty(useByReport)) {
|
|
|
|
+ useByReport.stream().forEach(item -> {
|
|
|
|
+ useProjects.add(item);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ // 查询项目是否被引用(报销)
|
|
|
|
+ List<String> useByReim = cwProjectRecordsMapper.isUseByReim(idArray);
|
|
|
|
+ if (CollectionUtil.isNotEmpty(useByReim)) {
|
|
|
|
+ useByReim.stream().forEach(item -> {
|
|
|
|
+ useProjects.add(item);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ // 查询项目是否被引用(发票)
|
|
|
|
+ List<String> useByFinance = cwProjectRecordsMapper.isUseByFinance(idArray);
|
|
|
|
+ if (CollectionUtil.isNotEmpty(useByFinance)) {
|
|
|
|
+ useByFinance.stream().forEach(item -> {
|
|
|
|
+ useProjects.add(item);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtil.isNotEmpty(useProjects)) {
|
|
|
|
+ List<String> collect = useProjects.stream().distinct().filter(item -> {
|
|
|
|
+ if (StringUtils.isNotBlank(item)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ String join = StringUtils.join(collect, ",");
|
|
|
|
+ return ResponseEntity.ok ("项目: "+join+" 被引用,不可删除");
|
|
|
|
+ }
|
|
this.removeByIds (Lists.newArrayList (idArray));
|
|
this.removeByIds (Lists.newArrayList (idArray));
|
|
return ResponseEntity.ok ("删除成功");
|
|
return ResponseEntity.ok ("删除成功");
|
|
}
|
|
}
|