| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627 |
- package cn.com.lzt.budget.costbreakdown.controller;
- import cn.com.lzt.budget.costbreakdown.entity.BudgetCostBreakdownEntity;
- import cn.com.lzt.budget.costbreakdown.service.BudgetCostBreakdownServiceI;
- import java.math.BigDecimal;
- import java.util.*;
- import java.text.SimpleDateFormat;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import cn.com.lzt.budget.costbreakdownmeasure.entity.BudgetCostBreakdownMeasureEntity;
- import cn.com.lzt.budget.data.dao.BudgetDataDao;
- import cn.com.lzt.budget.data.dto.BudgetCalc;
- import cn.com.lzt.budget.data.dto.BudgetContractEntity;
- import cn.com.lzt.budget.data.util.BudgetConstant;
- import cn.com.lzt.budget.dimfunction.service.BudgetDimFunctionServiceI;
- import cn.com.lzt.budget.entity.entity.BudgetEntity;
- import cn.com.lzt.budget.inst.entity.BudgetInstEntity;
- import cn.com.lzt.budget.instmeasure.entity.BudgetInstMeasureEntity;
- import cn.com.lzt.budget.measure.entity.BudgetMeasureEntity;
- import cn.com.lzt.common.util.DictUtil;
- import org.apache.commons.lang.xwork.StringUtils;
- import org.apache.log4j.Logger;
- import org.codehaus.jackson.map.ObjectMapper;
- import org.jeecgframework.core.aop.HibernateTableRename;
- import org.jeecgframework.web.system.pojo.base.TSType;
- import org.jeecgframework.web.system.pojo.base.TSUser;
- 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 org.jeecgframework.core.common.controller.BaseController;
- import org.jeecgframework.core.common.exception.BusinessException;
- import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
- import org.jeecgframework.core.common.model.common.TreeChildCount;
- import org.jeecgframework.core.common.model.json.AjaxJson;
- import org.jeecgframework.core.common.model.json.DataGrid;
- import org.jeecgframework.core.constant.Globals;
- import org.jeecgframework.core.util.StringUtil;
- import org.jeecgframework.tag.core.easyui.TagUtil;
- import org.jeecgframework.web.system.pojo.base.TSDepart;
- import org.jeecgframework.web.system.service.SystemService;
- import org.jeecgframework.core.util.MyBeanUtils;
- import java.io.OutputStream;
- import org.jeecgframework.core.util.BrowserUtils;
- import org.jeecgframework.poi.excel.ExcelExportUtil;
- import org.jeecgframework.poi.excel.ExcelImportUtil;
- import org.jeecgframework.poi.excel.entity.ExportParams;
- import org.jeecgframework.poi.excel.entity.ImportParams;
- import org.jeecgframework.poi.excel.entity.TemplateExportParams;
- import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
- import org.jeecgframework.poi.excel.entity.vo.TemplateExcelConstants;
- import org.apache.poi.hssf.usermodel.HSSFWorkbook;
- import org.jeecgframework.core.util.ResourceUtil;
- import java.io.IOException;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.multipart.MultipartFile;
- import org.springframework.web.multipart.MultipartHttpServletRequest;
- import org.jeecgframework.core.util.ExceptionUtil;
- import org.springframework.http.ResponseEntity;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- 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.bind.annotation.ResponseStatus;
- import org.springframework.http.HttpHeaders;
- import org.springframework.http.HttpStatus;
- import org.jeecgframework.core.beanvalidator.BeanValidators;
- import javax.validation.ConstraintViolation;
- import javax.validation.Validator;
- import java.net.URI;
- import org.springframework.http.MediaType;
- import org.springframework.web.util.UriComponentsBuilder;
- /**
- * @Title: Controller
- * @Description: t_b_budget_cost_breakdown
- * @author onlineGenerator
- * @date 2020-10-12 15:20:09
- * @version V1.0
- *
- */
- @Controller
- @RequestMapping("/budgetCostBreakdownController")
- public class BudgetCostBreakdownController extends BaseController {
- /**
- * Logger for this class
- */
- @Autowired
- private BudgetCostBreakdownServiceI budgetCostBreakdownService;
- @Autowired
- private SystemService systemService;
- @Autowired
- private Validator validator;
- @Autowired
- private BudgetDataDao budgetDataDao;
- @Autowired
- private BudgetDimFunctionServiceI budgetDimFunctionService;
- /**
- * t_b_budget_cost_breakdown列表 页面跳转
- *
- * @return
- */
- @RequestMapping(params = "list")
- public ModelAndView list(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/budget/costbreakdown/budgetCostBreakdownList");
- }
- /**
- * easyui AJAX请求数据
- *
- * @param request
- * @param response
- * @param dataGrid
- */
- @RequestMapping(params = "datagrid")
- public void datagrid(BudgetCostBreakdownEntity budgetCostBreakdown,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- CriteriaQuery cq = new CriteriaQuery(BudgetCostBreakdownEntity.class, dataGrid);
- String editAuth = request.getParameter("editAuth");
- //查询条件组装器
- org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, budgetCostBreakdown, request.getParameterMap());
- try{
- if(StringUtils.equals(editAuth,"yunying")){
- cq.ge("status", 1);
- }
- if(StringUtils.equals(editAuth,"renzi") ||StringUtils.equals(editAuth,"caigou") ){
- cq.eq("status", 2);
- }
- //自定义追加查询条件
- }catch (Exception e) {
- throw new BusinessException(e.getMessage());
- }
- cq.add();
- this.budgetCostBreakdownService.getDataGridReturn(cq, true);
- TagUtil.datagrid(response, dataGrid);
- }
-
- /**
- * 删除t_b_budget_cost_breakdown
- *
- * @return
- */
- @RequestMapping(params = "doDel")
- @ResponseBody
- public AjaxJson doDel(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- budgetCostBreakdown = systemService.getEntity(BudgetCostBreakdownEntity.class, budgetCostBreakdown.getId());
- message = "t_b_budget_cost_breakdown删除成功";
- try{
- budgetCostBreakdownService.delete(budgetCostBreakdown);
- systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
- }catch(Exception e){
- e.printStackTrace();
- message = "t_b_budget_cost_breakdown删除失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
-
- /**
- * 批量删除t_b_budget_cost_breakdown
- *
- * @return
- */
- @RequestMapping(params = "doBatchDel")
- @ResponseBody
- public AjaxJson doBatchDel(String ids,HttpServletRequest request){
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "t_b_budget_cost_breakdown删除成功";
- try{
- for(String id:ids.split(",")){
- BudgetCostBreakdownEntity budgetCostBreakdown = systemService.getEntity(BudgetCostBreakdownEntity.class,
- id
- );
- budgetCostBreakdownService.delete(budgetCostBreakdown);
- systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
- }
- }catch(Exception e){
- e.printStackTrace();
- message = "t_b_budget_cost_breakdown删除失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- /**
- * 添加t_b_budget_cost_breakdown
- *
- * @return
- */
- @RequestMapping(params = "doAdd")
- @ResponseBody
- public AjaxJson doAdd(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest request) {
- if(StringUtils.isNotBlank(budgetCostBreakdown.getId())){
- return doUpdate(budgetCostBreakdown,request );
- }
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "添加成功";
- try{
- List<?> exist = systemService.findByProperty(BudgetCostBreakdownEntity.class, "periodYear", budgetCostBreakdown.getPeriodYear());
- if(!exist.isEmpty()){
- j.setSuccess(false);
- j.setMsg(budgetCostBreakdown.getPeriodYear()+"年已存在预算成本总表。");
- return j;
- }
- budgetCostBreakdownService.save(budgetCostBreakdown);
- systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
- }catch(Exception e){
- e.printStackTrace();
- message = "添加失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
-
- /**
- * 更新t_b_budget_cost_breakdown
- *
- * @return
- */
- @RequestMapping(params = "doUpdate")
- @ResponseBody
- public AjaxJson doUpdate(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "更新成功";
- BudgetCostBreakdownEntity t = budgetCostBreakdownService.get(BudgetCostBreakdownEntity.class, budgetCostBreakdown.getId());
- try {
- MyBeanUtils.copyBeanNotNull2Bean(budgetCostBreakdown, t);
- budgetCostBreakdownService.saveOrUpdate(t);
- systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
- } catch (Exception e) {
- e.printStackTrace();
- message = "更新失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
-
- /**
- * t_b_budget_cost_breakdown新增页面跳转
- *
- * @return
- */
- @RequestMapping(params = "goAdd")
- public ModelAndView goAdd(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest req) {
- if (StringUtil.isNotEmpty(budgetCostBreakdown.getId())) {
- budgetCostBreakdown = budgetCostBreakdownService.getEntity(BudgetCostBreakdownEntity.class, budgetCostBreakdown.getId());
- req.setAttribute("budgetCostBreakdownPage", budgetCostBreakdown);
- }
- return new ModelAndView("cn/com/lzt/budget/costbreakdown/budgetCostBreakdown-add");
- }
- /**
- * t_b_budget_cost_breakdown编辑页面跳转
- *
- * @return
- */
- @RequestMapping(params = "goUpdate")
- public ModelAndView goUpdate(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest req) {
- if (StringUtil.isNotEmpty(budgetCostBreakdown.getId())) {
- budgetCostBreakdown = budgetCostBreakdownService.getEntity(BudgetCostBreakdownEntity.class, budgetCostBreakdown.getId());
- req.setAttribute("entity", budgetCostBreakdown);
- }
- return new ModelAndView("cn/com/lzt/budget/costbreakdown/budgetCostBreakdown-add");
- }
-
- /**
- * 导入功能跳转
- *
- * @return
- */
- @RequestMapping(params = "upload")
- public ModelAndView upload(HttpServletRequest req) {
- req.setAttribute("controller_name","budgetCostBreakdownController");
- return new ModelAndView("common/upload/pub_excel_upload");
- }
-
- /**
- * 导出excel
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportXls")
- public String exportXls(BudgetCostBreakdownEntity budgetCostBreakdown,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
- CriteriaQuery cq = new CriteriaQuery(BudgetCostBreakdownEntity.class, dataGrid);
- org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, budgetCostBreakdown, request.getParameterMap());
- List<BudgetCostBreakdownEntity> budgetCostBreakdowns = this.budgetCostBreakdownService.getListByCriteriaQuery(cq,false);
- modelMap.put(NormalExcelConstants.FILE_NAME,"t_b_budget_cost_breakdown");
- modelMap.put(NormalExcelConstants.CLASS,BudgetCostBreakdownEntity.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("t_b_budget_cost_breakdown列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,budgetCostBreakdowns);
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
- /**
- * 导出excel 使模板
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportXlsByT")
- public String exportXlsByT(BudgetCostBreakdownEntity budgetCostBreakdown,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
- modelMap.put(NormalExcelConstants.FILE_NAME,"t_b_budget_cost_breakdown");
- modelMap.put(NormalExcelConstants.CLASS,BudgetCostBreakdownEntity.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("t_b_budget_cost_breakdown列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
-
- @SuppressWarnings("unchecked")
- @RequestMapping(params = "importExcel", method = RequestMethod.POST)
- @ResponseBody
- public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
- AjaxJson j = new AjaxJson();
-
- MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
- Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
- for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
- MultipartFile file = entity.getValue();// 获取上传文件对象
- ImportParams params = new ImportParams();
- params.setTitleRows(2);
- params.setHeadRows(1);
- params.setNeedSave(true);
- try {
- List<BudgetCostBreakdownEntity> listBudgetCostBreakdownEntitys = ExcelImportUtil.importExcel(file.getInputStream(),BudgetCostBreakdownEntity.class,params);
- for (BudgetCostBreakdownEntity budgetCostBreakdown : listBudgetCostBreakdownEntitys) {
- budgetCostBreakdownService.save(budgetCostBreakdown);
- }
- j.setMsg("文件导入成功!");
- } catch (Exception e) {
- j.setMsg("文件导入失败!");
- log.error(ExceptionUtil.getExceptionMessage(e));
- }finally{
- try {
- file.getInputStream().close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return j;
- }
-
- @RequestMapping(method = RequestMethod.GET)
- @ResponseBody
- public List<BudgetCostBreakdownEntity> list() {
- List<BudgetCostBreakdownEntity> listBudgetCostBreakdowns=budgetCostBreakdownService.getList(BudgetCostBreakdownEntity.class);
- return listBudgetCostBreakdowns;
- }
-
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- @ResponseBody
- public ResponseEntity<?> get(@PathVariable("id") String id) {
- BudgetCostBreakdownEntity task = budgetCostBreakdownService.get(BudgetCostBreakdownEntity.class, id);
- if (task == null) {
- return new ResponseEntity(HttpStatus.NOT_FOUND);
- }
- return new ResponseEntity(task, HttpStatus.OK);
- }
- @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public ResponseEntity<?> create(@RequestBody BudgetCostBreakdownEntity budgetCostBreakdown, UriComponentsBuilder uriBuilder) {
- //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
- Set<ConstraintViolation<BudgetCostBreakdownEntity>> failures = validator.validate(budgetCostBreakdown);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- try{
- budgetCostBreakdownService.save(budgetCostBreakdown);
- } catch (Exception e) {
- e.printStackTrace();
- return new ResponseEntity(HttpStatus.NO_CONTENT);
- }
- //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
- String id = budgetCostBreakdown.getId();
- URI uri = uriBuilder.path("/rest/budgetCostBreakdownController/" + id).build().toUri();
- HttpHeaders headers = new HttpHeaders();
- headers.setLocation(uri);
- return new ResponseEntity(headers, HttpStatus.CREATED);
- }
- @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<?> update(@RequestBody BudgetCostBreakdownEntity budgetCostBreakdown) {
- //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
- Set<ConstraintViolation<BudgetCostBreakdownEntity>> failures = validator.validate(budgetCostBreakdown);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- try{
- budgetCostBreakdownService.saveOrUpdate(budgetCostBreakdown);
- } catch (Exception e) {
- e.printStackTrace();
- return new ResponseEntity(HttpStatus.NO_CONTENT);
- }
- //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码.
- return new ResponseEntity(HttpStatus.NO_CONTENT);
- }
- @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void delete(@PathVariable("id") String id) {
- budgetCostBreakdownService.deleteEntityById(BudgetCostBreakdownEntity.class, id);
- }
- @RequestMapping(params = "goFill")
- public ModelAndView goFill(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest req) {
- budgetCostBreakdown = systemService.getEntity(BudgetCostBreakdownEntity.class, budgetCostBreakdown.getId());
- String id=budgetCostBreakdown.getId();
- if(StringUtils.isBlank(budgetCostBreakdown.getJson())) {
- String sql = "select distinct bm.entity_id from t_b_budget_cost_breakdown_measure bm where bm.cost_breakdown_id=? ";
- List<String> existIdList = systemService.findListbySql(sql,id);
- List<BudgetContractEntity> contractInfo = budgetDataDao.getContractInfoByYear(budgetCostBreakdown.getPeriodYear(),existIdList);
- List<BudgetContractEntity> lastYearContractInfo = budgetDataDao.getContractInfoByYear(String.valueOf(Integer.valueOf(budgetCostBreakdown.getPeriodYear())-1),existIdList);
- for(BudgetContractEntity lastYearContract : lastYearContractInfo){
- String name = lastYearContract.getEntityName();
- boolean toAdd = true;
- for(BudgetContractEntity contract:contractInfo){
- String cName = contract.getEntityName();
- if(StringUtils.equals(name,cName)) {
- toAdd = false;
- break;
- }
- }
- if(toAdd){
- lastYearContract.setContractDate("");
- lastYearContract.setContractTotalAmount("");
- contractInfo.add(lastYearContract);
- }
- }
- Collections.sort(contractInfo, new Comparator<BudgetContractEntity>() {
- @Override
- public int compare(BudgetContractEntity o1, BudgetContractEntity o2) {
- return o1.getEntityName().compareTo(o2.getEntityName());
- }
- });
- req.setAttribute("contractInfo", contractInfo);
- }
- String measureHql = "from BudgetMeasureEntity where code like 'A02%'";
- List<BudgetMeasureEntity> measureList = systemService.findHql(measureHql);
- Map<String,BudgetMeasureEntity> measureEntityMap = new HashMap<>();
- for(BudgetMeasureEntity measureEntity : measureList){
- measureEntityMap.put(measureEntity.getId(), measureEntity);
- }
- ObjectMapper mapper = new ObjectMapper();
- try {
- req.setAttribute("costMeasure",mapper.writeValueAsString(measureEntityMap) );
- } catch (IOException e) {
- e.printStackTrace();
- }
- req.setAttribute("costEntity", budgetCostBreakdown);
- return new ModelAndView("cn/com/lzt/budget/costbreakdown/budgetCostBreakdown-fill");
- }
- @RequestMapping(params = "doFill")
- @ResponseBody
- public AjaxJson doFill(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "保存成功";
- String saveAuth = request.getParameter("saveAuth");
- try {
- budgetCostBreakdownService.doFill(budgetCostBreakdown,saveAuth);
- } catch (Exception e) {
- e.printStackTrace();
- message = "保存失败";
- j.setSuccess(false);
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "changeStatus")
- @ResponseBody
- public AjaxJson changeStatus(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "操作成功";
- Integer newStatus = budgetCostBreakdown.getStatus();
- BudgetCostBreakdownEntity entity = systemService.getEntity(BudgetCostBreakdownEntity.class, budgetCostBreakdown.getId());
- if(entity.getUpdateDate()==null){
- message="请先保存";
- j.setSuccess(false);
- }else {
- entity.setStatus(newStatus);
- systemService.updateEntitie(entity);
- budgetCostBreakdownService.notice(entity, "changeStatus");
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "selectAuth")
- public ModelAndView selectAuth(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest req) {
- return new ModelAndView("cn/com/lzt/budget/costbreakdown/budgetCostBreakdown-selectAuth");
- }
- @RequestMapping(params = "selectAuth2")
- public ModelAndView selectAuth2(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest req) {
- return new ModelAndView("cn/com/lzt/budget/tempsheet/budgetTempSheet-selectAuth");
- }
- @RequestMapping(params = "getMeasureInfo")
- @ResponseBody
- public AjaxJson getData(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- String hql = "from BudgetCostBreakdownMeasureEntity where costBreakdownId=? and dataFormula=''";
- List<BudgetCostBreakdownMeasureEntity> costBreakdownMeasureEntityList = systemService.findHql(hql,budgetCostBreakdown.getId());
- return j;
- }
- @RequestMapping(params = "selectEntity")
- public ModelAndView selectEntity(BudgetCostBreakdownEntity budgetCostBreakdown, HttpServletRequest req) {
- return new ModelAndView("cn/com/lzt/budget/costbreakdown/budgetCostBreakdown-selectEntity");
- }
- @RequestMapping(params = "selectEntityDatagrid")
- public void selectEntityDatagrid(BudgetEntity budgetEntity,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- CriteriaQuery cq = new CriteriaQuery(BudgetEntity.class, dataGrid);
- String costEntityId = request.getParameter("costEntityId");
- //查询条件组装器
- try{
- if(StringUtils.isNotBlank(budgetEntity.getEntityName())){
- cq.like("entityName","%"+budgetEntity.getEntityName()+"%" );
- }
- String sql = "select distinct bm.entity_id from t_b_budget_cost_breakdown_measure bm where bm.cost_breakdown_id=? ";
- List<String> entityIdList = systemService.findListbySql(sql,costEntityId);
- cq.notin("id", entityIdList.toArray());
- }catch (Exception e) {
- throw new BusinessException(e.getMessage());
- }
- cq.add();
- this.systemService.getDataGridReturn(cq, false);
- TagUtil.treegrid(response, dataGrid);
- }
- @RequestMapping(params = "calcFunction")
- @ResponseBody
- public AjaxJson calcFunction(HttpServletRequest req) {
- AjaxJson j = new AjaxJson();
- List<Object[]> valueList = new ArrayList<>();
- Map<String,Object> attriMap = new HashMap<>();
- Long t1 =System.currentTimeMillis();
- String info=req.getParameter("info");
- String[] infoArray=StringUtils.split(info,",");
- log.error("calcFunction start size:"+infoArray.length);
- List<BudgetCalc> calcList = new ArrayList<>();
- for(String oneFunctionInfo : infoArray){
- String[] dArray = StringUtils.split(oneFunctionInfo, "#");
- String row = dArray[0];
- String col = dArray[1];
- String functionId = dArray[2];
- String measureId = dArray[3];
- String entityId = dArray[4];
- try {
- BudgetCalc budgetCalc = new BudgetCalc();
- budgetCalc.setRow(Integer.valueOf(row));
- budgetCalc.setCol(Integer.valueOf(col));
- budgetCalc.setFunctionId(functionId);
- budgetCalc.setMeasureId(measureId);
- budgetCalc.setEntityId(entityId);
- budgetCalc.setDeep(false);
- budgetCalc.setUpdate(false);
- calcList.add(budgetCalc);
- }catch (IllegalStateException e){//死循环
- log.error("维度公式循环引用:"+functionId);
- attriMap.put("errorMsg", "维度公式循环引用,请联系管理员");
- break;
- }
- }
- budgetDimFunctionService.batchCalc(calcList);
- for(BudgetCalc budgetCalc:calcList){
- BigDecimal value = budgetCalc.getValue();
- if(value!=null) {
- valueList.add(new Object[]{budgetCalc.getRow(), budgetCalc.getCol(), value.toPlainString()});
- }
- }
- Long t2 =System.currentTimeMillis();
- log.error("calcFunction end took:"+(t2-t1));
- j.setObj(valueList);
- j.setAttributes(attriMap);
- return j;
- }
- @RequestMapping(params = "goStatis")
- public ModelAndView goStatis(HttpServletRequest req) {
- String page = req.getParameter("page");
- return new ModelAndView("cn/com/lzt/budget/costbreakdown/budgetCostBreakdown-statis-"+page);
- }
- }
|