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
4b61eb59
Commit
4b61eb59
authored
Feb 17, 2020
by
季圣华
Browse files
增加商品条码功能
parent
301d053b
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/service/MaterialExtend/MaterialExtendComponent.java
0 → 100644
View file @
4b61eb59
package
com.jsh.erp.service.MaterialExtend
;
import
com.jsh.erp.service.ICommonQuery
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
@Service
(
value
=
"material_extend"
)
@MaterialExtendResource
public
class
MaterialExtendComponent
implements
ICommonQuery
{
@Resource
private
MaterialExtendService
materialExtendService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
materialExtendService
.
getMaterialExtend
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getMaterialList
(
map
);
}
private
List
<?>
getMaterialList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
null
;
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
0L
;
}
@Override
public
int
insert
(
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
{
return
materialExtendService
.
insertMaterialExtend
(
beanJson
,
request
);
}
@Override
public
int
update
(
String
beanJson
,
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
materialExtendService
.
updateMaterialExtend
(
beanJson
,
id
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
materialExtendService
.
deleteMaterialExtend
(
id
,
request
);
}
@Override
public
int
batchDelete
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
materialExtendService
.
batchDeleteMaterialExtendByIds
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
materialExtendService
.
checkIsExist
(
id
,
name
);
}
}
src/main/java/com/jsh/erp/service/MaterialExtend/MaterialExtendResource.java
0 → 100644
View file @
4b61eb59
package
com.jsh.erp.service.MaterialExtend
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo
(
value
=
"materialExtend"
,
type
=
1574012422
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
MaterialExtendResource
{
}
src/main/java/com/jsh/erp/service/MaterialExtend/MaterialExtendService.java
0 → 100644
View file @
4b61eb59
package
com.jsh.erp.service.MaterialExtend
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.MaterialExtend
;
import
com.jsh.erp.datasource.entities.MaterialExtendExample
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.mappers.MaterialExtendMapper
;
import
com.jsh.erp.datasource.mappers.MaterialExtendMapperEx
;
import
com.jsh.erp.datasource.vo.MaterialExtendVo4List
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Service
public
class
MaterialExtendService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialExtendService
.
class
);
@Resource
private
MaterialExtendMapper
materialExtendMapper
;
@Resource
private
MaterialExtendMapperEx
materialExtendMapperEx
;
@Resource
private
LogService
logService
;
@Resource
private
UserService
userService
;
public
MaterialExtend
getMaterialExtend
(
long
id
)
throws
Exception
{
MaterialExtend
result
=
null
;
try
{
result
=
materialExtendMapper
.
selectByPrimaryKey
(
id
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
MaterialExtendVo4List
>
getDetailList
(
Long
materialId
)
{
List
<
MaterialExtendVo4List
>
list
=
null
;
try
{
list
=
materialExtendMapperEx
.
getDetailList
(
materialId
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
MaterialExtend
>
getListByMIds
(
List
<
Long
>
idList
)
{
List
<
MaterialExtend
>
meList
=
null
;
try
{
Long
[]
idArray
=
StringUtil
.
listToLongArray
(
idList
);
if
(
idArray
!=
null
&&
idArray
.
length
>
0
)
{
meList
=
materialExtendMapperEx
.
getListByMId
(
idArray
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
meList
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
String
saveDetials
(
String
inserted
,
String
deleted
,
String
updated
,
Long
materialId
)
throws
Exception
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
logService
.
insertLog
(
"商品价格扩展"
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
request
);
//转为json
JSONArray
insertedJson
=
JSONArray
.
parseArray
(
inserted
);
JSONArray
deletedJson
=
JSONArray
.
parseArray
(
deleted
);
JSONArray
updatedJson
=
JSONArray
.
parseArray
(
updated
);
if
(
null
!=
insertedJson
)
{
for
(
int
i
=
0
;
i
<
insertedJson
.
size
();
i
++)
{
MaterialExtend
materialExtend
=
new
MaterialExtend
();
JSONObject
tempInsertedJson
=
JSONObject
.
parseObject
(
insertedJson
.
getString
(
i
));
materialExtend
.
setMaterialId
(
materialId
);
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"BarCode"
)))
{
materialExtend
.
setBarCode
(
tempInsertedJson
.
getString
(
"BarCode"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"CommodityUnit"
)))
{
materialExtend
.
setCommodityUnit
(
tempInsertedJson
.
getString
(
"CommodityUnit"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"PurchaseDecimal"
)))
{
materialExtend
.
setPurchaseDecimal
(
tempInsertedJson
.
getBigDecimal
(
"PurchaseDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"CommodityDecimal"
)))
{
materialExtend
.
setCommodityDecimal
(
tempInsertedJson
.
getBigDecimal
(
"CommodityDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"WholesaleDecimal"
)))
{
materialExtend
.
setWholesaleDecimal
(
tempInsertedJson
.
getBigDecimal
(
"WholesaleDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"LowDecimal"
)))
{
materialExtend
.
setLowDecimal
(
tempInsertedJson
.
getBigDecimal
(
"LowDecimal"
));
}
this
.
insertMaterialExtend
(
materialExtend
);
}
}
if
(
null
!=
deletedJson
)
{
StringBuffer
bf
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
deletedJson
.
size
();
i
++)
{
JSONObject
tempDeletedJson
=
JSONObject
.
parseObject
(
deletedJson
.
getString
(
i
));
bf
.
append
(
tempDeletedJson
.
getLong
(
"Id"
));
if
(
i
<(
deletedJson
.
size
()-
1
)){
bf
.
append
(
","
);
}
}
this
.
batchDeleteMaterialExtendByIds
(
bf
.
toString
(),
request
);
}
if
(
null
!=
updatedJson
)
{
for
(
int
i
=
0
;
i
<
updatedJson
.
size
();
i
++)
{
JSONObject
tempUpdatedJson
=
JSONObject
.
parseObject
(
updatedJson
.
getString
(
i
));
MaterialExtend
materialExtend
=
new
MaterialExtend
();
materialExtend
.
setId
(
tempUpdatedJson
.
getLong
(
"Id"
));
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"BarCode"
)))
{
materialExtend
.
setBarCode
(
tempUpdatedJson
.
getString
(
"BarCode"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"CommodityUnit"
)))
{
materialExtend
.
setCommodityUnit
(
tempUpdatedJson
.
getString
(
"CommodityUnit"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"PurchaseDecimal"
)))
{
materialExtend
.
setPurchaseDecimal
(
tempUpdatedJson
.
getBigDecimal
(
"PurchaseDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"CommodityDecimal"
)))
{
materialExtend
.
setCommodityDecimal
(
tempUpdatedJson
.
getBigDecimal
(
"CommodityDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"WholesaleDecimal"
)))
{
materialExtend
.
setWholesaleDecimal
(
tempUpdatedJson
.
getBigDecimal
(
"WholesaleDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"LowDecimal"
)))
{
materialExtend
.
setLowDecimal
(
tempUpdatedJson
.
getBigDecimal
(
"LowDecimal"
));
}
this
.
updateMaterialExtend
(
materialExtend
,
request
);
}
}
return
null
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertMaterialExtend
(
MaterialExtend
materialExtend
)
throws
Exception
{
User
user
=
userService
.
getCurrentUser
();
materialExtend
.
setDeleteFlag
(
BusinessConstants
.
DELETE_FLAG_EXISTS
);
materialExtend
.
setCreateTime
(
new
Date
());
materialExtend
.
setUpdateTime
(
new
Date
().
getTime
());
materialExtend
.
setCreateSerial
(
user
.
getLoginame
());
materialExtend
.
setUpdateSerial
(
user
.
getLoginame
());
int
result
=
0
;
try
{
result
=
materialExtendMapper
.
insertSelective
(
materialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateMaterialExtend
(
MaterialExtend
MaterialExtend
,
HttpServletRequest
request
)
throws
Exception
{
User
user
=
userService
.
getCurrentUser
();
MaterialExtend
.
setUpdateTime
(
new
Date
().
getTime
());
MaterialExtend
.
setUpdateSerial
(
user
.
getLoginame
());
int
res
=
0
;
try
{
res
=
materialExtendMapper
.
updateByPrimaryKeySelective
(
MaterialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
res
;
}
public
int
checkIsExist
(
Long
id
,
String
MaterialExtendName
)
throws
Exception
{
MaterialExtendExample
example
=
new
MaterialExtendExample
();
MaterialExtendExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andBarCodeEqualTo
(
MaterialExtendName
);
if
(
id
>
0
)
{
criteria
.
andIdNotEqualTo
(
id
);
}
List
<
MaterialExtend
>
list
=
null
;
try
{
list
=
materialExtendMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
==
null
?
0
:
list
.
size
();
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteMaterialExtend
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
int
result
=
0
;
MaterialExtend
materialExtend
=
new
MaterialExtend
();
materialExtend
.
setId
(
id
);
materialExtend
.
setDeleteFlag
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
Object
userInfo
=
request
.
getSession
().
getAttribute
(
"user"
);
User
user
=
(
User
)
userInfo
;
materialExtend
.
setUpdateTime
(
new
Date
().
getTime
());
materialExtend
.
setUpdateSerial
(
user
.
getLoginame
());
try
{
result
=
materialExtendMapper
.
updateByPrimaryKeySelective
(
materialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialExtendByIds
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
logService
.
insertLog
(
"商品价格扩展"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
ids
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
String
[]
idArray
=
ids
.
split
(
","
);
int
result
=
0
;
try
{
result
=
materialExtendMapperEx
.
batchDeleteMaterialExtendByIds
(
idArray
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
int
insertMaterialExtend
(
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
{
MaterialExtend
materialExtend
=
JSONObject
.
parseObject
(
beanJson
,
MaterialExtend
.
class
);
int
result
=
0
;
try
{
result
=
materialExtendMapper
.
insertSelective
(
materialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
int
updateMaterialExtend
(
String
beanJson
,
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
MaterialExtend
materialExtend
=
JSONObject
.
parseObject
(
beanJson
,
MaterialExtend
.
class
);
int
result
=
0
;
try
{
result
=
materialExtendMapper
.
insertSelective
(
materialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
MaterialExtend
>
getMaterialExtendByTenantAndTime
(
Long
tenantId
,
Long
lastTime
,
Long
syncNum
)
throws
Exception
{
List
<
MaterialExtend
>
list
=
new
ArrayList
<
MaterialExtend
>();
try
{
//先获取最大的时间戳,再查两个时间戳之间的数据,这样同步能够防止丢失数据(应为时间戳有重复)
Long
maxTime
=
materialExtendMapperEx
.
getMaxTimeByTenantAndTime
(
tenantId
,
lastTime
,
syncNum
);
if
(
tenantId
!=
null
&&
lastTime
!=
null
&&
maxTime
!=
null
)
{
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andTenantIdEqualTo
(
tenantId
)
.
andUpdateTimeGreaterThan
(
lastTime
)
.
andUpdateTimeLessThanOrEqualTo
(
maxTime
);
list
=
materialExtendMapper
.
selectByExample
(
example
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
/**
* 根据条码更新零售价
* @param retailPrice
* @param barCode
*/
public
int
updateRetailPriceByCode
(
BigDecimal
retailPrice
,
String
barCode
)
{
int
result
=
0
;
try
{
MaterialExtend
materialExtend
=
new
MaterialExtend
();
materialExtend
.
setCommodityDecimal
(
retailPrice
);
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andBarCodeEqualTo
(
barCode
);
result
=
materialExtendMapper
.
updateByExampleSelective
(
materialExtend
,
example
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
/**
* 根据条码更新进价
* @param purchasePrice
* @param barCode
*/
public
int
updatePurchasePriceByCode
(
BigDecimal
purchasePrice
,
String
barCode
)
{
int
result
=
0
;
try
{
MaterialExtend
materialExtend
=
new
MaterialExtend
();
materialExtend
.
setPurchaseDecimal
(
purchasePrice
);
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andBarCodeEqualTo
(
barCode
);
result
=
materialExtendMapper
.
updateByExampleSelective
(
materialExtend
,
example
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
/**
* 根据条码更新进价
* @param barCode
* @param barCode
*/
public
MaterialExtend
getMaterialExtendByBarCode
(
String
barCode
)
{
MaterialExtend
me
=
new
MaterialExtend
();
try
{
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andBarCodeEqualTo
(
barCode
);
List
<
MaterialExtend
>
list
=
materialExtendMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
me
=
list
.
get
(
0
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
me
;
}
}
src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
4b61eb59
...
...
@@ -13,6 +13,7 @@ import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
import
com.jsh.erp.datasource.vo.DepotItemVo4Stock
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.MaterialExtend.MaterialExtendService
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.material.MaterialService
;
import
com.jsh.erp.service.serialNumber.SerialNumberService
;
...
...
@@ -49,6 +50,8 @@ public class DepotItemService {
@Resource
private
MaterialService
materialService
;
@Resource
private
MaterialExtendService
materialExtendService
;
@Resource
SerialNumberMapperEx
serialNumberMapperEx
;
@Resource
private
DepotHeadMapper
depotHeadMapper
;
...
...
@@ -349,20 +352,18 @@ public class DepotItemService {
DepotItem
depotItem
=
new
DepotItem
();
JSONObject
tempInsertedJson
=
JSONObject
.
parseObject
(
insertedJson
.
getString
(
i
));
depotItem
.
setHeaderid
(
headerId
);
depotItem
.
setMaterialid
(
tempInsertedJson
.
getLong
(
"MaterialId"
));
Long
materialExtendId
=
tempInsertedJson
.
getLong
(
"MaterialExtendId"
);
Long
materialId
=
materialExtendService
.
getMaterialExtend
(
materialExtendId
).
getMaterialId
();
depotItem
.
setMaterialid
(
materialId
);
depotItem
.
setMaterialExtendId
(
tempInsertedJson
.
getLong
(
"MaterialExtendId"
));
depotItem
.
setMunit
(
tempInsertedJson
.
getString
(
"Unit"
));
if
(!
StringUtil
.
isEmpty
(
tempInsertedJson
.
get
(
"OperNumber"
).
toString
()))
{
depotItem
.
setOpernumber
(
tempInsertedJson
.
getBigDecimal
(
"OperNumber"
));
try
{
String
Unit
=
tempInsertedJson
.
get
(
"Unit"
).
toString
();
BigDecimal
oNumber
=
tempInsertedJson
.
getBigDecimal
(
"OperNumber"
);
Long
mId
=
Long
.
parseLong
(
tempInsertedJson
.
get
(
"MaterialId"
).
toString
());
/***
* 为什么调用的方法要先把基础单位去掉,去掉之后后续还能获取到?
* */
//以下进行单位换算
// String UnitName = findUnitName(mId); //查询计量单位名称
String
unitName
=
materialService
.
findUnitName
(
mId
);
String
unitName
=
materialService
.
findUnitName
(
materialId
);
//查询计量单位名称
if
(!
StringUtil
.
isEmpty
(
unitName
))
{
String
unitList
=
unitName
.
substring
(
0
,
unitName
.
indexOf
(
"("
));
String
ratioList
=
unitName
.
substring
(
unitName
.
indexOf
(
"("
));
...
...
@@ -484,7 +485,13 @@ public class DepotItemService {
this
.
updateDepotItemWithObj
(
depotItem
);
}
depotItem
.
setId
(
tempUpdatedJson
.
getLong
(
"Id"
));
depotItem
.
setMaterialid
(
tempUpdatedJson
.
getLong
(
"MaterialId"
));
Long
materialId
=
null
;
if
(
StringUtil
.
isExist
(
tempUpdatedJson
.
get
(
"MaterialExtendId"
)))
{
Long
materialExtendId
=
tempUpdatedJson
.
getLong
(
"MaterialExtendId"
);
materialId
=
materialExtendService
.
getMaterialExtend
(
materialExtendId
).
getMaterialId
();
depotItem
.
setMaterialid
(
materialId
);
depotItem
.
setMaterialExtendId
(
tempUpdatedJson
.
getLong
(
"MaterialExtendId"
));
}
depotItem
.
setMunit
(
tempUpdatedJson
.
getString
(
"Unit"
));
if
(!
StringUtil
.
isEmpty
(
tempUpdatedJson
.
get
(
"OperNumber"
).
toString
()))
{
depotItem
.
setOpernumber
(
tempUpdatedJson
.
getBigDecimal
(
"OperNumber"
));
...
...
@@ -493,8 +500,7 @@ public class DepotItemService {
BigDecimal
oNumber
=
tempUpdatedJson
.
getBigDecimal
(
"OperNumber"
);
Long
mId
=
Long
.
parseLong
(
tempUpdatedJson
.
get
(
"MaterialId"
).
toString
());
//以下进行单位换算
// String UnitName = findUnitName(mId); //查询计量单位名称
String
unitName
=
materialService
.
findUnitName
(
mId
);
String
unitName
=
materialService
.
findUnitName
(
mId
);
//查询计量单位名称
if
(!
StringUtil
.
isEmpty
(
unitName
))
{
String
unitList
=
unitName
.
substring
(
0
,
unitName
.
indexOf
(
"("
));
String
ratioList
=
unitName
.
substring
(
unitName
.
indexOf
(
"("
));
...
...
src/main/java/com/jsh/erp/service/material/MaterialComponent.java
View file @
4b61eb59
...
...
@@ -33,21 +33,22 @@ public class MaterialComponent implements ICommonQuery {
private
List
<?>
getMaterialList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
String
standard
=
StringUtil
.
getInfo
(
search
,
"standard"
);
String
model
=
StringUtil
.
getInfo
(
search
,
"model"
);
String
categoryIds
=
StringUtil
.
getInfo
(
search
,
"categoryIds"
);
String
mpList
=
StringUtil
.
getInfo
(
search
,
"mpList"
);
String
order
=
QueryUtils
.
order
(
map
);
return
materialService
.
select
(
name
,
model
,
categoryIds
,
mpList
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
));
return
materialService
.
select
(
name
,
standard
,
model
,
categoryIds
,
mpList
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
));
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
String
standard
=
StringUtil
.
getInfo
(
search
,
"standard"
);
String
model
=
StringUtil
.
getInfo
(
search
,
"model"
);
String
categoryIds
=
StringUtil
.
getInfo
(
search
,
"categoryIds"
);
String
mpList
=
StringUtil
.
getInfo
(
search
,
"mpList"
);
return
materialService
.
countMaterial
(
name
,
model
,
categoryIds
,
mpList
);
return
materialService
.
countMaterial
(
name
,
standard
,
model
,
categoryIds
,
mpList
);
}
@Override
...
...
src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
4b61eb59
...
...
@@ -13,6 +13,7 @@ import com.jsh.erp.datasource.mappers.MaterialMapperEx;
import
com.jsh.erp.datasource.mappers.MaterialStockMapper
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.MaterialExtend.MaterialExtendService
;
import
com.jsh.erp.service.depot.DepotService
;
import
com.jsh.erp.service.depotItem.DepotItemService
;
import
com.jsh.erp.service.log.LogService
;
...
...
@@ -59,6 +60,8 @@ public class MaterialService {
private
MaterialStockMapper
materialStockMapper
;
@Resource
private
DepotService
depotService
;
@Resource
private
MaterialExtendService
materialExtendService
;
public
Material
getMaterial
(
long
id
)
throws
Exception
{
Material
result
=
null
;
...
...
@@ -82,27 +85,26 @@ public class MaterialService {
return
list
;
}
public
List
<
MaterialVo4Unit
>
select
(
String
name
,
String
model
,
String
categoryIds
,
String
mpList
,
int
offset
,
int
rows
)
public
List
<
MaterialVo4Unit
>
select
(
String
name
,
String
standard
,
String
model
,
String
categoryIds
,
String
mpList
,
int
offset
,
int
rows
)
throws
Exception
{
String
[]
mpArr
=
mpList
.
split
(
","
);
List
<
MaterialVo4Unit
>
resList
=
new
ArrayList
<
MaterialVo4Unit
>();
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
list
=
materialMapperEx
.
selectByConditionMaterial
(
name
,
model
,
categoryIds
,
mpList
,
offset
,
rows
);
list
=
materialMapperEx
.
selectByConditionMaterial
(
name
,
standard
,
model
,
categoryIds
,
mpList
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
null
!=
list
)
{
List
<
Long
>
idList
=
new
ArrayList
<
Long
>();
for
(
MaterialVo4Unit
m
:
list
)
{
idList
.
add
(
m
.
getId
());
}
List
<
MaterialExtend
>
meList
=
materialExtendService
.
getListByMIds
(
idList
);
for
(
MaterialVo4Unit
m
:
list
)
{
//扩展信息
String
materialOther
=
""
;
for
(
int
i
=
0
;
i
<
mpArr
.
length
;
i
++)
{
if
(
mpArr
[
i
].
equals
(
"颜色"
))
{
materialOther
=
materialOther
+
((
m
.
getColor
()
==
null
||
m
.
getColor
().
equals
(
""
))
?
""
:
"("
+
m
.
getColor
()
+
")"
);
}
if
(
mpArr
[
i
].
equals
(
"规格"
))
{
materialOther
=
materialOther
+
((
m
.
getStandard
()
==
null
||
m
.
getStandard
().
equals
(
""
))
?
""
:
"("
+
m
.
getStandard
()
+
")"
);
}
if
(
mpArr
[
i
].
equals
(
"制造商"
))
{
materialOther
=
materialOther
+
((
m
.
getMfrs
()
==
null
||
m
.
getMfrs
().
equals
(
""
))
?
""
:
"("
+
m
.
getMfrs
()
+
")"
);
}
...
...
@@ -119,16 +121,24 @@ public class MaterialService {
m
.
setMaterialOther
(
materialOther
);
Long
tenantId
=
m
.
getTenantId
();
m
.
setStock
(
depotItemService
.
getStockByParam
(
null
,
m
.
getId
(),
null
,
null
,
tenantId
));
for
(
MaterialExtend
me:
meList
)
{
if
(
me
.
getMaterialId
().
longValue
()
==
m
.
getId
().
longValue
())
{
m
.
setPurchaseDecimal
(
me
.
getPurchaseDecimal
());
//采购价
m
.
setCommodityDecimal
(
me
.
getCommodityDecimal
());
//零售价
m
.
setWholesaleDecimal
(
me
.
getWholesaleDecimal
());
//销售价
m
.
setLowDecimal
(
me
.
getLowDecimal
());
//最低售价
}
}
resList
.
add
(
m
);
}
}
return
resList
;
}
public
Long
countMaterial
(
String
name
,
String
model
,
String
categoryIds
,
String
mpList
)
throws
Exception
{
public
Long
countMaterial
(
String
name
,
String
standard
,
String
model
,
String
categoryIds
,
String
mpList
)
throws
Exception
{
Long
result
=
null
;
try
{
result
=
materialMapperEx
.
countsByMaterial
(
name
,
model
,
categoryIds
,
mpList
);
result
=
materialMapperEx
.
countsByMaterial
(
name
,
standard
,
model
,
categoryIds
,
mpList
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
...
...
@@ -137,13 +147,18 @@ public class MaterialService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertMaterial
(
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
{
Material
material
=
JSONObject
.
parseObject
(
beanJson
,
Material
.
class
);
material
.
setEnabled
(
true
);
int
result
=
0
;
Material
m
=
JSONObject
.
parseObject
(
beanJson
,
Material
.
class
);
m
.
setEnabled
(
true
);
try
{
result
=
materialMapper
.
insertSelective
(
material
);
Long
mId
=
null
;
materialMapper
.
insertSelective
(
m
);
List
<
Material
>
materials
=
getMaterialListByParam
(
m
.
getName
(),
m
.
getModel
(),
m
.
getColor
(),
m
.
getStandard
(),
m
.
getMfrs
(),
m
.
getUnit
(),
m
.
getUnitid
());
if
(
materials
!=
null
&&
materials
.
size
()>
0
)
{
mId
=
materials
.
get
(
0
).
getId
();
}
JSONObject
mObj
=
JSON
.
parseObject
(
beanJson
);
Long
mId
=
material
.
get
Id
(
);
materialExtendService
.
saveDetials
(
mObj
.
getString
(
"inserted"
),
mObj
.
getString
(
"deleted"
),
mObj
.
getString
(
"updated"
),
m
Id
);
if
(
mObj
.
get
(
"stock"
)!=
null
)
{
String
stockStr
=
mObj
.
getString
(
"stock"
);
JSONArray
stockArr
=
JSONArray
.
parseArray
(
stockStr
);
...
...
@@ -159,19 +174,19 @@ public class MaterialService {
}
}
logService
.
insertLog
(
"商品"
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
request
);
return
1
;
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
return
0
;
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateMaterial
(
String
beanJson
,
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
Material
material
=
JSONObject
.
parseObject
(
beanJson
,
Material
.
class
);
material
.
setId
(
id
);
int
res
=
0
;
try
{
res
=
materialMapper
.
updateByPrimaryKeySelective
(
material
);
materialMapper
.
updateByPrimaryKeySelective
(
material
);
Long
unitId
=
material
.
getUnitid
();
if
(
unitId
!=
null
)
{
materialMapperEx
.
updatePriceNullByPrimaryKey
(
id
);
//将价格置空
...
...
@@ -179,6 +194,7 @@ public class MaterialService {
materialMapperEx
.
updateUnitIdNullByPrimaryKey
(
id
);
//将多单位置空
}
JSONObject
mObj
=
JSON
.
parseObject
(
beanJson
);
materialExtendService
.
saveDetials
(
mObj
.
getString
(
"inserted"
),
mObj
.
getString
(
"deleted"
),
mObj
.
getString
(
"updated"
),
id
);
if
(
mObj
.
get
(
"stock"
)!=
null
)
{
String
stockStr
=
mObj
.
getString
(
"stock"
);
JSONArray
stockArr
=
JSONArray
.
parseArray
(
stockStr
);
...
...
@@ -199,11 +215,11 @@ public class MaterialService {
}
logService
.
insertLog
(
"商品"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
id
).
toString
(),
request
);
return
1
;
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
return
0
;
}
return
res
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
...
...
@@ -310,6 +326,16 @@ public class MaterialService {
return
list
;
}
public
List
<
MaterialVo4Unit
>
findByIdWithBarCode
(
Long
meId
)
throws
Exception
{
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
list
=
materialMapperEx
.
findByIdWithBarCode
(
meId
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
MaterialVo4Unit
>
findBySelect
()
throws
Exception
{
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
...
...
@@ -333,6 +359,29 @@ public class MaterialService {
return
list
;
}
public
List
<
MaterialVo4Unit
>
findBySelectWithBarCode
(
String
q
,
Integer
offset
,
Integer
rows
)
throws
Exception
{
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
list
=
materialMapperEx
.
findBySelectWithBarCode
(
q
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
int
findBySelectWithBarCodeCount
(
String
q
)
throws
Exception
{
int
result
=
0
;
try
{
result
=
materialMapperEx
.
findBySelectWithBarCodeCount
(
q
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
result
;
}
public
List
<
MaterialVo4Unit
>
findByAll
(
String
name
,
String
model
,
String
categoryIds
)
throws
Exception
{
List
<
MaterialVo4Unit
>
resList
=
new
ArrayList
<
MaterialVo4Unit
>();
List
<
MaterialVo4Unit
>
list
=
null
;
...
...
@@ -442,8 +491,12 @@ public class MaterialService {
List
<
Material
>
materials
=
getMaterialListByParam
(
m
.
getName
(),
m
.
getModel
(),
m
.
getColor
(),
m
.
getStandard
(),
m
.
getMfrs
(),
m
.
getUnit
(),
m
.
getUnitid
());
if
(
materials
.
size
()<=
0
)
{
materialMapperEx
.
insertSelectiveEx
(
m
);
mId
=
m
.
getId
();
materialMapper
.
insertSelective
(
m
);
List
<
Material
>
newList
=
getMaterialListByParam
(
m
.
getName
(),
m
.
getModel
(),
m
.
getColor
(),
m
.
getStandard
(),
m
.
getMfrs
(),
m
.
getUnit
(),
m
.
getUnitid
());
if
(
newList
!=
null
&&
newList
.
size
()>
0
)
{
mId
=
newList
.
get
(
0
).
getId
();
}
}
else
{
mId
=
materials
.
get
(
0
).
getId
();
String
materialJson
=
JSON
.
toJSONString
(
m
);
...
...
@@ -658,4 +711,19 @@ public class MaterialService {
}
return
stock
;
}
public
List
<
MaterialVo4Unit
>
getMaterialByMeId
(
long
meId
)
{
List
<
MaterialVo4Unit
>
result
=
new
ArrayList
<
MaterialVo4Unit
>();
try
{
result
=
materialMapperEx
.
getMaterialByMeId
(
meId
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
String
getMaxBarCode
()
{
String
maxBarCodeOld
=
materialMapperEx
.
getMaxBarCode
();
return
Long
.
parseLong
(
maxBarCodeOld
)+
""
;
}
}
src/main/java/com/jsh/erp/utils/StringUtil.java
View file @
4b61eb59
...
...
@@ -148,6 +148,13 @@ public class StringUtil {
return
new
String
[
0
];
}
public
static
Long
[]
listToLongArray
(
List
<
Long
>
list
)
{
if
(
list
!=
null
&&
!
list
.
isEmpty
())
{
return
list
.
toArray
(
new
Long
[
list
.
size
()]);
}
return
new
Long
[
0
];
}
public
static
List
<
String
>
stringToListArray
(
String
[]
strings
)
{
if
(
strings
!=
null
&&
strings
.
length
>
0
)
{
return
Arrays
.
asList
(
strings
);
...
...
@@ -223,6 +230,19 @@ public class StringUtil {
return
value
;
}
public
static
boolean
isExist
(
Object
value
)
{
if
(
value
!=
null
)
{
String
str
=
value
.
toString
();
if
(
""
.
equals
(
str
.
trim
()))
{
return
false
;
}
else
{
return
true
;
}
}
else
{
return
false
;
}
}
public
static
void
main
(
String
[]
args
)
{
int
i
=
10
/
3
;
System
.
out
.
println
(
i
);
...
...
src/main/resources/mapper_xml/DepotItemMapper.xml
View file @
4b61eb59
This diff is collapsed.
Click to expand it.
src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
4b61eb59
...
...
@@ -28,6 +28,7 @@
<result
column=
"AnotherDepotName"
jdbcType=
"VARCHAR"
property=
"AnotherDepotName"
/>
<result
column=
"UnitId"
jdbcType=
"BIGINT"
property=
"UnitId"
/>
<result
column=
"UName"
jdbcType=
"VARCHAR"
property=
"UName"
/>
<result
column=
"barCode"
jdbcType=
"VARCHAR"
property=
"barCode"
/>
</resultMap>
<resultMap
extends=
"com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap"
id=
"ResultByMaterial"
type=
"com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx"
>
...
...
@@ -134,9 +135,10 @@
<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,
dp1.name DepotName,dp2.name AnotherDepotName, u.id UnitId, u.UName
dp1.name DepotName,dp2.name AnotherDepotName, u.id UnitId, u.UName
, me.bar_code barCode
from jsh_depotitem di
left join jsh_material m on di.MaterialId=m.id and ifnull(m.delete_Flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_unit u on m.UnitId = u.id and ifnull(u.delete_Flag,'0') !='1'
left join jsh_depot dp1 on di.DepotId=dp1.id and ifnull(dp1.delete_Flag,'0') !='1'
left join jsh_depot dp2 on di.AnotherDepotId=dp2.id and ifnull(dp2.delete_Flag,'0') !='1'
...
...
src/main/resources/mapper_xml/MaterialExtendMapper.xml
0 → 100644
View file @
4b61eb59
This diff is collapsed.
Click to expand it.
src/main/resources/mapper_xml/MaterialExtendMapperEx.xml
0 → 100644
View file @
4b61eb59
This diff is collapsed.
Click to expand it.
src/main/resources/mapper_xml/MaterialMapperEx.xml
View file @
4b61eb59
This diff is collapsed.
Click to expand it.
src/test/resources/generatorConfig.xml
View file @
4b61eb59
...
...
@@ -51,6 +51,7 @@
<table tableName="jsh_inoutitem" domainObjectName="InOutItem"></table>
<table tableName="jsh_log" domainObjectName="Log"></table>
<table tableName="jsh_material" domainObjectName="Material"></table>
<table tableName="jsh_material_extend" domainObjectName="MaterialExtend"></table>
<table tableName="jsh_material_stock" domainObjectName="MaterialStock"></table>
<table tableName="jsh_materialcategory" domainObjectName="MaterialCategory"></table>
<table tableName="jsh_materialproperty" domainObjectName="MaterialProperty"></table>
...
...
Prev
1
2
Next
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