zhoulisky пре 10 месеци
родитељ
комит
338423f9c6

+ 43 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/dto/XmAssetQueryParam.java

@@ -0,0 +1,43 @@
+package org.sky.scientific.pojo.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+public class XmAssetQueryParam {
+
+	@Schema(description = "年月,格式:yyyyMM")
+	private String yearAndMonth;
+
+	@Schema(description = "项目名称")
+	private String xmmc;
+
+	@Schema(description = "资产名称")
+	private String zcmc;
+
+	@Schema(description = "用途")
+	private String yt;
+
+	@Schema(description = "使用寿命-小")
+	private Integer sysmMin;
+	@Schema(description = "使用寿命-大")
+	private Integer sysmMax;
+
+	@Schema(description = "已使用月数-小")
+	private Integer ysysmMin;
+	@Schema(description = "已使用月数-大")
+	private Integer ysysmMax;
+
+	@Schema(description = "资产原值-小")
+	private Double zcyzMin;
+	@Schema(description = "资产原值-大")
+	private Double zcyzMax;
+
+	@Schema(description = "月折旧额-小")
+	private Double yzjeMin;
+	@Schema(description = "月折旧额-大")
+	private Double yzjeMax;
+
+	@Schema(description = "状态")
+	private Integer status;
+}

+ 25 - 8
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/AssetController.java

@@ -22,11 +22,13 @@ import org.sky.core.tool.utils.Func;
 import org.sky.scientific.excel.AssetExcel;
 import org.sky.scientific.pojo.dto.AssetDTO;
 import org.sky.scientific.pojo.dto.XmAssetHoursDto;
+import org.sky.scientific.pojo.dto.XmAssetQueryParam;
 import org.sky.scientific.pojo.entity.AssetEntity;
 import org.sky.scientific.pojo.entity.XmAssetEntity;
 import org.sky.scientific.pojo.vo.AssetVO;
 import org.sky.scientific.pojo.vo.XmAssetHoursVO;
 import org.sky.scientific.service.IAssetService;
+import org.sky.scientific.service.IXmAssetHoursService;
 import org.sky.scientific.service.IXmAssetService;
 import org.sky.scientific.wrapper.ZcWrapper;
 import org.springframework.web.bind.annotation.*;
@@ -49,6 +51,7 @@ public class AssetController extends KdController {
 
 	private final IAssetService service;
 	private final IXmAssetService xmAssetService;
+	private final IXmAssetHoursService hoursService;
 
 	@GetMapping("/detail")
 	@ApiOperationSupport(order = 1)
@@ -122,23 +125,23 @@ public class AssetController extends KdController {
 	@GetMapping("/keyanyiqishebeimingxibiao/page")
 	@ApiOperationSupport(order = 20)
 	@Operation(summary = "科研仪器设备明细表-分页")
-	public R<IPage<XmAssetEntity>> pageXm(XmAssetEntity xmAsset, Query query) {
-		IPage<XmAssetEntity> pages = xmAssetService.keyanyiqishebeimingxibiao_page(Condition.getPage(query), xmAsset);
+	public R<IPage<XmAssetEntity>> pageYiqishebei(XmAssetQueryParam param, Query query) {
+		IPage<XmAssetEntity> pages = xmAssetService.selectXmFixAssetPage(Condition.getPage(query), param, "仪器设备");
 		return R.data(pages);
 	}
 
 	@GetMapping("/xm/fetchData")
 	@ApiOperationSupport(order = 21)
 	@Operation(summary = "科研仪器设备明细表-直接引用")
-	public R<Boolean> fetchData(String yearAndMonth) {
-		return R.status(xmAssetService.keyanyiqishebeimingxibiao_zhijieyinyong(yearAndMonth));
+	public R<Boolean> fetchYiqishebeiData(String yearAndMonth) {
+		return R.status(xmAssetService.xmFixAsset_zhijieyinyong(yearAndMonth, "仪器设备"));
 	}
 
 	@PostMapping("/hours/import")
 	@ApiOperationSupport(order = 30)
 	@Operation(summary = "科研仪器设备工时登记表-导入", description = "传入excel")
 	public R importXmAssetHours(MultipartFile file,String yearAndMonth) {
-		service.importXmAssetHours(file, yearAndMonth);
+		hoursService.importXmAssetHours(file, yearAndMonth);
 		return R.success("操作成功");
 	}
 
@@ -146,20 +149,34 @@ public class AssetController extends KdController {
 	@ApiOperationSupport(order = 31)
 	@Operation(summary = "科研仪器设备工时登记表-分页")
 	public R<IPage<XmAssetHoursVO>> selectXmAssetHourspage(XmAssetHoursDto dto, Query query) {
-		return R.data(service.selectXmAssetHoursPage(dto, Condition.getPage(query)));
+		return R.data(hoursService.selectXmAssetHoursPage(dto, Condition.getPage(query)));
 	}
 
 	@PostMapping("/hours/submit/batch")
 	@ApiOperationSupport(order = 32)
 	@Operation(summary = "科研仪器设备工时登记表-编辑")
 	public R submitAssetHours(@RequestBody XmAssetHoursDto dto) {
-		return R.status(service.batchSubmitXmAssetHours(dto));
+		return R.status(hoursService.batchSubmitXmAssetHours(dto));
 	}
 
 	@PostMapping("/hours/clear/batch")
 	@ApiOperationSupport(order = 33)
 	@Operation(summary = "科研仪器设备工时登记表-清除")
 	public R clearXmAssetHours(@RequestBody JSONObject dto) {
-		return R.status(service.clearXmAssetHours(dto));
+		return R.status(hoursService.clearXmAssetHours(dto));
+	}
+
+	@GetMapping("/fangwujianzhuwu/page")
+	@ApiOperationSupport(order = 40)
+	@Operation(summary = "科研房屋建筑物明细表-分页")
+	public R<IPage<XmAssetEntity>> pageFangwujianzhuwu(XmAssetQueryParam xmAsset, Query query) {
+		IPage<XmAssetEntity> pages = xmAssetService.selectXmFixAssetPage(Condition.getPage(query), xmAsset, "房屋建筑物");
+		return R.data(pages);
+	}
+	@GetMapping("/fangwujianzhuwu/fetchData")
+	@ApiOperationSupport(order = 41)
+	@Operation(summary = "科研房屋建筑物明细表-直接引用")
+	public R<Boolean> fetchFangwujianzhuwuData(String yearAndMonth) {
+		return R.status(xmAssetService.xmFixAsset_zhijieyinyong(yearAndMonth, "房屋建筑物"));
 	}
 }

+ 4 - 3
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmAssetMapper.java

@@ -4,6 +4,7 @@ package org.sky.scientific.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.sky.scientific.pojo.dto.XmAssetQueryParam;
 import org.sky.scientific.pojo.entity.XmAssetEntity;
 
 import java.util.List;
@@ -21,9 +22,9 @@ public interface XmAssetMapper extends BaseMapper<XmAssetEntity> {
 	 * @param yearAndMonth
 	 * @return
 	 */
-	List<XmAssetEntity> keyanyiqishebeimingxibiao_getLastMonthData(String yearAndMonth);
+	List<XmAssetEntity> selectXmFixedAssetByYearAndMonth(@Param("yearAndMonth") String yearAndMonth, @Param("zclb") String zclb);
 
-	List<XmAssetEntity> keyanyiqishebeimingxibiao_monthly(IPage<XmAssetEntity> page, @Param("ew") XmAssetEntity xmAsset);
+	List<XmAssetEntity> selectXmFixedAssetPageByYearAndMonth(IPage<XmAssetEntity> page, @Param("ew") XmAssetQueryParam xmAsset, @Param("zclb") String zclb);
 
-	List<XmAssetEntity> keyanyiqishebeimingxibiao_year(IPage<XmAssetEntity> page, @Param("ew")XmAssetEntity xmAsset);
+	List<XmAssetEntity> selectXmFixedAssetPageByYear(IPage<XmAssetEntity> page, @Param("ew")XmAssetQueryParam xmAsset, @Param("zclb") String zclb);
 }

+ 28 - 13
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmAssetMapper.xml

@@ -17,11 +17,12 @@
         <result column="is_deleted" property="isDeleted"/>
     </resultMap>
 
-    <select id="keyanyiqishebeimingxibiao_getLastMonthData"
+    <select id="selectXmFixedAssetByYearAndMonth"
             resultMap="ResultMap">
         SELECT xa.*
         FROM kd_xm_asset xa
-        INNER JOIN
+        inner JOIN kd_asset asset ON xa.asset_id = asset.id
+        LEFT JOIN
         (
             SELECT
                 xm.id,
@@ -31,25 +32,39 @@
             WHERE xm.is_deleted = 0 and DATE_FORMAT(XMKSSJ, '%Y%m') <![CDATA[<=]]> #{yearAndMonth}
         ) xm on xm.id = xa.xm_id
         WHERE xa.year_and_month = #{yearAndMonth} and #{yearAndMonth} between DATE_FORMAT(xm.XMKSSJ, '%Y%m') and DATE_FORMAT(xm.XMJSSJ,'%Y%m')
+        and asset.ZCLB = #{zclb}
     </select>
 
-    <select id="keyanyiqishebeimingxibiao_monthly" resultMap="ResultMap">
-        SELECT xa.*,xm.xmmc, xm.xmbh,<include refid="org.sky.scientific.mapper.AssetMapper.basicColumns"/>
+    <select id="selectXmFixedAssetPageByYearAndMonth" resultMap="ResultMap">
+        SELECT xa.*,xm.xmmc, xm.xmbh,
+        <include refid="org.sky.scientific.mapper.AssetMapper.basicColumns"/>
         FROM kd_xm_asset xa
         LEFT JOIN kd_asset asset ON xa.asset_id = asset.id
         LEFT JOIN
         (
-            SELECT
-                xm.id,
-                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[<=]]> #{ew.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 = 'XMBH' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMBH) AS XMBH
-                FROM kd_xm xm
-            WHERE xm.is_deleted = 0
+        SELECT
+        xm.id,
+        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[<=]]> #{ew.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 = 'XMBH' AND
+        DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMBH) AS
+        XMBH
+        FROM kd_xm xm
+        WHERE xm.is_deleted = 0
         ) xm on xm.id = xa.xm_id
-        WHERE xa.year_and_month = #{ew.yearAndMonth}
+        WHERE xa.year_and_month = #{ew.yearAndMonth} and asset.ZCLB = #{zclb}
+        <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 ew.sysmMax!=null">and asset.sysm between #{ew.sysmMin} and #{ew.sysmMax}</if>
+        <if test="ew.ysysmMin!=null and ew.ysysmMax!=null">and asset.ysysm between #{ew.ysysmMin} and #{ew.ysysmMax}</if>
+        <if test="ew.zcyzMin!=null and ew.zcyzMax!=null">and asset.zcyz between #{ew.zcyzMin} and #{ew.zcyzMax}</if>
+        <if test="ew.yzjeMin!=null and ew.yzjeMax!=null">and asset.yzje between #{ew.yzjeMin} and #{ew.yzjeMax}</if>
+        <if test="ew.status!=null">and asset.status = #{ew.status}</if>
     </select>
 
-    <select id="keyanyiqishebeimingxibiao_year" resultMap="ResultMap">
+    <select id="selectXmFixedAssetPageByYear" resultMap="ResultMap">
         SELECT xa.xm_id, xa.asset_id, <include refid="org.sky.scientific.mapper.AssetMapper.basicColumns"/>
         FROM kd_xm_asset xa
         LEFT JOIN kd_asset asset ON xa.asset_id = asset.id
@@ -62,7 +77,7 @@
             FROM kd_xm xm
             WHERE xm.is_deleted = 0
         ) xm on xm.id = xa.xm_id
-        WHERE left(xa.year_and_month,4 ) = #{ew.yearAndMonth}
+        WHERE left(xa.year_and_month,4 ) = #{ew.yearAndMonth} and asset.ZCLB = #{zclb}
         GROUP BY asset.ZCBM
     </select>
 

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

@@ -50,5 +50,5 @@ public interface YsZjfyycqdtfyMapper extends BaseMapper<YsZjfyycqdtfyEntity> {
 	 * @param yearAndMonth 年月
 	 * @return List<YsZjfyycqdtfyEntity>
 	 */
-	List<YsZjfyycqdtfyEntity> selectByYearAndMonth(String yearAndMonth);
+	List<YsZjfyycqdtfyEntity> selectByYearAndMonth(@Param("yearAndMonth") String yearAndMonth, @Param("zclb") String zclb);
 }

+ 15 - 9
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/YsZjfyycqdtfyMapper.xml

@@ -52,18 +52,24 @@
     <select id="selectByYearAndMonth" resultMap="ResultMap">
         SELECT xa.*, s.YZJE
         FROM kd_ys_zjfyycqdtfy xa
+        inner join kd_asset s on s.id = xa.asset_id
         INNER JOIN
         (
-            SELECT
-                xm.id,
-                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
-                FROM kd_xm xm
-                WHERE xm.is_deleted = 0 and DATE_FORMAT(XMKSSJ, '%Y%m') <![CDATA[<=]]> #{yearAndMonth}
-             ) xm on xm.id = xa.xm_id
-        Left join kd_asset s on s.id = xa.asset_id
+        SELECT
+        xm.id,
+        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
+        FROM kd_xm xm
+        WHERE xm.is_deleted = 0 and DATE_FORMAT(XMKSSJ, '%Y%m') <![CDATA[<=]]> #{yearAndMonth}
+        ) xm on xm.id = xa.xm_id
         WHERE #{yearAndMonth} between DATE_FORMAT(xm.XMKSSJ, '%Y%m') and DATE_FORMAT(xm.XMJSSJ,'%Y%m')
-          and s.ZCLB= '仪器设备'
+        <if test="zclb!=null">
+            and s.ZCLB= #{zclb}
+        </if>
     </select>
 
 </mapper>

+ 0 - 32
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/IAssetService.java

@@ -1,16 +1,13 @@
 
 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;
 import org.sky.scientific.excel.AssetExcel;
 import org.sky.scientific.pojo.dto.AssetDTO;
-import org.sky.scientific.pojo.dto.XmAssetHoursDto;
 import org.sky.scientific.pojo.entity.AssetEntity;
 import org.sky.scientific.pojo.vo.AssetVO;
-import org.sky.scientific.pojo.vo.XmAssetHoursVO;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
@@ -68,33 +65,4 @@ public interface IAssetService extends BaseService<AssetEntity> {
 	 * @return List<ZcExcel>
 	 */
 	List<AssetExcel> exportAsset(Wrapper<AssetEntity> queryWrapper);
-
-	/**
-	 * 科研仪器设备工时登记表-导入
-	 * @param file
-	 * @param yearAndMonth
-	 */
-    void importXmAssetHours(MultipartFile file, String yearAndMonth);
-
-	/**
-	 * 科研仪器设备工时登记表-分页
-	 * @param dto
-	 * @param page
-	 * @return
-	 */
-	IPage<XmAssetHoursVO> selectXmAssetHoursPage(XmAssetHoursDto dto, IPage<XmAssetHoursVO> page);
-
-	/**
-	 * 科研仪器设备工时登记表-编辑
-	 * @param dto
-	 * @return
-	 */
-	boolean batchSubmitXmAssetHours(XmAssetHoursDto dto);
-
-	/**
-	 * 科研仪器设备工时登记表-清除
-	 * @param dto
-	 * @return
-	 */
-	boolean clearXmAssetHours(JSONObject dto);
 }

+ 48 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/IXmAssetHoursService.java

@@ -0,0 +1,48 @@
+
+package org.sky.scientific.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.sky.core.mp.base.BaseService;
+import org.sky.scientific.pojo.dto.XmAssetHoursDto;
+import org.sky.scientific.pojo.entity.XmAssetHoursEntity;
+import org.sky.scientific.pojo.vo.XmAssetHoursVO;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 科研仪器设备工时 服务类
+ *
+ * @author Kd
+ * @since 2025-06-29
+ */
+public interface IXmAssetHoursService extends BaseService<XmAssetHoursEntity> {
+
+	/**
+	 * 科研仪器设备工时登记表-导入
+	 * @param file
+	 * @param yearAndMonth
+	 */
+	void importXmAssetHours(MultipartFile file, String yearAndMonth);
+
+	/**
+	 * 科研仪器设备工时登记表-分页
+	 * @param dto
+	 * @param page
+	 * @return
+	 */
+	IPage<XmAssetHoursVO> selectXmAssetHoursPage(XmAssetHoursDto dto, IPage<XmAssetHoursVO> page);
+
+	/**
+	 * 科研仪器设备工时登记表-编辑
+	 * @param dto
+	 * @return
+	 */
+	boolean batchSubmitXmAssetHours(XmAssetHoursDto dto);
+
+	/**
+	 * 科研仪器设备工时登记表-清除
+	 * @param dto
+	 * @return
+	 */
+	boolean clearXmAssetHours(JSONObject dto);
+}

+ 3 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/IXmAssetService.java

@@ -3,6 +3,7 @@ package org.sky.scientific.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.sky.core.mp.base.BaseService;
+import org.sky.scientific.pojo.dto.XmAssetQueryParam;
 import org.sky.scientific.pojo.entity.XmAssetEntity;
 
 /**
@@ -19,12 +20,12 @@ public interface IXmAssetService extends BaseService<XmAssetEntity> {
 	 * @param xmAsset
 	 * @return
 	 */
-	IPage<XmAssetEntity> keyanyiqishebeimingxibiao_page(IPage<XmAssetEntity> page, XmAssetEntity xmAsset);
+	IPage<XmAssetEntity> selectXmFixAssetPage(IPage<XmAssetEntity> page, XmAssetQueryParam param, String zclb);
 
 	/**
 	 * 科研仪器设备明细表-直接引用
 	 * @param asset
 	 * @return
 	 */
-	boolean keyanyiqishebeimingxibiao_zhijieyinyong(String yearAndMonth);
+	boolean xmFixAsset_zhijieyinyong(String yearAndMonth, String zclb);
 }

+ 6 - 177
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/AssetServiceImpl.java

@@ -1,41 +1,33 @@
 
 package org.sky.scientific.service.impl;
 
-import com.alibaba.excel.EasyExcel;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import jakarta.annotation.Resource;
-import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 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.secure.utils.SecureUtil;
-import org.sky.core.tool.utils.*;
+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.scientific.excel.AssetExcel;
-import org.sky.scientific.excel.XmAssetHoursMonthlyDataListener;
-import org.sky.scientific.excel.XmAssetHoursMonthlyExcel;
 import org.sky.scientific.mapper.AssetMapper;
 import org.sky.scientific.mapper.XmAssetHoursMapper;
 import org.sky.scientific.mapper.XmMapper;
 import org.sky.scientific.pojo.dto.AssetDTO;
-import org.sky.scientific.pojo.dto.XmAssetHoursDto;
 import org.sky.scientific.pojo.entity.AssetEntity;
-import org.sky.scientific.pojo.entity.XmAssetHoursEntity;
 import org.sky.scientific.pojo.vo.AssetVO;
-import org.sky.scientific.pojo.vo.DailyAttendance;
-import org.sky.scientific.pojo.vo.XmAssetHoursVO;
 import org.sky.scientific.service.IAssetService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.BufferedInputStream;
-import java.util.*;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * 资产表 服务实现类
@@ -135,167 +127,4 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
 		//});
 		return assetList;
 	}
-
-	@SneakyThrows
-	@Transactional(rollbackFor = Exception.class)
-    @Override
-    public void importXmAssetHours(MultipartFile file, String yearAndMonth) {
-		XmAssetHoursMonthlyDataListener listener = new XmAssetHoursMonthlyDataListener();
-		listener.setYearAndMonth(yearAndMonth);
-		EasyExcel.read(new BufferedInputStream(file.getInputStream()))
-			.registerReadListener(listener)
-			.sheet(0)
-			.headRowNumber(3) // 重要:设置表头行数(0-based)
-			.doRead();
-		List<XmAssetHoursMonthlyExcel> records = listener.getRecords();
-		if (CollectionUtil.isEmpty(records)) {
-			throw new ServiceException("未能从模板中读取数据,请检查模板格式是否正确");
-		}
-
-		//需要新增的,以便后续批量新增
-		List<XmAssetHoursEntity> insertList = new ArrayList<>();
-		//需要更新的,以便后续批量修改
-		List<XmAssetHoursEntity> updateList = new ArrayList<>();
-
-		int batchCount = 20;
-
-		List<XmAssetHoursEntity> dbList = xmAssetHoursMapper.selectByYearAndMonth(yearAndMonth, null, null);
-		for (XmAssetHoursMonthlyExcel record : records) {
-			//保存
-			if(StringUtil.isAllBlank(record.getXmmc(), record.getXmbh())){
-				throw new ServiceException("研发项目编号、研发项目名称都为空,请检查数据");
-			}
-			Long xmId = xmMapper.getXmIdByXmmcOrXmbh(yearAndMonth, record.getXmmc(), record.getXmbh());
- 			if (xmId == null) {
-				throw new ServiceException("序号为[" + record.getSerialNumber() + "]的研发项目编号和研发项目名称都不存在");
-			}
-
-			if(StringUtil.isBlank(record.getZcbm())){
-				throw new ServiceException("序号为[" + record.getSerialNumber() + "]的资产编码为空");
-			}
-			AssetEntity dbAsset = baseMapper.selectOne(Wrappers.<AssetEntity>lambdaQuery().eq(AssetEntity::getZcbm, record.getZcbm()).eq(AssetEntity::getYearAndMonth, yearAndMonth));
-			if (dbAsset == null) {
-				throw new ServiceException("序号为[" + record.getSerialNumber() + "]的资产不存在");
-			}
-			List<XmAssetHoursEntity> byXmAndAssetList = dbList.stream().filter(e -> e.getXmId().equals(xmId) && e.getAssetId().equals(dbAsset.getId())).toList();
-			for (DailyAttendance dailyAttendance : record.getDailyAttendances()) {
-
-				List<Long> primaryKeyList = byXmAndAssetList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).map(XmAssetHoursEntity::getId).toList();
-				Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
-				XmAssetHoursEntity entity = new XmAssetHoursEntity();
-				if (primaryKey == null) {
-					entity.setXmId(xmId);
-					entity.setAssetId(dbAsset.getId());
-					entity.setWorkDate(dailyAttendance.getWorkDate());
-					entity.setWorkHours(dailyAttendance.getWorkHours());
-					entity.setTenantId(SecureUtil.getTenantId());
-					entity.setCreateUser(SecureUtil.getUserId());
-					entity.setCreateDept(Func.toLong(SecureUtil.getDeptId()));
-					insertList.add(entity);
-				} else {
-					entity.setId(primaryKey);
-					entity.setWorkHours(dailyAttendance.getWorkHours());
-					updateList.add(entity);
-				}
-				if (!insertList.isEmpty() && insertList.size() % batchCount == 0) {
-					int insertCount = xmAssetHoursMapper.batchInsert(insertList);
-					if (insertCount == batchCount) {
-						insertList.clear();
-					}
-
-				}
-				if (!updateList.isEmpty() && updateList.size() % batchCount == 0) {
-					int updateCount = xmAssetHoursMapper.batchUpdate(updateList);
-					if (updateCount == batchCount) {
-						updateList.clear();
-					}
-				}
-			}
-		}
-		if (!insertList.isEmpty()) {
-			xmAssetHoursMapper.batchInsert(insertList);
-		}
-		if (!updateList.isEmpty()) {
-			xmAssetHoursMapper.batchUpdate(updateList);
-		}
-    }
-
-	@Override
-	public IPage<XmAssetHoursVO> selectXmAssetHoursPage(XmAssetHoursDto dto, IPage<XmAssetHoursVO> page) {
-		if (StringUtil.isBlank(dto.getYearAndMonth())) {
-			throw new ServiceException("参数yearAndMonth不能为空");
-		}
-		List<XmAssetHoursVO> list = xmAssetHoursMapper.selectXmAssetHoursPage(page, dto);
-		for (XmAssetHoursVO temp : list) {
-			List<DailyAttendance> dailyAttendanceList = xmAssetHoursMapper.selectHoursByXmIdAndAssetId(temp.getXmId(), temp.getAssetId(), dto.getYearAndMonth());
-			if(CollectionUtil.isEmpty(dailyAttendanceList)){
-				continue;
-			}
-			temp.setDailyAttendances(dailyAttendanceList);
-		}
-		return page.setRecords(list);
-	}
-
-	@Override
-	public boolean batchSubmitXmAssetHours(XmAssetHoursDto dto) {
-		if (StringUtil.isBlank(dto.getYearAndMonth())) {
-			throw new ServiceException("参数yearAndMonth不能为空");
-		}
-		if(dto.getXmId()==null){
-			throw new ServiceException("参数xmId不能为空");
-		}
-		if(dto.getAssetId()==null){
-			throw new ServiceException("参数assetId不能为空");
-		}
-		List<XmAssetHoursEntity> dbList = xmAssetHoursMapper.selectByYearAndMonth(dto.getYearAndMonth(), dto.getXmId(), dto.getAssetId());
-
-		//需要新增的,以便后续批量新增
-		List<XmAssetHoursEntity> insertList = new ArrayList<>();
-		//需要更新的,以便后续批量修改
-		List<XmAssetHoursEntity> updateList = new ArrayList<>();
-
-		for (DailyAttendance dailyAttendance : dto.getDailyHoursList()) {
-
-			List<Long> primaryKeyList = dbList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).map(XmAssetHoursEntity::getId).toList();
-			Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
-			XmAssetHoursEntity entity = new XmAssetHoursEntity();
-			if (primaryKey == null) {
-				entity.setXmId(dto.getXmId());
-				entity.setAssetId(dto.getAssetId());
-				entity.setWorkDate(dailyAttendance.getWorkDate());
-				entity.setWorkHours(dailyAttendance.getWorkHours());
-				entity.setTenantId(SecureUtil.getTenantId());
-				entity.setCreateUser(SecureUtil.getUserId());
-				entity.setCreateDept(Func.toLong(SecureUtil.getDeptId()));
-				insertList.add(entity);
-			} else {
-				entity.setId(primaryKey);
-				entity.setWorkHours(dailyAttendance.getWorkHours());
-				updateList.add(entity);
-			}
-		}
-
-		if (!insertList.isEmpty()) {
-			xmAssetHoursMapper.batchInsert(insertList);
-			insertList.clear();
-		}
-		if (!updateList.isEmpty()) {
-			xmAssetHoursMapper.batchUpdate(updateList);
-			updateList.clear();
-		}
-		return true;
-	}
-
-	@Override
-	public boolean clearXmAssetHours(JSONObject dto) {
-		JSONArray xmAndAssetIdList = dto.getJSONArray("xmAndAssetIdList");
-		if (xmAndAssetIdList == null || xmAndAssetIdList.isEmpty()) {
-			throw new ServiceException("参数xmAndAssetIdList不能为空");
-		}
-		for (Object xmAndAssetId : xmAndAssetIdList) {
-			Map<String, Long> map =(HashMap<String,Long>) xmAndAssetId;
-			xmAssetHoursMapper.clearXmAssetHours(dto.getString("yearAndMonth"),(Long) map.get("xmId"), (Long)map.get("assetId"));
-		}
-		return true;
-	}
 }

+ 214 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmAssetHoursServiceImpl.java

@@ -0,0 +1,214 @@
+
+package org.sky.scientific.service.impl;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import jakarta.annotation.Resource;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.sky.core.log.exception.ServiceException;
+import org.sky.core.mp.base.BaseServiceImpl;
+import org.sky.core.secure.utils.SecureUtil;
+import org.sky.core.tool.utils.CollectionUtil;
+import org.sky.core.tool.utils.Func;
+import org.sky.core.tool.utils.StringUtil;
+import org.sky.scientific.excel.XmAssetHoursMonthlyDataListener;
+import org.sky.scientific.excel.XmAssetHoursMonthlyExcel;
+import org.sky.scientific.mapper.AssetMapper;
+import org.sky.scientific.mapper.XmAssetHoursMapper;
+import org.sky.scientific.mapper.XmMapper;
+import org.sky.scientific.pojo.dto.XmAssetHoursDto;
+import org.sky.scientific.pojo.entity.AssetEntity;
+import org.sky.scientific.pojo.entity.XmAssetHoursEntity;
+import org.sky.scientific.pojo.vo.DailyAttendance;
+import org.sky.scientific.pojo.vo.XmAssetHoursVO;
+import org.sky.scientific.service.IXmAssetHoursService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.BufferedInputStream;
+import java.util.*;
+
+/**
+ * 科研仪器设备工时 服务实现类
+ *
+ * @author Kd
+ * @since 2025-06-29
+ */
+@Slf4j
+@Service
+public class XmAssetHoursServiceImpl extends BaseServiceImpl<XmAssetHoursMapper, XmAssetHoursEntity> implements IXmAssetHoursService {
+
+	@Resource
+	private XmMapper xmMapper;
+
+	@Resource
+	private AssetMapper assetMapper;
+
+	@SneakyThrows
+	@Transactional(rollbackFor = Exception.class)
+	@Override
+	public void importXmAssetHours(MultipartFile file, String yearAndMonth) {
+		XmAssetHoursMonthlyDataListener listener = new XmAssetHoursMonthlyDataListener();
+		listener.setYearAndMonth(yearAndMonth);
+		EasyExcel.read(new BufferedInputStream(file.getInputStream()))
+			.registerReadListener(listener)
+			.sheet(0)
+			.headRowNumber(3) // 重要:设置表头行数(0-based)
+			.doRead();
+		List<XmAssetHoursMonthlyExcel> records = listener.getRecords();
+		if (CollectionUtil.isEmpty(records)) {
+			throw new ServiceException("未能从模板中读取数据,请检查模板格式是否正确");
+		}
+
+		//需要新增的,以便后续批量新增
+		List<XmAssetHoursEntity> insertList = new ArrayList<>();
+		//需要更新的,以便后续批量修改
+		List<XmAssetHoursEntity> updateList = new ArrayList<>();
+
+		int batchCount = 20;
+
+		List<XmAssetHoursEntity> dbList = baseMapper.selectByYearAndMonth(yearAndMonth, null, null);
+		for (XmAssetHoursMonthlyExcel record : records) {
+			//保存
+			if(StringUtil.isAllBlank(record.getXmmc(), record.getXmbh())){
+				throw new ServiceException("研发项目编号、研发项目名称都为空,请检查数据");
+			}
+			Long xmId = xmMapper.getXmIdByXmmcOrXmbh(yearAndMonth, record.getXmmc(), record.getXmbh());
+			if (xmId == null) {
+				throw new ServiceException("序号为[" + record.getSerialNumber() + "]的研发项目编号和研发项目名称都不存在");
+			}
+
+			if(StringUtil.isBlank(record.getZcbm())){
+				throw new ServiceException("序号为[" + record.getSerialNumber() + "]的资产编码为空");
+			}
+			AssetEntity dbAsset = assetMapper.selectOne(Wrappers.<AssetEntity>lambdaQuery().eq(AssetEntity::getZcbm, record.getZcbm()).eq(AssetEntity::getYearAndMonth, yearAndMonth));
+			if (null == dbAsset) {
+				throw new ServiceException("序号为[" + record.getSerialNumber() + "]的资产不存在");
+			}
+			List<XmAssetHoursEntity> byXmAndAssetList = dbList.stream().filter(e -> e.getXmId().equals(xmId) && e.getAssetId().equals(dbAsset.getId())).toList();
+			for (DailyAttendance dailyAttendance : record.getDailyAttendances()) {
+
+				List<Long> primaryKeyList = byXmAndAssetList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).map(XmAssetHoursEntity::getId).toList();
+				Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
+				XmAssetHoursEntity entity = new XmAssetHoursEntity();
+				if (primaryKey == null) {
+					entity.setXmId(xmId);
+					entity.setAssetId(dbAsset.getId());
+					entity.setWorkDate(dailyAttendance.getWorkDate());
+					entity.setWorkHours(dailyAttendance.getWorkHours());
+					entity.setTenantId(SecureUtil.getTenantId());
+					entity.setCreateUser(SecureUtil.getUserId());
+					entity.setCreateDept(Func.toLong(SecureUtil.getDeptId()));
+					insertList.add(entity);
+				} else {
+					entity.setId(primaryKey);
+					entity.setWorkHours(dailyAttendance.getWorkHours());
+					updateList.add(entity);
+				}
+				if (!insertList.isEmpty() && insertList.size() % batchCount == 0) {
+					int insertCount = baseMapper.batchInsert(insertList);
+					if (insertCount == batchCount) {
+						insertList.clear();
+					}
+
+				}
+				if (!updateList.isEmpty() && updateList.size() % batchCount == 0) {
+					int updateCount = baseMapper.batchUpdate(updateList);
+					if (updateCount == batchCount) {
+						updateList.clear();
+					}
+				}
+			}
+		}
+		if (!insertList.isEmpty()) {
+			baseMapper.batchInsert(insertList);
+		}
+		if (!updateList.isEmpty()) {
+			baseMapper.batchUpdate(updateList);
+		}
+	}
+
+	@Override
+	public IPage<XmAssetHoursVO> selectXmAssetHoursPage(XmAssetHoursDto dto, IPage<XmAssetHoursVO> page) {
+		if (StringUtil.isBlank(dto.getYearAndMonth())) {
+			throw new ServiceException("参数yearAndMonth不能为空");
+		}
+		List<XmAssetHoursVO> list = baseMapper.selectXmAssetHoursPage(page, dto);
+		for (XmAssetHoursVO temp : list) {
+			List<DailyAttendance> dailyAttendanceList = baseMapper.selectHoursByXmIdAndAssetId(temp.getXmId(), temp.getAssetId(), dto.getYearAndMonth());
+			if(CollectionUtil.isEmpty(dailyAttendanceList)){
+				continue;
+			}
+			temp.setDailyAttendances(dailyAttendanceList);
+		}
+		return page.setRecords(list);
+	}
+
+	@Override
+	public boolean batchSubmitXmAssetHours(XmAssetHoursDto dto) {
+		if (StringUtil.isBlank(dto.getYearAndMonth())) {
+			throw new ServiceException("参数yearAndMonth不能为空");
+		}
+		if(dto.getXmId()==null){
+			throw new ServiceException("参数xmId不能为空");
+		}
+		if(dto.getAssetId()==null){
+			throw new ServiceException("参数assetId不能为空");
+		}
+		List<XmAssetHoursEntity> dbList = baseMapper.selectByYearAndMonth(dto.getYearAndMonth(), dto.getXmId(), dto.getAssetId());
+
+		//需要新增的,以便后续批量新增
+		List<XmAssetHoursEntity> insertList = new ArrayList<>();
+		//需要更新的,以便后续批量修改
+		List<XmAssetHoursEntity> updateList = new ArrayList<>();
+
+		for (DailyAttendance dailyAttendance : dto.getDailyHoursList()) {
+
+			List<Long> primaryKeyList = dbList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).map(XmAssetHoursEntity::getId).toList();
+			Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
+			XmAssetHoursEntity entity = new XmAssetHoursEntity();
+			if (primaryKey == null) {
+				entity.setXmId(dto.getXmId());
+				entity.setAssetId(dto.getAssetId());
+				entity.setWorkDate(dailyAttendance.getWorkDate());
+				entity.setWorkHours(dailyAttendance.getWorkHours());
+				entity.setTenantId(SecureUtil.getTenantId());
+				entity.setCreateUser(SecureUtil.getUserId());
+				entity.setCreateDept(Func.toLong(SecureUtil.getDeptId()));
+				insertList.add(entity);
+			} else {
+				entity.setId(primaryKey);
+				entity.setWorkHours(dailyAttendance.getWorkHours());
+				updateList.add(entity);
+			}
+		}
+
+		if (!insertList.isEmpty()) {
+			baseMapper.batchInsert(insertList);
+			insertList.clear();
+		}
+		if (!updateList.isEmpty()) {
+			baseMapper.batchUpdate(updateList);
+			updateList.clear();
+		}
+		return true;
+	}
+
+	@Override
+	public boolean clearXmAssetHours(JSONObject dto) {
+		JSONArray xmAndAssetIdList = dto.getJSONArray("xmAndAssetIdList");
+		if (xmAndAssetIdList == null || xmAndAssetIdList.isEmpty()) {
+			throw new ServiceException("参数xmAndAssetIdList不能为空");
+		}
+		for (Object xmAndAssetId : xmAndAssetIdList) {
+			Map<String, String> map =(HashMap<String,String>) xmAndAssetId;
+			baseMapper.clearXmAssetHours(dto.getString("yearAndMonth"),Long.valueOf(map.get("xmId")), Long.valueOf(map.get("assetId")));
+		}
+		return true;
+	}
+}

+ 10 - 9
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmAssetServiceImpl.java

@@ -11,6 +11,7 @@ import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.StringUtil;
 import org.sky.scientific.mapper.XmAssetMapper;
 import org.sky.scientific.mapper.YsZjfyycqdtfyMapper;
+import org.sky.scientific.pojo.dto.XmAssetQueryParam;
 import org.sky.scientific.pojo.entity.XmAssetEntity;
 import org.sky.scientific.pojo.entity.YsZjfyycqdtfyEntity;
 import org.sky.scientific.service.IXmAssetService;
@@ -34,30 +35,30 @@ public class XmAssetServiceImpl extends BaseServiceImpl<XmAssetMapper, XmAssetEn
 	private YsZjfyycqdtfyMapper ysZjfyycqdtfyMapper;
 
 	@Override
-	public IPage<XmAssetEntity> keyanyiqishebeimingxibiao_page(IPage<XmAssetEntity> page, XmAssetEntity xmAsset) {
-		if (StringUtil.isBlank(xmAsset.getYearAndMonth())) {
+	public IPage<XmAssetEntity> selectXmFixAssetPage(IPage<XmAssetEntity> page, XmAssetQueryParam param, String zclb) {
+		if (StringUtil.isBlank(param.getYearAndMonth())) {
 			throw new ServiceException("参数yearAndMonth不能为空");
 		}
 		List<XmAssetEntity> list = null;
-		if(xmAsset.getYearAndMonth().length() == 4){
+		if (param.getYearAndMonth().length() == 4) {
 			//全年
-			list = baseMapper.keyanyiqishebeimingxibiao_year(page, xmAsset);
-		}else {
+			list = baseMapper.selectXmFixedAssetPageByYear(page, param, zclb);
+		} else {
 			//按月
-			list = baseMapper.keyanyiqishebeimingxibiao_monthly(page, xmAsset);
+			list = baseMapper.selectXmFixedAssetPageByYearAndMonth(page, param, zclb);
 		}
 
 		return page.setRecords(list);
 	}
 
 	@Override
-	public boolean keyanyiqishebeimingxibiao_zhijieyinyong(String yearAndMonth) {
+	public boolean xmFixAsset_zhijieyinyong(String yearAndMonth, String zclb) {
 		if (StringUtil.isBlank(yearAndMonth)) {
 			throw new ServiceException("参数yearAndMonth不能为空");
 		}
 		Date lastDate = DateUtil.minusMonths(DateUtil.parse(yearAndMonth, DateUtil.PATTERN_YYYYMM), 1);
 		//获取上个月数据
-		List<XmAssetEntity> lastMonthList = baseMapper.keyanyiqishebeimingxibiao_getLastMonthData(DateUtil.format(lastDate, DateUtil.PATTERN_YYYYMM));
+		List<XmAssetEntity> lastMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(DateUtil.format(lastDate, DateUtil.PATTERN_YYYYMM), zclb);
 		if (!CollectionUtil.isEmpty(lastMonthList)) {
 			//复制上个月数据到本月
 			List<XmAssetEntity> insertList = new ArrayList<>();
@@ -71,7 +72,7 @@ public class XmAssetServiceImpl extends BaseServiceImpl<XmAssetMapper, XmAssetEn
 			return this.saveBatch(insertList);
 		} else {
 			//若无,则获取预算表中的科研仪器设备,研发项目周期(含变更)包含本月的
-			List<YsZjfyycqdtfyEntity> ysZjfyycqdtfyEntities = ysZjfyycqdtfyMapper.selectByYearAndMonth(yearAndMonth);
+			List<YsZjfyycqdtfyEntity> ysZjfyycqdtfyEntities = ysZjfyycqdtfyMapper.selectByYearAndMonth(yearAndMonth, zclb);
 			if (CollectionUtil.isEmpty(ysZjfyycqdtfyEntities)) {
 				throw new ServiceException("未能从项目预算表中读取科研仪器设备");
 			}