zhuzeyu 11 luni în urmă
părinte
comite
5331768f54

+ 144 - 0
src/main/java/cn/ezhizao/project/business/conversion/controller/BizProductDrawingConversionController.java

@@ -0,0 +1,144 @@
+package cn.ezhizao.project.business.conversion.controller;
+
+import java.time.LocalDate;
+import java.time.YearMonth;
+import java.time.ZoneId;
+import java.util.*;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.ezhizao.common.utils.poi.ExcelUtil;
+import cn.ezhizao.framework.aspectj.lang.annotation.Log;
+import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
+import cn.ezhizao.framework.web.controller.BaseController;
+import cn.ezhizao.framework.web.domain.AjaxResult;
+import cn.ezhizao.framework.web.page.TableDataInfo;
+import cn.ezhizao.project.business.conversion.domain.BizProductDrawingConversion;
+import cn.ezhizao.project.business.conversion.service.IBizProductDrawingConversionService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 产品电子化率记录Controller
+ *
+ * @author ezhizao
+ * @date 2024-07-16
+ */
+@RestController
+@RequestMapping("/business/conversion")
+public class BizProductDrawingConversionController extends BaseController
+{
+    @Resource
+    private IBizProductDrawingConversionService bizProductDrawingConversionService;
+
+    /**
+     * 查询产品电子化率记录列表
+     */
+    @GetMapping("/list")
+    public AjaxResult list(BizProductDrawingConversion bizProductDrawingConversion) throws NoSuchFieldException, IllegalAccessException
+    {
+        if (bizProductDrawingConversion.getYear()!=null ){
+            int year = Integer.parseInt(bizProductDrawingConversion.getYear());
+            // 将 LocalDate 转换为 Date
+            LocalDate startLocalDate = YearMonth.of(year, 1).atDay(1);
+            LocalDate endLocalDate = YearMonth.of(year, 12).atEndOfMonth();
+
+            // 使用 atStartOfDay 将 LocalDate 转换为 Date
+            Date startTime = Date.from(startLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+            Date endTime = Date.from(endLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+
+            bizProductDrawingConversion.setStartTime(startTime);
+            bizProductDrawingConversion.setEndTime(endTime);
+        }
+        List<BizProductDrawingConversion> list = bizProductDrawingConversionService.getList(bizProductDrawingConversion);
+
+        List<BizProductDrawingConversion> bizProductDrawingConversions = filterByMonth(list);
+        return success(bizProductDrawingConversions);
+    }
+
+    public static List<BizProductDrawingConversion> filterByMonth(List<BizProductDrawingConversion> list) {
+        Map<Integer, BizProductDrawingConversion> latestRecords = new HashMap<>();
+
+        for (BizProductDrawingConversion record : list) {
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(record.getDate());
+            int month = cal.get(Calendar.MONTH) + 1; // Calendar.MONTH 是从0开始的,所以需要+1
+            int year = cal.get(Calendar.YEAR);
+
+            // 将月份和年份组合成一个唯一的键
+            int key = (year * 100) + month;
+
+            if (!latestRecords.containsKey(key) || record.getDate().after(latestRecords.get(key).getDate())) {
+                latestRecords.put(key, record);
+            }
+        }
+
+        // 将 Map 转换为 List 返回
+        return new ArrayList<>(latestRecords.values());
+    }
+
+    /**
+     * 导出产品电子化率记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('business:conversion:export')")
+    @Log(title = "产品电子化率记录", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, BizProductDrawingConversion bizProductDrawingConversion) throws NoSuchFieldException, IllegalAccessException
+    {
+        setTenantId(bizProductDrawingConversion);
+        List<BizProductDrawingConversion> list = bizProductDrawingConversionService.getList(bizProductDrawingConversion);
+        ExcelUtil<BizProductDrawingConversion> util = new ExcelUtil<BizProductDrawingConversion>(BizProductDrawingConversion.class);
+        util.exportExcel(response, list, "产品电子化率记录数据");
+    }
+
+    /**
+     * 获取产品电子化率记录详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('business:conversion:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(bizProductDrawingConversionService.getById(id));
+    }
+
+    /**
+     * 新增产品电子化率记录
+     */
+    @Log(title = "产品电子化率记录", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody BizProductDrawingConversion bizProductDrawingConversion) throws NoSuchFieldException, IllegalAccessException
+    {
+        bizProductDrawingConversion.setDate(new Date());
+        return toAjax(bizProductDrawingConversionService.save(bizProductDrawingConversion));
+    }
+
+    /**
+     * 修改产品电子化率记录
+     */
+    @PreAuthorize("@ss.hasPermi('business:conversion:edit')")
+    @Log(title = "产品电子化率记录", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody BizProductDrawingConversion bizProductDrawingConversion) throws NoSuchFieldException, IllegalAccessException
+    {
+        setTenantId(bizProductDrawingConversion);
+        return toAjax(bizProductDrawingConversionService.updateById(bizProductDrawingConversion));
+    }
+
+    /**
+     * 删除产品电子化率记录
+     */
+    @PreAuthorize("@ss.hasPermi('business:conversion:remove')")
+    @Log(title = "产品电子化率记录", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable List<Long> ids)
+    {
+        return toAjax(bizProductDrawingConversionService.removeBatchByIds(ids));
+    }
+}

+ 52 - 0
src/main/java/cn/ezhizao/project/business/conversion/domain/BizProductDrawingConversion.java

@@ -0,0 +1,52 @@
+package cn.ezhizao.project.business.conversion.domain;
+
+import java.util.Date;
+
+import cn.ezhizao.framework.aspectj.lang.annotation.Excel;
+import cn.ezhizao.framework.web.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+import io.swagger.annotations.ApiModelProperty;
+
+
+/**
+ * 产品电子化率记录对象 biz_product_drawing_conversion
+ *
+ * @author ezhizao
+ * @date 2024-07-16
+ */
+@Data
+@TableName(value = "biz_product_drawing_conversion")
+public class BizProductDrawingConversion extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 租户id,厂别或类型1:Ⅰ类2:Ⅱ类 */
+    @ApiModelProperty(value = "${comment}")
+    private Long tenantId;
+
+    /** 日期 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
+    @ApiModelProperty(value = "日期")
+    private Date date;
+
+    /** 电子化率基数 */
+    @Excel(name = "电子化率基数")
+    @ApiModelProperty(value = "电子化率基数")
+    private Long number;
+
+
+    @TableField(exist = false)
+    private String year;
+
+    @TableField(exist = false)
+    private Date startTime;
+
+    @TableField(exist = false)
+    private Date endTime;
+
+}

+ 30 - 0
src/main/java/cn/ezhizao/project/business/conversion/mapper/BizProductDrawingConversionMapper.java

@@ -0,0 +1,30 @@
+package cn.ezhizao.project.business.conversion.mapper;
+
+import java.util.List;
+
+import cn.ezhizao.project.business.conversion.domain.BizProductDrawingConversion;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 产品电子化率记录Mapper接口
+ *
+ * @author ezhizao
+ * @date 2024-07-16
+ */
+public interface BizProductDrawingConversionMapper extends BaseMapper<BizProductDrawingConversion>
+{
+    /**
+     * 查询产品电子化率记录列表
+     *
+     * @param bizProductDrawingConversion 产品电子化率记录
+     * @return 产品电子化率记录集合
+     */
+    public List<BizProductDrawingConversion> getList(BizProductDrawingConversion bizProductDrawingConversion);
+
+    /**
+     * 物理删除
+     * @param bizProductDrawingConversion
+     * @return 删除结果
+    */
+    public int physicalDelete(BizProductDrawingConversion bizProductDrawingConversion);
+}

+ 32 - 0
src/main/java/cn/ezhizao/project/business/conversion/service/IBizProductDrawingConversionService.java

@@ -0,0 +1,32 @@
+package cn.ezhizao.project.business.conversion.service;
+
+import java.util.List;
+
+import cn.ezhizao.project.business.conversion.domain.BizProductDrawingConversion;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+
+/**
+ * 产品电子化率记录Service接口
+ *
+ * @author ezhizao
+ * @date 2024-07-16
+ */
+public interface IBizProductDrawingConversionService extends IService<BizProductDrawingConversion>
+{
+    /**
+     * 查询产品电子化率记录列表
+     *
+     * @param bizProductDrawingConversion 产品电子化率记录
+     * @return 产品电子化率记录集合
+     */
+    public List<BizProductDrawingConversion> getList(BizProductDrawingConversion bizProductDrawingConversion);
+
+    /**
+     * 物理删除
+     * @param bizProductDrawingConversion
+     * @return 删除结果
+     */
+    public int physicalDelete(BizProductDrawingConversion bizProductDrawingConversion);
+
+}

+ 44 - 0
src/main/java/cn/ezhizao/project/business/conversion/service/impl/BizProductDrawingConversionServiceImpl.java

@@ -0,0 +1,44 @@
+package cn.ezhizao.project.business.conversion.service.impl;
+
+import java.util.List;
+import javax.annotation.Resource;
+
+import cn.ezhizao.project.business.conversion.domain.BizProductDrawingConversion;
+import cn.ezhizao.project.business.conversion.mapper.BizProductDrawingConversionMapper;
+import cn.ezhizao.project.business.conversion.service.IBizProductDrawingConversionService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 产品电子化率记录Service业务层处理
+ *
+ * @author ezhizao
+ * @date 2024-07-16
+ */
+@Service
+public class BizProductDrawingConversionServiceImpl  extends ServiceImpl<BizProductDrawingConversionMapper, BizProductDrawingConversion> implements IBizProductDrawingConversionService
+{
+    @Resource
+    private BizProductDrawingConversionMapper bizProductDrawingConversionMapper;
+
+    /**
+     * 查询产品电子化率记录列表
+     *
+     * @param bizProductDrawingConversion 产品电子化率记录
+     * @return 产品电子化率记录
+     */
+    @Override
+    public List<BizProductDrawingConversion> getList(BizProductDrawingConversion bizProductDrawingConversion)
+    {
+        return bizProductDrawingConversionMapper.getList(bizProductDrawingConversion);
+    }
+
+    /**
+     * 物理删除
+     * @param bizProductDrawingConversion
+     * @return 删除结果
+     */
+    @Override
+    public int physicalDelete(BizProductDrawingConversion bizProductDrawingConversion){ return bizProductDrawingConversionMapper.physicalDelete(bizProductDrawingConversion); };
+
+}

+ 33 - 0
src/main/resources/mybatis/business/conversion/BizProductDrawingConversionMapper.xml

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.ezhizao.project.business.conversion.mapper.BizProductDrawingConversionMapper">
+
+    <resultMap type="cn.ezhizao.project.business.conversion.domain.BizProductDrawingConversion" id="BizProductDrawingConversionResult">
+        <id column="id" property="id"/>
+    </resultMap>
+
+
+    <select id="getList" parameterType="BizProductDrawingConversion" resultMap="BizProductDrawingConversionResult">
+        SELECT * FROM biz_product_drawing_conversion
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            deleted = 0
+            <if test="startTime != null">AND date >= #{startTime}</if>
+            <if test="endTime != null">AND date &lt; #{endTime}</if>
+            <if test="date != null "> AND date = #{date}</if>
+            <if test="number != null "> AND number = #{number}</if>
+        </trim>
+        order by date desc
+    </select>
+
+    <delete id="physicalDelete">
+        DELETE FROM biz_product_drawing_conversion
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            <if test="id != null">
+                id = #{id} AND
+            </if>
+       <!-- 删除条件为其他外键可以在这里加 -->
+        </trim>
+    </delete>
+</mapper>