Browse Source

直接投入费用汇总表

zhouli 10 months ago
parent
commit
d3d65b0b2e

+ 7 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/XmDirectCostController.java

@@ -1,6 +1,7 @@
 
 package org.sky.scientific.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@@ -81,4 +82,10 @@ public class XmDirectCostController extends KdController {
 		ExcelUtil.export(response, "直接投入费用-基本信息台账" + DateUtil.time(), "直接投入费用-基本信息台账", list, XmDirectCostExcel.class);
 	}
 
+	@GetMapping("summary")
+	@ApiOperationSupport(order = 20)
+	@Operation(summary = "直接投入费用汇总表p081")
+	public R<List<JSONObject>> tourufeiyonghuizongbiao(XmDirectCostEntity dto){
+		return R.data(service.tourufeiyonghuizongbiao(dto));
+	}
 }

+ 15 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmDirectCostMapper.java

@@ -1,6 +1,7 @@
 
 package org.sky.scientific.mapper;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -42,4 +43,18 @@ public interface XmDirectCostMapper extends BaseMapper<XmDirectCostEntity> {
      * @return
 	 */
 	int physicalDeleteByIds(List<Long> ids);
+
+	/**
+	 * 直接投入费用汇总表p081-月度
+	 * @param dto
+	 * @return
+	 */
+	List<JSONObject> tourufeiyonghuizongbiao(XmDirectCostEntity dto);
+
+	/**
+	 * 直接投入费用汇总表p081-年度
+	 * @param dto
+	 * @return
+	 */
+	List<JSONObject> tourufeiyonghuizongbiaoByYear(XmDirectCostEntity dto);
 }

+ 41 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmDirectCostMapper.xml

@@ -37,7 +37,7 @@
         where kxl.is_deleted = 0 and kxl.year_and_month = #{ew.yearAndMonth}
         <if test="ew.xmmc!=null and ew.xmbh!=''">and xm.xmmc like concat('%',#{ew.xmmc},'%')</if>
         <if test="ew.xmbh!=null and ew.xmbh!=''">and xm.xmbh like concat('%',#{ew.xmbh},'%')</if>
-        <if test="ew.type!=null and ew.type!=''">and xm.type = #{ew.type}</if>
+        <if test="ew.type!=null and ew.type!=''">and kxl.type = #{ew.type}</if>
     </select>
 
     <select id="exportXmDirectCost" resultType="org.sky.scientific.excel.XmDirectCostExcel">
@@ -50,4 +50,44 @@
         <if test="ew.type!=null and ew.type!=''">and xm.type = #{ew.type}</if>
     </select>
 
+    <select id="tourufeiyonghuizongbiao" resultType="com.alibaba.fastjson.JSONObject" >
+        SELECT
+        id,
+        XMBH,
+        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMMC' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMMC) AS XMMC,
+        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMKSSJ' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMKSSJ) AS XMKSSJ,
+        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMJSSJ' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMJSSJ) AS XMJSSJ,
+        (SELECT IFNULL(sum(unit_price*use_quantity),0) FROM kd_xm_goods g WHERE xm_id=xm.id and g.year_and_month=#{yearAndMonth} and g.type ='材料') as cailiaofy,
+        (SELECT IFNULL(sum(unit_price*use_quantity),0) FROM kd_xm_goods g WHERE xm_id=xm.id and g.year_and_month=#{yearAndMonth} and g.type ='燃料') as ranliaofy,
+        (SELECT IFNULL(sum(unit_price*use_quantity),0) FROM kd_xm_goods g WHERE xm_id=xm.id and g.year_and_month=#{yearAndMonth} and g.type ='动力') as donglify,
+        (SELECT IFNULL(sum(unit_price*quantity),0) FROM kd_xm_lease xl WHERE xm_id=xm.id and xl.year_and_month=#{yearAndMonth} and xl.type ='仪器设备') as yiqishebeify,
+        (SELECT IFNULL(sum(unit_price*quantity),0) FROM kd_xm_lease xl WHERE xm_id=xm.id and xl.year_and_month=#{yearAndMonth} and xl.type ='房屋建筑物') as fawuzulinfy,
+        (SELECT IFNULL(sum(amount),0) FROM kd_xm_direct_cost xdc WHERE xm_id=xm.id and xdc.year_and_month=#{yearAndMonth} and xdc.type ='1') as fy6,
+        (SELECT IFNULL(sum(amount),0) FROM kd_xm_direct_cost xdc WHERE xm_id=xm.id and xdc.year_and_month=#{yearAndMonth} and xdc.type ='2') as fy7,
+        (SELECT IFNULL(sum(amount),0) FROM kd_xm_direct_cost xdc WHERE xm_id=xm.id and xdc.year_and_month=#{yearAndMonth} and xdc.type ='3') as fy8
+        FROM kd_xm xm
+        where #{yearAndMonth} between DATE_FORMAT(XMKSSJ, '%Y%m') and DATE_FORMAT(XMJSSJ,'%Y%m')
+        <if test="xmmc!=null">and XMMC like concat('%',#{xmmc},'%')</if>
+    </select>
+
+    <select id="tourufeiyonghuizongbiaoByYear" resultType="com.alibaba.fastjson.JSONObject" >
+        SELECT
+        id,
+        XMBH,
+        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMMC' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y') <![CDATA[<=]]> #{yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMMC) AS XMMC,
+        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMKSSJ' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y') <![CDATA[<=]]> #{yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMKSSJ) AS XMKSSJ,
+        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMJSSJ' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y') <![CDATA[<=]]> #{yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMJSSJ) AS XMJSSJ,
+        (SELECT IFNULL(sum(unit_price*use_quantity),0) FROM kd_xm_goods g WHERE xm_id=xm.id and left(g.year_and_month,4)=#{yearAndMonth} and g.type ='材料') as cailiaofy,
+        (SELECT IFNULL(sum(unit_price*use_quantity),0) FROM kd_xm_goods g WHERE xm_id=xm.id and left(g.year_and_month,4)=#{yearAndMonth} and g.type ='燃料') as ranliaofy,
+        (SELECT IFNULL(sum(unit_price*use_quantity),0) FROM kd_xm_goods g WHERE xm_id=xm.id and left(g.year_and_month,4)=#{yearAndMonth} and g.type ='动力') as donglify,
+        (SELECT IFNULL(sum(unit_price*quantity),0) FROM kd_xm_lease xl WHERE xm_id=xm.id and left(xl.year_and_month,4)=#{yearAndMonth} and xl.type ='仪器设备') as yiqishebeify,
+        (SELECT IFNULL(sum(unit_price*quantity),0) FROM kd_xm_lease xl WHERE xm_id=xm.id and left(xl.year_and_month,4)=#{yearAndMonth} and xl.type ='房屋建筑物') as fawuzulinfy,
+        (SELECT IFNULL(sum(amount),0) FROM kd_xm_direct_cost xdc WHERE xm_id=xm.id and left(xdc.year_and_month,4)=#{yearAndMonth} and xdc.type ='1') as fy6,
+        (SELECT IFNULL(sum(amount),0) FROM kd_xm_direct_cost xdc WHERE xm_id=xm.id and left(xdc.year_and_month,4)=#{yearAndMonth} and xdc.type ='2') as fy7,
+        (SELECT IFNULL(sum(amount),0) FROM kd_xm_direct_cost xdc WHERE xm_id=xm.id and left(xdc.year_and_month,4)=#{yearAndMonth} and xdc.type ='3') as fy8
+        FROM kd_xm xm
+        where #{yearAndMonth} between DATE_FORMAT(XMKSSJ, '%Y') and DATE_FORMAT(XMJSSJ,'%Y')
+        <if test="xmmc!=null">and XMMC like concat('%',#{xmmc},'%')</if>
+    </select>
+
 </mapper>

+ 8 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/IXmDirectCostService.java

@@ -1,6 +1,7 @@
 
 package org.sky.scientific.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.sky.core.mp.base.BaseService;
@@ -55,4 +56,11 @@ public interface IXmDirectCostService extends BaseService<XmDirectCostEntity> {
      * @return
 	 */
 	boolean submit(XmDirectCostEntity xmDirectCost);
+
+	/**
+	 * 直接投入费用汇总表p081
+	 * @param param
+	 * @return
+	 */
+	List<JSONObject> tourufeiyonghuizongbiao(XmDirectCostEntity dto);
 }

+ 17 - 8
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmDirectCostServiceImpl.java

@@ -1,16 +1,14 @@
 
 package org.sky.scientific.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import jakarta.annotation.Resource;
 import org.sky.core.excel.util.ExcelUtil;
 import org.sky.core.log.exception.ServiceException;
 import org.sky.core.mp.base.BaseServiceImpl;
-import org.sky.core.tool.utils.BeanUtil;
-import org.sky.core.tool.utils.CollectionUtil;
-import org.sky.core.tool.utils.DateUtil;
-import org.sky.core.tool.utils.StringUtil;
+import org.sky.core.tool.utils.*;
 import org.sky.scientific.excel.XmDirectCostExcel;
 import org.sky.scientific.mapper.XmDirectCostMapper;
 import org.sky.scientific.mapper.XmMapper;
@@ -19,10 +17,7 @@ import org.sky.scientific.service.IXmDirectCostService;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * 研发项目直投费用清单 服务实现类
@@ -93,6 +88,20 @@ public class XmDirectCostServiceImpl extends BaseServiceImpl<XmDirectCostMapper,
 		return this.saveOrUpdate(xmDirectCost);
 	}
 
+	@Override
+	public List<JSONObject> tourufeiyonghuizongbiao(XmDirectCostEntity dto) {
+		if(Func.isBlank(dto.getYearAndMonth())){
+			throw new ServiceException("参数yearAndMonth不能为空");
+		}
+		List<JSONObject> list = null;
+		if(dto.getYearAndMonth().length() == 6){
+			list = baseMapper.tourufeiyonghuizongbiao(dto);
+		}else if(dto.getYearAndMonth().length() == 4){
+			list = baseMapper.tourufeiyonghuizongbiaoByYear(dto);
+		}
+		return list;
+	}
+
 	private void judgeDate(Date date, String yearAndMonth) {
 		//租赁日期,必须时当月日期
 		if (date != null) {