diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java index 20b66e36..d8e2d239 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java @@ -321,6 +321,14 @@ public interface MaterialMapper { List findMaterialByType(Long oldId); + /** + * 查询当前类型下最大的物料编码 + * @param oldId + * @return + */ + String findMaxMaterialCodeForMt(Long oldId); + + /** * 批量查询当前类型下的物料 * @param list diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml index eb6cf945..147cb08c 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml @@ -7,13 +7,13 @@ - - - - - - - + + + + + + + @@ -31,14 +31,14 @@ - + - - - - - - + + + + + + @@ -53,16 +53,15 @@ - - + - - - - - - - + + + + + + + @@ -74,36 +73,38 @@ - - - - + + + + - - - - - + + + + + - + - - - - - - - - - + + + + + + + + + - + - - + + @@ -142,8 +143,7 @@ - - + id,bmcode,mcode,mid,depositoryId,mname,mtid,version,texture,unit,tname,price,shelfLife @@ -185,13 +185,13 @@ and #{shelfLife} >= shelfLife - and producedDate >= #{producedDate} + and producedDate >= #{producedDate} - and productionPlace = #{productionPlace} + and productionPlace = #{productionPlace} - and brand = #{brand} + and brand = #{brand} and remark = #{remark} @@ -202,7 +202,7 @@ - - + - - select from materialandproduceddate mp - where 1 = 1 + where 1 = 1 and mp.mid = #{mid} @@ -298,7 +298,7 @@ - SELECT - - from findInventory - where 1 = 1 + SELECT + + from findInventory + where 1 = 1 AND depositoryId = #{depositoryId} @@ -397,7 +397,7 @@ and #{shelfLife} >= m.shelfLife - and m.producedDate >= #{producedDate} + and m.producedDate >= #{producedDate} and m.productionPlace = #{productionPlace} @@ -414,7 +414,7 @@ - + SELECT - + from findInventory where depositoryId in - + - + select - + from materialandbarcode where 1 = 1 @@ -625,12 +625,11 @@ - SELECT - + FROM material m WHERE m.id =#{id} select - + from findInventory where mid = #{mid} @@ -701,10 +700,18 @@ + + + SELECT - + FROM findInventory where mname like concat('%',#{mname},'%') @@ -739,18 +746,19 @@ - + 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}, - + #{id}, + #{depositoryId}, - - - null, - - #{mname}, + + + null, + + #{mname}, #{quantity}, @@ -763,11 +771,11 @@ 0, - #{materialTypeId}, - #{code}, - #{unit}, - #{version}, - #{texture}, + #{materialTypeId}, + #{code}, + #{unit}, + #{version}, + #{texture}, #{amounts}, @@ -780,15 +788,15 @@ '', - #{producedDate}, - #{shelfLife}, - #{brand}, - #{productionPlace}, - #{remark} + #{producedDate}, + #{shelfLife}, + #{brand}, + #{productionPlace}, + #{remark} ) - + insert into inventory(id,mid,quantity,producedDate,depository_id) values ( #{id}, @@ -837,30 +845,30 @@ - - + + 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 ( - #{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} ) - + delete from qrcodeandmaterial @@ -879,13 +887,11 @@ - - update materialandproduceddate - inid = #{inid}, + inid = #{inid}, mid = #{mid}, @@ -970,7 +976,7 @@ - remark = #{remark} + remark = #{remark} WHERE id = #{id} @@ -1027,7 +1033,6 @@ - DELETE FROM material WHERE id = #{id} diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java index c1ae76c0..82ac4ab7 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java +++ b/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 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); diff --git a/target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml b/target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml index eb6cf945..147cb08c 100644 --- a/target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml +++ b/target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml @@ -7,13 +7,13 @@ - - - - - - - + + + + + + + @@ -31,14 +31,14 @@ - + - - - - - - + + + + + + @@ -53,16 +53,15 @@ - - + - - - - - - - + + + + + + + @@ -74,36 +73,38 @@ - - - - + + + + - - - - - + + + + + - + - - - - - - - - - + + + + + + + + + - + - - + + @@ -142,8 +143,7 @@ - - + id,bmcode,mcode,mid,depositoryId,mname,mtid,version,texture,unit,tname,price,shelfLife @@ -185,13 +185,13 @@ and #{shelfLife} >= shelfLife - and producedDate >= #{producedDate} + and producedDate >= #{producedDate} - and productionPlace = #{productionPlace} + and productionPlace = #{productionPlace} - and brand = #{brand} + and brand = #{brand} and remark = #{remark} @@ -202,7 +202,7 @@ - - + - - select from materialandproduceddate mp - where 1 = 1 + where 1 = 1 and mp.mid = #{mid} @@ -298,7 +298,7 @@ - SELECT - - from findInventory - where 1 = 1 + SELECT + + from findInventory + where 1 = 1 AND depositoryId = #{depositoryId} @@ -397,7 +397,7 @@ and #{shelfLife} >= m.shelfLife - and m.producedDate >= #{producedDate} + and m.producedDate >= #{producedDate} and m.productionPlace = #{productionPlace} @@ -414,7 +414,7 @@ - + SELECT - + from findInventory where depositoryId in - + - + select - + from materialandbarcode where 1 = 1 @@ -625,12 +625,11 @@ - SELECT - + FROM material m WHERE m.id =#{id} select - + from findInventory where mid = #{mid} @@ -701,10 +700,18 @@ + + + SELECT - + FROM findInventory where mname like concat('%',#{mname},'%') @@ -739,18 +746,19 @@ - + 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}, - + #{id}, + #{depositoryId}, - - - null, - - #{mname}, + + + null, + + #{mname}, #{quantity}, @@ -763,11 +771,11 @@ 0, - #{materialTypeId}, - #{code}, - #{unit}, - #{version}, - #{texture}, + #{materialTypeId}, + #{code}, + #{unit}, + #{version}, + #{texture}, #{amounts}, @@ -780,15 +788,15 @@ '', - #{producedDate}, - #{shelfLife}, - #{brand}, - #{productionPlace}, - #{remark} + #{producedDate}, + #{shelfLife}, + #{brand}, + #{productionPlace}, + #{remark} ) - + insert into inventory(id,mid,quantity,producedDate,depository_id) values ( #{id}, @@ -837,30 +845,30 @@ - - + + 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 ( - #{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} ) - + delete from qrcodeandmaterial @@ -879,13 +887,11 @@ - - update materialandproduceddate - inid = #{inid}, + inid = #{inid}, mid = #{mid}, @@ -970,7 +976,7 @@ - remark = #{remark} + remark = #{remark} WHERE id = #{id} @@ -1027,7 +1033,6 @@ - DELETE FROM material WHERE id = #{id}