Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
f90aa299
Commit
f90aa299
authored
Oct 12, 2019
by
季圣华
Browse files
优化商品模块的库存统计
parent
ee839055
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/datasource/entities/MaterialVo4Unit.java
View file @
f90aa299
...
...
@@ -10,7 +10,7 @@ public class MaterialVo4Unit extends Material{
private
String
materialOther
;
private
Long
stock
;
private
BigDecimal
stock
;
public
String
getUnitName
()
{
return
unitName
;
...
...
@@ -36,11 +36,11 @@ public class MaterialVo4Unit extends Material{
this
.
materialOther
=
materialOther
;
}
public
Long
getStock
()
{
public
BigDecimal
getStock
()
{
return
stock
;
}
public
void
setStock
(
Long
stock
)
{
public
void
setStock
(
BigDecimal
stock
)
{
this
.
stock
=
stock
;
}
}
\ No newline at end of file
src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java
View file @
f90aa299
...
...
@@ -36,12 +36,6 @@ public interface DepotItemMapperEx {
Long
findDetailByTypeAndMaterialIdCounts
(
@Param
(
"mId"
)
Long
mId
);
Long
findByTypeAndMaterialIdIn
(
@Param
(
"mId"
)
Long
mId
);
Long
findByTypeAndMaterialIdOut
(
@Param
(
"mId"
)
Long
mId
);
List
<
DepotItemVo4WithInfoEx
>
getDetailList
(
@Param
(
"headerId"
)
Long
headerId
);
...
...
@@ -77,12 +71,10 @@ public interface DepotItemMapperEx {
@Param
(
"tenantId"
)
Long
tenantId
);
/**
* create by: cjl
* description:
* 通过单据主表id查询所有单据子表数据
* create time: 2019/1/24 16:56
* @Param: depotheadId
* @return java.util.List<com.jsh.erp.datasource.entities.DepotItem>
* 通过单据主表id查询所有单据子表数据
* @param depotheadId
* @param enableSerialNumber
* @return
*/
List
<
DepotItem
>
findDepotItemListBydepotheadId
(
@Param
(
"depotheadId"
)
Long
depotheadId
,
@Param
(
"enableSerialNumber"
)
String
enableSerialNumber
);
...
...
@@ -103,7 +95,6 @@ public interface DepotItemMapperEx {
List
<
DepotItem
>
getDepotItemListListByMaterialIds
(
@Param
(
"materialIds"
)
String
[]
materialIds
);
List
<
DepotItemStockWarningCount
>
findStockWarningCount
(
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"rows"
)
Integer
rows
,
@Param
(
"pid"
)
Integer
pid
);
...
...
src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
f90aa299
...
...
@@ -215,20 +215,6 @@ public class DepotItemService {
return
result
;
}
public
Long
findByTypeAndMaterialId
(
String
type
,
Long
mId
)
throws
Exception
{
Long
result
=
0
l
;
try
{
if
(
type
.
equals
(
TYPE
))
{
result
=
depotItemMapperEx
.
findByTypeAndMaterialIdIn
(
mId
);
}
else
{
result
=
depotItemMapperEx
.
findByTypeAndMaterialIdOut
(
mId
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
DepotItemVo4WithInfoEx
>
getDetailList
(
Long
headerId
)
throws
Exception
{
List
<
DepotItemVo4WithInfoEx
>
list
=
null
;
try
{
...
...
src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
f90aa299
...
...
@@ -100,9 +100,8 @@ public class MaterialService {
}
}
m
.
setMaterialOther
(
materialOther
);
Long
InSum
=
depotItemService
.
findByTypeAndMaterialId
(
"入库"
,
m
.
getId
());
Long
OutSum
=
depotItemService
.
findByTypeAndMaterialId
(
"出库"
,
m
.
getId
());
m
.
setStock
(
InSum
-
OutSum
);
Long
tenantId
=
m
.
getTenantId
();
m
.
setStock
(
depotItemService
.
getStockByParam
(
null
,
m
.
getId
(),
null
,
null
,
tenantId
));
resList
.
add
(
m
);
}
}
...
...
src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
f90aa299
...
...
@@ -40,6 +40,7 @@
<result
column=
"PresetPriceOne"
jdbcType=
"DECIMAL"
property=
"presetPriceOne"
/>
<result
column=
"PriceStrategy"
jdbcType=
"VARCHAR"
property=
"priceStrategy"
/>
</resultMap>
<resultMap
id=
"ResultStockWarningCount"
type=
"com.jsh.erp.datasource.vo.DepotItemStockWarningCount"
>
<result
column=
"MaterialName"
jdbcType=
"VARCHAR"
property=
"MaterialName"
/>
<result
column=
"MaterialModel"
jdbcType=
"VARCHAR"
property=
"MaterialModel"
/>
...
...
@@ -76,6 +77,7 @@
limit #{offset},#{rows}
</if>
</select>
<select
id=
"countsByDepotItem"
resultType=
"java.lang.Long"
>
SELECT
COUNT(id)
...
...
@@ -95,12 +97,22 @@
<select
id=
"findDetailByTypeAndMaterialIdList"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"DetailByTypeAndMIdResultMap"
>
select dh.Number,concat(dh.SubType,dh.Type) as newType,
case when type='入库' then ifnull(di.BasicNumber,0) when type='出库' then 0-di.BasicNumber else 0 end as b_num,
case
when type='入库' then ifnull(di.BasicNumber,0)
when type='出库' then 0-di.BasicNumber
when dh.SubType='组装单' and di.MType='组合件' then ifnull(di.BasicNumber,0)
when dh.SubType='组装单' and di.MType='普通子件' then 0-di.BasicNumber
when dh.SubType='拆卸单' and di.MType='普通子件' then ifnull(di.BasicNumber,0)
when dh.SubType='拆卸单' and di.MType='组合件' then 0-di.BasicNumber
else 0
end
as b_num,
date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime
from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
where dh.type!='其它'
and dh.SubType!='调拨'
where ((dh.type!='其它' and dh.SubType!='调拨')
or (dh.type='其它' and dh.SubType='组装单')
or (dh.type='其它' and dh.SubType='拆卸单'))
and di.MaterialId =${mId}
and ifnull(dh.delete_Flag,'0') !='1'
ORDER BY oTime desc
...
...
@@ -108,6 +120,7 @@
limit #{offset},#{rows}
</if>
</select>
<select
id=
"findDetailByTypeAndMaterialIdCounts"
resultType=
"java.lang.Long"
>
select count(1)
from jsh_depothead dh
...
...
@@ -118,23 +131,6 @@
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select
id=
"findByTypeAndMaterialIdIn"
resultType=
"java.lang.Long"
>
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
where dh.type='入库'
and di.MaterialId = ${mId}
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select
id=
"findByTypeAndMaterialIdOut"
resultType=
"java.lang.Long"
>
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
where dh.type='出库'
and dh.SubType!='调拨'
and di.MaterialId = ${mId}
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select
id=
"getDetailList"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"ResultWithInfoExMap"
>
select di.*,m.Name MName,m.Model MModel,m.Unit MaterialUnit,m.Color MColor,m.Standard MStandard,m.Mfrs MMfrs,
m.OtherField1 MOtherField1,m.OtherField2 MOtherField2,m.OtherField3 MOtherField3,
...
...
@@ -254,6 +250,7 @@
and ifnull(dep.delete_Flag,'0') !='1'
and ifnull(mat.delete_Flag,'0') !='1'
</select>
<delete
id=
"deleteDepotItemByDepotHeadIds"
>
delete from jsh_depotitem
where 1=1
...
...
@@ -264,6 +261,7 @@
</foreach>
)
</delete>
<update
id=
"batchDeleteDepotItemByDepotHeadIds"
>
update jsh_depotitem
set delete_Flag='1'
...
...
@@ -275,6 +273,7 @@
</foreach>
)
</update>
<update
id=
"batchDeleteDepotItemByIds"
>
update jsh_depotitem
set delete_Flag='1'
...
...
@@ -285,6 +284,7 @@
</foreach>
)
</update>
<select
id=
"getDepotItemListListByDepotIds"
resultMap=
"com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap"
>
select
<include
refid=
"com.jsh.erp.datasource.mappers.DepotItemMapper.Base_Column_List"
/>
...
...
@@ -297,6 +297,7 @@
)
and ifnull(delete_Flag,'0') !='1'
</select>
<select
id=
"getDepotItemListListByMaterialIds"
resultMap=
"com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap"
>
select
<include
refid=
"com.jsh.erp.datasource.mappers.DepotItemMapper.Base_Column_List"
/>
...
...
@@ -310,8 +311,6 @@
and ifnull(delete_Flag,'0') !='1'
</select>
<select
id=
"findStockWarningCount"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"ResultStockWarningCount"
>
SELECT
m. NAME MaterialName,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment