Bläddra i källkod

发运单统计首页统计

jz.kai 2 år sedan
förälder
incheckning
ab780b4f87

+ 3 - 0
common/src/main/java/com/jpsoft/prices/modules/base/dao/InvoiceDAO.java

@@ -1,6 +1,8 @@
 package com.jpsoft.prices.modules.base.dao;
 package com.jpsoft.prices.modules.base.dao;
 
 
 import java.util.List;
 import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 import com.jpsoft.prices.modules.base.entity.Invoice;
 import com.jpsoft.prices.modules.base.entity.Invoice;
 import java.util.Map;
 import java.util.Map;
@@ -15,4 +17,5 @@ public interface InvoiceDAO {
 	int delete(String id);
 	int delete(String id);
 	List<Invoice> list();
 	List<Invoice> list();
 	List<Invoice> search(Map<String,Object> searchParams,List<Sort> sortList);
 	List<Invoice> search(Map<String,Object> searchParams,List<Sort> sortList);
+	List<Invoice> findByStatus(@Param(value="status") Boolean status);
 }
 }

+ 2 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/InvoiceService.java

@@ -5,6 +5,7 @@ import java.util.Map;
 import com.jpsoft.prices.modules.base.entity.Invoice;
 import com.jpsoft.prices.modules.base.entity.Invoice;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.Page;
 import com.jpsoft.prices.modules.common.dto.Sort;
 import com.jpsoft.prices.modules.common.dto.Sort;
+import org.apache.ibatis.annotations.Param;
 
 
 public interface InvoiceService {
 public interface InvoiceService {
 	Invoice get(String id);
 	Invoice get(String id);
@@ -14,4 +15,5 @@ public interface InvoiceService {
 	int delete(String id);
 	int delete(String id);
 	List<Invoice> list();
 	List<Invoice> list();
 	Page<Invoice> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
 	Page<Invoice> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+	List<Invoice> findByStatus(@Param(value="status") Boolean status);
 }
 }

+ 8 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/impl/InvoiceServiceImpl.java

@@ -4,6 +4,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.UUID;
 import java.util.UUID;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import com.jpsoft.prices.modules.base.dao.InvoiceDAO;
 import com.jpsoft.prices.modules.base.dao.InvoiceDAO;
@@ -67,4 +69,10 @@ public class InvoiceServiceImpl implements InvoiceService {
         
         
         return page;
         return page;
 	}
 	}
+
+	@Override
+	public List<Invoice> findByStatus(@Param(value="status") Boolean status) {
+		// TODO Auto-generated method stub
+		return invoiceDAO.findByStatus(status);
+	}
 }
 }

+ 7 - 0
common/src/main/resources/mapper/base/Invoice.xml

@@ -136,4 +136,11 @@
 	        ${sort.name} ${sort.order}
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	 	</foreach>
 	</select>
 	</select>
+	<select id="findByStatus" resultMap="InvoiceMap">
+		select * from base_invoice
+		where del_flag = 0
+		<if test="status != null">
+			and status_ = #{status}
+		</if>
+	</select>
 </mapper>
 </mapper>

+ 26 - 124
web/src/main/java/com/jpsoft/prices/modules/HomeController.java

@@ -1,138 +1,40 @@
 package com.jpsoft.prices.modules;
 package com.jpsoft.prices.modules;
 
 
+import com.jpsoft.prices.modules.base.entity.Invoice;
+import com.jpsoft.prices.modules.base.service.InvoiceService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @RestController
 @RestController
 @RequestMapping("/home")
 @RequestMapping("/home")
 @Api(description = "home")
 @Api(description = "home")
 public class HomeController {
 public class HomeController {
     private Logger logger = LoggerFactory.getLogger(getClass());
     private Logger logger = LoggerFactory.getLogger(getClass());
 
 
-//    @Autowired
-//    private AdvisoryService advisoryService;
-//    @Autowired
-//    private ReportService reportService;
-//
-//    @ApiOperation(value="咨询数量")
-//    @RequestMapping(value = "countByAdvisory",method = RequestMethod.POST)
-//    public Map<String,Object> countByAdvisory(@RequestAttribute String subject){
-//        Map<String,Object> map = new HashMap<>();
-//
-//        Map<String,Object> searchParams = new HashMap<>();
-//        searchParams.put("createBy", subject);
-//
-//        List<Sort> sortList = new ArrayList<>();
-//        sortList.add(new Sort("id_","asc"));
-//
-//        Page<Advisory> page = new Page<>();
-//        //今天
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-//        String today = sdf.format(new Date());
-//        searchParams.put("startTime", today + " 00:00:00");
-//        searchParams.put("endTime", today + "23:59:59");
-//        page = advisoryService.pageSearch(searchParams,1,10000,false,sortList);
-//        map.put("item3",page.size());
-//
-//        //昨天
-//        Calendar calendar = new GregorianCalendar();
-//        calendar.setTime(new Date());
-//        calendar.add(calendar.DATE,-1);
-//        String yesterday= sdf.format(calendar.getTime());
-//        searchParams.put("startTime", yesterday + " 00:00:00");
-//        searchParams.put("endTime", yesterday + "23:59:59");
-//        page = advisoryService.pageSearch(searchParams,1,10000,false,sortList);
-//        map.put("item4",page.size());
-//
-//        return map;
-//    }
-//
-//    @ApiOperation(value="报案数量")
-//    @RequestMapping(value = "countByReport",method = RequestMethod.POST)
-//    public Map<String,Object> countByReport(@RequestAttribute String subject){
-//        Map<String,Object> map = new HashMap<>();
-//
-//        Map<String,Object> searchParams = new HashMap<>();
-//        searchParams.put("createBy", subject);
-//
-//        List<Sort> sortList = new ArrayList<>();
-//        sortList.add(new Sort("id_","asc"));
-//
-//        Page<Report> page = new Page<>();
-//        //今天
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-//        String today = sdf.format(new Date());
-//        searchParams.put("startTime", today + " 00:00:00");
-//        searchParams.put("endTime", today + "23:59:59");
-//        page = reportService.pageSearch(searchParams,1,10000,false,sortList);
-//        map.put("item1",page.size());
-//
-//        //昨天
-//        Calendar calendar = new GregorianCalendar();
-//        calendar.setTime(new Date());
-//        calendar.add(calendar.DATE,-1);
-//        String yesterday= sdf.format(calendar.getTime());
-//        searchParams.put("startTime", yesterday + " 00:00:00");
-//        searchParams.put("endTime", yesterday + "23:59:59");
-//        page = reportService.pageSearch(searchParams,1,10000,false,sortList);
-//        map.put("item2",page.size());
-//
-//        return map;
-//    }
-//
-//    @ApiOperation(value = "月趋势图数据")
-//    @RequestMapping(value = "trendDataForMonth",method = RequestMethod.POST)
-//    public MessageResult<Map> trendDataForMonth(@RequestAttribute String subject) {
-//        MessageResult<Map> msgResult = new MessageResult<>();
-//        HashMap<String, Object> map = new HashMap<>();
-//        try {
-//            List<String> dayList = new ArrayList<>();
-//            List<Integer> reportNumList = new ArrayList<>();
-//            List<Integer> advisoryNumList = new ArrayList<>();
-//
-//            Calendar calendar = Calendar.getInstance();
-//            calendar.setTime(new Date());
-//            int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
-//
-//            calendar.set(Calendar.DATE, 1);//把日期设置为当月第一天
-//            calendar.roll(Calendar.DATE, -1);//日期回滚一天,也就是最后一天
-//            int maxDate = calendar.get(Calendar.DATE);
-//            calendar.set(Calendar.DATE, 1);
-//            for(int i = 1; i <= maxDate; i++){
-//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-//                String day = simpleDateFormat.format(calendar.getTime());
-//
-//                dayList.add(day.substring(5));
-//                if(i <= dayOfMonth) {
-//                    List<Sort> sortList = new ArrayList<>();
-//                    sortList.add(new Sort("id_", "asc"));
-//                    Map<String, Object> searchParams = new HashMap<>();
-//                    searchParams.put("startTime", day + " 00:00:00");
-//                    searchParams.put("endTime", day + "23:59:59");
-//                    Page<Report> reportPage = reportService.pageSearch(searchParams, 1, 10000, false, sortList);
-//                    Page<Advisory> advisoryPage = advisoryService.pageSearch(searchParams, 1, 10000, false, sortList);
-//                    reportNumList.add(reportPage.size());
-//                    advisoryNumList.add(advisoryPage.size());
-//                }
-//                calendar.add(calendar.DATE, 1);
-//            }
-//
-//            map.put("day", dayList);
-//            map.put("reportNumList", reportNumList);
-//            map.put("advisoryNumList", advisoryNumList);
-//
-//            msgResult.setData(map);
-//            msgResult.setResult(true);
-//            msgResult.setMessage("获取成功");
-//
-//
-//        } catch (Exception e) {
-//            msgResult.setData(map);
-//            msgResult.setResult(false);
-//            msgResult.setMessage(e.getMessage());
-//        }
-//        return msgResult;
-//    }
+    @Autowired
+    private InvoiceService invoiceService;
+
+    @ApiOperation(value="发运单统计")
+    @RequestMapping(value = "countByInvoice",method = RequestMethod.POST)
+    public Map<String,Object> countByInvoice(@RequestAttribute String subject){
+        Map<String,Object> map = new HashMap<>();
+
+        List<Invoice> list1 = invoiceService.findByStatus(null);
+        List<Invoice> list2 = invoiceService.findByStatus(false);
+        List<Invoice> list3 = invoiceService.findByStatus(true);
+
+        map.put("countTotal",list1.size());
+        map.put("countProgress",list2.size());
+        map.put("countCompleted",list3.size());
+
+        return map;
+    }
 }
 }