Explorar el Código

增加打印票据的导入

zhoux hace 1 año
padre
commit
d6f6d00f90

+ 190 - 0
src/main/java/com/dk/oauth/entity/PrintLayout.java

@@ -0,0 +1,190 @@
+package com.dk.oauth.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.*;
+import java.io.Serializable;
+
+import com.dk.common.infrastructure.annotaiton.ExportTitle;
+import com.dk.common.infrastructure.handler.*;
+import com.dk.common.model.pojo.PageInfo;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+import java.time.LocalDateTime;
+
+/**
+ *  打印模版
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@ExportTitle("打印模版")
+@TableName(value = "t_mst_print_layout", autoResultMap = true, schema =  "dkic_b")
+@ApiModel(value="实体类:打印模版", description="表名:t_mst_print_layout")
+public class PrintLayout extends PageInfo<PrintLayout> implements Serializable {
+
+    /*
+     * 数据库字段
+     */
+
+    /**
+     * 模版ID
+     */
+    @TableId(value = "layout_id", type = IdType.AUTO)
+    @ApiModelProperty(value = "模版ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String layoutId;
+
+
+    /**
+     * 模板名称
+     */
+    @Excel(name = "模板名称")
+    @ApiModelProperty(value = "模板名称")
+    private String layoutName;
+
+
+    /**
+     * 模板数据
+     */
+    @Excel(name = "模板数据")
+    @ApiModelProperty(value = "模板数据")
+    @TableField(typeHandler = JsonTypeHandler.class)
+    private JSONObject layoutData;
+
+
+    /**
+     * 业务单据
+     */
+    @Excel(name = "业务单据")
+    @ApiModelProperty(value = "业务单据")
+    private String docName;
+
+
+    /**
+     * 显示顺序 (【1 ~ 46655】)
+     */
+    @Excel(name = "显示顺序 (【1 ~ 46655】)")
+    @ApiModelProperty(value = "显示顺序 (【1 ~ 46655】)")
+    private Integer displayNo;
+
+
+    /**
+     * 有效标识
+     */
+    @Excel(name = "有效标识")
+    @ApiModelProperty(value = "有效标识")
+    private Boolean flgValid;
+
+
+    /**
+     * 备注
+     */
+    @Excel(name = "备注")
+    @ApiModelProperty(value = "备注")
+    private String remarks;
+
+
+    /**
+     * 企业ID
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @Excel(name = "企业ID")
+    @ApiModelProperty(value = "企业ID")
+    private Integer cpId;
+
+
+    /**
+     * 创建时间 (触发器自动处理)
+     */
+    @Excel(name = "创建时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
+    @ApiModelProperty(value = "创建时间 (触发器自动处理)")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime opCreateTime;
+
+
+    /**
+     * 创建用户 (触发器自动处理)
+     */
+    @Excel(name = "创建用户 (触发器自动处理)")
+    @ApiModelProperty(value = "创建用户 (触发器自动处理)")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String opCreateUserId;
+
+
+    /**
+     * 修改时间 (触发器自动处理)
+     */
+    @Excel(name = "修改时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
+    @ApiModelProperty(value = "修改时间 (触发器自动处理)")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime opUpdateTime;
+
+
+    /**
+     * 修改用户 (触发器自动处理)
+     */
+    @Excel(name = "修改用户 (触发器自动处理)")
+    @ApiModelProperty(value = "修改用户 (触发器自动处理)")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String opUpdateUserId;
+
+
+    /**
+     * 数据操作应用 (触发器自动处理)
+     */
+    @Excel(name = "数据操作应用 (触发器自动处理)")
+    @ApiModelProperty(value = "数据操作应用 (触发器自动处理)")
+    private String opAppCode;
+
+
+    /**
+     * 数据时间戳 (触发器自动处理)
+     */
+    @Excel(name = "数据时间戳 (触发器自动处理)")
+    @ApiModelProperty(value = "数据时间戳 (触发器自动处理)")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime opTimestamp;
+
+
+    /**
+     * 数据操作数据库用户 (触发器自动处理)
+     */
+    @Excel(name = "数据操作数据库用户 (触发器自动处理)")
+    @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
+    private String opDbUser;
+
+
+    /*
+     * 相关属性
+     * @TableField(exist = false)
+     */
+
+    /*
+     * 关联属性 + 查询条件
+     * @TableField(exist = false)
+     */
+    /**
+     * 有效标识list
+     */
+    @TableField(exist = false)
+    @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
+    private List<Boolean> flgValidList;
+
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 28 - 0
src/main/java/com/dk/oauth/mapper/PrintLayoutMapper.java

@@ -0,0 +1,28 @@
+package com.dk.oauth.mapper;
+
+import com.dk.common.mapper.BaseMapper;
+import com.dk.oauth.entity.PrintLayout;
+import org.springframework.stereotype.Repository;
+
+import java.util.Map;
+
+/**
+*  打印模版 Mapper
+*/
+@Repository
+public interface PrintLayoutMapper extends BaseMapper<PrintLayout>{
+    /**
+     * @desc : 获取打印数据
+     * @author : 周兴
+     * @date : 2024-4-22 15:47
+     */
+    Map<String, Object> getPrintData(Map param);
+
+    /**
+     * @desc   : 票据名称是否重复
+     * @date   : 2024/4/23 16:39
+     * @author : 周兴
+     */
+    Long selectByName(PrintLayout printLayout);
+}
+

+ 15 - 13
src/main/java/com/dk/oauth/service/impl/CompanyServiceImpl.java

@@ -65,6 +65,8 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
     WarehouseMapper warehouseMapper;
     @Resource
     MoneyAccountMapper moneyAccountMapper;
+    @Resource
+    PrintLayoutMapper printLayoutMapper;
     @Autowired
     private CompanyConvert companyConvert;
     @Autowired
@@ -389,19 +391,19 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
         map.put("goodsCategorys",listGoodsCategorys);
 
         //  打印票据
-        //List<PrintLayout> printLayoutResponses = printLayoutMapper.selectByCond(new PrintLayout());
-        //List<Map<String, Object>> listPrintLayout = new ArrayList<>();
-        //for (int i = 0; i < printLayoutResponses.size(); i++) {
-        //    m = new HashMap<>();
-        //    m.put("layoutName",printLayoutResponses.get(i).getLayoutName());
-        //    m.put("layoutData",printLayoutResponses.get(i).getLayoutData());
-        //    m.put("displayNo",printLayoutResponses.get(i).getDisplayNo());
-        //    m.put("docName",printLayoutResponses.get(i).getDocName());
-        //    m.put("cpId",cpId);
-        //    m.put("opCreateUserId",staffId);
-        //    listPrintLayout.add(m);
-        //}
-        //map.put("printLayout",listPrintLayout);
+        List<PrintLayout> printLayoutResponses = printLayoutMapper.selectByCond(new PrintLayout());
+        List<Map<String, Object>> listPrintLayout = new ArrayList<>();
+        for (int i = 0; i < printLayoutResponses.size(); i++) {
+            m = new HashMap<>();
+            m.put("layoutName",printLayoutResponses.get(i).getLayoutName());
+            m.put("layoutData",printLayoutResponses.get(i).getLayoutData());
+            m.put("displayNo",printLayoutResponses.get(i).getDisplayNo());
+            m.put("docName",printLayoutResponses.get(i).getDocName());
+            m.put("cpId",cpId);
+            m.put("opCreateUserId",staffId);
+            listPrintLayout.add(m);
+        }
+        map.put("printLayout",listPrintLayout);
 
 
 

+ 160 - 0
src/main/resources/mapper/PrintLayoutMapper.xml

@@ -0,0 +1,160 @@
+<?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="com.dk.oauth.mapper.PrintLayoutMapper">
+
+    <!-- 通用设置 -->
+    <!-- 通用查询列 -->
+    <sql id="Base_Column_List">
+        layout_id, layout_name, layout_data, doc_name, display_no, flg_valid, remarks, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
+    </sql>
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.dk.oauth.entity.PrintLayout">
+        <id column="layout_id" property="layoutId"/>
+                <result column="layout_name" property="layoutName"/>
+                <result column="layout_data" property="layoutData" typeHandler="JsonTypeHandler"/>
+                <result column="doc_name" property="docName"/>
+                <result column="display_no" property="displayNo"/>
+                <result column="flg_valid" property="flgValid"/>
+                <result column="remarks" property="remarks"/>
+                <result column="cp_id" property="cpId"/>
+            <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
+                <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
+            <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
+                <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
+                <result column="op_app_code" property="opAppCode"/>
+            <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
+                <result column="op_db_user" property="opDbUser"/>
+    </resultMap>
+
+    <!-- 通用条件列 -->
+    <sql id="Condition">
+        <where>
+            <if test="layoutName != null and layoutName != ''">
+                AND layout_name = #{layoutName}
+            </if>
+            <if test="layoutData != null and layoutData != ''">
+                AND layout_data = #{layoutData}
+            </if>
+            <if test="docName != null and docName != ''">
+                AND doc_name = #{docName}
+            </if>
+            <if test="displayNo != null">
+                AND display_no = #{displayNo}
+            </if>
+            <if test="flgValid != null">
+                AND flg_valid = #{flgValid}
+            </if>
+            <if test="remarks != null and remarks != ''">
+                AND remarks = #{remarks}
+            </if>
+            <if test="cpId != null">
+                AND cp_id = #{cpId}
+            </if>
+            <if test="flgValidList != null and flgValidList.size()>0">
+                AND flg_valid = any(#{flgValidList, typeHandler=BooleanListTypeHandler})
+            </if>
+        </where>
+    </sql>
+
+    <sql id="idsForeach">
+        <!-- 根据主键layoutId批量操作 -->
+        WHERE layout_id in
+        <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </sql>
+
+    <!-- 查询表t_mst_print_layout,(条件查询+分页)列表 -->
+    <select id="selectByCond" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_b.t_mst_print_layout
+        <include refid="Condition"/>
+        order by display_no
+        <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
+            limit #{end} offset #{start}
+        </if>
+    </select>
+
+    <!-- 查询表t_mst_print_layout,(条件查询)个数 -->
+    <select id="countByCond" resultType="Long">
+        SELECT
+        count(1)
+        FROM dkic_b.t_mst_print_layout
+        <include refid="Condition"/>
+    </select>
+
+    <!-- 根据主键查询表t_mst_print_layout的一行数据 -->
+    <select id="selectById" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_b.t_mst_print_layout
+        WHERE layout_id = #{id}::uuid
+    </select>
+
+    <!-- 根据主键锁定表t_mst_print_layout的一行数据 -->
+    <select id="selectByIdForUpdate" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_b.t_mst_print_layout
+        WHERE layout_id = #{id}
+        for update
+    </select>
+
+    <!-- 根据主键锁定表t_mst_print_layout的多行数据 -->
+    <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_b.t_mst_print_layout
+        <include refid="idsForeach"/>
+        for update
+    </select>
+
+    <!--票据名称是否重复-->
+    <select id="selectByName" resultType="Long">
+        select count(1)
+        from dkic_b.t_mst_print_layout
+        where #{layoutName} = layout_name
+        and cp_id = #{cpId}
+        <if test="layoutId != null">
+            and layout_id != #{layoutId} ::uuid
+        </if>
+    </select>
+
+    <!--获取打印数据-->
+    <select id="getPrintData" resultType="java.util.Map">
+        SELECT *
+        FROM
+            dkic_b.f_get_print_data(#{dataId} ::uuid, #{objectCode}, #{i18n})
+    </select>
+
+    <insert id="insertBatch">
+        insert into dkic_b.t_mst_print_layout
+        (
+        <trim suffixOverrides=",">
+            layout_name,
+            layout_data,
+            doc_name,
+            display_no,
+            remarks,
+            cp_id,
+            op_app_code,
+        </trim>
+        )
+        values
+        <foreach collection="list" index="index" item="item" separator=",">
+            (
+            <trim suffixOverrides=",">
+                #{item.layoutName},
+                #{item.layoutData,typeHandler=JsonTypeHandler},
+                #{item.docName},
+                #{item.displayNo},
+                #{item.remarks},
+                #{item.cpId},
+                #{item.opAppCode},
+            </trim>
+            )
+        </foreach>
+    </insert>
+</mapper>