目标费用报表问题修改
正在显示
3 个修改的文件
包含
56 行增加
和
29 行删除
... | @@ -18,13 +18,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ... | @@ -18,13 +18,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
18 | import com.baomidou.mybatisplus.core.metadata.IPage; | 18 | import com.baomidou.mybatisplus.core.metadata.IPage; |
19 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 19 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
20 | import lombok.extern.slf4j.Slf4j; | 20 | import lombok.extern.slf4j.Slf4j; |
21 | |||
22 | import org.jeecgframework.poi.excel.ExcelImportUtil; | 21 | import org.jeecgframework.poi.excel.ExcelImportUtil; |
23 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; | 22 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
24 | import org.jeecgframework.poi.excel.entity.ExportParams; | 23 | import org.jeecgframework.poi.excel.entity.ExportParams; |
25 | import org.jeecgframework.poi.excel.entity.ImportParams; | 24 | import org.jeecgframework.poi.excel.entity.ImportParams; |
26 | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; | 25 | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
27 | |||
28 | import org.springframework.beans.factory.annotation.Autowired; | 26 | import org.springframework.beans.factory.annotation.Autowired; |
29 | import org.springframework.web.bind.annotation.*; | 27 | import org.springframework.web.bind.annotation.*; |
30 | import org.springframework.web.multipart.MultipartFile; | 28 | import org.springframework.web.multipart.MultipartFile; |
... | @@ -92,8 +90,17 @@ public class ReportElectricCostController { | ... | @@ -92,8 +90,17 @@ public class ReportElectricCostController { |
92 | public Result<ReportElectricCost> add(@RequestBody ReportElectricCost reportElectricCost) { | 90 | public Result<ReportElectricCost> add(@RequestBody ReportElectricCost reportElectricCost) { |
93 | Result<ReportElectricCost> result = new Result<ReportElectricCost>(); | 91 | Result<ReportElectricCost> result = new Result<ReportElectricCost>(); |
94 | try { | 92 | try { |
95 | reportElectricCostService.save(reportElectricCost); | 93 | //判断是否重复 |
96 | result.success("添加成功!"); | 94 | QueryWrapper<ReportElectricCost> queryWrapper = new QueryWrapper<ReportElectricCost>(); |
95 | queryWrapper.eq("month", reportElectricCost.getMonth()); | ||
96 | queryWrapper.eq("depart_id", reportElectricCost.getDepartId()); | ||
97 | List<ReportElectricCost> list = reportElectricCostService.list(queryWrapper); | ||
98 | if(list.size()>0){ | ||
99 | result.error500("已存在"); | ||
100 | }else{ | ||
101 | reportElectricCostService.save(reportElectricCost); | ||
102 | result.success("添加成功!"); | ||
103 | } | ||
97 | } catch (Exception e) { | 104 | } catch (Exception e) { |
98 | log.error(e.getMessage(),e); | 105 | log.error(e.getMessage(),e); |
99 | result.error500("操作失败"); | 106 | result.error500("操作失败"); |
... | @@ -114,17 +121,24 @@ public class ReportElectricCostController { | ... | @@ -114,17 +121,24 @@ public class ReportElectricCostController { |
114 | @PutMapping(value = "/edit") | 121 | @PutMapping(value = "/edit") |
115 | public Result<ReportElectricCost> edit(@RequestBody ReportElectricCost reportElectricCost) { | 122 | public Result<ReportElectricCost> edit(@RequestBody ReportElectricCost reportElectricCost) { |
116 | Result<ReportElectricCost> result = new Result<ReportElectricCost>(); | 123 | Result<ReportElectricCost> result = new Result<ReportElectricCost>(); |
117 | ReportElectricCost reportElectricCostEntity = reportElectricCostService.getById(reportElectricCost.getId()); | 124 | boolean ok = false; |
118 | if(reportElectricCostEntity==null) { | 125 | String id = reportElectricCost.getId(); |
119 | result.error500("未找到对应实体"); | 126 | //判断是否重复 |
120 | }else { | 127 | QueryWrapper<ReportElectricCost> queryWrapper = new QueryWrapper<ReportElectricCost>(); |
121 | boolean ok = reportElectricCostService.updateById(reportElectricCost); | 128 | queryWrapper.eq("month", reportElectricCost.getMonth()); |
122 | //TODO 返回false说明什么? | 129 | queryWrapper.eq("depart_id", reportElectricCost.getDepartId()); |
123 | if(ok) { | 130 | List<ReportElectricCost> list = reportElectricCostService.list(queryWrapper); |
124 | result.success("修改成功!"); | 131 | if(list.size()>0){ |
132 | ReportElectricCost cost = list.get(0); | ||
133 | if(id.equals(cost.getId())){ | ||
134 | ok = reportElectricCostService.updateById(reportElectricCost); | ||
125 | } | 135 | } |
136 | }else{ | ||
137 | ok = reportElectricCostService.updateById(reportElectricCost); | ||
138 | } | ||
139 | if(ok) { | ||
140 | result.success("修改成功!"); | ||
126 | } | 141 | } |
127 | |||
128 | return result; | 142 | return result; |
129 | } | 143 | } |
130 | /** | 144 | /** | ... | ... |
... | @@ -10,24 +10,19 @@ import javax.servlet.http.HttpServletRequest; | ... | @@ -10,24 +10,19 @@ import javax.servlet.http.HttpServletRequest; |
10 | import javax.servlet.http.HttpServletResponse; | 10 | import javax.servlet.http.HttpServletResponse; |
11 | import com.skua.core.api.vo.Result; | 11 | import com.skua.core.api.vo.Result; |
12 | import com.skua.core.aspect.annotation.AutoLog; | 12 | import com.skua.core.aspect.annotation.AutoLog; |
13 | import com.skua.core.context.BaseContextHandler; | ||
14 | import com.skua.core.query.QueryGenerator; | 13 | import com.skua.core.query.QueryGenerator; |
15 | import com.skua.core.service.ISequenceService; | ||
16 | import com.skua.core.util.ConvertUtils; | 14 | import com.skua.core.util.ConvertUtils; |
17 | import com.skua.modules.report.entity.ReportTargetConfig; | 15 | import com.skua.modules.report.entity.ReportTargetConfig; |
18 | import com.skua.modules.report.service.IReportTargetConfigService; | 16 | import com.skua.modules.report.service.IReportTargetConfigService; |
19 | import java.util.Date; | ||
20 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 17 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
21 | import com.baomidou.mybatisplus.core.metadata.IPage; | 18 | import com.baomidou.mybatisplus.core.metadata.IPage; |
22 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 19 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
23 | import lombok.extern.slf4j.Slf4j; | 20 | import lombok.extern.slf4j.Slf4j; |
24 | |||
25 | import org.jeecgframework.poi.excel.ExcelImportUtil; | 21 | import org.jeecgframework.poi.excel.ExcelImportUtil; |
26 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; | 22 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
27 | import org.jeecgframework.poi.excel.entity.ExportParams; | 23 | import org.jeecgframework.poi.excel.entity.ExportParams; |
28 | import org.jeecgframework.poi.excel.entity.ImportParams; | 24 | import org.jeecgframework.poi.excel.entity.ImportParams; |
29 | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; | 25 | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
30 | |||
31 | import org.springframework.beans.factory.annotation.Autowired; | 26 | import org.springframework.beans.factory.annotation.Autowired; |
32 | import org.springframework.web.bind.annotation.*; | 27 | import org.springframework.web.bind.annotation.*; |
33 | import org.springframework.web.multipart.MultipartFile; | 28 | import org.springframework.web.multipart.MultipartFile; |
... | @@ -81,6 +76,7 @@ public class ReportTargetConfigController { | ... | @@ -81,6 +76,7 @@ public class ReportTargetConfigController { |
81 | if(reportTargetConfig.getTargetYear()!=null){ | 76 | if(reportTargetConfig.getTargetYear()!=null){ |
82 | queryWrapper.like("target_year",reportTargetConfig.getTargetYear()); | 77 | queryWrapper.like("target_year",reportTargetConfig.getTargetYear()); |
83 | } | 78 | } |
79 | queryWrapper.orderByDesc("target_year"); | ||
84 | IPage<ReportTargetConfig> pageList = reportTargetConfigService.page(page, queryWrapper); | 80 | IPage<ReportTargetConfig> pageList = reportTargetConfigService.page(page, queryWrapper); |
85 | result.setSuccess(true); | 81 | result.setSuccess(true); |
86 | result.setResult(pageList); | 82 | result.setResult(pageList); |
... | @@ -102,8 +98,17 @@ public class ReportTargetConfigController { | ... | @@ -102,8 +98,17 @@ public class ReportTargetConfigController { |
102 | public Result<ReportTargetConfig> add(@RequestBody ReportTargetConfig reportTargetConfig) { | 98 | public Result<ReportTargetConfig> add(@RequestBody ReportTargetConfig reportTargetConfig) { |
103 | Result<ReportTargetConfig> result = new Result<ReportTargetConfig>(); | 99 | Result<ReportTargetConfig> result = new Result<ReportTargetConfig>(); |
104 | try { | 100 | try { |
105 | reportTargetConfigService.save(reportTargetConfig); | 101 | //判断是否重复 |
106 | result.success("添加成功!"); | 102 | QueryWrapper<ReportTargetConfig> queryWrapper = new QueryWrapper<ReportTargetConfig>(); |
103 | queryWrapper.eq("target_year", reportTargetConfig.getTargetYear()); | ||
104 | queryWrapper.eq("depart_id", reportTargetConfig.getDepartId()); | ||
105 | List<ReportTargetConfig> list = reportTargetConfigService.list(queryWrapper); | ||
106 | if(list.size()>0){ | ||
107 | result.error500("已存在"); | ||
108 | }else{ | ||
109 | reportTargetConfigService.save(reportTargetConfig); | ||
110 | result.success("添加成功!"); | ||
111 | } | ||
107 | } catch (Exception e) { | 112 | } catch (Exception e) { |
108 | log.error(e.getMessage(),e); | 113 | log.error(e.getMessage(),e); |
109 | result.error500("操作失败"); | 114 | result.error500("操作失败"); |
... | @@ -124,17 +129,24 @@ public class ReportTargetConfigController { | ... | @@ -124,17 +129,24 @@ public class ReportTargetConfigController { |
124 | @PutMapping(value = "/edit") | 129 | @PutMapping(value = "/edit") |
125 | public Result<ReportTargetConfig> edit(@RequestBody ReportTargetConfig reportTargetConfig) { | 130 | public Result<ReportTargetConfig> edit(@RequestBody ReportTargetConfig reportTargetConfig) { |
126 | Result<ReportTargetConfig> result = new Result<ReportTargetConfig>(); | 131 | Result<ReportTargetConfig> result = new Result<ReportTargetConfig>(); |
127 | ReportTargetConfig reportTargetConfigEntity = reportTargetConfigService.getById(reportTargetConfig.getId()); | 132 | boolean ok = false; |
128 | if(reportTargetConfigEntity==null) { | 133 | String id = reportTargetConfig.getId(); |
129 | result.error500("未找到对应实体"); | 134 | //判断是否重复 |
130 | }else { | 135 | QueryWrapper<ReportTargetConfig> queryWrapper = new QueryWrapper<ReportTargetConfig>(); |
131 | boolean ok = reportTargetConfigService.updateById(reportTargetConfig); | 136 | queryWrapper.eq("target_year", reportTargetConfig.getTargetYear()); |
132 | //TODO 返回false说明什么? | 137 | queryWrapper.eq("depart_id", reportTargetConfig.getDepartId()); |
133 | if(ok) { | 138 | List<ReportTargetConfig> list = reportTargetConfigService.list(queryWrapper); |
134 | result.success("修改成功!"); | 139 | if(list.size()>0){ |
140 | ReportTargetConfig cost = list.get(0); | ||
141 | if(id.equals(cost.getId())){ | ||
142 | ok = reportTargetConfigService.updateById(reportTargetConfig); | ||
135 | } | 143 | } |
144 | }else{ | ||
145 | ok = reportTargetConfigService.updateById(reportTargetConfig); | ||
146 | } | ||
147 | if(ok) { | ||
148 | result.success("修改成功!"); | ||
136 | } | 149 | } |
137 | |||
138 | return result; | 150 | return result; |
139 | } | 151 | } |
140 | /** | 152 | /** | ... | ... |
... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
10 | <if test="reportElectricCost.month!=null and reportElectricCost.month!=''"> | 10 | <if test="reportElectricCost.month!=null and reportElectricCost.month!=''"> |
11 | AND month like CONCAT(#{reportElectricCost.month},'%') | 11 | AND month like CONCAT(#{reportElectricCost.month},'%') |
12 | </if> | 12 | </if> |
13 | order by month desc | ||
13 | </select> | 14 | </select> |
14 | 15 | ||
15 | </mapper> | 16 | </mapper> | ... | ... |
-
请 注册 或 登录 后发表评论