Browse Source

会计科目

zhoulisky 10 months ago
parent
commit
4ce576dfc0

+ 3 - 6
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/vo/TechnicianVO.java

@@ -1,16 +1,11 @@
 
 package org.sky.scientific.pojo.vo;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.v3.oas.annotations.media.Schema;
-import org.sky.core.tool.utils.DateUtil;
-import org.sky.scientific.pojo.entity.TechnicianEntity;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import org.springframework.format.annotation.DateTimeFormat;
+import org.sky.scientific.pojo.entity.TechnicianEntity;
 
 import java.io.Serial;
-import java.util.Date;
 
 /**
  * 技术人员花名册 视图实体类
@@ -24,6 +19,8 @@ public class TechnicianVO extends TechnicianEntity {
 	@Serial
 	private static final long serialVersionUID = 1L;
 
+	private int serialNumber;
 
+	private String genderName;
 
 }

+ 2 - 4
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/TechnicianController.java

@@ -14,7 +14,6 @@ import org.sky.core.excel.util.ExcelUtil;
 import org.sky.core.mp.support.Condition;
 import org.sky.core.mp.support.Query;
 import org.sky.core.tool.api.R;
-import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.Func;
 import org.sky.scientific.excel.TechnicianExcel;
 import org.sky.scientific.excel.TechnicianImporter;
@@ -94,9 +93,8 @@ public class TechnicianController extends KdController {
 	@PostMapping("/export")
 	@ApiOperationSupport(order = 9)
 	@Operation(summary = "导出数据", description = "传入technician")
-	public void exportTechnician(@RequestBody TechnicianDTO technician, HttpServletResponse response) {
-		List<TechnicianExcel> list = technicianService.exportTechnician(technician);
-		ExcelUtil.export(response, "技术人员花名册数据" + DateUtil.time(), "技术人员花名册数据表", list, TechnicianExcel.class);
+	public void exportTechnician(HttpServletResponse response, @RequestBody TechnicianDTO technician) {
+		technicianService.exportTechnician(response,technician);
 	}
 
 	@GetMapping("/fetchLastMonthData")

+ 10 - 3
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/XmOtherCostController.java

@@ -15,7 +15,6 @@ import org.sky.core.excel.util.ExcelUtil;
 import org.sky.core.mp.support.Condition;
 import org.sky.core.mp.support.Query;
 import org.sky.core.secure.KdUser;
-import org.sky.core.secure.annotation.IsAdmin;
 import org.sky.core.tool.api.R;
 import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.Func;
@@ -73,8 +72,7 @@ public class XmOtherCostController extends KdController {
 		return R.status(service.physicalDeleteByIds(Func.toLongList(ids)));
 	}
 
-	@IsAdmin
-	@GetMapping("/export")
+ 	@GetMapping("/export")
 	@ApiOperationSupport(order = 9)
 	@Operation(summary = "导出数据", description  = "传入xmDesignCost")
 	public void exportXmDesignCost(@Parameter(hidden = true) @RequestParam Map<String, Object> xmDesignCost, KdUser kdUser, HttpServletResponse response) {
@@ -82,4 +80,13 @@ public class XmOtherCostController extends KdController {
 		List<XmOtherCostExcel> list = service.export(queryWrapper);
 		ExcelUtil.export(response, "项目-其他费用-基本信息台账" + DateUtil.time(), "项目-其他费用-基本信息台账数据表", list, XmOtherCostExcel.class);
 	}
+//
+//	@GetMapping("/summary")
+//	@ApiOperationSupport(order = 10)
+//	@Operation(summary = "其他费用-汇总表")
+//	public R<List<XmOtherCostExcel>> summary(XmOtherCostQuery param) {
+//		List<XmOtherCostExcel> list = service.export(Condition.getQueryWrapper(param, XmOtherCostEntity.class));
+//		return R.data(list);
+//	}
+
 }

+ 10 - 34
kd-service/kd-scientific/src/main/java/org/sky/scientific/excel/TechnicianExcel.java

@@ -3,14 +3,12 @@ package org.sky.scientific.excel;
 
 
 import com.alibaba.excel.annotation.ExcelIgnore;
-import lombok.Data;
-
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.annotation.write.style.ColumnWidth;
-import com.alibaba.excel.annotation.write.style.ContentRowHeight;
-import com.alibaba.excel.annotation.write.style.HeadRowHeight;
-import java.io.Serializable;
+import lombok.Data;
+
 import java.io.Serial;
+import java.io.Serializable;
 import java.util.Date;
 
 
@@ -21,52 +19,30 @@ import java.util.Date;
  * @since 2025-06-11
  */
 @Data
-@ColumnWidth(25)
-@HeadRowHeight(20)
-@ContentRowHeight(18)
-//@HeadStyle(fillBackgroundColor = )
 public class TechnicianExcel implements Serializable {
 
 	@Serial
 	private static final long serialVersionUID = 1L;
 
-	/**
-	 * 姓名
-	 */
-	@ColumnWidth(20)
 	@ExcelProperty("姓名")
 	private String name;
-	/**
-	 * 工号
-	 */
-	@ColumnWidth(20)
-	@ExcelProperty("工号")
+
+ 	@ExcelProperty("工号")
 	private String number;
-	/**
-	 * 身份证号码
-	 */
-	@ColumnWidth(20)
-	@ExcelProperty("身份证号")
+
+ 	@ExcelProperty("身份证号")
 	private String idCard;
-	/**
-	 * 性别,1:男,2:女
-	 */
 
 	@ExcelIgnore
 	private Integer gender;
 
-	@ColumnWidth(20)
-	@ExcelProperty("性别")
+ 	@ExcelProperty("性别")
 	private String genderName;
-	/**
-	 * 出生日期
-	 */
+
 	@ColumnWidth(20)
 	@ExcelProperty("出生日期")
 	private Date birthday;
-	/**
-	 * 民族
-	 */
+
 	@ColumnWidth(20)
 	@ExcelProperty("民族")
 	private String ethnic;

+ 0 - 3
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/TechnicianMapper.java

@@ -4,7 +4,6 @@ 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.excel.TechnicianExcel;
 import org.sky.scientific.pojo.dto.TechnicianDTO;
 import org.sky.scientific.pojo.entity.TechnicianEntity;
 import org.sky.scientific.pojo.vo.TechnicianVO;
@@ -29,8 +28,6 @@ public interface TechnicianMapper extends BaseMapper<TechnicianEntity> {
 	 */
 	List<TechnicianVO> selectTechnicianPage(IPage page, @Param("technician") TechnicianDTO technician);
 
-	List<TechnicianExcel> exportTechnicianList(@Param("technician") TechnicianDTO technician);
-
 	TechnicianEntity selectByUnicodeAndYearAndMonth(@Param("unicode") String unicode, @Param("yearAndMonth") String yearAndMonth);
 
 	String getUnicodeByNumberAndIdentityCard(@Param("number") String number, @Param("idCard") String idCard);

+ 2 - 67
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/TechnicianMapper.xml

@@ -48,7 +48,8 @@
 
     <select id="selectTechnicianPage" resultMap="technicianResultMap"
             parameterType="org.sky.scientific.pojo.dto.TechnicianDTO">
-        select * from kd_technician
+        select *
+        from kd_technician
         where is_deleted = 0 and year_and_month = #{technician.yearAndMonth}
         <if test="technician.name!=null and technician.name!=''">and name like concat(concat('%', #{technician.name}),
             '%')
@@ -74,67 +75,6 @@
         order by year_and_month asc, id asc
     </select>
 
-    <select id="exportTechnicianList" resultType="org.sky.scientific.excel.TechnicianExcel"
-            parameterType="org.sky.scientific.pojo.dto.TechnicianDTO">
-        select t1.*
-        from kd_technician t1
-        <if test="technician.yearAndMonth.length()==4">
-            INNER JOIN
-            (
-            SELECT unicode, MAX( year_and_month ) AS max_month
-            FROM kd_technician
-            WHERE LEFT ( year_and_month, 4 ) = #{technician.yearAndMonth} AND is_deleted = 0
-            GROUP BY unicode
-            ) t2
-            ON t1.unicode= t2.unicode AND year_and_month = t2.max_month
-        </if>
-        where is_deleted = 0
-        <if test="technician.name!=null and technician.name!=''">and name like concat(concat('%', #{technician.name}),
-            '%')
-        </if>
-        <if test="technician.number!=null and technician.number!=''">and name like concat(concat('%',
-            #{technician.number}), '%')
-        </if>
-        <if test="technician.idCard!=null and technician.idCard!=''">and id_card like
-            concat(concat('%', #{technician.idCard}), '%')
-        </if>
-        <if test="technician.secondaryUnit!=null and technician.secondaryUnit!=''">and secondary_unit like
-            concat(concat('%', #{technician.secondaryUnit}), '%')
-        </if>
-        <if test="technician.department!=null and technician.department!=''">and department like concat(concat('%',
-            #{technician.department}), '%')
-        </if>
-        <if test="technician.post!=null and technician.post!=''">and post like concat(concat('%', #{technician.post}),
-            '%')
-        </if>
-        <if test="technician.postLocation!=null and technician.postLocation!=''">and post_location like
-            concat(concat('%', #{technician.postLocation}), '%')
-        </if>
-        <if test="technician.nature!=null and technician.nature!=''">and nature = #{technician.nature}</if>
-        <if test="technician.education!=null and technician.education!=''">and education = #{technician.education}</if>
-        <if test="technician.degree!=null and technician.degree!=''">and degree = #{technician.degree}</if>
-        <if test="technician.rank!=null and technician.rank!=''">and rank = #{technician.rank}</if>
-        <if test="technician.personnelType!=null and technician.personnelType!=''">and personnel_type =
-            #{technician.personnelType}
-        </if>
-        <if test="technician.situation !=null and technician.situation!=''">and situation = #{technician.situation}</if>
-        <if test="technician.practicingRequirement !=null and technician.practicingRequirement!=''">and
-            practicing_requirement like concat(concat('%', #{technician.practicingRequirement}), '%')
-        </if>
-        <if test="technician.hireStartDate!=null and technician.hireEndDate!=''">and hire_Date between
-            #{technician.hireStartDate} and #{technician.hireEndDate}
-        </if>
-        <choose>
-            <when test="technician.yearAndMonth.length()==4">
-                and LEFT ( t1.year_and_month, 4 ) = #{technician.yearAndMonth}
-            </when>
-            <otherwise>
-                and t1.year_and_month = #{technician.yearAndMonth}
-            </otherwise>
-        </choose>
-        order by year_and_month asc, id asc
-    </select>
-
     <select id="selectByYear" resultMap="technicianResultMap" parameterType="org.sky.scientific.pojo.dto.TechnicianDTO">
         select t1.*
         from kd_technician t1
@@ -177,11 +117,6 @@
         order by year_and_month asc, t1.id asc
     </select>
 
-    <select id="exportTechnician" resultType="org.sky.scientific.excel.TechnicianExcel">
-        SELECT *
-        FROM kd_technician ${ew.customSqlSegment}
-    </select>
-
     <select id="selectByUnicodeAndYearAndMonth"
             resultType="org.sky.scientific.pojo.entity.TechnicianEntity">
         select *

+ 2 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/ITechnicianService.java

@@ -1,6 +1,7 @@
 package org.sky.scientific.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import jakarta.servlet.http.HttpServletResponse;
 import org.sky.core.mp.base.BaseService;
 import org.sky.scientific.excel.TechnicianExcel;
 import org.sky.scientific.pojo.dto.TechnicianDTO;
@@ -51,7 +52,7 @@ public interface ITechnicianService extends BaseService<TechnicianEntity> {
 	 * @param technician 查询条件
 	 * @return List<TechnicianExcel>
 	 */
-	List<TechnicianExcel> exportTechnician(TechnicianDTO technician);
+	void exportTechnician(HttpServletResponse response, TechnicianDTO technician);
 
 	/**
 	 * 导入

+ 36 - 7
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/TechnicianServiceImpl.java

@@ -1,20 +1,24 @@
 
 package org.sky.scientific.service.impl;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.support.ExcelTypeEnum;
+import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.excel.write.metadata.fill.FillWrapper;
 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 jakarta.servlet.http.HttpServletResponse;
+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.mp.support.Condition;
 import org.sky.core.mp.support.Query;
 import org.sky.core.secure.utils.SecureUtil;
-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.TechnicianExcel;
 import org.sky.scientific.mapper.TechnicianMapper;
 import org.sky.scientific.mapper.XmMapper;
@@ -34,6 +38,8 @@ import org.sky.system.pojo.enums.DictEnum;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.InputStream;
+import java.net.URLEncoder;
 import java.util.*;
 
 /**
@@ -98,13 +104,36 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 		return page.setRecords(voList);
 	}
 
+	@SneakyThrows
 	@Override
-	public List<TechnicianExcel> exportTechnician(TechnicianDTO technician) {
-		List<TechnicianExcel> technicianList = baseMapper.exportTechnicianList(technician);
+	public void exportTechnician(HttpServletResponse response, TechnicianDTO technician) {
+
+
+		Query query = new Query().setCurrent(1).setSize(Integer.MAX_VALUE);
+		List<TechnicianVO> technicianList = this.selectTechnicianPage(Condition.getPage(query), technician).getRecords();
+		if(CollectionUtil.isEmpty(technicianList)){
+			throw new ServiceException("花名册无数据!");
+		}
 		technicianList.forEach(temp -> {
 			temp.setGenderName(DictCache.getValue(DictEnum.SEX, temp.getGender()));
 		});
-		return technicianList;
+
+		InputStream templateFileName = this.getClass().getClassLoader().getResourceAsStream("export-template/技术人员花名册.xls");
+		response.setContentType("application/vnd.ms-excel");
+		response.setCharacterEncoding("utf-8");
+		response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("技术人员花名册.xls", Charsets.UTF_8));
+		ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
+			.withTemplate((templateFileName))
+			.excelType(ExcelTypeEnum.XLS)
+			.build();
+
+		WriteSheet writeSheet = EasyExcel.writerSheet().build();
+		//设置list集合数据
+		excelWriter.fill(new FillWrapper("list", technicianList), writeSheet);
+		excelWriter.finish();
+		if (templateFileName != null) {
+			templateFileName.close();
+		}
 	}
 
 	@Transactional

BIN
kd-service/kd-scientific/src/main/resources/export-template/技术人员花名册.xls