From 69cd9f59a0fabf12f8c9147fcba7f69817a870b3 Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期一, 06 十一月 2023 23:40:59 +0800
Subject: [PATCH] 更新仓内抓拍2

---
 igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java |  137 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 110 insertions(+), 27 deletions(-)

diff --git a/igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java b/igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java
index a2c0721..ee04cae 100644
--- a/igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java
+++ b/igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java
@@ -1,24 +1,38 @@
 package com.ld.igds.inout.view;
 
+import java.io.File;
+import java.net.URLDecoder;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import com.bstek.bdf2.core.business.IUser;
 import com.bstek.dorado.annotation.DataProvider;
 import com.bstek.dorado.annotation.DataResolver;
 import com.bstek.dorado.annotation.Expose;
 import com.bstek.dorado.data.provider.Page;
+import com.bstek.dorado.uploader.UploadFile;
+import com.bstek.dorado.uploader.annotation.FileResolver;
+
+import com.ld.igds.file.CoreFileService;
 import com.ld.igds.inout.InoutConstant;
 import com.ld.igds.inout.dto.InoutData;
 import com.ld.igds.inout.dto.InoutParam;
 import com.ld.igds.inout.manager.InoutManager;
 import com.ld.igds.inout.manager.InoutReportManager;
 import com.ld.igds.inout.service.InoutService;
+import com.ld.igds.models.DicTrigger;
 import com.ld.igds.util.ContextUtil;
+
+import com.ld.igds.util.RedisUtil;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateFormatUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
 
 /**
  * 鍑哄叆搴撹鍗曢〉闈㈢鐞�
@@ -31,12 +45,45 @@
 @Component
 public class InoutDataPR {
 
-    @Autowired
+    @Resource
     private InoutService inoutService;
-    @Autowired
+    @Resource
     private InoutReportManager inoutReportManager;
-    @Autowired
+    @Resource
     private InoutManager inoutManager;
+    @Autowired
+    private CoreFileService fileService;
+    @Autowired
+    private RedisUtil redisUtil;
+
+
+    // ${dorado.getDataProvider("inoutDataPR#triggerRecordStatus1").getResult()}
+    @DataProvider
+    public List<DicTrigger> triggerRecordStatus1() {
+        List<DicTrigger> list = new ArrayList<DicTrigger>();
+        list.add(new DicTrigger(InoutConstant.RECORD_STATUS_DEL, "浣滃簾鍗�"));
+        list.add(new DicTrigger(InoutConstant.RECORD_STATUS_NORMAL, "姝e父鍗�"));
+        return list;
+    }
+
+    // ${dorado.getDataProvider("inoutDataPR#triggerResult").getResult()}
+    @DataProvider
+    public List<DicTrigger> triggerResult() {
+        List<DicTrigger> list = new ArrayList<DicTrigger>();
+        list.add(new DicTrigger(InoutConstant.RESULT_1, "鍚堟牸"));
+        list.add(new DicTrigger(InoutConstant.RESULT_0, "涓嶅悎鏍�"));
+        return list;
+    }
+
+    // ${dorado.getDataProvider("inoutDataPR#triggerSampleType").getResult()}
+    @DataProvider
+    public List<DicTrigger> triggerSampleType() {
+        List<DicTrigger> list = new ArrayList<DicTrigger>();
+        list.add(new DicTrigger(InoutConstant.SAMPLE_TYPE_MANUAL, "浜哄伐"));
+        list.add(new DicTrigger(InoutConstant.SAMPLE_TYPE_AUTOMATIC, "鑷姩"));
+        list.add(new DicTrigger(InoutConstant.SAMPLE_TYPE_RANDOM, "鏅鸿兘闅忔満"));
+        return list;
+    }
 
     /**
      * inoutDataPR#pageInoutData
@@ -46,8 +93,7 @@
      * @throws Exception
      */
     @DataProvider
-    public void pageInoutData(Page<InoutData> page, InoutParam param)
-            throws Exception {
+    public void pageInoutData(Page<InoutData> page, InoutParam param) throws Exception {
         // 璋冪敤鏍稿績鍖呬腑鏂规硶锛岄渶瑕佸仛瀵硅薄杞崲
         param.setPage(page.getPageNo());
         param.setLimit(page.getPageSize());
@@ -73,14 +119,6 @@
     }
 
     /**
-     * 鍒犻櫎鏁版嵁 inoutDataPR#delInoutData
-     */
-    @DataResolver
-    public String delInoutData(InoutData data) throws Exception {
-        return inoutManager.delInoutData(data, false);
-    }
-
-    /**
      * inoutDataPR#errorInoutData 鍑哄叆搴撴暟鎹墽琛� 寮傚父缁堟
      *
      * @param data
@@ -88,6 +126,7 @@
      * @throws Exception
      */
     @DataResolver
+    @Transactional
     public String errorInoutData(InoutData data) throws Exception {
         return inoutManager.errorInoutData(data);
     }
@@ -119,9 +158,6 @@
         if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
             return "鍒犻櫎鐨勬暟鎹笉鏀寔鎵撳嵃锛�";
         }
-        if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) {
-            return "寮傚父缁堟鐨勬暟鎹笉鏀寔鎵撳嵃锛�";
-        }
         if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
             return "鏈畬鎴愮殑鏁版嵁涓嶆敮鎸佹墦鍗帮紒";
         }
@@ -145,9 +181,6 @@
         if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
             return null;
         }
-        if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) {
-            return null;
-        }
         if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
             return null;
         }
@@ -167,9 +200,6 @@
         if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
             return "鍒犻櫎鐨勬暟鎹笉鏀寔鎵撳嵃锛�";
         }
-        if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) {
-            return "寮傚父缁堟鐨勬暟鎹笉鏀寔鎵撳嵃锛�";
-        }
         return inoutReportManager.inCheckBill(data);
     }
 
@@ -181,7 +211,6 @@
     @Expose
     public InoutData initAddData(String type) {
         IUser user = ContextUtil.getLoginUser();
-
         InoutData data = new InoutData();
         data.setCompanyId(user.getCompanyId());
         data.setRegisterTime(new Date());
@@ -203,15 +232,11 @@
      */
     @DataProvider
     public InoutData initDataByHand(String type) {
-
         IUser user = ContextUtil.getLoginUser();
-
         InoutData data = new InoutData();
         data.setCompanyId(user.getCompanyId());
         data.setRegisterTime(new Date());
-        data.setCompleteTime(new Date());
         data.setType(type);
-        data.setIntelCard("0000");
         data.setRegisterUser(user.getCname());
         data.setDeptId(ContextUtil.subDeptId(user));
         data.setCheckUser(user.getCname());
@@ -220,4 +245,62 @@
         return data;
     }
 
+    /**
+     * inoutDataPR#uploadImage
+     *
+     * @param file
+     * @param parameter
+     * @return
+     */
+    @FileResolver
+    public String uploadImage(UploadFile file, Map<String, Object> parameter) {
+        //杞︾墝
+        String plateNum = (String) parameter.get("plateNum");
+        //娴佺▼
+        String bizTag = (String) parameter.get("bizTag");
+        String newFileName = null;
+        try {
+            String basePath = fileService.getInoutFilePath(new Date());
+            // 鑾峰彇鏂扮殑ID
+            newFileName = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
+            if(StringUtils.isNotEmpty(bizTag)){
+                newFileName = bizTag + "_" + newFileName;
+            }
+            // 鏂囦欢鍚庣紑鍚�
+            String suffixName = file.getFileName().substring(file.getFileName().lastIndexOf("."));
+            // 鍚堟垚鏂扮殑鏂囦欢鍚�
+
+            newFileName = newFileName + suffixName;
+            file.transferTo(new File(basePath + newFileName));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return newFileName;
+    }
+
+    /**
+     * inoutDataPR#delImage
+     *
+     * @param parameter
+     * @return
+     */
+    @Expose
+    public String delImage(Map<String, Object> parameter) throws Exception {
+
+        String fileName = (String) parameter.get("fileName");
+        Date createTime = (Date) parameter.get("createTime");
+        if (null == createTime) createTime = new Date();
+        fileName = URLDecoder.decode(fileName, "UTF-8");
+
+        File file = new File(fileService.getInoutFilePath(createTime), fileName);
+
+        if (!file.exists()) {
+            return "鍒犻櫎澶辫触锛岀郴缁熸湭鎵惧埌褰撳墠闄勪欢";
+        }
+
+        file.delete();
+        return null;
+    }
+
 }

--
Gitblit v1.9.3