1 рік тому
батько
коміт
7e0a1f7fa7

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/mapper/sqarepartmanage/SparePartInfoMapper.java

@@ -17,6 +17,8 @@ import java.util.List;
  */
 @Component
 public interface SparePartInfoMapper extends MyMapper<SparePartInfo> {
+    SparePartInfoVO getSpareInfoVOById(String id);
+
     List<SparePartInfoVO> getInOrOut(SparePartInfoDTO dto);
 
     /**

+ 7 - 0
platform-dao/src/main/resources/mapper/sqarepartmanage/SparePartInfoMapper.xml

@@ -470,4 +470,11 @@ warn_status,forecast_status,
             HAVING info.min_stock > SUM( spareStore.num )
         </if>
     </select>
+    <select id="getSpareInfoVOById" resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO"
+            parameterType="com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO">
+        select info.*,store.store_id as storeId from
+        t_spare_part_info info left join t_spare_store store
+        on store.spare_id = info.id
+        where info.id = #{id}
+    </select>
 </mapper>

+ 12 - 0
platform-rest/src/main/java/com/platform/rest/controller/sqarepartmanage/SparePartInfoController.java

@@ -66,6 +66,17 @@ public class SparePartInfoController {
         return new R<>(sparePartInfoService.getModelById(id));
     }
 
+    /**
+     * 通过id查询单条记录
+     *
+     * @param id 主键
+     * @return R
+     */
+    @GetMapping("/getVO/{id}")
+    public R<SparePartInfoVO> getVOById(@PathVariable("id") String id) {
+        return new R<>(sparePartInfoService.getSpareInfoVOById(id));
+    }
+
     /**
      * 批量查询记录
      *
@@ -91,6 +102,7 @@ public class SparePartInfoController {
         return new R<>(sparePartInfoService.saveModelByDTO(sparePartInfoDTO));
     }
 
+
     /**
      * 批量校正记录
      * 将备件修改为其他备件,并更新库存对应的备件id

+ 1 - 0
platform-rest/src/main/resources/application-dev.yml

@@ -85,6 +85,7 @@ ignore:
     - /store/in-store-forms/**
     - /store/out-store-forms/**
     - /check/jobs/**
+    - /sqarepartmanage/spare-part-info/**
 upload:
   root-dir: D://data//xian
 

+ 2 - 0
platform-service/src/main/java/com/platform/service/sqarepartmanage/SparePartInfoService.java

@@ -21,6 +21,8 @@ import java.util.List;
  * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
  */
 public interface SparePartInfoService extends IBaseService<SparePartInfo, SparePartInfoDTO> {
+ SparePartInfoVO getSpareInfoVOById(String id);
+
  AbstractPageResultBean<SparePartInfoVO> selectPageInfo2(SparePartInfoDTO record, int pageNum, int pageSize);
 
 

+ 33 - 0
platform-service/src/main/java/com/platform/service/sqarepartmanage/impl/SparePartInfoServiceImpl.java

@@ -456,6 +456,39 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         }
     }
 
+    @Override
+    public SparePartInfoVO getSpareInfoVOById(String id) {
+        SparePartInfoVO vo = mapper.getSpareInfoVOById(id);
+        String finalName = "";
+        if (vo.getStoreId()!=null) {
+            List<String> names = new ArrayList<>();
+            names = getFinalStoreName(vo.getStoreId(), names);
+            if (names.size() == 3) {
+                finalName = names.get(2).replaceAll("\\s*","").replaceAll("[^(0-9)]","")
+                        +"-"+names.get(1).replaceAll("\\s*","").replaceAll("[^(0-9)]","")
+                        +"-"+names.get(0);
+            }else {
+                for (int i = names.size() - 1; i >= 0; i--) {
+                    finalName = finalName + "-" + names.get(i);
+                    finalName = finalName.substring(1);
+                }
+            }
+        }
+        vo.setStoreName(finalName);
+        return vo;
+    }
+    private List<String> getFinalStoreName(String id,List<String> names){
+        Store store = storeMapper.selectByPrimaryKey(id);
+        if (store!=null) {
+            names.add(store.getName());
+            if (store.getParentId() != null&&!store.getParentId().trim().equals("")) {
+                getFinalStoreName(store.getParentId(),names);
+            }
+        }
+        return names;
+    }
+
+
     @Override
     public AbstractPageResultBean<SparePartInfoVO> selectPageInfo2(SparePartInfoDTO record, int pageNum, int pageSize) {