935090232@qq.com
2022-01-11 2f3fa592eb9d8edd9b4af8cdecbf1e2e6e5fc016
新增固定资产导出功能
3 files modified
90 ■■■■ changed files
zq-erp/pom.xml 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/oa/actions/OaFixedAssetsAction.java 79 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/oa/assets/fixeAssets-list.html 7 ●●●●● patch | view | raw | blame | history
zq-erp/pom.xml
@@ -413,11 +413,11 @@
                    <exclude>config/xcx/*</exclude>
                    <exclude>config/xcshop/*</exclude>
                    <!---->
                    <!--
                    <exclude>config/config.json</exclude>
                    <exclude>config/application.properties</exclude>
                    <exclude>config/system.properties</exclude>
                    -->
                    <exclude>**/*.woff</exclude>
zq-erp/src/main/java/com/matrix/system/oa/actions/OaFixedAssetsAction.java
@@ -8,24 +8,36 @@
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.DateUtil;
import com.matrix.core.tools.ModelUtils;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.WebUtil;
import com.matrix.core.tools.excl.ExcelSheetPO;
import com.matrix.core.tools.excl.ExcelUtil;
import com.matrix.core.tools.excl.ExcelVersion;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.tools.ResponseHeadUtil;
import com.matrix.system.oa.bean.OaFixedAssets;
import com.matrix.system.oa.dao.OaFixedAssetsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @description 固定资产
 * @author 
 * @description 固定资产
 * @date 2019-12-13 07:19
 */
@Controller
@@ -43,7 +55,8 @@
     * 列表显示
     */
    @RequestMapping(value =  "/showList")
    public @ResponseBody AjaxResult showList(OaFixedAssets oaFixedAssets, PaginationVO pageVo) {
    public @ResponseBody
    AjaxResult showList(OaFixedAssets oaFixedAssets, PaginationVO pageVo) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        oaFixedAssets.setCompanyId(user.getCompanyId());
        List<OaFixedAssets> dataList = oaFixedAssetsDao.selectInPage(oaFixedAssets, pageVo);
@@ -57,7 +70,8 @@
     */   
    @RemoveRequestToken    
       @RequestMapping(value =  "/addOaFixedAssets")
    public @ResponseBody AjaxResult addOaFixedAssets(OaFixedAssets oaFixedAssets) {
    public @ResponseBody
    AjaxResult addOaFixedAssets(OaFixedAssets oaFixedAssets) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        oaFixedAssets.setCreateBy(user.getSuName());
        oaFixedAssets.setUpdateBy(user.getSuName());
@@ -71,15 +85,13 @@
    }
    
    
    /**
     * 修改
     */   
    @RemoveRequestToken    
       @RequestMapping(value =  "/modifyOaFixedAssets")
    public @ResponseBody AjaxResult modifyOaFixedAssets(OaFixedAssets newOaFixedAssets) {
    public @ResponseBody
    AjaxResult modifyOaFixedAssets(OaFixedAssets newOaFixedAssets) {
           OaFixedAssets oldOaFixedAssets = WebUtil.getSessionAttribute(BEV);
        int i = 0;
        Map<String, Object> modifyMap = null;
@@ -105,8 +117,6 @@
    }
    
    
       /**
     * 进入修改界面
     */   
@@ -128,7 +138,8 @@
     * 删除
     */  
     @RequestMapping(value = "/del")
    public @ResponseBody AjaxResult del(String keys) {
    public @ResponseBody
    AjaxResult del(String keys) {
        List<String> ids = StringUtils.strToCollToString(keys, ",");
        int i =  oaFixedAssetsDao.deleteByIds(ids);
        if (i > 0) {
@@ -138,4 +149,52 @@
        }
    }
  
    /**
     * 总部导出服务单导出,不限门店
     */
    @RequestMapping(value = "/exportExcel")
    public void erpExportExcel(ModelMap model, HttpServletRequest request, HttpServletResponse response, OaFixedAssets oaFixedAssets) throws Exception {
        doExportServiceOrder(response, oaFixedAssets);
    }
    private void doExportServiceOrder(HttpServletResponse response, OaFixedAssets oaFixedAssets) throws IOException {
        List<ExcelSheetPO> res = new ArrayList<>();
        ExcelSheetPO orderSheet = new ExcelSheetPO();
        String title = "固定资产明细";
        orderSheet.setSheetName(title);
        orderSheet.setTitle(title);
        String[] header = {"资产类型", "资产编号", "资产型号", "所在部门", "成本价", "数量", "往来单位", "使用人"};
        orderSheet.setHeaders(header);
        List<OaFixedAssets> dataList = oaFixedAssetsDao.selectByModel(oaFixedAssets);
        List<List<Object>> list = new ArrayList<>();
        if (dataList.size() > 0) {
            for (OaFixedAssets item : dataList) {
                List<Object> temp = new ArrayList<>();
                temp.add(item.getAssetsType());
                temp.add(item.getName());
                temp.add(item.getNumber());
                temp.add(item.getModel());
                temp.add(item.getDepartment());
                temp.add(item.getPrice());
                temp.add(item.getCount());
                temp.add(item.getSupplier());
                temp.add(item.getUser());
                list.add(temp);
            }
        }
        orderSheet.setDataList(list);
        res.add(orderSheet);
        response = ResponseHeadUtil.setExcelHead(response);
        response.setHeader("Content-Disposition",
                "attachment;filename=" + URLEncoder.encode(title + DateUtil.getTimeMark() + ".xlsx".trim(), "UTF-8"));
        OutputStream os = response.getOutputStream();
        ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true);
    }
}
zq-erp/src/main/resources/templates/views/admin/oa/assets/fixeAssets-list.html
@@ -55,6 +55,7 @@
            <button matrix:btn="oaFixedAssets-add"  onclick="openAdd()" type="button" class="btn btn-info btn-sm"><i class="fa fa-plus" ></i>  新增</button>
            <button matrix:btn="oaFixedAssets-edit"  onclick="openEdit()" type="button" class="btn btn-info btn-sm"><i class="fa fa-edit" ></i> 编辑</button>
            <button  matrix:btn="oaFixedAssets-dels" onclick="myGrid.delItems('id')" type="button" class="btn btn-danger btn-sm"><i class="fa fa-trash" ></i>批量删除</button>
            <button    onclick="exportExcel()" type="button" class="btn btn-info btn-sm"><i class="fa fa-download" ></i> 导出</button>
        </div>
        <!-- 数据表格部分 -->
        <table id="mgrid">
@@ -115,6 +116,12 @@
            content: [basePath + '/admin/oaFixedAssets/editForm?id=' + id]
        });
    }
    function exportExcel(){
        var param=MForm.toUrlParam("#serchform");
        window.location.href=basePath+"/admin/oaFixedAssets/exportExcel?"+param;
    }
</script>
</body>