表重命名:biz_document-history->biz_doc_history

master
toesbieya 6 years ago
parent c7a6d6784f
commit 6c7599acfc
  1. 12
      java/my.sql
  2. 6
      java/src/main/resources/mapper/BizDocumentHistory.xml
  3. 96
      java/src/main/resources/mapper/BizStock.xml

@ -18,10 +18,10 @@ SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0; SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------- -- ----------------------------
-- Table structure for biz_document_history -- Table structure for biz_do_history
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `biz_document_history`; DROP TABLE IF EXISTS `biz_do_history`;
CREATE TABLE `biz_document_history` ( CREATE TABLE `biz_do_history` (
`id` int(20) NOT NULL AUTO_INCREMENT COMMENT '单据状态变更记录表', `id` int(20) NOT NULL AUTO_INCREMENT COMMENT '单据状态变更记录表',
`pid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '单据ID', `pid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '单据ID',
`type` int(11) NOT NULL COMMENT '变更类型,0撤回,1提交,2通过,3驳回', `type` int(11) NOT NULL COMMENT '变更类型,0撤回,1提交,2通过,3驳回',
@ -37,10 +37,10 @@ CREATE TABLE `biz_document_history` (
) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Records of biz_document_history -- Records of biz_do_history
-- ---------------------------- -- ----------------------------
INSERT INTO `biz_document_history` VALUES (29, 'CGDD202006190001', 1, 1, 'admin', 0, 1, 1592537930953, NULL); INSERT INTO `biz_do_history` VALUES (29, 'CGDD202006190001', 1, 1, 'admin', 0, 1, 1592537930953, NULL);
INSERT INTO `biz_document_history` VALUES (30, 'CGDD202006190001', 2, 1, 'admin', 1, 2, 1592537934419, NULL); INSERT INTO `biz_do_history` VALUES (30, 'CGDD202006190001', 2, 1, 'admin', 1, 2, 1592537934419, NULL);
-- ---------------------------- -- ----------------------------
-- Table structure for biz_purchase_inbound -- Table structure for biz_purchase_inbound

@ -3,14 +3,14 @@
<mapper namespace="com.toesbieya.my.mapper.BizDocumentHistoryMapper"> <mapper namespace="com.toesbieya.my.mapper.BizDocumentHistoryMapper">
<select id="getByPid" resultType="com.toesbieya.my.model.entity.BizDocumentHistory"> <select id="getByPid" resultType="com.toesbieya.my.model.entity.BizDocumentHistory">
select * select *
from biz_document_history from biz_do_history
where pid = #{pid} where pid = #{pid}
order by id desc order by id desc
</select> </select>
<select id="search" resultType="com.toesbieya.my.model.entity.BizDocumentHistory" <select id="search" resultType="com.toesbieya.my.model.entity.BizDocumentHistory"
parameterType="com.toesbieya.my.model.vo.search.DocumentHistorySearch"> parameterType="com.toesbieya.my.model.vo.search.DocumentHistorySearch">
select * select *
from biz_document_history from biz_do_history
where 1 where 1
<if test="pid!=null and pid!=''">and pid=#{pid}</if> <if test="pid!=null and pid!=''">and pid=#{pid}</if>
<if test="uid!=null and uid!=''">and uid in (${uid})</if> <if test="uid!=null and uid!=''">and uid in (${uid})</if>
@ -20,7 +20,7 @@
</select> </select>
<insert id="insert" parameterType="com.toesbieya.my.model.entity.BizDocumentHistory"> <insert id="insert" parameterType="com.toesbieya.my.model.entity.BizDocumentHistory">
insert into biz_document_history (pid, type, uid, uname, status_before, status_after, time, info) insert into biz_do_history (pid, type, uid, uname, status_before, status_after, time, info)
VALUES (#{pid}, #{type}, #{uid}, #{uname}, #{status_before}, #{status_after}, #{time}, #{info}) VALUES (#{pid}, #{type}, #{uid}, #{uname}, #{status_before}, #{status_after}, #{time}, #{info})
</insert> </insert>
</mapper> </mapper>

@ -2,28 +2,48 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.toesbieya.my.mapper.BizStockMapper"> <mapper namespace="com.toesbieya.my.mapper.BizStockMapper">
<sql id="searchCondition"> <sql id="searchCondition">
<if test="id!=null">and id=#{id}</if> where 1
<if test="ids!=null and ids!=''">and id in (${ids})</if> <if test="id != null">
<if test="cid!=null">and cid=#{cid}</if> and id=#{id}
<if test="cids!=null and cids!=''">and cid in (${cids})</if> </if>
<if test="cgddid!=null and cgddid!=''">and cgddid=#{cgddid}</if> <if test="ids != null and ids != ''">
<if test="cgddids!=null and cgddids!=''">and cgddid in (${cgddids})</if> and id in (${ids})
<if test="cgrkid!=null and cgrkid!=''">and cgrkid=#{cgrkid}</if> </if>
<if test="cgrkids!=null and cgrkids!=''">and cgrkid in (${cgrkids})</if> <if test="cid != null">
<if test="startTime!=null">and ctime <![CDATA[ >= ]]> #{startTime}</if> and cid=#{cid}
<if test="endTime!=null">and ctime <![CDATA[ <= ]]> #{endTime}</if> </if>
<if test="cids != null and cids != ''">
and cid in (${cids})
</if>
<if test="cgddid != null and cgddid != ''">
and cgddid=#{cgddid}
</if>
<if test="cgddids != null and cgddids != ''">
and cgddid in (${cgddids})
</if>
<if test="cgrkid != null and cgrkid != ''">
and cgrkid=#{cgrkid}
</if>
<if test="cgrkids != null and cgrkids != ''">
and cgrkid in (${cgrkids})
</if>
<if test="startTime != null">
and ctime <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null">
and ctime <![CDATA[ <= ]]> #{endTime}
</if>
and num > 0
</sql> </sql>
<select id="search" parameterType="com.toesbieya.my.model.vo.search.StockSearch" <select id="search" parameterType="com.toesbieya.my.model.vo.search.StockSearch"
resultType="com.toesbieya.my.model.vo.result.StockSearchResult"> resultType="com.toesbieya.my.model.vo.result.StockSearchResult">
select cid, select cid,
cname, cname,
sum(num) total_num, sum(num) total_num,
sum(num*price) total_price sum(num * price) total_price
from biz_stock from biz_stock
where 1
<include refid="searchCondition"/> <include refid="searchCondition"/>
and num >0
group by cid group by cid
</select> </select>
@ -43,36 +63,40 @@
<select id="export" parameterType="com.toesbieya.my.model.vo.search.StockSearch" <select id="export" parameterType="com.toesbieya.my.model.vo.search.StockSearch"
resultType="com.toesbieya.my.model.vo.export.StockExport"> resultType="com.toesbieya.my.model.vo.export.StockExport">
select a.cid,a.cname,a.total_num,a.total_price,b.cgddid,b.cgrkid,b.price cg_price, select a.cid,
from_unixtime(b.ctime / 1000, '%Y-%m-%d %H:%m:%s') ctime, a.cname,
c.num rk_num, a.total_num,
d.num cg_num a.total_price,
from ( b.cgddid,
select cid, b.cgrkid,
cname, b.price cg_price,
sum(num) total_num, from_unixtime(b.ctime / 1000, '%Y-%m-%d %H:%m:%s') ctime,
sum(num * price) total_price c.num rk_num,
from biz_stock d.num cg_num
where 1 from (
select cid,
cname,
sum(num) total_num,
sum(num * price) total_price
from biz_stock
<include refid="searchCondition"/> <include refid="searchCondition"/>
and num > 0
group by cid group by cid
) a ) a
join biz_stock b using (cid) join biz_stock b using (cid)
left join biz_purchase_inbound_sub c on c.cid = a.cid and c.pid = b.cgrkid left join biz_purchase_inbound_sub c on c.cid = a.cid and c.pid = b.cgrkid
left join biz_purchase_order_sub d on c.cid = d.cid and d.pid = b.cgddid left join biz_purchase_order_sub d on c.cid = d.cid and d.pid = b.cgddid
order by a.cid,b.cgddid desc, b.cgrkid desc order by a.cid, b.cgddid desc, b.cgrkid desc
</select> </select>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="com.toesbieya.my.model.entity.BizStock" <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="com.toesbieya.my.model.entity.BizStock"
useGeneratedKeys="true"> useGeneratedKeys="true">
insert into biz_stock insert into biz_stock
(cid, cname, num, price, ctime, cgrkid, cgddid) (cid, cname, num, price, ctime, cgrkid, cgddid)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.cid,jdbcType=INTEGER}, #{item.cname,jdbcType=VARCHAR}, #{item.num,jdbcType=DECIMAL}, (#{item.cid,jdbcType=INTEGER}, #{item.cname,jdbcType=VARCHAR}, #{item.num,jdbcType=DECIMAL},
#{item.price,jdbcType=DECIMAL}, #{item.ctime,jdbcType=BIGINT}, #{item.cgrkid,jdbcType=VARCHAR}, #{item.price,jdbcType=DECIMAL}, #{item.ctime,jdbcType=BIGINT}, #{item.cgrkid,jdbcType=VARCHAR},
#{item.cgddid,jdbcType=VARCHAR}) #{item.cgddid,jdbcType=VARCHAR})
</foreach> </foreach>
</insert> </insert>

Loading…
Cancel
Save