Browse Source

出库退库bug修复

hfxc226 2 years ago
parent
commit
5fff089579

+ 4 - 0
platform-common/src/main/java/com/platform/common/constant/CommonConstants.java

@@ -135,6 +135,10 @@ public interface CommonConstants {
      * 备件获取请求地址
      */
     String RESOURCE_PREFIX_SPARE = "/spare/upload";
+    /**
+     * 备件获取请求地址
+     */
+    String RESOURCE_PREFIX_POSITION= "/position/upload";
     /**
      * 一年多少天计算
      */

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/dto/sb/SbPositionDTO.java

@@ -21,6 +21,10 @@ import java.time.LocalDateTime;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = true)
 public class SbPositionDTO extends BaseDTO implements Serializable {
+    /**
+     * opc标识:0否1是
+     */
+    private Integer opcFlag;
     /**
      * 车间opc图片
      */

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/entity/sb/SbPosition.java

@@ -20,6 +20,10 @@ import java.time.LocalDateTime;
 @Data
 @Accessors(chain = true)
 public class SbPosition implements Serializable {
+    /**
+     * opc标识:0否1是
+     */
+    private Integer opcFlag;
     /**
      * 车间opc图片
      */

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/vo/sb/SbPositionVO.java

@@ -18,6 +18,10 @@ import java.time.LocalDateTime;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = true)
 public class SbPositionVO extends BaseVO implements Serializable {
+    /**
+     * opc标识:0否1是
+     */
+    private Integer opcFlag;
     /**
      * 车间opc图片
      */

+ 5 - 2
platform-dao/src/main/resources/mapper/sb/SbPositionMapper.xml

@@ -2,12 +2,12 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.platform.dao.mapper.sb.SbPositionMapper">
     <sql id="Base_Column_List">
-        id, no, name, type, sort, code, user_id, del_flag, parent_id, opc_img, remark, created_user_id, update_user_id,
+        id, no, name, type, sort, code, user_id, del_flag, parent_id, opc_flag, opc_img, remark, created_user_id, update_user_id,
         created_time, update_time
     </sql>
 
     <sql id="Join_Column">
-        position.id, position.no, position.name, position.code, position.opc_img, position.user_id, position.type, position.sort, position.del_flag, position.parent_id,
+        position.id, position.no, position.name, position.code, position.opc_flag, position.opc_img, position.user_id, position.type, position.sort, position.del_flag, position.parent_id,
         position.remark, position.created_user_id, position.update_user_id,
         position.created_time, position.update_time,
         p.name as parentName, user.real_name as userName
@@ -31,6 +31,9 @@
         <if test="parentCode != null and parentCode != ''">
             and position.code like concat(#{parentCode},'%')
         </if>
+        <if test="opcFlag != null and opcFlag != ''">
+            and position.opc_flag = #{opcFlag}
+        </if>
         <if test="userName != null and userName != ''">
             and ( user.real_name like concat('%',#{userName},'%') or
             user.username like concat('%',#{userName},'%'))

+ 51 - 0
platform-rest/src/main/java/com/platform/rest/controller/upms/SysFileController.java

@@ -232,5 +232,56 @@ public class SysFileController {
         return R.success(fileVO, "上传成功");
     }
 
+    /**
+     * 车间位置图片上传
+     *
+     * @param file 文件
+     * @return :
+     */
+    @PostMapping("/upload/position")
+    @SneakyThrows
+    public R doUploadPositioon(@RequestParam("file") MultipartFile file) {
+        if (file.isEmpty()) {
+            return R.error("请选择一个上传文件");
+        }
+        FileVO fileVO = new FileVO();
+
+        String fileFullName = file.getOriginalFilename();
+
+        if (StringUtils.isNotBlank(fileFullName)) {
+            fileFullName = fileFullName.replace(",", ",");
+            fileVO.setName(fileFullName);
+            int endIndex = fileFullName.lastIndexOf(".");
+            fileVO.setFileName(fileFullName.substring(0, endIndex));
+            fileVO.setFileFormat(fileFullName.substring(endIndex + 1));
+            String fileType = fileFullName.substring(endIndex);
+            String id = IdGeneratorUtils.getObjectId();
+            String path = CommonConstants.RESOURCE_PREFIX + CommonConstants.RESOURCE_PREFIX_POSITION + "/";
+            String filePath = UPLOAD_ROOT_FOLDER + path;
+            fileVO.setUrl(path + id + fileType);
+            fileVO.setFileFormat(fileType);
+
+            try {
+                if (fileVO.getFileFormat().contains("png") || fileVO.getFileFormat().contains("JPEG")
+                        || fileVO.getFileFormat().contains("jpg") || fileVO.getFileFormat().contains("jpeg")
+                        || fileVO.getFileFormat().contains("PNG") || fileVO.getFileFormat().contains("JPG")) {
+                    File targetFile = new File(filePath);
+                    if (!targetFile.exists()) {
+                        targetFile.mkdirs();
+                    }
+                    FileOutputStream out = new FileOutputStream(filePath + id + fileType);
+                    Thumbnails.of(file.getInputStream()).scale(1).outputQuality(0.2)
+                            .outputFormat(fileFullName.substring(endIndex + 1)).toOutputStream(out);
+                    out.flush();
+                    out.close();
+                } else {
+                    FileUtils.uploadFile(file.getBytes(), filePath, id + fileType);
+                }
+            } catch (Exception e) {
+                throw new Exception("上传文件失败:" + e.getMessage());
+            }
+        }
+        return R.success(fileVO, "上传成功");
+    }
 
 }