diff --git a/src/main/java/com/zhgd/xmgl/modules/jz/controller/JzInvestController.java b/src/main/java/com/zhgd/xmgl/modules/jz/controller/JzInvestController.java index 8134c53eb..d7f2564ac 100644 --- a/src/main/java/com/zhgd/xmgl/modules/jz/controller/JzInvestController.java +++ b/src/main/java/com/zhgd/xmgl/modules/jz/controller/JzInvestController.java @@ -66,9 +66,6 @@ public class JzInvestController { @Autowired private IProjectService projectService; - @Autowired - private ICompanyService companyService; - /** * 分页列表查询 * @@ -84,7 +81,7 @@ public class JzInvestController { public Result> queryPageList(@ApiIgnore @RequestBody Map map) { QueryWrapper queryWrapper = QueryGenerator.initPageQueryWrapper(JzInvest.class, map); Page page = PageUtil.getPage(map); - IPage pageList = jzInvestService.page(page, queryWrapper); + IPage pageList = jzInvestService.pageList(page, queryWrapper); return Result.success(pageList); } @@ -239,7 +236,7 @@ public class JzInvestController { //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); - List pageList = jzInvestService.list(queryWrapper); + List pageList = jzInvestService.pageList(new Page(-1, -1), queryWrapper).getRecords(); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "项目投资列表"); mv.addObject(NormalExcelConstants.CLASS, JzInvest.class); diff --git a/src/main/java/com/zhgd/xmgl/modules/jz/entity/JzInvest.java b/src/main/java/com/zhgd/xmgl/modules/jz/entity/JzInvest.java index 9d3549244..829776cd3 100644 --- a/src/main/java/com/zhgd/xmgl/modules/jz/entity/JzInvest.java +++ b/src/main/java/com/zhgd/xmgl/modules/jz/entity/JzInvest.java @@ -71,13 +71,13 @@ public class JzInvest implements Serializable { */ @Excel(name = "年", width = 15) @ApiModelProperty(value = "年") - private String year; + private Integer year; /** * 月 */ @Excel(name = "月", width = 15) @ApiModelProperty(value = "月") - private String month; + private Integer month; /** * 实际完成投资 */ diff --git a/src/main/java/com/zhgd/xmgl/modules/jz/mapper/JzInvestMapper.java b/src/main/java/com/zhgd/xmgl/modules/jz/mapper/JzInvestMapper.java index 18abccda6..1806ae296 100644 --- a/src/main/java/com/zhgd/xmgl/modules/jz/mapper/JzInvestMapper.java +++ b/src/main/java/com/zhgd/xmgl/modules/jz/mapper/JzInvestMapper.java @@ -2,10 +2,15 @@ package com.zhgd.xmgl.modules.jz.mapper; import java.util.List; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import com.zhgd.xmgl.modules.jz.entity.JzInvest; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.checkerframework.checker.signedness.qual.Constant; /** * @Description: 项目投资 @@ -16,4 +21,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; @Mapper public interface JzInvestMapper extends BaseMapper { + IPage pageList(Page page, @Param(Constants.WRAPPER) Wrapper wrapper); } diff --git a/src/main/java/com/zhgd/xmgl/modules/jz/mapper/xml/JzInvestMapper.xml b/src/main/java/com/zhgd/xmgl/modules/jz/mapper/xml/JzInvestMapper.xml index 5bc4ec2ae..61472bdfd 100644 --- a/src/main/java/com/zhgd/xmgl/modules/jz/mapper/xml/JzInvestMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/jz/mapper/xml/JzInvestMapper.xml @@ -2,4 +2,11 @@ + \ No newline at end of file diff --git a/src/main/java/com/zhgd/xmgl/modules/jz/service/IJzInvestService.java b/src/main/java/com/zhgd/xmgl/modules/jz/service/IJzInvestService.java index cb5ded9f4..a92a0024f 100644 --- a/src/main/java/com/zhgd/xmgl/modules/jz/service/IJzInvestService.java +++ b/src/main/java/com/zhgd/xmgl/modules/jz/service/IJzInvestService.java @@ -1,5 +1,8 @@ package com.zhgd.xmgl.modules.jz.service; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhgd.xmgl.modules.jz.entity.JzInvest; import com.baomidou.mybatisplus.extension.service.IService; @@ -11,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface IJzInvestService extends IService { + IPage pageList(Page page, Wrapper wrapper); } diff --git a/src/main/java/com/zhgd/xmgl/modules/jz/service/impl/JzInvestServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/jz/service/impl/JzInvestServiceImpl.java index 1384bcb9f..29a751689 100644 --- a/src/main/java/com/zhgd/xmgl/modules/jz/service/impl/JzInvestServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/jz/service/impl/JzInvestServiceImpl.java @@ -1,5 +1,9 @@ package com.zhgd.xmgl.modules.jz.service.impl; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhgd.jeecg.common.util.DateUtil; import com.zhgd.xmgl.modules.jz.entity.JzInvest; import com.zhgd.xmgl.modules.jz.mapper.JzInvestMapper; import com.zhgd.xmgl.modules.jz.service.IJzInvestService; @@ -7,6 +11,10 @@ import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.math.BigDecimal; +import java.util.List; +import java.util.stream.Collectors; + /** * @Description: 项目投资 * @author: pengj @@ -16,4 +24,23 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @Service public class JzInvestServiceImpl extends ServiceImpl implements IJzInvestService { + @Override + public IPage pageList(Page page, Wrapper wrapper) { + IPage jzInvestIPage = baseMapper.pageList(page, wrapper); + List allList = baseMapper.pageList(new Page(-1, -1), null).getRecords(); + for (JzInvest record : jzInvestIPage.getRecords()) { + List yearAmount = allList.stream().filter(a -> a.getProjectSn().equals(record.getProjectSn()) && + a.getYear().equals(record.getYear()) + && a.getMonth() <= record.getMonth()).collect(Collectors.toList()); + record.setYearAmount(yearAmount.size() > 0 ? yearAmount.stream().map(a -> new BigDecimal(a.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toString() : "0"); + Integer year = record.getYear() - 1; + List lastYearAmount = allList.stream().filter(a -> a.getProjectSn().equals(record.getProjectSn()) && + a.getYear().equals(year) + && a.getMonth() <= record.getMonth()).collect(Collectors.toList()); + record.setLastYearAmount(lastYearAmount.size() > 0 ? yearAmount.stream().map(a -> new BigDecimal(a.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toString() : "0"); + List totalYearAmount = allList.stream().filter(a -> a.getProjectSn().equals(record.getProjectSn())).collect(Collectors.toList()); + record.setTotalYearAmount(totalYearAmount.size() > 0 ? totalYearAmount.stream().map(a -> new BigDecimal(a.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toString() : "0"); + } + return jzInvestIPage; + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/project/mapper/xml/ProjectEnterpriseMapper.xml b/src/main/java/com/zhgd/xmgl/modules/project/mapper/xml/ProjectEnterpriseMapper.xml index ade8c5165..f1aba685a 100644 --- a/src/main/java/com/zhgd/xmgl/modules/project/mapper/xml/ProjectEnterpriseMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/project/mapper/xml/ProjectEnterpriseMapper.xml @@ -126,7 +126,10 @@ ) t1 on t1.data = b.cbs_project_type - WHERE b.project_sn = #{param.projectSn} + WHERE 1 = 1 + + and b.project_sn = #{param.projectSn} + and b.cbs_project_type = #{param.cbsProjectType}