zhoulisky 5 months ago
parent
commit
4cc8b091f9

+ 4 - 4
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/AssetMapper.xml

@@ -176,14 +176,14 @@
         SELECT
             m.month AS yearAndMonth,
             (select ROUND(IFNULL(sum(IFNULL(average_monthly_salary,0)) + sum(IFNULL(pension_insurance,0)) + sum(IFNULL(medical_insurance,0)) + sum(IFNULL(unemployment_insurance,0)) + sum(IFNULL(injury_insurance,0)) + sum(IFNULL(maternity_insurance,0)),0), 2) from kd_salary where tenant_id = #{tenantId} and year_and_month = m.month ) as ryrgfy,
-            (SELECT ROUND(IFNULL(sum(amount),0),2)
+            (SELECT ROUND(IFNULL(sum(unit_price*quantity),0),2)
             from
             (
-                SELECT xm_id,sum(unit_price*use_quantity) as amount,year_and_month from kd_xm_goods g where tenant_id =  #{tenantId} and year_and_month = #{yearAndMonth}
+                SELECT id,xm_id, unit_price, use_quantity as quantity ,year_and_month from kd_xm_goods where tenant_id = #{tenantId}
                 union
-                SELECT xm_id,sum(unit_price*quantity) as amount,year_and_month from kd_xm_lease l where tenant_id =  #{tenantId} and year_and_month = #{yearAndMonth}
+                SELECT id,xm_id, unit_price, quantity ,year_and_month from kd_xm_lease where tenant_id = #{tenantId}
                 union
-                select xm_id,sum(amount) as amount,year_and_month from kd_xm_direct_cost d where tenant_id =  #{tenantId} and year_and_month = #{yearAndMonth}
+                select id,xm_id, amount as unit_price, 1 as quantity ,year_and_month from kd_xm_direct_cost where tenant_id = #{tenantId}
             )cost where cost.year_and_month = m.month) as zjtrfy,
             (ROUND((SELECT IFNULL(sum(yanfa_tan_xiao),0) FROM yiqishebeiassetcostview WHERE  tenant_id = #{tenantId} and year_and_month = m.month ) + (SELECT IFNULL(sum(yanfa_fen_tan),0) FROM fangwujianzhuwuAssetCostView WHERE  tenant_id = #{tenantId} and year_and_month = m.month ) + (SELECT IFNULL(sum(ytxe*syzb),0) FROM kd_xm_cqdtfy WHERE  tenant_id = #{tenantId} and year_and_month = m.month),2)) as zjfyycqdtfy,
             (SELECT ROUND(IFNULL(sum(amount),0),2) FROM kd_xm_design_cost WHERE tenant_id = #{tenantId} and cost_type='设计费用' and year_and_month = m.month) as sjfy,

+ 12 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmFixedAssetMapper.xml

@@ -85,7 +85,7 @@
     <select id="selectXmFixedAssetPageByYear" resultMap="ResultMap">
         SELECT xa.xm_id, xm.XMBH as xmbh, xm.XMMC as xmmc, asset.id as asset_id, xa.zcbm, <include refid="org.sky.scientific.mapper.AssetMapper.basicColumns"/>
         FROM kd_xm_fixed_asset xa
-        left join kd_asset asset on asset.zcbm = xa.zcbm and asset.year_and_month = (SELECT max(year_and_month) from kd_asset t WHERE t.zcbm = zcbm and left(t.year_and_month, 4) = #{ew.yearAndMonth})
+        left join kd_asset asset on asset.zcbm = xa.zcbm and asset.year_and_month = (SELECT max(year_and_month) from kd_xm_fixed_asset where ZCBM = xa.zcbm and left(year_and_month,4)=#{ew.yearAndMonth})
         LEFT JOIN
         (
             SELECT
@@ -95,7 +95,17 @@
             FROM kd_xm xm
         ) xm on xm.id = xa.xm_id
         WHERE left(xa.year_and_month,4 ) = #{ew.yearAndMonth} and xa.type = #{type}
-        GROUP BY asset.ZCBM
+        <if test="ew.xmmc!=null and ew.xmmc!=''">and xm.XMMC like concat('%',#{ew.xmmc},'%')</if>
+        <if test="ew.zcmc!=null and ew.zcmc!=''">and asset.ZCMC like concat('%',#{ew.zcmc},'%')</if>
+        <if test="ew.yt!=null and ew.yt!=''">and asset.yt=#{ew.yt}</if>
+        <if test="ew.sysmMin!=null">and asset.sysm <![CDATA[>=]]> #{ew.sysmMin}</if>
+        <if test="ew.sysmMax!=null">and asset.sysm <![CDATA[<=]]> #{ew.sysmMax}</if>
+        <if test="ew.zcyzMin!=null">and asset.zcyz <![CDATA[>=]]> #{ew.zcyzMin}</if>
+        <if test="ew.zcyzMax!=null">and asset.zcyz <![CDATA[<=]]> #{ew.zcyzMax}</if>
+        <if test="ew.yzjeMin!=null">and asset.YZJE <![CDATA[>=]]> #{ew.yzjeMin}</if>
+        <if test="ew.yzjeMax!=null">and asset.YZJE <![CDATA[<=]]> #{ew.yzjeMax}</if>
+        <if test="ew.status!=null">and asset.status = #{status}</if>
+        GROUP BY xa.xm_id,xa.ZCBM
     </select>
 
     <resultMap id="XmFixedAssetCostVo" type="org.sky.scientific.pojo.vo.XmFixedAssetCostVo" extends="ResultMap">

+ 4 - 4
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmGoodsMapper.xml

@@ -72,10 +72,10 @@
                 COALESCE(get_xm_info(temp.id,'XMMC',#{yearAndMonth}),XMMC) AS xmmc
             FROM kd_xm temp
         ) xm on xm.id = xg.xm_id
-        WHERE xg.type = #{type} and xg.year_and_month = #{yearAndMonth}
-          <if test="xmmc!=null">and xm.xmmc like concat('%',#{xmmc},'%')</if>
-          <if test="name!=null">and xg.name like concat('%',#{name},'%')</if>
-          <if test="model!=null">and xg.model like concat('%',#{model},'%')</if>
+        WHERE xg.year_and_month = #{yearAndMonth}
+          <if test="xmmc!=null and xmmc!=''">and xm.xmmc like concat('%',#{xmmc},'%')</if>
+          <if test="name!=null and name!=''">and xg.name like concat('%',#{name},'%')</if>
+          <if test="model!=null and model!=''">and xg.model like concat('%',#{model},'%')</if>
           <if test="dateMin!=null and dateMax!=null">and date_format(xg.use_date,'%Y-%m-%d') between #{dateMin} and #{dateMax}</if>
           <if test="xmId!=null">and xg.xm_id = #{xmId}</if>
           <if test="useDate!=null">and xg.use_date = #{useDate}</if>

+ 12 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmIntangibleAssetMapper.xml

@@ -68,7 +68,7 @@
     <select id="selectPageByYear" resultMap="ResultMap">
         SELECT xa.xm_id, xm.XMMC as xmmc, xm.XMBH as xmbh, xa.zcbm, t.name as user_name,<include refid="org.sky.scientific.mapper.AssetMapper.basicColumns"/>
         FROM kd_xm_intangible_asset xa
-        left join kd_asset asset on asset.zcbm = xa.zcbm and asset.year_and_month = (SELECT max(year_and_month) from kd_asset t WHERE t.zcbm = asset.zcbm and left(t.year_and_month,4) =#{ew.yearAndMonth} )
+        left join kd_asset asset on asset.zcbm = xa.zcbm and asset.year_and_month = (SELECT max(year_and_month) from kd_xm_intangible_asset WHERE zcbm = xa.zcbm and left(year_and_month,4) =#{ew.yearAndMonth})
         LEFT JOIN kd_technician t on t.unicode=xa.user_unicode and t.year_and_month = xa.year_and_month
         LEFT JOIN
         (
@@ -80,7 +80,17 @@
             WHERE xm.is_deleted = 0
         ) xm on xm.id = xa.xm_id
         WHERE left(xa.year_and_month,4 ) = #{ew.yearAndMonth}
-        GROUP BY asset.ZCBM
+        <if test="ew.xmmc!=null and ew.xmmc!=''">and xm.XMMC like concat('%',#{ew.xmmc},'%')</if>
+        <if test="ew.zcmc!=null and ew.zcmc!=''">and asset.ZCMC like concat('%',#{ew.zcmc},'%')</if>
+        <if test="ew.yt!=null and ew.yt!=''">and asset.yt=#{ew.yt}</if>
+        <if test="ew.sysmMin!=null">and asset.sysm <![CDATA[>=]]> #{ew.sysmMin}</if>
+        <if test="ew.sysmMax!=null">and asset.sysm <![CDATA[<=]]> #{ew.sysmMax}</if>
+        <if test="ew.zcyzMin!=null">and asset.zcyz <![CDATA[>=]]> #{ew.zcyzMin}</if>
+        <if test="ew.zcyzMax!=null">and asset.zcyz <![CDATA[<=]]> #{ew.zcyzMax}</if>
+        <if test="ew.yzjeMin!=null">and asset.YZJE <![CDATA[>=]]> #{ew.yzjeMin}</if>
+        <if test="ew.yzjeMax!=null">and asset.YZJE <![CDATA[<=]]> #{ew.yzjeMax}</if>
+        <if test="ew.status!=null">and asset.status = #{status}</if>
+        GROUP BY xa.xm_id,xa.ZCBM
     </select>
 
     <resultMap id="XmIntangibleAssetCostVo" type="org.sky.scientific.pojo.vo.XmIntangibleAssetCostVo" extends="ResultMap">

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

@@ -37,7 +37,7 @@
     <select id="selectHoursPage" resultMap="ResultVoMap" >
         SELECT
             xm.xmmc,xm.xmbh,xm.xm_id,
-            t.name, t.unicode, t.number,t.id_card,t.department,t.nature,t.situation,t.personnel_type
+            t.name, xt.unicode, t.number,t.id_card,t.department,t.nature,t.situation,t.personnel_type
         FROM kd_xm_technician_hours xt
         LEFT JOIN kd_technician t on xt.unicode = t.unicode and t.year_and_month = #{ew.yearAndMonth}
         LEFT JOIN

+ 41 - 13
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmFixedAssetServiceImpl.java

@@ -42,6 +42,7 @@ import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
 
 /**
  * 研发项目固定资产表 服务实现类
@@ -84,11 +85,11 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 		}
 		Date lastDate = DateUtil.minusMonths(DateUtil.parse(yearAndMonth, DateUtil.PATTERN_YYYYMM), 1);
 		//获取上个月数据
-
 		List<XmFixedAsset> lastMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(DateUtil.format(lastDate, DateUtil.PATTERN_YYYYMM), type.getCode());
 		//获取本月数据
 		List<XmFixedAsset> thisMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(yearAndMonth, type.getCode());
-		List<String> zcbmList = thisMonthList.stream().map(XmFixedAsset::getZcbm).toList();
+
+		Map<Long, List<String>> map = thisMonthList.stream().collect(Collectors.groupingBy(XmFixedAsset::getXmId, Collectors.mapping(XmFixedAsset::getZcbm, Collectors.toList())));
 
 		//已结题项目列表
 		List<Long> jtXmIdList = new ArrayList<>();
@@ -97,10 +98,7 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 		if (!CollectionUtil.isEmpty(lastMonthList)) {
 			//复制上个月数据到本月
 			for (XmFixedAsset dbAsset : lastMonthList) {
-				//dbAsset已存在,则跳过
-				if (zcbmList.contains(dbAsset.getZcbm())) {
-					continue;
-				}
+
 				if (jtXmIdList.contains(dbAsset.getXmId())) {
 					continue;
 				}
@@ -111,6 +109,18 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 				if (dbAsset.getAsset() != null && !Func.equals(dbAsset.getAsset().getStatus(), AssetStatusEnum.正常.getCode())) {
 					continue;
 				}
+
+				//dbAsset已存在,则跳过
+				List<String> thisMonthZcbmList = map.get(dbAsset.getXmId());
+				if(Func.isNull(thisMonthZcbmList)){
+					thisMonthZcbmList = new ArrayList<>();
+					map.put(dbAsset.getXmId(), thisMonthZcbmList);
+				}
+				if (thisMonthZcbmList.contains(dbAsset.getZcbm())) {
+					continue;
+				}
+				thisMonthZcbmList.add(dbAsset.getZcbm());
+
 				XmFixedAsset asset = new XmFixedAsset();
 				asset.setYearAndMonth(yearAndMonth);
 				asset.setXmId(dbAsset.getXmId());
@@ -125,9 +135,7 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 				throw new ServiceException("项目预算表中无数据");
 			}
 			for (YsZjfyycqdtfyEntity ys : ysList) {
-				if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(ys.getZcbm())) {
-					continue;
-				}
+
 				if (jtXmIdList.contains(ys.getXmId())) {
 					continue;
 				}
@@ -138,6 +146,17 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 				if (!Func.equals(ys.getAssetStatus(), AssetStatusEnum.正常.getCode())) {
 					continue;
 				}
+
+				List<String> thisMonthZcbmList = map.get(ys.getXmId());
+				if(Func.isNull(thisMonthZcbmList)){
+					thisMonthZcbmList = new ArrayList<>();
+					map.put(ys.getXmId(), thisMonthZcbmList);
+				}
+				if (thisMonthZcbmList.contains(ys.getZcbm())) {
+					continue;
+				}
+				thisMonthZcbmList.add(ys.getZcbm());
+
 				XmFixedAsset asset = new XmFixedAsset();
 				asset.setYearAndMonth(yearAndMonth);
 				asset.setXmId(ys.getXmId());
@@ -164,15 +183,13 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 		}
 		//获取本月数据
 		List<XmFixedAsset> thisMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(yearAndMonth, type.getCode());
-		List<String> zcbmList = thisMonthList.stream().map(XmFixedAsset::getZcbm).toList();
+ 		Map<Long, List<String>> map = thisMonthList.stream().collect(Collectors.groupingBy(XmFixedAsset::getXmId, Collectors.mapping(XmFixedAsset::getZcbm, Collectors.toList())));
 
 		List<XmFixedAsset> insertList = new ArrayList<>();
 		Map<String, Long> xmIdMap = new HashMap<>();
 		Map<String, AssetEntity> assetIdMap = new HashMap<>();
 		for (XmFixedAssetExcel excel : data) {
-			if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(excel.getZcbm())) {
-				continue;
-			}
+
 			if (Func.isBlank(excel.getXmbh())) {
 				throw new ServiceException("序号为[" + excel.getXh() + "]的项目研发编号为空");
 			}
@@ -206,6 +223,17 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 			}
 			assetIdMap.put(assetkey, dbAsset);
 
+			List<String> zcbmList = map.get(xmId);
+			if(Func.isNull(zcbmList)){
+				zcbmList = new ArrayList<>();
+				map.put(xmId, zcbmList);
+			}
+
+			if (zcbmList.contains(excel.getZcbm())) {
+				continue;
+			}
+			zcbmList.add(excel.getZcbm());
+
 			XmFixedAsset xmAsset = new XmFixedAsset();
 			xmAsset.setYearAndMonth(yearAndMonth);
 			xmAsset.setXmId(xmId);

+ 11 - 6
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmIntangibleAssetServiceImpl.java

@@ -165,16 +165,13 @@ public class XmIntangibleAssetServiceImpl extends BaseServiceImpl<XmIntangibleAs
 		}
 		//获取本月数据
 		List<XmIntangibleAsset> thisMonthList = baseMapper.selectListByYearAndMonth(yearAndMonth);
-		List<String> zcbmList = thisMonthList.stream().map(XmIntangibleAsset::getZcbm).toList();
+ 		Map<Long, List<String>> map = thisMonthList.stream().collect(Collectors.groupingBy(XmIntangibleAsset::getXmId, Collectors.mapping(XmIntangibleAsset::getZcbm, Collectors.toList())));
 
 		List<XmIntangibleAsset> insertList = new ArrayList<>();
 		Map<String, Long> xmIdMap = new HashMap<>();
 		Map<String, AssetEntity> assetIdMap = new HashMap<>();
 		for (XmIntangibleAssetExcel excel : data) {
 
-			if (zcbmList.contains(excel.getZcbm())) {
-				throw new ServiceException("序号为[" + excel.getXh() + "]的资产已存在");
-			}
 			if (StringUtil.isBlank(excel.getXmbh())) {
 				throw new ServiceException("序号为[" + excel.getXh() + "]的项目研发编号为空");
 			}
@@ -189,6 +186,13 @@ public class XmIntangibleAssetServiceImpl extends BaseServiceImpl<XmIntangibleAs
 			}
 			xmIdMap.put(xmkey, xmId);
 
+			List<String> zcbmList = map.get(xmId);
+			if (zcbmList.contains(excel.getZcbm())) {
+				throw new ServiceException("序号为[" + excel.getXh() + "]的资产已存在");
+			}else {
+				zcbmList.add(excel.getZcbm());
+			}
+
 			if (StringUtil.isAllBlank(excel.getZcbm(), excel.getZcmc())) {
 				throw new ServiceException("序号为[" + excel.getXh() + "]的资产编码和资产名称都为空");
 			}
@@ -238,9 +242,10 @@ public class XmIntangibleAssetServiceImpl extends BaseServiceImpl<XmIntangibleAs
 
 		//获取本月数据
 		List<XmIntangibleAsset> thisMonthList = baseMapper.selectListByYearAndMonth(xmAsset.getYearAndMonth());
-		List<String> zcbmList = thisMonthList.stream().map(XmIntangibleAsset::getZcbm).toList();
+		Map<Long, List<String>> map = thisMonthList.stream().collect(Collectors.groupingBy(XmIntangibleAsset::getXmId, Collectors.mapping(XmIntangibleAsset::getZcbm, Collectors.toList())));
 
-		if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(xmAsset.getZcbm())) {
+		List<String> list = map.get(xmAsset.getXmId());
+		if(Func.isNotEmpty(list) && list.contains(xmAsset.getZcbm())){
 			throw new ServiceException("资产已配置到项目中");
 		}
 		return this.save(xmAsset);