Selaa lähdekoodia

稽核统计0730

sunyize 2 vuotta sitten
vanhempi
commit
e903cea6a4

+ 122 - 20
tnc-sms/src/main/java/org/jeecg/modules/smscheck/controller/SmsCheckStatisticsController.java

@@ -1,31 +1,39 @@
 package org.jeecg.modules.smscheck.controller;
 
-import cn.hutool.core.lang.Dict;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.poi.ss.formula.functions.T;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.PermissionData;
-import org.jeecg.common.constant.CommonConstant;
+
 import org.jeecg.common.system.base.controller.JeecgController;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.modules.smscheck.entity.SmsCheckCustomerInfo;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.smscheck.entity.SmsStatisticsCheckVo;
-import org.jeecg.modules.smscheck.service.ISmsCheckCustomerInfoService;
 import org.jeecg.modules.smscheck.service.SmsCheckStatisticsService;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @Author: Syze
@@ -36,16 +44,16 @@ import java.util.Map;
 @RestController
 @RequestMapping("/smsCheck/statistics")
 @Slf4j
-public class SmsCheckStatisticsController extends JeecgController<SmsCheckCustomerInfo, ISmsCheckCustomerInfoService> {
+public class SmsCheckStatisticsController extends JeecgController<SmsStatisticsCheckVo, SmsCheckStatisticsService> {
 
 
     @Resource
     private SmsCheckStatisticsService smsCheckStatisticsService;
-
+    @Value("${jeecg.path.upload}")
+    private String upLoadPath;
     /**
      * 分页列表查询
      *
-     * @param   smsStatisticsCheckVo
      * @param pageNo               页码
      * @param pageSize             每页条数
      * @param request              请求
@@ -54,14 +62,24 @@ public class SmsCheckStatisticsController extends JeecgController<SmsCheckCustom
     @ApiOperation(value = "稽核统计-分页列表查询", notes = "稽核统计-分页列表查询")
     @GetMapping(value = "/list")
     @PermissionData(pageComponent = "statistics/SmsCheckStatistics")
-    public Result< Map<String, Object>> queryPageList(SmsStatisticsCheckVo smsStatisticsCheckVo,
+    public Result< Map<String, Object>> queryPageList(
                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                              HttpServletRequest request ) {
         Page<SmsStatisticsCheckVo> page = new Page<>(pageNo, pageSize);
-        String infoId = request.getParameterMap().get("infoId")==null?"": Arrays.toString(request.getParameterMap().get("infoId")).replace("[", "").replace("]", "");
-        String endDate = request.getParameterMap().get("endDate")==null?"": Arrays.toString(request.getParameterMap().get("endDate")).replace("[", "").replace("]", "");
-        String startDate = request.getParameterMap().get("startDate")==null?"": Arrays.toString(request.getParameterMap().get("startDate")).replace("[", "").replace("]", "");
+        String infoId = request.getParameterMap().get("infoId")==null?"": Arrays.toString(request.getParameterMap().get("infoId")).replace("[", "").replace("]", "").replace("*", "");
+        String endDate = request.getParameterMap().get("endDate")==null?"": Arrays.toString(request.getParameterMap().get("endDate")).replace("[", "").replace("]", "").replace("*", "");
+        String startDate = request.getParameterMap().get("startDate")==null?"": Arrays.toString(request.getParameterMap().get("startDate")).replace("[", "").replace("]", "").replace("*", "");
+        String taskType = request.getParameterMap().get("taskType")==null?"": Arrays.toString(request.getParameterMap().get("taskType")).replace("[", "").replace("]", "").replace("*", "");
+        String customerNo = request.getParameterMap().get("customerNo")==null?"": Arrays.toString(request.getParameterMap().get("customerNo")).replace("[", "").replace("]", "").replace("*", "");
+        String customerName = request.getParameterMap().get("customerName")==null?"": Arrays.toString(request.getParameterMap().get("customerName")).replace("[", "").replace("]", "").replace("*", "");
+        String taskName = request.getParameterMap().get("taskName")==null?"": Arrays.toString(request.getParameterMap().get("taskName")).replace("[", "").replace("]", "").replace("*", "");
+
+        SmsStatisticsCheckVo smsStatisticsCheckVo=new SmsStatisticsCheckVo();
+        smsStatisticsCheckVo.setType(taskType);
+        smsStatisticsCheckVo.setCustomerName(customerName);
+        smsStatisticsCheckVo.setCustomerNo(customerNo);
+        smsStatisticsCheckVo.setTaskName(taskName);
         Map<String, Object> stringObjectMap = smsCheckStatisticsService.smsCheckStatisticsList(smsStatisticsCheckVo, page,startDate,endDate,infoId);
         return Result.OK(stringObjectMap);
     }
@@ -76,14 +94,98 @@ public class SmsCheckStatisticsController extends JeecgController<SmsCheckCustom
     @GetMapping(value = "/count")
     @PermissionData(pageComponent = "statistics/SmsCheckStatistics")
     public Result<Map<String, Object>> count(   HttpServletRequest request) {
-        String infoId = request.getParameterMap().get("infoId")==null?"": Arrays.toString(request.getParameterMap().get("infoId")).replace("[", "").replace("]", "");
-        String endDate = request.getParameterMap().get("endDate")==null?"": Arrays.toString(request.getParameterMap().get("endDate")).replace("[", "").replace("]", "");
-        String startDate = request.getParameterMap().get("startDate")==null?"": Arrays.toString(request.getParameterMap().get("startDate")).replace("[", "").replace("]", "");
-        String type = request.getParameterMap().get("type")==null?"": Arrays.toString(request.getParameterMap().get("type")).replace("[", "").replace("]", "");
-        Map<String, Object> stringObjectMap = smsCheckStatisticsService.statisticsCountListByType(type,  startDate,  endDate,infoId);
+        String infoId = request.getParameterMap().get("infoId")==null?"": Arrays.toString(request.getParameterMap().get("infoId")).replace("[", "").replace("]", "").replace("*", "");
+        String endDate = request.getParameterMap().get("endDate")==null?"": Arrays.toString(request.getParameterMap().get("endDate")).replace("[", "").replace("]", "").replace("*", "");
+        String startDate = request.getParameterMap().get("startDate")==null?"": Arrays.toString(request.getParameterMap().get("startDate")).replace("[", "").replace("]", "").replace("*", "");
+        String taskType = request.getParameterMap().get("taskType")==null?"": Arrays.toString(request.getParameterMap().get("taskType")).replace("[", "").replace("]", "").replace("*", "");
+        String customerNo = request.getParameterMap().get("customerNo")==null?"": Arrays.toString(request.getParameterMap().get("customerNo")).replace("[", "").replace("]", "").replace("*", "");
+        String customerName = request.getParameterMap().get("customerName")==null?"": Arrays.toString(request.getParameterMap().get("customerName")).replace("[", "").replace("]", "").replace("*", "");
+        String taskName = request.getParameterMap().get("taskName")==null?"": Arrays.toString(request.getParameterMap().get("taskName")).replace("[", "").replace("]", "").replace("*", "");
+
+        SmsStatisticsCheckVo smsStatisticsCheckVo=new SmsStatisticsCheckVo();
+        smsStatisticsCheckVo.setCustomerName(customerName);
+        smsStatisticsCheckVo.setCustomerNo(customerNo);
+        smsStatisticsCheckVo.setTaskName(taskName);
+
+        Map<String, Object> stringObjectMap = smsCheckStatisticsService.statisticsCountListByType(taskType,  startDate,  endDate,infoId,smsStatisticsCheckVo);
 
         return Result.OK(stringObjectMap);
     }
+    /**
+     * 导出excel
+     *
+     * @param request      请求
+     * @param smsCheckTask 对象
+     * @return excel文件
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, SmsStatisticsCheckVo smsCheckTask)  throws Exception {
+        String title ="稽核统计";
+        // Step.1 组装查询条件
+        String infoId = request.getParameterMap().get("infoId")==null?"": Arrays.toString(request.getParameterMap().get("infoId")).replace("[", "").replace("]", "").replace("*", "");
+        String endDate = request.getParameterMap().get("endDate")==null?"": Arrays.toString(request.getParameterMap().get("endDate")).replace("[", "").replace("]", "").replace("*", "");
+        String startDate = request.getParameterMap().get("startDate")==null?"": Arrays.toString(request.getParameterMap().get("startDate")).replace("[", "").replace("]", "").replace("*", "");
+        String taskType = request.getParameterMap().get("taskType")==null?"": Arrays.toString(request.getParameterMap().get("taskType")).replace("[", "").replace("]", "").replace("*", "");
+        String customerNo = request.getParameterMap().get("customerNo")==null?"": Arrays.toString(request.getParameterMap().get("customerNo")).replace("[", "").replace("]", "").replace("*", "");
+        String customerName = request.getParameterMap().get("customerName")==null?"": Arrays.toString(request.getParameterMap().get("customerName")).replace("[", "").replace("]", "").replace("*", "");
+        String taskName = request.getParameterMap().get("taskName")==null?"": Arrays.toString(request.getParameterMap().get("taskName")).replace("[", "").replace("]", "").replace("*", "");
+
+        SmsStatisticsCheckVo smsStatisticsCheckVo=new SmsStatisticsCheckVo();
+        smsStatisticsCheckVo.setCustomerName(customerName);
+        smsStatisticsCheckVo.setCustomerNo(customerNo);
+        smsStatisticsCheckVo.setTaskName(taskName);
+        smsStatisticsCheckVo.setType(taskType);
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 
+        long totalNum = (long) smsCheckStatisticsService.statisticsCountListByType(null,endDate,startDate,infoId,smsStatisticsCheckVo).get("totalNum");
+        Page<SmsStatisticsCheckVo> page = new Page<>(1, totalNum);
 
+        // Step.2 获取导出数据
+        List<T> records = (List<T>) smsCheckStatisticsService.smsCheckStatisticsList(smsStatisticsCheckVo, page, startDate, endDate, infoId).get("records");
+        List<T> exportList = new ArrayList<>();
+
+        // 过滤选中数据
+        String selections = request.getParameter("selections");
+        if (oConvertUtils.isNotEmpty(selections)) {
+            List<String> selectionList = Arrays.asList(selections.split(","));
+            for (String s : selectionList) {
+                for (int i = 0; i < records.size(); i++) {
+                    String id = PropertyUtils.getProperty(records.get(i), "id").toString();
+                    if (id.equals(s)) {
+                        exportList.add(records.get(i));
+                    }
+                }
+            }
+
+        } else {
+            exportList = records;
+        }
+
+        // Step.3 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        //此处设置的filename无效 ,前端会重更新设置一下
+        mv.addObject(NormalExcelConstants.FILE_NAME, title);
+        mv.addObject(NormalExcelConstants.CLASS, SmsStatisticsCheckVo.class);
+        //update-begin--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
+        ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
+        exportParams.setImageBasePath(upLoadPath);
+        //update-end--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
+        mv.addObject(NormalExcelConstants.PARAMS,exportParams);
+        mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
+        return mv;
+
+    }
+    /**
+     * 获取对象ID
+     *
+     * @return
+     */
+    private String getId(T item) {
+        try {
+            return PropertyUtils.getProperty(item, "id").toString();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
 }

+ 9 - 2
tnc-sms/src/main/java/org/jeecg/modules/smscheck/mapper/SmsCheckStaticsMapper.java

@@ -23,12 +23,19 @@ public interface SmsCheckStaticsMapper  extends BaseMapper<SmsStatisticsCheckVo>
      * @param size
      * @return
      */
-    List<Map<String,Object>> selectCheckStaticsList(@Param("type") String type,@Param("start") Long start,@Param("size") Long size,@Param("startDate")String startDate,@Param("endDate")String endDate,@Param("taskId") String taskId);
+    List<Map<String,Object>> selectCheckStaticsList(@Param("type") String type,@Param("start") Long start,
+                                                    @Param("size") Long size, @Param("startDate")String startDate,
+                                                    @Param("endDate")String endDate,@Param("taskId") String taskId,
+                                                    @Param("customerName") String customerName,@Param("customerNo") String customerNo,
+                                                    @Param("taskName") String taskName);
 
     /**
      * 获取总记录条数
      * @return
      */
-    Long selectTotal(@Param("type") String type,@Param("startDate")String startDate,@Param("endDate")String endDate,@Param("taskId") String taskId);
+    Long selectTotal(@Param("type") String type,@Param("startDate")String startDate,
+                     @Param("endDate")String endDate,@Param("taskId") String taskId,
+                     @Param("customerName") String customerName,@Param("customerNo") String customerNo,
+                     @Param("taskName") String taskName);
 
 }

+ 11 - 1
tnc-sms/src/main/java/org/jeecg/modules/smscheck/mapper/xml/SmsCheckStaticsMapper.xml

@@ -9,7 +9,7 @@
 
     <select id="selectCheckStaticsList"   parameterType="org.jeecg.modules.smscheck.entity.SmsStatisticsCheckVo" resultType ="org.jeecg.modules.smscheck.entity.SmsStatisticsCheckVo">
         select
-        task_id   taskId,customer_no  customerNo,customer_name  customerName,sms_number  smsNumber,user_no  userNo,
+        a.id,task_id   taskId,customer_no  customerNo,customer_name  customerName,sms_number  smsNumber,user_no  userNo,
         network_access_time
         networkAccessTime,user_state  userState,staff_info  staffInfo,staff_id  staffId,
         staff_username
@@ -40,6 +40,13 @@
         <if test="startDate != null and startDate!='' "> and  a.create_time >= #{startDate} </if>
         <if test="endDate != null   and endDate!='' "> and a.create_time <![CDATA[<=]]> #{endDate} </if>
         <if test="taskId != null   and taskId!='' "> and  a.task_id = #{taskId} </if>
+
+        <if test="customerName != null   and customerName!='' "> and  a.customer_name = #{customerName} </if>
+        <if test="customerNo != null   and customerNo!='' "> and  a.customer_no = #{customerNo} </if>
+        <if test="taskName != null   and taskName!='' "> and  b.task_name = #{taskId} </if>
+
+
+
         order BY a.create_time  desc
         <if test="start != null and size != null">
             LIMIT #{start},#{size}
@@ -56,6 +63,9 @@
         <if test="startDate != null and startDate!='' "> and  a.create_time >= #{startDate} </if>
         <if test="endDate != null   and endDate!='' "> and a.create_time <![CDATA[<=]]> #{endDate} </if>
         <if test="taskId != null   and taskId!='' "> and  a.task_id = #{taskId} </if>
+        <if test="customerName != null   and customerName!='' "> and  a.customer_name = #{customerName} </if>
+        <if test="customerNo != null   and customerNo!='' "> and  a.customer_no = #{customerNo} </if>
+        <if test="taskName != null   and taskName!='' "> and  b.task_name = #{taskId} </if>
     </select>
 
 </mapper>

+ 1 - 1
tnc-sms/src/main/java/org/jeecg/modules/smscheck/service/SmsCheckStatisticsService.java

@@ -20,5 +20,5 @@ public interface SmsCheckStatisticsService extends IService<SmsStatisticsCheckVo
 
     Map<String,Object>  smsCheckStatisticsList(SmsStatisticsCheckVo smsStatisticsCheckVo, Page page,String startDate,String endDate,String infoId);
 
-    Map<String,Object>  statisticsCountListByType(String type,String startDate,String endDate,String infoId);
+    Map<String,Object>  statisticsCountListByType(String type,String startDate,String endDate,String infoId,SmsStatisticsCheckVo smsStatisticsCheckVo);
 }

+ 16 - 9
tnc-sms/src/main/java/org/jeecg/modules/smscheck/service/impl/SmsCheckStatisticsServiceImpl.java

@@ -40,9 +40,14 @@ public class SmsCheckStatisticsServiceImpl extends ServiceImpl<SmsCheckStaticsMa
 
         long start = (current - 1) * size;//开始位置
 
-        List<Map<String, Object>> maps = smsCheckStaticsMapper.selectCheckStaticsList(smsStatisticsCheckVo.getType(), start,size,startDate,endDate,taskId);
 
-        Long total = smsCheckStaticsMapper.selectTotal(smsStatisticsCheckVo.getType(),startDate,endDate,taskId);
+        String customerName = smsStatisticsCheckVo.getCustomerName();
+        String customerNo = smsStatisticsCheckVo.getCustomerNo();
+        String taskName = smsStatisticsCheckVo.getTaskName();
+
+        List<Map<String, Object>> maps = smsCheckStaticsMapper.selectCheckStaticsList(smsStatisticsCheckVo.getType(), start,size,startDate,endDate,taskId,customerName,customerNo,taskName);
+
+        Long total = smsCheckStaticsMapper.selectTotal(smsStatisticsCheckVo.getType(),startDate,endDate,taskId,customerName,customerNo,taskName);
 
         //构建返回对象内容
         mapResult.put("current",current);
@@ -65,26 +70,28 @@ public class SmsCheckStatisticsServiceImpl extends ServiceImpl<SmsCheckStaticsMa
 
 
     @Override
-    public Map<String, Object> statisticsCountListByType(String type,String startDate,String endDate,String infoId) {
-
+    public Map<String, Object> statisticsCountListByType(String type,String startDate,String endDate,String infoId,SmsStatisticsCheckVo smsStatisticsCheckVo) {
+        String customerName = smsStatisticsCheckVo.getCustomerName();
+        String customerNo = smsStatisticsCheckVo.getCustomerNo();
+        String taskName = smsStatisticsCheckVo.getTaskName();
         //总数
-        Long totalNum = smsCheckStaticsMapper.selectTotal(null,startDate,endDate,infoId);
+        Long totalNum = smsCheckStaticsMapper.selectTotal(null,startDate,endDate,infoId,customerName,customerNo,taskName);
 
         //1:行短稽核
         String line = CheckTaskTypeEnum.Line.getCode();
-        Long lineNum = smsCheckStaticsMapper.selectTotal(line,startDate,endDate,infoId);
+        Long lineNum = smsCheckStaticsMapper.selectTotal(line,startDate,endDate,infoId,customerName,customerNo,taskName);
 
         //2:物联网业务稽核
         String business = CheckTaskTypeEnum.Business.getCode();
-        Long businessNum = smsCheckStaticsMapper.selectTotal(business,startDate,endDate,infoId);
+        Long businessNum = smsCheckStaticsMapper.selectTotal(business,startDate,endDate,infoId,customerName,customerNo,taskName);
 
         //3.复开审批
         String reopening = CheckTaskTypeEnum.Reopening.getCode();
-        Long reopeningNum = smsCheckStaticsMapper.selectTotal(reopening,startDate,endDate,infoId);
+        Long reopeningNum = smsCheckStaticsMapper.selectTotal(reopening,startDate,endDate,infoId,customerName,customerNo,taskName);
 
         //4.中继线稽核
         String trunkLineAudit = CheckTaskTypeEnum.TrunkLineAudit.getCode();
-        Long trunkLineAuditNum = smsCheckStaticsMapper.selectTotal(trunkLineAudit,startDate,endDate,infoId);
+        Long trunkLineAuditNum = smsCheckStaticsMapper.selectTotal(trunkLineAudit,startDate,endDate,infoId,customerName,customerNo,taskName);
 
         Map<String,Object> mapNums = new HashMap<>();