Browse Source

修改物料编码生产规则

lwx_dev
erdanergou 3 years ago
parent
commit
a3cb836de0
  1. 8
      src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java
  2. 269
      src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml
  3. 6
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java
  4. 269
      target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

8
src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java

@ -321,6 +321,14 @@ public interface MaterialMapper {
List<Material> findMaterialByType(Long oldId);
/**
* 查询当前类型下最大的物料编码
* @param oldId
* @return
*/
String findMaxMaterialCodeForMt(Long oldId);
/**
* 批量查询当前类型下的物料
* @param list

269
src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

@ -7,13 +7,13 @@
<!-- This code was generated by TableGo tools, mark 1 begin. -->
<!-- 字段映射 -->
<resultMap id="materialMap" type="com.dreamchaser.depository_manage.entity.Material">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="depository_id" property="depositoryId" jdbcType="INTEGER" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
<result column="quantity" property="quantity" jdbcType="VARCHAR" />
<result column="price" property="price" jdbcType="INTEGER" />
<result column="type_id" property="materialTypeId" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="INTEGER" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="depository_id" property="depositoryId" jdbcType="INTEGER"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="VARCHAR"/>
<result column="price" property="price" jdbcType="INTEGER"/>
<result column="type_id" property="materialTypeId" jdbcType="INTEGER"/>
<result column="state" property="state" jdbcType="INTEGER"/>
<result column="code" property="code" jdbcType="VARCHAR"/>
<result column="version" property="version" jdbcType="VARCHAR"/>
<result column="amounts" property="amounts" jdbcType="INTEGER"/>
@ -31,14 +31,14 @@
<!-- 字段映射 -->
<resultMap id="InventoryMap" type="com.dreamchaser.depository_manage.entity.Inventory">
<id column="id" property="id" jdbcType="INTEGER" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="mid" property="mid" jdbcType="INTEGER"/>
<result column="depositoryId" property="depositoryId" jdbcType="INTEGER" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
<result column="quantity" property="quantity" jdbcType="VARCHAR" />
<result column="price" property="price" jdbcType="INTEGER" />
<result column="mtid" property="materialTypeId" jdbcType="INTEGER" />
<result column="mstate" property="state" jdbcType="INTEGER" />
<result column="depositoryId" property="depositoryId" jdbcType="INTEGER"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="VARCHAR"/>
<result column="price" property="price" jdbcType="INTEGER"/>
<result column="mtid" property="materialTypeId" jdbcType="INTEGER"/>
<result column="mstate" property="state" jdbcType="INTEGER"/>
<result column="mcode" property="code" jdbcType="VARCHAR"/>
<result column="version" property="version" jdbcType="VARCHAR"/>
<result column="amounts" property="amounts" jdbcType="INTEGER"/>
@ -53,16 +53,15 @@
</resultMap>
<!-- 字段映射-->
<!-- 字段映射-->
<resultMap id="materialAndTypeMap" type="com.dreamchaser.depository_manage.entity.Material">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="depository_id" property="depositoryId" jdbcType="INTEGER" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
<result column="quantity" property="quantity" jdbcType="VARCHAR" />
<result column="price" property="price" jdbcType="VARCHAR" />
<result column="type_id" property="materialTypeId" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="VARCHAR" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="depository_id" property="depositoryId" jdbcType="INTEGER"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="VARCHAR"/>
<result column="price" property="price" jdbcType="VARCHAR"/>
<result column="type_id" property="materialTypeId" jdbcType="INTEGER"/>
<result column="state" property="state" jdbcType="VARCHAR"/>
<result column="code" property="code" jdbcType="VARCHAR"/>
<result column="version" property="version" jdbcType="VARCHAR"/>
<result column="amounts" property="amounts" jdbcType="DOUBLE"/>
@ -74,36 +73,38 @@
<result column="productionPlace" property="productionPlace" jdbcType="VARCHAR"/>
<result column="brand" property="brand" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<association property="materialType" column="typeId" javaType="com.dreamchaser.depository_manage.entity.MaterialType">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="tname" property="tname" jdbcType="VARCHAR" />
<result column="introduce" property="introduce" jdbcType="VARCHAR" />
<association property="materialType" column="typeId"
javaType="com.dreamchaser.depository_manage.entity.MaterialType">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="tname" property="tname" jdbcType="VARCHAR"/>
<result column="introduce" property="introduce" jdbcType="VARCHAR"/>
</association>
<association property="depository" column="depositoryId" javaType="com.dreamchaser.depository_manage.entity.Depository">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="dname" property="dname" jdbcType="VARCHAR" />
<result column="address" property="address" jdbcType="VARCHAR" />
<result column="introduce" property="introduce" jdbcType="VARCHAR" />
<association property="depository" column="depositoryId"
javaType="com.dreamchaser.depository_manage.entity.Depository">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="dname" property="dname" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<result column="introduce" property="introduce" jdbcType="VARCHAR"/>
</association>
</resultMap>
<!-- 当前批次中物料与生产日期字段映射-->
<!-- 当前批次中物料与生产日期字段映射-->
<resultMap id="MaterialAndProducedDate" type="com.dreamchaser.depository_manage.entity.MaterialAndProducedDate">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="inid" property="inid" jdbcType="INTEGER" />
<result column="mid" property="mid" jdbcType="INTEGER" />
<result column="quantity" property="quantity" jdbcType="INTEGER" />
<result column="expendnum" property="expendnum" jdbcType="INTEGER" />
<result column="inventory" property="inventory" jdbcType="INTEGER" />
<result column="producedDate" property="producedDate" jdbcType="INTEGER" />
<result column="barCode" property="barCode" jdbcType="VARCHAR" />
<result column="qrCode" property="qrCode" jdbcType="VARCHAR" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="inid" property="inid" jdbcType="INTEGER"/>
<result column="mid" property="mid" jdbcType="INTEGER"/>
<result column="quantity" property="quantity" jdbcType="INTEGER"/>
<result column="expendnum" property="expendnum" jdbcType="INTEGER"/>
<result column="inventory" property="inventory" jdbcType="INTEGER"/>
<result column="producedDate" property="producedDate" jdbcType="INTEGER"/>
<result column="barCode" property="barCode" jdbcType="VARCHAR"/>
<result column="qrCode" property="qrCode" jdbcType="VARCHAR"/>
</resultMap>
<!-- 条形码与物料对应-->
<!-- 条形码与物料对应-->
<resultMap id="BarCodeAndMaterialMap" type="com.dreamchaser.depository_manage.entity.MaterialAndBarCode">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="price" property="price" jdbcType="INTEGER" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="price" property="price" jdbcType="INTEGER"/>
<result column="texture" property="texture" jdbcType="VARCHAR"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="unit" property="unit" jdbcType="VARCHAR"/>
@ -142,8 +143,7 @@
</sql>
<!-- 表查询字段,用于查询物料与条形码视图-->
<!-- 表查询字段,用于查询物料与条形码视图-->
<sql id="materialAndBarCode">
id,bmcode,mcode,mid,depositoryId,mname,mtid,version,texture,unit,tname,price,shelfLife
</sql>
@ -185,13 +185,13 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
and productionPlace = #{productionPlace}
</if>
<if test="brand != '' and brand != null">
and brand = #{brand}
and brand = #{brand}
</if>
<if test="remark != '' and remark != null">
and remark = #{remark}
@ -202,7 +202,7 @@
<select id="findMaterialByMnameAndVersion" resultMap="materialMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnView" />
<include refid="allColumnsAndTypeNameOnView"/>
from findMaterial
where 1 = 1
<if test="mname != null and mname != ''">
@ -218,11 +218,10 @@
</select>
<!-- 根据条件参数查询数据列表 -->
<select id="findMaterialByCondition" resultMap="materialMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnView" />
<include refid="allColumnsAndTypeNameOnView"/>
from findMaterial
where 1 = 1
<if test="mid != null">
@ -253,7 +252,7 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
@ -273,7 +272,7 @@
</if>
</select>
<!-- 根据物料id查询所有物料与生产日期的对应-->
<!-- 根据物料id查询所有物料与生产日期的对应-->
<select id="findMaterialAndProducedDateByMid" resultMap="MaterialAndProducedDate" parameterType="int">
select
<include refid="allColumnsByMaterialAndProducedDate"/>
@ -281,12 +280,13 @@
where mp.mid = #{mid} and mp.inventory != 0 and producedDate is not null ORDER BY producedDate
</select>
<!-- 根据物料id与生产日期获取对应关系-->
<select id="findMaterialAndProducedDateByMidAndProducedDate" resultMap="MaterialAndProducedDate" parameterType="map">
<!-- 根据物料id与生产日期获取对应关系-->
<select id="findMaterialAndProducedDateByMidAndProducedDate" resultMap="MaterialAndProducedDate"
parameterType="map">
select
<include refid="allColumnsByMaterialAndProducedDate"/>
from materialandproduceddate mp
where 1 = 1
where 1 = 1
<if test="mid != null and mid != ''">
and mp.mid = #{mid}
</if>
@ -298,7 +298,7 @@
<!--根据条件查询库存-->
<select id="findInventory" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where 1 = 1
<if test="mid != null">
@ -332,7 +332,7 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
@ -350,10 +350,10 @@
<!--根据条件查询库存-->
<select id="findInventoryForImport" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
from findInventory
where 1 = 1
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where 1 = 1
<if test="depositoryId != null">
AND depositoryId = #{depositoryId}
</if>
@ -397,7 +397,7 @@
and #{shelfLife} >= m.shelfLife
</if>
<if test="producedDate != null">
and m.producedDate >= #{producedDate}
and m.producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and m.productionPlace = #{productionPlace}
@ -414,7 +414,7 @@
<!--根据条件查询库存数量-->
<select id="findInventoryCount" parameterType="map" resultType="int">
SELECT
count(*)
count(*)
from findInventory
where 1 = 1
<if test="mid != null">
@ -448,7 +448,7 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
@ -462,10 +462,10 @@
</select>
<!-- 根据仓库查询物料-->
<!-- 根据仓库查询物料-->
<select id="findMaterialByDepositorys" resultMap="InventoryMap" parameterType="list">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where depositoryId in
<foreach collection="list" index="index" item="item" open="("
@ -477,7 +477,7 @@
<select id="findMaterialByTypeIds" resultMap="materialMap" parameterType="list">
SELECT
<include refid="allColumns" />
<include refid="allColumns"/>
from material m
where m.type_id in
<foreach collection="list" index="index" item="item" open="("
@ -489,12 +489,12 @@
<select id="findMaterialByTypeIdsAndMname" resultMap="materialMap" parameterType="map">
SELECT
<include refid="allColumns" />
<include refid="allColumns"/>
from material m
where
m.mname like concat('%',#{mname},'%')
and
m.type_id in
m.mname like concat('%',#{mname},'%')
and
m.type_id in
<foreach collection="list" index="index" item="item" open="("
separator="," close=")">
#{item}
@ -504,7 +504,7 @@
<select id="findMaterialByDepositorysAndType" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where depositoryId in
<foreach collection="list" index="index" item="item" open="("
@ -514,10 +514,10 @@
and mtid = #{materialTypeId}
</select>
<!-- 根据条形码查询物料-->
<!-- 根据条形码查询物料-->
<select id="findMaterialByBarCodeByCondition" resultMap="BarCodeAndMaterialMap" parameterType="map">
select
<include refid="materialAndBarCode" />
<include refid="materialAndBarCode"/>
from materialandbarcode
where 1 = 1
<if test="barCode != null and barCode != ''">
@ -548,7 +548,7 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
@ -565,10 +565,10 @@
group by bmcode
</select>
<!-- 根据物料编码code查询对应的二维码-->
<!-- 根据物料编码code查询对应的二维码-->
<select id="findMaterialByBarCodeByMcode" resultMap="BarCodeAndMaterialMap" parameterType="String">
select
<include refid="materialAndBarCode" />
<include refid="materialAndBarCode"/>
from materialandbarcode
where 1 = 1
<if test="mcode != null and mcode != ''">
@ -581,7 +581,7 @@
<select id="findMaterialAndBarCodeByQrCode" resultMap="BarCodeAndMaterialMap" parameterType="map">
select
<include refid="materialAndBarCode" />
<include refid="materialAndBarCode"/>
from materialandbarcode
where 1 = 1
<if test="mcode != null and mcode != ''">
@ -625,12 +625,11 @@
</select>
<!-- 根据仓库查询物料-->
<select id="findMaterialByDepository" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
from findInventory
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where depositoryId = #{depositoryId}
<if test="begin != null and size != null">
LIMIT #{begin},#{size}
@ -649,25 +648,25 @@
<!-- 根据主键查询数据 -->
<select id="findMaterialById" resultMap="materialMap" parameterType="integer">
SELECT
<include refid="allColumns" />
<include refid="allColumns"/>
FROM material m WHERE m.id =#{id}
</select>
<select id="findInventoryById" resultMap="InventoryMap" parameterType="integer">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
FROM findInventory WHERE id =#{mid}
</select>
<select id="findInventoryByMid" resultMap="InventoryMap" parameterType="integer">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
FROM findInventory WHERE mid =#{mid}
</select>
<select id="findInventoryByMidAndDid" resultMap="InventoryMap" parameterType="map">
select
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where
mid = #{mid}
@ -676,7 +675,7 @@
<select id="findInventoryByMidAndDids" resultMap="InventoryMap" parameterType="map">
select
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where
mid = #{mid}
@ -701,10 +700,18 @@
</select>
<select id="findMaxMaterialCodeForMt" resultType="string" parameterType="long">
select
max(code)
from material m
where m.type_id = #{oldId}
</select>
<!-- 根据主键查询数据 -->
<select id="findInventoryByIds" resultMap="InventoryMap" parameterType="list">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
FROM findInventory WHERE id IN
<foreach collection="list" index="index" item="id" open="(" separator="," close=")">
#{id}
@ -714,7 +721,7 @@
<select id="findInventoryByTypeIdsAndMname" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
FROM findInventory
where
mname like concat('%',#{mname},'%')
@ -739,18 +746,19 @@
<!-- 插入数据 -->
<insert id="insertMaterial" useGeneratedKeys="true" keyProperty="id">
<insert id="insertMaterial" useGeneratedKeys="true" keyProperty="id">
INSERT INTO material (
id, depository_id, mname, quantity, price, type_id,code,unit,version,texture,amounts,depositoryCode,producedDate,shelfLife,brand,productionPlace,remark
id, depository_id, mname, quantity, price,
type_id,code,unit,version,texture,amounts,depositoryCode,producedDate,shelfLife,brand,productionPlace,remark
) VALUES (
#{id},
<if test="depositoryId != null">
#{id},
<if test="depositoryId != null">
#{depositoryId},
</if>
<if test="depositoryId == null">
null,
</if>
#{mname},
</if>
<if test="depositoryId == null">
null,
</if>
#{mname},
<if test="quantity != null">
#{quantity},
</if>
@ -763,11 +771,11 @@
<if test="price == null">
0,
</if>
#{materialTypeId},
#{code},
#{unit},
#{version},
#{texture},
#{materialTypeId},
#{code},
#{unit},
#{version},
#{texture},
<if test="amounts != null">
#{amounts},
</if>
@ -780,15 +788,15 @@
<if test="depositoryCode == null">
'',
</if>
#{producedDate},
#{shelfLife},
#{brand},
#{productionPlace},
#{remark}
#{producedDate},
#{shelfLife},
#{brand},
#{productionPlace},
#{remark}
)
</insert>
<!-- 插入数据 -->
<insert id="insertInventory" useGeneratedKeys="true" keyProperty="id">
<insert id="insertInventory" useGeneratedKeys="true" keyProperty="id">
insert into inventory(id,mid,quantity,producedDate,depository_id)
values (
#{id},
@ -837,30 +845,30 @@
</insert>
<!-- 批量插入数据-->
<insert id="insertMaterials" parameterType="list">
<!-- 批量插入数据-->
<insert id="insertMaterials" parameterType="list">
INSERT INTO material (
id, depository_id, mname, quantity, price, type_id,code,unit,version,texture,amounts,depositoryCode
id, depository_id, mname, quantity, price, type_id,code,unit,version,texture,amounts,depositoryCode
) VALUES
<foreach collection="list" index="index" item="item" separator=",">
(
#{item.id},
#{item.depositoryId},
#{item.mname},
#{item.quantity},
#{item.price},
#{item.typeId},
#{item.code},
#{item.unit},
#{item.version},
#{item.texture},
#{item.amounts},
#{item.depositoryCode}
#{item.id},
#{item.depositoryId},
#{item.mname},
#{item.quantity},
#{item.price},
#{item.typeId},
#{item.code},
#{item.unit},
#{item.version},
#{item.texture},
#{item.amounts},
#{item.depositoryCode}
)
</foreach>
</insert>
<!-- 删除映射-->
<!-- 删除映射-->
<delete id="deleteBarCodeAndMaterial" parameterType="map">
delete
from qrcodeandmaterial
@ -879,13 +887,11 @@
</delete>
<update id="updateMaterialAndProducedDate">
update materialandproduceddate
<set>
<if test="inid != null and inid != ''">
inid = #{inid},
inid = #{inid},
</if>
<if test="mid != null and mid != ''">
mid = #{mid},
@ -970,7 +976,7 @@
</if>
<if test="remark != '' and remark != null">
remark = #{remark}
remark = #{remark}
</if>
</set>
WHERE id = #{id}
@ -1027,7 +1033,6 @@
</update>
<!-- 根据主键删除数据 -->
<delete id="deleteMaterialById" parameterType="int">
DELETE FROM material WHERE id = #{id}

6
src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java

@ -112,12 +112,12 @@ public class MaterialServiceImpl implements MaterialService {
Integer typeId = ObjectFormatUtil.toInteger(map.get("typeId").toString());
MaterialType materialTypeById = materialTypeMapper.findMaterialTypeById(typeId);
map.put("materialTypeId", materialTypeById.getOldId());
List<Material> materialByType = materialMapper.findMaterialByType(materialTypeById.getOldId());
String maxCode = materialMapper.findMaxMaterialCodeForMt(materialTypeById.getOldId());
String newCode = "";
if (materialByType == null) {
if (maxCode == null) {
newCode = String.format("%04d", 1);
} else {
newCode = String.format("%04d",Integer.parseInt(materialByType.get(materialByType.size() - 1).getCode()) + 1);
newCode = String.format("%04d",Integer.parseInt(maxCode) + 1);
}
map.put("code",newCode);

269
target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

@ -7,13 +7,13 @@
<!-- This code was generated by TableGo tools, mark 1 begin. -->
<!-- 字段映射 -->
<resultMap id="materialMap" type="com.dreamchaser.depository_manage.entity.Material">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="depository_id" property="depositoryId" jdbcType="INTEGER" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
<result column="quantity" property="quantity" jdbcType="VARCHAR" />
<result column="price" property="price" jdbcType="INTEGER" />
<result column="type_id" property="materialTypeId" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="INTEGER" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="depository_id" property="depositoryId" jdbcType="INTEGER"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="VARCHAR"/>
<result column="price" property="price" jdbcType="INTEGER"/>
<result column="type_id" property="materialTypeId" jdbcType="INTEGER"/>
<result column="state" property="state" jdbcType="INTEGER"/>
<result column="code" property="code" jdbcType="VARCHAR"/>
<result column="version" property="version" jdbcType="VARCHAR"/>
<result column="amounts" property="amounts" jdbcType="INTEGER"/>
@ -31,14 +31,14 @@
<!-- 字段映射 -->
<resultMap id="InventoryMap" type="com.dreamchaser.depository_manage.entity.Inventory">
<id column="id" property="id" jdbcType="INTEGER" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="mid" property="mid" jdbcType="INTEGER"/>
<result column="depositoryId" property="depositoryId" jdbcType="INTEGER" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
<result column="quantity" property="quantity" jdbcType="VARCHAR" />
<result column="price" property="price" jdbcType="INTEGER" />
<result column="mtid" property="materialTypeId" jdbcType="INTEGER" />
<result column="mstate" property="state" jdbcType="INTEGER" />
<result column="depositoryId" property="depositoryId" jdbcType="INTEGER"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="VARCHAR"/>
<result column="price" property="price" jdbcType="INTEGER"/>
<result column="mtid" property="materialTypeId" jdbcType="INTEGER"/>
<result column="mstate" property="state" jdbcType="INTEGER"/>
<result column="mcode" property="code" jdbcType="VARCHAR"/>
<result column="version" property="version" jdbcType="VARCHAR"/>
<result column="amounts" property="amounts" jdbcType="INTEGER"/>
@ -53,16 +53,15 @@
</resultMap>
<!-- 字段映射-->
<!-- 字段映射-->
<resultMap id="materialAndTypeMap" type="com.dreamchaser.depository_manage.entity.Material">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="depository_id" property="depositoryId" jdbcType="INTEGER" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
<result column="quantity" property="quantity" jdbcType="VARCHAR" />
<result column="price" property="price" jdbcType="VARCHAR" />
<result column="type_id" property="materialTypeId" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="VARCHAR" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="depository_id" property="depositoryId" jdbcType="INTEGER"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="VARCHAR"/>
<result column="price" property="price" jdbcType="VARCHAR"/>
<result column="type_id" property="materialTypeId" jdbcType="INTEGER"/>
<result column="state" property="state" jdbcType="VARCHAR"/>
<result column="code" property="code" jdbcType="VARCHAR"/>
<result column="version" property="version" jdbcType="VARCHAR"/>
<result column="amounts" property="amounts" jdbcType="DOUBLE"/>
@ -74,36 +73,38 @@
<result column="productionPlace" property="productionPlace" jdbcType="VARCHAR"/>
<result column="brand" property="brand" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<association property="materialType" column="typeId" javaType="com.dreamchaser.depository_manage.entity.MaterialType">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="tname" property="tname" jdbcType="VARCHAR" />
<result column="introduce" property="introduce" jdbcType="VARCHAR" />
<association property="materialType" column="typeId"
javaType="com.dreamchaser.depository_manage.entity.MaterialType">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="tname" property="tname" jdbcType="VARCHAR"/>
<result column="introduce" property="introduce" jdbcType="VARCHAR"/>
</association>
<association property="depository" column="depositoryId" javaType="com.dreamchaser.depository_manage.entity.Depository">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="dname" property="dname" jdbcType="VARCHAR" />
<result column="address" property="address" jdbcType="VARCHAR" />
<result column="introduce" property="introduce" jdbcType="VARCHAR" />
<association property="depository" column="depositoryId"
javaType="com.dreamchaser.depository_manage.entity.Depository">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="dname" property="dname" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<result column="introduce" property="introduce" jdbcType="VARCHAR"/>
</association>
</resultMap>
<!-- 当前批次中物料与生产日期字段映射-->
<!-- 当前批次中物料与生产日期字段映射-->
<resultMap id="MaterialAndProducedDate" type="com.dreamchaser.depository_manage.entity.MaterialAndProducedDate">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="inid" property="inid" jdbcType="INTEGER" />
<result column="mid" property="mid" jdbcType="INTEGER" />
<result column="quantity" property="quantity" jdbcType="INTEGER" />
<result column="expendnum" property="expendnum" jdbcType="INTEGER" />
<result column="inventory" property="inventory" jdbcType="INTEGER" />
<result column="producedDate" property="producedDate" jdbcType="INTEGER" />
<result column="barCode" property="barCode" jdbcType="VARCHAR" />
<result column="qrCode" property="qrCode" jdbcType="VARCHAR" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="inid" property="inid" jdbcType="INTEGER"/>
<result column="mid" property="mid" jdbcType="INTEGER"/>
<result column="quantity" property="quantity" jdbcType="INTEGER"/>
<result column="expendnum" property="expendnum" jdbcType="INTEGER"/>
<result column="inventory" property="inventory" jdbcType="INTEGER"/>
<result column="producedDate" property="producedDate" jdbcType="INTEGER"/>
<result column="barCode" property="barCode" jdbcType="VARCHAR"/>
<result column="qrCode" property="qrCode" jdbcType="VARCHAR"/>
</resultMap>
<!-- 条形码与物料对应-->
<!-- 条形码与物料对应-->
<resultMap id="BarCodeAndMaterialMap" type="com.dreamchaser.depository_manage.entity.MaterialAndBarCode">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="price" property="price" jdbcType="INTEGER" />
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="price" property="price" jdbcType="INTEGER"/>
<result column="texture" property="texture" jdbcType="VARCHAR"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="unit" property="unit" jdbcType="VARCHAR"/>
@ -142,8 +143,7 @@
</sql>
<!-- 表查询字段,用于查询物料与条形码视图-->
<!-- 表查询字段,用于查询物料与条形码视图-->
<sql id="materialAndBarCode">
id,bmcode,mcode,mid,depositoryId,mname,mtid,version,texture,unit,tname,price,shelfLife
</sql>
@ -185,13 +185,13 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
and productionPlace = #{productionPlace}
</if>
<if test="brand != '' and brand != null">
and brand = #{brand}
and brand = #{brand}
</if>
<if test="remark != '' and remark != null">
and remark = #{remark}
@ -202,7 +202,7 @@
<select id="findMaterialByMnameAndVersion" resultMap="materialMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnView" />
<include refid="allColumnsAndTypeNameOnView"/>
from findMaterial
where 1 = 1
<if test="mname != null and mname != ''">
@ -218,11 +218,10 @@
</select>
<!-- 根据条件参数查询数据列表 -->
<select id="findMaterialByCondition" resultMap="materialMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnView" />
<include refid="allColumnsAndTypeNameOnView"/>
from findMaterial
where 1 = 1
<if test="mid != null">
@ -253,7 +252,7 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
@ -273,7 +272,7 @@
</if>
</select>
<!-- 根据物料id查询所有物料与生产日期的对应-->
<!-- 根据物料id查询所有物料与生产日期的对应-->
<select id="findMaterialAndProducedDateByMid" resultMap="MaterialAndProducedDate" parameterType="int">
select
<include refid="allColumnsByMaterialAndProducedDate"/>
@ -281,12 +280,13 @@
where mp.mid = #{mid} and mp.inventory != 0 and producedDate is not null ORDER BY producedDate
</select>
<!-- 根据物料id与生产日期获取对应关系-->
<select id="findMaterialAndProducedDateByMidAndProducedDate" resultMap="MaterialAndProducedDate" parameterType="map">
<!-- 根据物料id与生产日期获取对应关系-->
<select id="findMaterialAndProducedDateByMidAndProducedDate" resultMap="MaterialAndProducedDate"
parameterType="map">
select
<include refid="allColumnsByMaterialAndProducedDate"/>
from materialandproduceddate mp
where 1 = 1
where 1 = 1
<if test="mid != null and mid != ''">
and mp.mid = #{mid}
</if>
@ -298,7 +298,7 @@
<!--根据条件查询库存-->
<select id="findInventory" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where 1 = 1
<if test="mid != null">
@ -332,7 +332,7 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
@ -350,10 +350,10 @@
<!--根据条件查询库存-->
<select id="findInventoryForImport" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
from findInventory
where 1 = 1
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where 1 = 1
<if test="depositoryId != null">
AND depositoryId = #{depositoryId}
</if>
@ -397,7 +397,7 @@
and #{shelfLife} >= m.shelfLife
</if>
<if test="producedDate != null">
and m.producedDate >= #{producedDate}
and m.producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and m.productionPlace = #{productionPlace}
@ -414,7 +414,7 @@
<!--根据条件查询库存数量-->
<select id="findInventoryCount" parameterType="map" resultType="int">
SELECT
count(*)
count(*)
from findInventory
where 1 = 1
<if test="mid != null">
@ -448,7 +448,7 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
@ -462,10 +462,10 @@
</select>
<!-- 根据仓库查询物料-->
<!-- 根据仓库查询物料-->
<select id="findMaterialByDepositorys" resultMap="InventoryMap" parameterType="list">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where depositoryId in
<foreach collection="list" index="index" item="item" open="("
@ -477,7 +477,7 @@
<select id="findMaterialByTypeIds" resultMap="materialMap" parameterType="list">
SELECT
<include refid="allColumns" />
<include refid="allColumns"/>
from material m
where m.type_id in
<foreach collection="list" index="index" item="item" open="("
@ -489,12 +489,12 @@
<select id="findMaterialByTypeIdsAndMname" resultMap="materialMap" parameterType="map">
SELECT
<include refid="allColumns" />
<include refid="allColumns"/>
from material m
where
m.mname like concat('%',#{mname},'%')
and
m.type_id in
m.mname like concat('%',#{mname},'%')
and
m.type_id in
<foreach collection="list" index="index" item="item" open="("
separator="," close=")">
#{item}
@ -504,7 +504,7 @@
<select id="findMaterialByDepositorysAndType" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where depositoryId in
<foreach collection="list" index="index" item="item" open="("
@ -514,10 +514,10 @@
and mtid = #{materialTypeId}
</select>
<!-- 根据条形码查询物料-->
<!-- 根据条形码查询物料-->
<select id="findMaterialByBarCodeByCondition" resultMap="BarCodeAndMaterialMap" parameterType="map">
select
<include refid="materialAndBarCode" />
<include refid="materialAndBarCode"/>
from materialandbarcode
where 1 = 1
<if test="barCode != null and barCode != ''">
@ -548,7 +548,7 @@
and #{shelfLife} >= shelfLife
</if>
<if test="producedDate != null">
and producedDate >= #{producedDate}
and producedDate >= #{producedDate}
</if>
<if test="productionPlace != null and productionPlace !=''">
and productionPlace = #{productionPlace}
@ -565,10 +565,10 @@
group by bmcode
</select>
<!-- 根据物料编码code查询对应的二维码-->
<!-- 根据物料编码code查询对应的二维码-->
<select id="findMaterialByBarCodeByMcode" resultMap="BarCodeAndMaterialMap" parameterType="String">
select
<include refid="materialAndBarCode" />
<include refid="materialAndBarCode"/>
from materialandbarcode
where 1 = 1
<if test="mcode != null and mcode != ''">
@ -581,7 +581,7 @@
<select id="findMaterialAndBarCodeByQrCode" resultMap="BarCodeAndMaterialMap" parameterType="map">
select
<include refid="materialAndBarCode" />
<include refid="materialAndBarCode"/>
from materialandbarcode
where 1 = 1
<if test="mcode != null and mcode != ''">
@ -625,12 +625,11 @@
</select>
<!-- 根据仓库查询物料-->
<select id="findMaterialByDepository" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
from findInventory
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where depositoryId = #{depositoryId}
<if test="begin != null and size != null">
LIMIT #{begin},#{size}
@ -649,25 +648,25 @@
<!-- 根据主键查询数据 -->
<select id="findMaterialById" resultMap="materialMap" parameterType="integer">
SELECT
<include refid="allColumns" />
<include refid="allColumns"/>
FROM material m WHERE m.id =#{id}
</select>
<select id="findInventoryById" resultMap="InventoryMap" parameterType="integer">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
FROM findInventory WHERE id =#{mid}
</select>
<select id="findInventoryByMid" resultMap="InventoryMap" parameterType="integer">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
FROM findInventory WHERE mid =#{mid}
</select>
<select id="findInventoryByMidAndDid" resultMap="InventoryMap" parameterType="map">
select
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where
mid = #{mid}
@ -676,7 +675,7 @@
<select id="findInventoryByMidAndDids" resultMap="InventoryMap" parameterType="map">
select
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
from findInventory
where
mid = #{mid}
@ -701,10 +700,18 @@
</select>
<select id="findMaxMaterialCodeForMt" resultType="string" parameterType="long">
select
max(code)
from material m
where m.type_id = #{oldId}
</select>
<!-- 根据主键查询数据 -->
<select id="findInventoryByIds" resultMap="InventoryMap" parameterType="list">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
FROM findInventory WHERE id IN
<foreach collection="list" index="index" item="id" open="(" separator="," close=")">
#{id}
@ -714,7 +721,7 @@
<select id="findInventoryByTypeIdsAndMname" resultMap="InventoryMap" parameterType="map">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
<include refid="allColumnsAndTypeNameOnViewByInventory"/>
FROM findInventory
where
mname like concat('%',#{mname},'%')
@ -739,18 +746,19 @@
<!-- 插入数据 -->
<insert id="insertMaterial" useGeneratedKeys="true" keyProperty="id">
<insert id="insertMaterial" useGeneratedKeys="true" keyProperty="id">
INSERT INTO material (
id, depository_id, mname, quantity, price, type_id,code,unit,version,texture,amounts,depositoryCode,producedDate,shelfLife,brand,productionPlace,remark
id, depository_id, mname, quantity, price,
type_id,code,unit,version,texture,amounts,depositoryCode,producedDate,shelfLife,brand,productionPlace,remark
) VALUES (
#{id},
<if test="depositoryId != null">
#{id},
<if test="depositoryId != null">
#{depositoryId},
</if>
<if test="depositoryId == null">
null,
</if>
#{mname},
</if>
<if test="depositoryId == null">
null,
</if>
#{mname},
<if test="quantity != null">
#{quantity},
</if>
@ -763,11 +771,11 @@
<if test="price == null">
0,
</if>
#{materialTypeId},
#{code},
#{unit},
#{version},
#{texture},
#{materialTypeId},
#{code},
#{unit},
#{version},
#{texture},
<if test="amounts != null">
#{amounts},
</if>
@ -780,15 +788,15 @@
<if test="depositoryCode == null">
'',
</if>
#{producedDate},
#{shelfLife},
#{brand},
#{productionPlace},
#{remark}
#{producedDate},
#{shelfLife},
#{brand},
#{productionPlace},
#{remark}
)
</insert>
<!-- 插入数据 -->
<insert id="insertInventory" useGeneratedKeys="true" keyProperty="id">
<insert id="insertInventory" useGeneratedKeys="true" keyProperty="id">
insert into inventory(id,mid,quantity,producedDate,depository_id)
values (
#{id},
@ -837,30 +845,30 @@
</insert>
<!-- 批量插入数据-->
<insert id="insertMaterials" parameterType="list">
<!-- 批量插入数据-->
<insert id="insertMaterials" parameterType="list">
INSERT INTO material (
id, depository_id, mname, quantity, price, type_id,code,unit,version,texture,amounts,depositoryCode
id, depository_id, mname, quantity, price, type_id,code,unit,version,texture,amounts,depositoryCode
) VALUES
<foreach collection="list" index="index" item="item" separator=",">
(
#{item.id},
#{item.depositoryId},
#{item.mname},
#{item.quantity},
#{item.price},
#{item.typeId},
#{item.code},
#{item.unit},
#{item.version},
#{item.texture},
#{item.amounts},
#{item.depositoryCode}
#{item.id},
#{item.depositoryId},
#{item.mname},
#{item.quantity},
#{item.price},
#{item.typeId},
#{item.code},
#{item.unit},
#{item.version},
#{item.texture},
#{item.amounts},
#{item.depositoryCode}
)
</foreach>
</insert>
<!-- 删除映射-->
<!-- 删除映射-->
<delete id="deleteBarCodeAndMaterial" parameterType="map">
delete
from qrcodeandmaterial
@ -879,13 +887,11 @@
</delete>
<update id="updateMaterialAndProducedDate">
update materialandproduceddate
<set>
<if test="inid != null and inid != ''">
inid = #{inid},
inid = #{inid},
</if>
<if test="mid != null and mid != ''">
mid = #{mid},
@ -970,7 +976,7 @@
</if>
<if test="remark != '' and remark != null">
remark = #{remark}
remark = #{remark}
</if>
</set>
WHERE id = #{id}
@ -1027,7 +1033,6 @@
</update>
<!-- 根据主键删除数据 -->
<delete id="deleteMaterialById" parameterType="int">
DELETE FROM material WHERE id = #{id}

Loading…
Cancel
Save