|
@@ -24,16 +24,19 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.huashe.common.exception.ServiceException;
|
|
|
+import com.huashe.common.utils.DateUtils;
|
|
|
+import com.huashe.common.utils.StringUtils;
|
|
|
+import com.huashe.common.utils.uuid.Seq;
|
|
|
import com.huashe.park.common.EnhancedIDGenerator;
|
|
|
import com.huashe.park.common.consts.enums.ConsStatus;
|
|
|
import com.huashe.park.common.excel.CsvAlias;
|
|
|
import com.huashe.park.common.i18n.MessageUtils;
|
|
|
import com.huashe.park.core.mapper.ConsUnitInfoMapper;
|
|
|
+import com.huashe.park.core.mapper.PileMachineInfoMapper;
|
|
|
import com.huashe.park.core.service.IConsPileHoleInfoService;
|
|
|
import com.huashe.park.core.service.IConsUnitInfoService;
|
|
|
import com.huashe.park.core.service.IConsUnitMachineRelService;
|
|
|
import com.huashe.park.core.service.IMachineProcessResultService;
|
|
|
-import com.huashe.park.core.service.IPileMachineInfoService;
|
|
|
import com.huashe.park.core.service.IProjectInfoService;
|
|
|
import com.huashe.park.core.service.ISysCustConfigService;
|
|
|
import com.huashe.park.domain.dto.cons.CADJson;
|
|
@@ -77,7 +80,7 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
private IConsUnitMachineRelService consUnitMachineRelService;
|
|
|
|
|
|
@Autowired
|
|
|
- private IPileMachineInfoService pileMachineInfoService;
|
|
|
+ private PileMachineInfoMapper pileMachineInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
private IMachineProcessResultService machineProcessResultService;
|
|
@@ -217,12 +220,12 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void importConsUnitHole(ConsUnitInfo consUnitHole) {
|
|
|
+ public void importConsUnitHole(ConsUnitInfo consUnitInfo) {
|
|
|
int lastIndex = RuoYiConfig.getUploadPath().lastIndexOf("/");
|
|
|
- String filePath = consUnitHole.getFileId().replaceFirst(PROFILE,
|
|
|
+ String filePath = consUnitInfo.getFileId().replaceFirst(PROFILE,
|
|
|
RuoYiConfig.getUploadPath().substring(0, lastIndex));
|
|
|
- consUnitHole.setFileId(filePath);
|
|
|
- consUnitInfoMapper.updateConsUnitInfo(consUnitHole);
|
|
|
+ consUnitInfo.setFileId(filePath);
|
|
|
+ consUnitInfoMapper.updateConsUnitInfo(consUnitInfo);
|
|
|
// filePath 读取成 File
|
|
|
File file = new File(filePath);
|
|
|
|
|
@@ -232,12 +235,12 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
log.info(">>>>>>>>>>>>{}", form.toString());
|
|
|
String json = form.execute().body();
|
|
|
List<CADJson> cadJsons = JSONArray.parseArray(json, CADJson.class);
|
|
|
- pileHoleInfoService.deleteConsPileHoleInfoByConsUnitId(consUnitHole.getId());
|
|
|
+ pileHoleInfoService.deleteConsPileHoleInfoByConsUnitId(consUnitInfo.getId());
|
|
|
List<ConsPileHoleInfo> consPileHoleInfo = new ArrayList<>(cadJsons.size());
|
|
|
cadJsons.stream().filter(Objects::nonNull).forEach(item -> {
|
|
|
consPileHoleInfo.add(new ConsPileHoleInfo() {
|
|
|
{
|
|
|
- setConsUnitId(consUnitHole.getId());
|
|
|
+ setConsUnitId(consUnitInfo.getId());
|
|
|
setDeltaX(item.getCoordX());
|
|
|
setDeltaY(item.getCoordY());
|
|
|
setLng(item.getEarthCoordX());
|
|
@@ -258,14 +261,9 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
@Override
|
|
|
public void exportConsUnitHole(ConsUnitInfo consUnitHole, HttpServletResponse response) {
|
|
|
ConsUnitInfo consUnitInfo = consUnitInfoMapper.selectConsUnitInfoById(consUnitHole.getId());
|
|
|
- // String filePath = consUnitHole.getFileId().replaceFirst(PROFILE,
|
|
|
- // RuoYiConfig.getUploadPath().substring(0, lastIndex));
|
|
|
- // consUnitHole.setFileId(filePath);
|
|
|
- // consUnitInfoMapper.updateConsUnitInfo(consUnitHole);
|
|
|
// filePath 读取成 File
|
|
|
File file = new File(consUnitInfo.getFileId());
|
|
|
- File csvFile = new File(
|
|
|
- "E:\\opt\\project\\ruoyi\\ruoyi-backend\\upload-file-path\\upload\\2025\\03\\10\\1.csv");
|
|
|
+ File csvFile = generatePileHoleFile(consUnitInfo);
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
InputStream dwgFile = HttpRequest.post(cadForestCfg.getCadServer() + "/download").form("dwg_file", file)
|
|
|
.form("csv_file", csvFile).execute().bodyStream();
|
|
@@ -337,7 +335,7 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void generatePileHoleFile(ConsUnitInfo consUnitInfo) {
|
|
|
+ private File generatePileHoleFile(ConsUnitInfo consUnitInfo) {
|
|
|
List<ProjectInfo> projectInfos = projectInfoService.selectProjectInfoList(new ProjectInfo());
|
|
|
|
|
|
ProjectInfo projectInfo = projectInfos.get(0);
|
|
@@ -349,8 +347,11 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
csvWriteConfig.addHeaderAlias(field.getName(), annotation.alias());
|
|
|
}
|
|
|
}
|
|
|
- CsvWriter writer = CsvUtil.getWriter(FileUtil.file("e:/testWrite.csv"), CharsetUtil.CHARSET_UTF_8, true,
|
|
|
- csvWriteConfig);
|
|
|
+ String filePath = StringUtils.format("{}/{}/{}_{}.{}", RuoYiConfig.getUploadPath(), DateUtils.datePath(),
|
|
|
+ "cad-csv", Seq.getId("UPLOAD"), "csv");
|
|
|
+ File csvFile = FileUtil.file(filePath);
|
|
|
+ CsvWriter writer = CsvUtil.getWriter(csvFile, CharsetUtil.CHARSET_UTF_8, true, csvWriteConfig);
|
|
|
+
|
|
|
List<String[]> header = new ArrayList<>();
|
|
|
// 按行写出
|
|
|
header.add(new String[] {
|
|
@@ -387,5 +388,8 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
writer.write(header);
|
|
|
List<ResultCADCsv> resultCADCsvs = machineProcessResultService.qeyConsUnitResult(consUnitInfo.getId());
|
|
|
writer.writeBeans(resultCADCsvs);
|
|
|
+ writer.flush();
|
|
|
+ writer.close();
|
|
|
+ return csvFile;
|
|
|
}
|
|
|
}
|