Browse Source

新增获取本月和上月询价单数量接口

dongbw 7 năm trước cách đây
mục cha
commit
dc81e7b6d2

+ 14 - 1
src/main/java/com/uas/ps/inquiry/controller/PublicInquiryController.java

@@ -289,7 +289,7 @@ public class PublicInquiryController {
     /**
      * 公共询价单明细某年某月总数
      *                  B2C
-     * @param month
+     * @param month 月份
      * @return
      */
     @RequestMapping(value = "/getPurcInquiryItemCountByMonth", method = RequestMethod.GET)
@@ -300,6 +300,19 @@ public class PublicInquiryController {
         return map;
     }
 
+    /**
+     * 公共询价单明细本月数量和上月数量
+     *                  B2C
+     * @return
+     */
+    @RequestMapping(value = "/getCountOfLastAndThisMonth", method = RequestMethod.GET)
+    public ModelMap getPurcInquiryItemCountByMonth() {
+        long start = System.currentTimeMillis();
+        ModelMap map = publicInquiryService.getCountOfLastAndThisMonth();
+        log.info("/inquiry/public/getCountOfLastAndThisMonth 耗时:" + (System.currentTimeMillis() - start));
+        return map;
+    }
+
     /* ===========================================app接口start============================================================ */
 
     /**

+ 16 - 0
src/main/java/com/uas/ps/inquiry/service/PublicInquiryService.java

@@ -282,6 +282,16 @@ public interface PublicInquiryService {
      */
     ModelMap countByMonth(Integer year, Integer month);
 
+
+    /**
+     * 根据年份和月份字符串获取条数
+     *
+     * @param year 年份
+     * @param months 月份字符串 6,7,8
+     * @return map
+     */
+    List<ModelMap> countByMonths(Integer year, String months);
+
     /**
      * 根据enUU获取已被采纳或拒绝的报价单明细
      * @param enUU  报价企业UU
@@ -320,5 +330,11 @@ public interface PublicInquiryService {
      * @param idArray 报价单明细id list
      */
     void downEnRemindSuccess(String[] idArray, Long enUU);
+
+    /**
+     * 获取当前月和上个月询价单数量
+     * @return 数量map
+     */
+    ModelMap getCountOfLastAndThisMonth();
 }
 

+ 61 - 0
src/main/java/com/uas/ps/inquiry/service/impl/PublicInquiryServiceImpl.java

@@ -700,6 +700,37 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
         }
     }
 
+    /**
+     * 获取当前月和上个月询价单数量
+     *
+     * @return 数量map
+     */
+    @Override
+    public ModelMap getCountOfLastAndThisMonth() {
+        Calendar now = Calendar.getInstance();
+        Integer year = now.get(Calendar.YEAR);
+        Integer month = now.get(Calendar.MONTH) + 1;
+        ModelMap result = new ModelMap();
+        try {
+            Long current = inquiryItemInfoDao.countByMonth(year, month);
+            result.put("current", current);
+            if (month == 1) {
+                year = year - 1;
+                month = 12;
+            } else {
+                month = month - 1;
+            }
+            Long last = inquiryItemInfoDao.countByMonth(year, month);
+            result.put("last", last);
+            result.put("success", "true");
+        } catch (Exception e) {
+            result.put("message", e.getMessage());
+            result.put("success", false);
+            e.printStackTrace();
+        }
+        return result;
+    }
+
     /**
      * 将公共询价服务中心的公共询价转成ERP的对应的字段
      *
@@ -1610,6 +1641,36 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
         return result;
     }
 
+    /**
+     * 根据年份和月份字符串获取条数
+     *
+     * @param year   年份
+     * @param months 月份字符串 6,7,8
+     * @return map
+     */
+    @Override
+    public List<ModelMap> countByMonths(Integer year, String months) {
+        List<ModelMap> results = new ArrayList<>();
+        try {
+            String[] monthArray = months.split(",");
+            for (String month : monthArray) {
+                ModelMap result = new ModelMap();
+                Long count = inquiryItemInfoDao.countByMonth(year, Integer.valueOf(month));
+                result.put("count", count);
+                result.put("success", "true");
+                result.put("month", Integer.valueOf(month));
+                results.add(result);
+            }
+        } catch (Exception e) {
+            ModelMap result = new ModelMap();
+            result.put("message", e.getMessage());
+            result.put("success", false);
+            results.add(result);
+            e.printStackTrace();
+        }
+        return results;
+    }
+
     /**
      * 根据enUU获取
      *