Jelajahi Sumber

* cad功能对接

chen.cheng 4 bulan lalu
induk
melakukan
c16760f114

+ 1 - 1
bd-park/park-backend/park-application/src/main/java/com/huashe/park/application/web/controller/cons/PileMachineInfoController.java

@@ -111,7 +111,7 @@ public class PileMachineInfoController extends BaseController {
     @Log(title = "施工桩机信息", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody PileMachineInfo pileMachineInfo) {
-        return toAjax(pileMachineInfoService.updatePileMachineInfo(pileMachineInfo));
+        return toAjax(pileMachineInfoService.updatePileMachineInfoWidthPwd(pileMachineInfo));
     }
 
     @PostMapping("/terminal/login")

+ 2 - 0
bd-park/park-backend/park-collect/src/main/java/com/huashe/park/collect/core/MqttTemplate.java

@@ -80,6 +80,8 @@ public class MqttTemplate {
             // 保留会话
             connOpts.setCleanSession(false);
             connOpts.setAutomaticReconnect(true);
+            connOpts.setUserName(productKey);
+            connOpts.setPassword(deviceSecret.toCharArray());
             // 建立连接
             mqttClient.connect(connOpts);
             mqttClient.subscribe(format, qos);

+ 1 - 1
bd-park/park-backend/park-collect/src/main/resources/application-locale.yml

@@ -1,7 +1,7 @@
 ## MQTT##
 aliyun:
   mqtt:
-    uri: tcp://xt.wenhq.top:8581
+    uri: tcp://8.219.137.9:1883
 
 
 # 数据源配置

+ 2 - 0
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/IPileMachineInfoService.java

@@ -49,6 +49,8 @@ public interface IPileMachineInfoService {
      */
     int updatePileMachineInfo(PileMachineInfo pileMachineInfo);
 
+    int updatePileMachineInfoWidthPwd(PileMachineInfo pileMachineInfo);
+
     /**
      * 批量删除施工桩机信息
      * 

+ 21 - 17
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/ConsUnitInfoServiceImpl.java

@@ -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;
     }
 }

+ 5 - 0
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/PileMachineInfoServiceImpl.java

@@ -117,6 +117,11 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
      */
     @Override
     public int updatePileMachineInfo(PileMachineInfo pileMachineInfo) {
+        return pileMachineInfoMapper.updatePileMachineInfo(pileMachineInfo);
+    }
+
+    @Override
+    public int updatePileMachineInfoWidthPwd(PileMachineInfo pileMachineInfo) {
         pileMachineInfo.setPwd(pileMachineInfo.getSn() + "381.2371");
         return pileMachineInfoMapper.updatePileMachineInfo(pileMachineInfo);
     }

+ 5 - 0
bd-park/park-backend/park-core/src/main/resources/mapper/cons/ConsUnitInfoMapper.xml

@@ -15,6 +15,7 @@
         <result property="name" column="name"/>
         <result property="ancestors" column="ancestors"/>
         <result property="projectId" column="project_id"/>
+        <result property="fileId" column="file_id"/>
         <result property="updateTime" column="update_time"/>
         <result property="createTime" column="create_time"/>
         <result property="createBy" column="create_by"/>
@@ -32,6 +33,7 @@
                name,
                ancestors,
                project_id,
+               file_id,
                update_time,
                create_time,
                create_by,
@@ -68,6 +70,7 @@
             <if test="name != null and name != ''">name,</if>
             <if test="ancestors != null and ancestors!=''">ancestors,</if>
             <if test="projectId != null">update_time,</if>
+            <if test="fileId != null">file_id,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="createTime != null">create_time,</if>
             <if test="createBy != null">create_by,</if>
@@ -83,6 +86,7 @@
             <if test="name != null and name != ''">#{name},</if>
             <if test="ancestors != null and ancestors!=''">#{ancestors},</if>
             <if test="projectId != null">#{projectId},</if>
+            <if test="fileId != null">#{fileId},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="createBy != null">#{createBy},</if>
@@ -101,6 +105,7 @@
             <if test="name != null and name != ''">name = #{name},</if>
             <if test="ancestors != null and ancestors!=''">ancestors = #{ancestors},</if>
             <if test="projectId != null">project_id = #{projectId},</if>
+            <if test="fileId != null">file_id = #{fileId},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>

+ 1 - 1
bd-park/park-backend/park-core/src/main/resources/mapper/cons/MachineProcessResultMapper.xml

@@ -451,7 +451,7 @@
         from cons_machine_process_result cmpr
                  inner join cons_pile_hole_index_realtime cphir on
             cmpr.pile_id = cphir.hole_byte_key
-        where cphir.cons_unit_id =
+        where cphir.cons_unit_id = #{consUnitId}
     </select>
 
 </mapper>