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
8cc8dea0
Commit
8cc8dea0
authored
Dec 21, 2020
by
季圣华
Browse files
优化单据中计量单位的查询方法
parent
8554fda9
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
8cc8dea0
...
...
@@ -122,27 +122,6 @@ public class DepotItemController {
return
res
;
}
/**
* 查询计量单位信息
*
* @return
*/
public
String
findUnitName
(
Long
mId
)
throws
Exception
{
String
unitName
=
""
;
try
{
unitName
=
materialService
.
findUnitName
(
mId
);
if
(
unitName
!=
null
)
{
unitName
=
unitName
.
substring
(
1
,
unitName
.
length
()
-
1
);
if
(
unitName
.
equals
(
"null"
))
{
unitName
=
""
;
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
unitName
;
}
@GetMapping
(
value
=
"/getDetailList"
)
public
BaseResponseInfo
getDetailList
(
@RequestParam
(
"headerId"
)
Long
headerId
,
@RequestParam
(
"mpList"
)
String
mpList
,
...
...
src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java
View file @
8cc8dea0
...
...
@@ -3,6 +3,7 @@ package com.jsh.erp.datasource.mappers;
import
com.jsh.erp.datasource.entities.AccountHead
;
import
com.jsh.erp.datasource.entities.Material
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
com.jsh.erp.datasource.entities.Unit
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Date
;
...
...
@@ -35,7 +36,7 @@ public interface MaterialMapperEx {
@Param
(
"categoryIds"
)
String
categoryIds
,
@Param
(
"mpList"
)
String
mpList
);
String
findUnit
Name
(
@Param
(
"mId"
)
Long
mId
);
List
<
Unit
>
findUnit
List
(
@Param
(
"mId"
)
Long
mId
);
List
<
MaterialVo4Unit
>
findById
(
@Param
(
"id"
)
Long
id
);
...
...
src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
8cc8dea0
...
...
@@ -329,27 +329,21 @@ public class DepotItemService {
depotItem
.
setMaterialUnit
(
rowObj
.
getString
(
"Unit"
));
if
(
StringUtil
.
isExist
(
rowObj
.
get
(
"OperNumber"
)))
{
depotItem
.
setOperNumber
(
rowObj
.
getBigDecimal
(
"OperNumber"
));
try
{
String
Unit
=
rowObj
.
get
(
"Unit"
).
toString
();
BigDecimal
oNumber
=
rowObj
.
getBigDecimal
(
"OperNumber"
);
//以下进行单位换算
String
unitName
=
materialService
.
findUnitName
(
materialExtend
.
getMaterialId
());
//查询计量单位名称
if
(!
StringUtil
.
isEmpty
(
unitName
))
{
String
unitList
=
unitName
.
substring
(
0
,
unitName
.
indexOf
(
"("
));
String
ratioList
=
unitName
.
substring
(
unitName
.
indexOf
(
"("
));
String
basicUnit
=
unitList
.
substring
(
0
,
unitList
.
indexOf
(
","
));
//基本单位
String
otherUnit
=
unitList
.
substring
(
unitList
.
indexOf
(
","
)
+
1
);
//副单位
Integer
ratio
=
Integer
.
parseInt
(
ratioList
.
substring
(
ratioList
.
indexOf
(
":"
)
+
1
).
replace
(
")"
,
""
));
//比例
if
(
Unit
.
equals
(
basicUnit
))
{
//如果等于基础单位
depotItem
.
setBasicNumber
(
oNumber
);
//数量一致
}
else
if
(
Unit
.
equals
(
otherUnit
))
{
//如果等于副单位
depotItem
.
setBasicNumber
(
oNumber
.
multiply
(
new
BigDecimal
(
ratio
))
);
//数量乘以比例
}
}
else
{
depotItem
.
setBasicNumber
(
oNumber
);
//其他情况
String
unit
=
rowObj
.
get
(
"Unit"
).
toString
();
BigDecimal
oNumber
=
rowObj
.
getBigDecimal
(
"OperNumber"
);
//以下进行单位换算
Unit
unitInfo
=
materialService
.
findUnit
(
materialExtend
.
getMaterialId
());
//查询计量单位信息
if
(
StringUtil
.
isNotEmpty
(
unitInfo
.
getName
()))
{
String
basicUnit
=
unitInfo
.
getBasicUnit
();
//基本单位
String
otherUnit
=
unitInfo
.
getOtherUnit
();
//副单位
Integer
ratio
=
unitInfo
.
getRatio
();
//比例
if
(
unit
.
equals
(
basicUnit
))
{
//如果等于基础单位
depotItem
.
setBasicNumber
(
oNumber
);
//数量一致
}
else
if
(
unit
.
equals
(
otherUnit
))
{
//如果等于副单位
depotItem
.
setBasicNumber
(
oNumber
.
multiply
(
new
BigDecimal
(
ratio
))
);
//数量乘以比例
}
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>>>>>>>>>>设置基础数量异常"
,
e
);
}
else
{
depotItem
.
setBasicNumber
(
oNumber
);
//其他情况
}
}
if
(
StringUtil
.
isExist
(
rowObj
.
get
(
"UnitPrice"
)))
{
...
...
@@ -413,26 +407,6 @@ public class DepotItemService {
}
}
}
/**
* 查询计量单位信息
*
* @return
*/
public
String
findUnitName
(
Long
mId
)
throws
Exception
{
String
unitName
=
""
;
try
{
unitName
=
materialService
.
findUnitName
(
mId
);
if
(
unitName
!=
null
)
{
unitName
=
unitName
.
substring
(
1
,
unitName
.
length
()
-
1
);
if
(
unitName
.
equals
(
"null"
))
{
unitName
=
""
;
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
unitName
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
deleteDepotItemHeadId
(
Long
headerId
)
throws
Exception
{
...
...
src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
8cc8dea0
...
...
@@ -310,14 +310,17 @@ public class MaterialService {
return
result
;
}
public
String
findUnit
Name
(
Long
mId
)
throws
Exception
{
String
result
=
null
;
public
Unit
findUnit
(
Long
mId
)
throws
Exception
{
Unit
unit
=
new
Unit
()
;
try
{
result
=
materialMapperEx
.
findUnitName
(
mId
);
List
<
Unit
>
list
=
materialMapperEx
.
findUnitList
(
mId
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
unit
=
list
.
get
(
0
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
resul
t
;
return
uni
t
;
}
public
List
<
MaterialVo4Unit
>
findById
(
Long
id
)
throws
Exception
{
...
...
src/main/resources/mapper_xml/MaterialMapperEx.xml
View file @
8cc8dea0
...
...
@@ -74,8 +74,8 @@
and ifnull(m.delete_flag,'0') !='1'
</select>
<select
id=
"findUnit
Name
"
resultType=
"
java.lang.String
"
>
select u.
name
from jsh_unit u
<select
id=
"findUnit
List
"
resultType=
"
com.jsh.erp.datasource.entities.Unit
"
>
select u.
*
from jsh_unit u
left join jsh_material m on m.unit_id=u.id and ifnull(m.delete_flag,'0') !='1'
where m.id = ${mId}
and ifnull(u.delete_flag,'0') !='1'
...
...
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