|
@@ -19,6 +19,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -111,9 +112,13 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
@Autowired
|
|
|
private CADForestCfg cadForestCfg;
|
|
|
|
|
|
- @Autowired
|
|
|
private IProjectInfoService projectInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public void setProjectInfoService(@Lazy IProjectInfoService projectInfoService) {
|
|
|
+ this.projectInfoService = projectInfoService;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询施工单元
|
|
|
*
|
|
@@ -153,19 +158,25 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
* @param consUnitInfo 施工单元
|
|
|
* @return 结果
|
|
|
*/
|
|
|
- @Override
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int insertConsUnitInfo(ConsUnitMachine consUnitInfo) {
|
|
|
// 处理施工单元信息
|
|
|
ConsUnitInfo parentConsUnit = consUnitInfoMapper.selectConsUnitInfoById(consUnitInfo.getParentId());
|
|
|
consUnitInfo.setAncestors(parentConsUnit.getAncestors() + "," + parentConsUnit.getId());
|
|
|
consUnitInfo.setByteId(byte8Id.generate());
|
|
|
+ consUnitInfo.setProjectId(parentConsUnit.getProjectId());
|
|
|
int cnt = consUnitInfoMapper.insertConsUnitInfo(consUnitInfo);
|
|
|
// 处理施工单元关联信息
|
|
|
handleMachine(consUnitInfo);
|
|
|
return cnt;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int insertConsUnitInfo(ConsUnitInfo consUnitInfo) {
|
|
|
+ return consUnitInfoMapper.insertConsUnitInfo(consUnitInfo);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改施工单元
|
|
|
*
|
|
@@ -185,7 +196,9 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
String newAncestors = newParentConsUnit.getAncestors() + "," + newParentConsUnit.getId();
|
|
|
String oldAncestors = oldConsUnit.getAncestors();
|
|
|
consUnitInfo.setAncestors(newAncestors);
|
|
|
- updateConsUnitChildren(consUnitInfo.getId(), newAncestors, oldAncestors);
|
|
|
+ consUnitInfo.setProjectId(newParentConsUnit.getProjectId());
|
|
|
+ updateConsUnitChildren(consUnitInfo.getId(), newParentConsUnit.getParentId(), newAncestors,
|
|
|
+ oldAncestors);
|
|
|
}
|
|
|
}
|
|
|
return consUnitInfoMapper.updateConsUnitInfo(consUnitInfo);
|
|
@@ -219,6 +232,7 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public int deleteConsUnitInfoById(Long id) {
|
|
|
if (hasChildById(id)) {
|
|
|
throw new ServiceException(MessageUtils.message("cons.unit.delete.no.child"));
|
|
@@ -229,8 +243,23 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public int deleteConsUnitInfoByProjectId(Long projId) {
|
|
|
+ List<ConsUnitInfo> consUnitInfos = consUnitInfoMapper.selectConsUnitInfoList(new ConsUnitInfo() {
|
|
|
+ {
|
|
|
+ setProjectId(projId);
|
|
|
+ setParentId(0L);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (CollectionUtils.isEmpty(consUnitInfos)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ ConsUnitInfo consUnitInfo = consUnitInfos.get(0);
|
|
|
+8 return deleteConsUnitInfoById(consUnitInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void importConsUnitHole(ConsUnitInfo consUnitInfo) {
|
|
|
- // TODO 要做多项目切换
|
|
|
int lastIndex = RuoYiConfig.getUploadPath().lastIndexOf("/");
|
|
|
String filePath = consUnitInfo.getFileId().replaceFirst(PROFILE,
|
|
|
RuoYiConfig.getUploadPath().substring(0, lastIndex));
|
|
@@ -242,7 +271,6 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
CustSysConfig custSysConfig = sysCustConfigService.selectConfigObjByKey(cadForestCfg.getCadBizParam());
|
|
|
HttpRequest form = HttpRequest.post(cadForestCfg.getCadServer() + "/upload").form("dwg_file", file)
|
|
|
.form("param", custSysConfig.getCfgJson());
|
|
|
- log.info(">>>>>>>>>>>>{}", form.toString());
|
|
|
String json = form.execute().body();
|
|
|
List<CADJson> cadJsons = JSONArray.parseArray(json, CADJson.class);
|
|
|
pileHoleInfoService.deleteConsPileHoleInfoByConsUnitId(consUnitInfo.getId());
|
|
@@ -339,13 +367,14 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
return consUnitInfoMapper.qryConsUnitInfoByIds(unitIds);
|
|
|
}
|
|
|
|
|
|
- private void updateConsUnitChildren(Long id, String newAncestors, String oldAncestors) {
|
|
|
+ private void updateConsUnitChildren(Long id, Long projectId, String newAncestors, String oldAncestors) {
|
|
|
List<ConsUnitInfo> children = consUnitInfoMapper.selectChildrenById(id);
|
|
|
if (CollectionUtils.isEmpty(children)) {
|
|
|
return;
|
|
|
}
|
|
|
for (ConsUnitInfo child : children) {
|
|
|
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
|
|
|
+ child.setProjectId(projectId);
|
|
|
}
|
|
|
consUnitInfoMapper.updateConstUnitChildren(children);
|
|
|
}
|