From 1eedb8a57c2eb5c9953dcf058184ebdc6987fbf5 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 24 May 2022 15:14:21 +0800
Subject: [PATCH] Merge branch 'feature/订单服务单代码改造' into alpha
---
zq-erp/src/main/java/com/matrix/system/oa/actions/OaFixedAssetsAction.java | 273 +++++++++++++++++++++++++++++++++---------------------
1 files changed, 166 insertions(+), 107 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/oa/actions/OaFixedAssetsAction.java b/zq-erp/src/main/java/com/matrix/system/oa/actions/OaFixedAssetsAction.java
index befc7c8..546bb82 100644
--- a/zq-erp/src/main/java/com/matrix/system/oa/actions/OaFixedAssetsAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/oa/actions/OaFixedAssetsAction.java
@@ -8,134 +8,193 @@
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;
/**
+ * @author
* @description 固定资产
- * @author
* @date 2019-12-13 07:19
*/
@Controller
@RequestMapping(value = "admin/oaFixedAssets")
public class OaFixedAssetsAction {
- @Autowired
- private OaFixedAssetsDao oaFixedAssetsDao;
-
- //记录编辑前的值Before_Edit_Value
- public static final String BEV="OaFixedAssets_BEV";
-
-
- /**
- * 列表显示
- */
- @RequestMapping(value = "/showList")
- 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);
- AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList,
- oaFixedAssetsDao.selectTotalRecord(oaFixedAssets));
- return result;
- }
-
- /**
- * 新增
- */
- @RemoveRequestToken
- @RequestMapping(value = "/addOaFixedAssets")
- public @ResponseBody AjaxResult addOaFixedAssets(OaFixedAssets oaFixedAssets) {
- SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
- oaFixedAssets.setCreateBy(user.getSuName());
- oaFixedAssets.setUpdateBy(user.getSuName());
- oaFixedAssets.setCompanyId(user.getCompanyId());
- int i=oaFixedAssetsDao.insert(oaFixedAssets);
- if(i > 0){
- return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "固定资产");
- }else {
- throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL);
- }
- }
-
-
-
-
-
- /**
- * 修改
- */
- @RemoveRequestToken
- @RequestMapping(value = "/modifyOaFixedAssets")
- public @ResponseBody AjaxResult modifyOaFixedAssets(OaFixedAssets newOaFixedAssets) {
- OaFixedAssets oldOaFixedAssets = WebUtil.getSessionAttribute(BEV);
- int i = 0;
- Map<String, Object> modifyMap = null;
- try {
- if (!ModelUtils.isModified(oldOaFixedAssets, newOaFixedAssets)) {
- i = MatrixConstance.DML_SUCCESSS;
- }
- modifyMap = ModelUtils.comparePojo2Map(oldOaFixedAssets, newOaFixedAssets);
- } catch (Exception e) {
- throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL, e, newOaFixedAssets);
- }
- if (modifyMap.size() > 0) {
- modifyMap.put("id", oldOaFixedAssets.getId());
- oaFixedAssetsDao.updateByMap(modifyMap);
- }
- i = MatrixConstance.DML_SUCCESSS;
- WebUtil.removeSessionAttribute(BEV);
- if (i > 0) {
- return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, "固定资产");
- } else {
- throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL);
- }
- }
-
-
-
-
- /**
- * 进入修改界面
- */
- @SaveRequestToken
- @RequestMapping(value = "/editForm")
- public ModelAndView editForm(String id) {
- OaFixedAssets oaFixedAssets = new OaFixedAssets();
- ModelAndView modelAndView = new ModelAndView("admin/oa/assets/fixeAssets-form");
- if (id != null) {
- oaFixedAssets = oaFixedAssetsDao.selectById(id);
- WebUtil.setSessionAttribute(BEV, oaFixedAssets);
- }
- modelAndView.addObject("obj",oaFixedAssets);
- return modelAndView;
- }
-
-
- /**
- * 删除
- */
- @RequestMapping(value = "/del")
- public @ResponseBody AjaxResult del(String keys) {
- List<String> ids = StringUtils.strToCollToString(keys, ",");
- int i = oaFixedAssetsDao.deleteByIds(ids);
- if (i > 0) {
- return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.DELETE_SUCCES, i);
- } else {
- throw new GlobleException(SystemErrorCode.DATA_DELETE_FAIL);
- }
- }
-
+ @Autowired
+ private OaFixedAssetsDao oaFixedAssetsDao;
+
+ //记录编辑前的值Before_Edit_Value
+ public static final String BEV = "OaFixedAssets_BEV";
+
+
+ /**
+ * 列表显示
+ */
+ @RequestMapping(value = "/showList")
+ 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);
+ AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList,
+ oaFixedAssetsDao.selectTotalRecord(oaFixedAssets));
+ return result;
+ }
+
+ /**
+ * 新增
+ */
+ @RemoveRequestToken
+ @RequestMapping(value = "/addOaFixedAssets")
+ public @ResponseBody
+ AjaxResult addOaFixedAssets(OaFixedAssets oaFixedAssets) {
+ SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
+ oaFixedAssets.setCreateBy(user.getSuName());
+ oaFixedAssets.setUpdateBy(user.getSuName());
+ oaFixedAssets.setCompanyId(user.getCompanyId());
+ int i = oaFixedAssetsDao.insert(oaFixedAssets);
+ if (i > 0) {
+ return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "固定资产");
+ } else {
+ throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL);
+ }
+ }
+
+
+ /**
+ * 修改
+ */
+ @RemoveRequestToken
+ @RequestMapping(value = "/modifyOaFixedAssets")
+ public @ResponseBody
+ AjaxResult modifyOaFixedAssets(OaFixedAssets newOaFixedAssets) {
+ OaFixedAssets oldOaFixedAssets = WebUtil.getSessionAttribute(BEV);
+ int i = 0;
+ Map<String, Object> modifyMap = null;
+ try {
+ if (!ModelUtils.isModified(oldOaFixedAssets, newOaFixedAssets)) {
+ i = MatrixConstance.DML_SUCCESSS;
+ }
+ modifyMap = ModelUtils.comparePojo2Map(oldOaFixedAssets, newOaFixedAssets);
+ } catch (Exception e) {
+ throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL, e, newOaFixedAssets);
+ }
+ if (modifyMap.size() > 0) {
+ modifyMap.put("id", oldOaFixedAssets.getId());
+ oaFixedAssetsDao.updateByMap(modifyMap);
+ }
+ i = MatrixConstance.DML_SUCCESSS;
+ WebUtil.removeSessionAttribute(BEV);
+ if (i > 0) {
+ return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, "固定资产");
+ } else {
+ throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL);
+ }
+ }
+
+
+ /**
+ * 进入修改界面
+ */
+ @SaveRequestToken
+ @RequestMapping(value = "/editForm")
+ public ModelAndView editForm(String id) {
+ OaFixedAssets oaFixedAssets = new OaFixedAssets();
+ ModelAndView modelAndView = new ModelAndView("admin/oa/assets/fixeAssets-form");
+ if (id != null) {
+ oaFixedAssets = oaFixedAssetsDao.selectById(id);
+ WebUtil.setSessionAttribute(BEV, oaFixedAssets);
+ }
+ modelAndView.addObject("obj", oaFixedAssets);
+ return modelAndView;
+ }
+
+
+ /**
+ * 删除
+ */
+ @RequestMapping(value = "/del")
+ public @ResponseBody
+ AjaxResult del(String keys) {
+ List<String> ids = StringUtils.strToCollToString(keys, ",");
+ int i = oaFixedAssetsDao.deleteByIds(ids);
+ if (i > 0) {
+ return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.DELETE_SUCCES, i);
+ } else {
+ throw new GlobleException(SystemErrorCode.DATA_DELETE_FAIL);
+ }
+ }
+
+ /**
+ * 总部导出服务单导出,不限门店
+ */
+ @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);
+ }
+
+
}
\ No newline at end of file
--
Gitblit v1.9.1