瀏覽代碼

新增部分日志

liyg 2 年之前
父節點
當前提交
b64c3bab27

+ 3 - 0
src/main/java/com/steerinfo/dil/mapper/SaleLogMapper.java

@@ -19,4 +19,7 @@ public interface SaleLogMapper extends IBaseMapper<SaleLog, BigDecimal> {
 
     //查询用户名
     String getUserNameById(Map<String,Object> map);
+
+    //根据总实绩查询订单ID
+    BigDecimal getOrderIdByTotal(Map<String,Object> map);
 }

+ 5 - 1
src/main/java/com/steerinfo/dil/service/impl/QmsQueueListServiceImpl.java

@@ -376,6 +376,9 @@ public class QmsQueueListServiceImpl implements IQmsQueueListService {
                 continue;   //如果已经确认过了就不继续处理
             }
             mesMap.put("jobName", jobName);
+            //新增日志
+            mesMap.put("userName", jobName);
+            saleLogUtil.logOrder(DataChange.dataToBigDecimal(mesMap.get("orderId")),"钢材科放行",mesMap,SaleLogUtil.UPDATE);
             if(mesMap.get("listId") != null){ //单拼
                 //如果是通过查询的,则需要去判断
                 //if (DataChange.dataToBigDecimal(map.get("isQueryCapacity")).intValue() == 1) {
@@ -531,7 +534,8 @@ public class QmsQueueListServiceImpl implements IQmsQueueListService {
         //去除掉排队信息
         Integer resultTotalId = queuingRulesMapper.checkoutQQR(DataChange.dataToBigDecimal(map.get("resultTotalId")));
         i =+ queuingRulesMapper.updateSpellingDate(resultTotalId);
-
+        //记录日志
+        saleLogUtil.logOrder(map,"撤销放行",SaleLogUtil.UPDATE);
         return i;
     }
 

+ 8 - 0
src/main/java/com/steerinfo/dil/service/impl/QueueDealWithAsync.java

@@ -4,6 +4,7 @@ import com.steerinfo.dil.mapper.QmsQueueListMapper;
 import com.steerinfo.dil.mapper.QmsQueueSpellingListMapper;
 import com.steerinfo.dil.mapper.QueuingRulesMapper;
 import com.steerinfo.dil.util.DataChange;
+import com.steerinfo.dil.util.SaleLogUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.scheduling.annotation.Async;
@@ -32,6 +33,9 @@ public class QueueDealWithAsync {
     @Autowired
     private QmsQueueSpellingListMapper qmsQueueSpellingListMapper;
 
+    @Autowired
+    private SaleLogUtil saleLogUtil;
+
     /**
      * 单拼
      * @param nowTime
@@ -42,6 +46,8 @@ public class QueueDealWithAsync {
         List<Map<String, Object>> listListMap = queuingRulesMapper.getAllSureTimeList();
         for (Map<String, Object> map : listListMap) {
             if((nowTime - ((Date) map.get("entrySureTime")).getTime()) > 5400000){
+                //记录日志
+                saleLogUtil.logOrder(map,"超过勾选时间30分钟,自动回滚到队列最后",SaleLogUtil.UPDATE);
                 //如果超过勾选时间30分钟 自动回滚到队列最后--修改为1个小时
                 BigDecimal listId = DataChange.dataToBigDecimal(map.get("listId"));
                 Integer maxListNodeOrder = qmsQueueListMapper.getMaxListNodeOrder(map);
@@ -68,6 +74,8 @@ public class QueueDealWithAsync {
         List<Map<String, Object>> allSureTimeSpellingList = queuingRulesMapper.getAllSureTimeSpellingList();
         for (Map<String, Object> map : allSureTimeSpellingList) {
             if ((nowTime - ((Date) map.get("entrySureTime")).getTime()) > 5400000) {
+                //记录日志
+                saleLogUtil.logOrder(map,"超过勾选时间30分钟,自动回滚到队列最后",SaleLogUtil.UPDATE);
                 BigDecimal spellingResultId = DataChange.dataToBigDecimal(map.get("spellingResultId"));
                 //如果超过勾选时间30分钟 自动回滚到队列最后
                 queuingRulesMapper.updateSpellingListToLast(spellingResultId);

+ 56 - 0
src/main/java/com/steerinfo/dil/util/SaleLogUtil.java

@@ -67,6 +67,47 @@ public class SaleLogUtil {
         }
     }
 
+    /**
+     * 插入运输订单的操作日志
+     * @param descriptoin
+     * @param oprationType 操作类型
+     * @param map 必传
+     * @return
+     */
+    public int logOrder(Map<String,Object> map,String descriptoin,int oprationType){
+        try{
+            SaleLog saleLog=new SaleLog();
+            saleLog.setResultId(saleLogMapper.selectMaxId());
+            saleLog.setOrderId(getOrderId(map));
+            saleLog.setDescription(descriptoin);
+            saleLog.setInsertTime(new Date());
+            saleLog.setInsertUsername(getUserName(map));
+            switch (oprationType){
+                case INSERT:
+                    saleLog.setOprationType("新增");
+                    break;
+                case UPDATE:
+                    saleLog.setOprationType("修改");
+                    break;
+                case DELETE:
+                    saleLog.setOprationType("删除");
+                    break;
+                case OPEN:
+                    saleLog.setOprationType("启用");
+                    break;
+                case CLOSE:
+                    saleLog.setOprationType("关闭");
+                    break;
+                default:
+                    saleLog.setOprationType("未知操作");
+            }
+            return saleLogMapper.insertSelective(saleLog);
+        }catch (Exception e){
+            e.printStackTrace();
+            return -1;
+        }
+    }
+
     /**
      * 处理插入用户名
      * @param map
@@ -88,4 +129,19 @@ public class SaleLogUtil {
             return "未知用户";
         }
     }
+
+    /**
+     * 获取OrderId
+     * @param map
+     * @return
+     */
+    private BigDecimal getOrderId(Map<String,Object> map) throws Exception {
+        if(map.get("orderId")!=null){
+            return DataChange.dataToBigDecimal(map.get("orderId"));
+        }else if(map.get("resultTotalId")!=null){
+            return saleLogMapper.getOrderIdByTotal(map);
+        }else{
+            throw new Exception("没有订单Id,保存日志失败");
+        }
+    }
 }

+ 5 - 0
src/main/resources/com/steerinfo/dil/mapper/SaleLogMapper.xml

@@ -329,4 +329,9 @@
       WHERE USER_ID = #{userId}
       FETCH NEXT 1 ROWS ONLY
     </select>
+    <select id="getOrderIdByTotal" resultType="java.math.BigDecimal">
+      SELECT ORDER_ID FROM TMSTRUCK_TOTAL_RESULT
+      WHERE RESULT_TOTAL_ID = #{totalResultId}
+      FETCH NEXT 1 ROWS ONLY
+    </select>
 </mapper>