bfafc9c5 张雷

目标费用报表问题修改

1 个父辈 f7991bb6
......@@ -18,13 +18,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -92,8 +90,17 @@ public class ReportElectricCostController {
public Result<ReportElectricCost> add(@RequestBody ReportElectricCost reportElectricCost) {
Result<ReportElectricCost> result = new Result<ReportElectricCost>();
try {
reportElectricCostService.save(reportElectricCost);
result.success("添加成功!");
//判断是否重复
QueryWrapper<ReportElectricCost> queryWrapper = new QueryWrapper<ReportElectricCost>();
queryWrapper.eq("month", reportElectricCost.getMonth());
queryWrapper.eq("depart_id", reportElectricCost.getDepartId());
List<ReportElectricCost> list = reportElectricCostService.list(queryWrapper);
if(list.size()>0){
result.error500("已存在");
}else{
reportElectricCostService.save(reportElectricCost);
result.success("添加成功!");
}
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
......@@ -114,17 +121,24 @@ public class ReportElectricCostController {
@PutMapping(value = "/edit")
public Result<ReportElectricCost> edit(@RequestBody ReportElectricCost reportElectricCost) {
Result<ReportElectricCost> result = new Result<ReportElectricCost>();
ReportElectricCost reportElectricCostEntity = reportElectricCostService.getById(reportElectricCost.getId());
if(reportElectricCostEntity==null) {
result.error500("未找到对应实体");
}else {
boolean ok = reportElectricCostService.updateById(reportElectricCost);
//TODO 返回false说明什么?
if(ok) {
result.success("修改成功!");
boolean ok = false;
String id = reportElectricCost.getId();
//判断是否重复
QueryWrapper<ReportElectricCost> queryWrapper = new QueryWrapper<ReportElectricCost>();
queryWrapper.eq("month", reportElectricCost.getMonth());
queryWrapper.eq("depart_id", reportElectricCost.getDepartId());
List<ReportElectricCost> list = reportElectricCostService.list(queryWrapper);
if(list.size()>0){
ReportElectricCost cost = list.get(0);
if(id.equals(cost.getId())){
ok = reportElectricCostService.updateById(reportElectricCost);
}
}else{
ok = reportElectricCostService.updateById(reportElectricCost);
}
if(ok) {
result.success("修改成功!");
}
return result;
}
/**
......
......@@ -10,24 +10,19 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.query.QueryGenerator;
import com.skua.core.service.ISequenceService;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.report.entity.ReportTargetConfig;
import com.skua.modules.report.service.IReportTargetConfigService;
import java.util.Date;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -81,6 +76,7 @@ public class ReportTargetConfigController {
if(reportTargetConfig.getTargetYear()!=null){
queryWrapper.like("target_year",reportTargetConfig.getTargetYear());
}
queryWrapper.orderByDesc("target_year");
IPage<ReportTargetConfig> pageList = reportTargetConfigService.page(page, queryWrapper);
result.setSuccess(true);
result.setResult(pageList);
......@@ -102,8 +98,17 @@ public class ReportTargetConfigController {
public Result<ReportTargetConfig> add(@RequestBody ReportTargetConfig reportTargetConfig) {
Result<ReportTargetConfig> result = new Result<ReportTargetConfig>();
try {
reportTargetConfigService.save(reportTargetConfig);
result.success("添加成功!");
//判断是否重复
QueryWrapper<ReportTargetConfig> queryWrapper = new QueryWrapper<ReportTargetConfig>();
queryWrapper.eq("target_year", reportTargetConfig.getTargetYear());
queryWrapper.eq("depart_id", reportTargetConfig.getDepartId());
List<ReportTargetConfig> list = reportTargetConfigService.list(queryWrapper);
if(list.size()>0){
result.error500("已存在");
}else{
reportTargetConfigService.save(reportTargetConfig);
result.success("添加成功!");
}
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
......@@ -124,17 +129,24 @@ public class ReportTargetConfigController {
@PutMapping(value = "/edit")
public Result<ReportTargetConfig> edit(@RequestBody ReportTargetConfig reportTargetConfig) {
Result<ReportTargetConfig> result = new Result<ReportTargetConfig>();
ReportTargetConfig reportTargetConfigEntity = reportTargetConfigService.getById(reportTargetConfig.getId());
if(reportTargetConfigEntity==null) {
result.error500("未找到对应实体");
}else {
boolean ok = reportTargetConfigService.updateById(reportTargetConfig);
//TODO 返回false说明什么?
if(ok) {
result.success("修改成功!");
boolean ok = false;
String id = reportTargetConfig.getId();
//判断是否重复
QueryWrapper<ReportTargetConfig> queryWrapper = new QueryWrapper<ReportTargetConfig>();
queryWrapper.eq("target_year", reportTargetConfig.getTargetYear());
queryWrapper.eq("depart_id", reportTargetConfig.getDepartId());
List<ReportTargetConfig> list = reportTargetConfigService.list(queryWrapper);
if(list.size()>0){
ReportTargetConfig cost = list.get(0);
if(id.equals(cost.getId())){
ok = reportTargetConfigService.updateById(reportTargetConfig);
}
}else{
ok = reportTargetConfigService.updateById(reportTargetConfig);
}
if(ok) {
result.success("修改成功!");
}
return result;
}
/**
......
......@@ -10,6 +10,7 @@
<if test="reportElectricCost.month!=null and reportElectricCost.month!=''">
AND month like CONCAT(#{reportElectricCost.month},'%')
</if>
order by month desc
</select>
</mapper>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!