com.esd.cs.audit.QueryAuditController.java Source code

Java tutorial

Introduction

Here is the source code for com.esd.cs.audit.QueryAuditController.java

Source

/*
 * Copyright (c) 2013 ????www.hrbesd.com. All rights reserved.
 * 
 * HRBESD PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.esd.cs.audit;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.esd.common.util.PaginationRecordsAndNumber;
import com.esd.cs.Constants;
import com.esd.cs.company.CompanyParamModel;
import com.esd.cs.worker.QueryWorkerController;
import com.esd.hesf.model.Audit;
import com.esd.hesf.model.Company;
import com.esd.hesf.service.AuditService;
import com.esd.hesf.service.CompanyService;

@Controller
@RequestMapping(value = "/security/query/audit")
public class QueryAuditController {
    private static final Logger logger = LoggerFactory.getLogger(QueryWorkerController.class);

    @Autowired
    private AuditService auditService;

    @Autowired
    private CompanyService companyService;

    /**
     * ?
     * 
     * @param request
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ModelAndView queryAuditList(HttpServletRequest request, HttpSession session) {
        String nowYear = (String) session.getAttribute(Constants.YEAR);
        request.setAttribute("nowYear", nowYear);
        return new ModelAndView("query/audit");
    }

    /**
     * ??
     * 
     * @param page
     * @param rows
     * @param params
     * @param request
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> provincePost(AuditParamModel params, HttpServletRequest request) {
        logger.debug("queryAuditParams:{}", params);

        Map<String, Object> entity = new HashMap<>();
        try {
            Map<String, Object> paramsMap = new HashMap<String, Object>();
            paramsMap.put("year", params.getYear()); // 
            paramsMap.put("companyCode", params.getCompanyCode()); // ??
            paramsMap.put("companyTaxCode", params.getCompanyTaxCode()); // ??
            paramsMap.put("companyOrganizationCode", params.getCompanyOrganizationCode()); // ??
            paramsMap.put("companyProperty", params.getCompanyProperty()); // ?
            paramsMap.put("companyEconomyType", params.getCompanyEconomyType()); // ??
            paramsMap.put("areaCode", params.getArea()); //   code
            paramsMap.put("minTotal", params.getCompanyEmpTotal_1()); // 
            paramsMap.put("maxTotal", params.getCompanyEmpTotal_2()); // 
            paramsMap.put("companyName", params.getCompanyName()); // ???
            paramsMap.put("companyAddress", params.getCompanyAddress()); // ??
            paramsMap.put("companyLegal", params.getCompanyLegal()); // ?
            paramsMap.put("auditProcessStatus", params.getAuditProcessStatus()); // ??
            paramsMap.put("paymentPerson", params.getPaymentPerson()); //  id
            String overYear = params.getOverYear();// ??
            if (StringUtils.isBlank(overYear)) {
                overYear = "0";
            }
            paramsMap.put("overYear", overYear);// ??
            paramsMap.put("isExempt", Boolean.valueOf(params.getIsExempt())); // ??
            // true?,
            // false??
            paramsMap.put("page", params.getPage()); // --
            paramsMap.put("pageSize", params.getRows());// --?

            logger.debug("queryAuditParamsEx:{}", params);
            PaginationRecordsAndNumber<Audit, Number> query = auditService.getByMultiCondition(paramsMap);
            Integer total = query.getNumber().intValue();// ??
            List<Map<String, Object>> list = new ArrayList<>();
            for (Iterator<Audit> iterator = query.getRecords().iterator(); iterator.hasNext();) {
                Audit it = iterator.next();
                Map<String, Object> map = new HashMap<>();
                map.put("id", it.getId());// id
                map.put("companyId", it.getCompany().getId());// id
                map.put("companyCode", it.getCompany().getCompanyCode());// ??
                map.put("companyTaxCode", it.getCompany().getCompanyTaxCode());// ?
                map.put("companyName", it.getCompany().getCompanyName());// ???
                map.put("companyLegal", it.getCompany().getCompanyLegal());
                map.put("companyAddress", it.getCompany().getCompanyAddress());
                map.put("companyPhone", it.getCompany().getCompanyPhone());// ??
                list.add(map);
            }
            entity.put("total", total);
            entity.put("rows", list);
            logger.debug("queryAuditResult:{}", total);

        } catch (Exception e) {
            e.printStackTrace();
            logger.error("queryAuditError{}", e.getMessage());
        }
        return entity;
    }

    /**
     * ??
     * 
     * @param request
     * @return
     */
    @RequestMapping(value = "/listforcompany", method = RequestMethod.GET)
    public ModelAndView queryAuditListForQueryer(HttpServletRequest request, HttpSession session) {
        return new ModelAndView("query/audit_for_queryer");
    }

    /**
     * ???
     * 
     * @param page
     * @param rows
     * @param params
     * @param request
     * @return
     */
    @RequestMapping(value = "/listforcompany", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> provincePostForQueryer(CompanyParamModel params, HttpServletRequest request) {
        logger.debug("queryCompanyParams:{}", params);

        Map<String, Object> entity = new HashMap<>();
        try {
            Company t = new Company();
            t.setCompanyName(params.getCompanyName());
            t.setCompanyAddress(params.getCompanyAddress());
            if ("firstTime".equals(params.getFirstTime())) {
                params.setRows(0);// --?
            }
            PaginationRecordsAndNumber<Company, Number> query = companyService.getPaginationRecords(t,
                    params.getPage(), params.getRows());
            Integer total = query.getNumber().intValue();// ??
            List<Map<String, Object>> list = new ArrayList<>();
            for (Iterator<Company> iterator = query.getRecords().iterator(); iterator.hasNext();) {
                Company it = iterator.next();
                Map<String, Object> map = new HashMap<>();
                map.put("companyId", it.getId());// id
                map.put("companyName", it.getCompanyName());// ???
                map.put("companyAddress", it.getCompanyAddress());
                list.add(map);
            }
            entity.put("total", total);
            entity.put("rows", list);
            logger.debug("queryCompanyResult:{}", total);

        } catch (Exception e) {
            e.printStackTrace();
            logger.error("queryCompanyResult{}", e.getMessage());
        }
        return entity;
    }
}