elis 2 rokov pred
rodič
commit
be1500ab8b

+ 10 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/program/controller/WorkerMiniController.java

@@ -60,6 +60,16 @@ public class WorkerMiniController {
         return SendUtil.send(true, service.myOrderInfo(id));
     }
 
+    @PostMapping("/closeOrder")
+    public Map<String, Object> closeOrder(@RequestParam(value = "files", required = false) MultipartFile[] files, SRepair sRepair) {
+        try {
+            return service.closeOrder(files, sRepair);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return SendUtil.send(false, ConstStr.ADD_FAILED);
+    }
+
 
 
 

+ 39 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/program/service/Impl/SRepairServiceImpl.java

@@ -155,4 +155,43 @@ public class SRepairServiceImpl implements SRepairService {
     public SRepair myOrderInfo(String id) {
         return sRepairDao.queryById(id);
     }
+
+    @Override
+    public Map<String, Object> closeOrder(MultipartFile[] files, SRepair sRepair) throws IOException {
+        if (Blank.isNotEmpty(files)) {
+            File pathFile = new File(location);
+            if (!pathFile.isDirectory()) {
+                if (!pathFile.mkdirs()) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "");
+                }
+            }
+            ArrayList<String> picPathList = new ArrayList<>();
+            for (MultipartFile file : files) {
+                //获取上传过来的文件名
+                File temporaryFile = new File(location + file.getOriginalFilename());
+                file.transferTo(temporaryFile);
+                String type = FileTypeUtil.getType(temporaryFile);
+                if (!("jpg".equals(type) || "png".equals(type) || "bmp".equals(type) || "jpeg".equals(type))) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "上传的格式必须是jpg或png或bmp或jpeg");
+                }
+                String newName = (new Date()).getTime() + ((int) (Math.random() * 9000) + 1000) + "." + type;
+                String filePath = location + newName;
+                File newFile = new File(filePath);
+                if (!temporaryFile.renameTo(newFile)) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "");
+                }
+                // 增加数据到s_file表
+                SFile sFile = new SFile();
+                sFile.setPath(newName);
+                sFile.setSuffix(type);
+                if (fileDao.addFile(sFile) <= 0) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "");
+                }
+                picPathList.add(sFile.getId().toString());
+            }
+            String picPath = String.join(",", picPathList);
+            sRepair.setResultPic(picPath);
+        }
+        return SendUtil.send(true,sRepairDao.update(sRepair)>0);
+    }
 }

+ 2 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/program/service/SRepairService.java

@@ -64,4 +64,6 @@ public interface SRepairService {
     List<SRepair> myOrder(String id,Integer status);
 
     SRepair myOrderInfo(String id);
+
+    Map<String, Object> closeOrder(MultipartFile[] files, SRepair sRepair) throws IOException;
 }

+ 1 - 9
nngkxxdp/src/main/resources/mapper/SRepairDao.xml

@@ -178,15 +178,7 @@
             <if test="workerId != null">
                 worker_id = #{workerId},
             </if>
-            <if test="createTime != null">
-                create_time = #{createTime},
-            </if>
-            <if test="updateTime != null">
-                update_time = #{updateTime},
-            </if>
-            <if test="isDel != null">
-                is_del = #{isDel},
-            </if>
+                update_time = now()
         </set>
         where id = #{id}
     </update>