异常封装之单据明细信息后台修改

This commit is contained in:
qiankunpingtai
2019-04-18 15:33:42 +08:00
parent ca6c23f2a3
commit 17cb110836
4 changed files with 367 additions and 132 deletions

View File

@@ -71,7 +71,7 @@ public class DepotHeadController {
* @return
*/
@GetMapping(value = "/buildNumber")
public BaseResponseInfo buildNumber(HttpServletRequest request) {
public BaseResponseInfo buildNumber(HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -93,7 +93,7 @@ public class DepotHeadController {
* @return
*/
@GetMapping(value = "/getMaxId")
public BaseResponseInfo getMaxId(HttpServletRequest request) {
public BaseResponseInfo getMaxId(HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -117,7 +117,7 @@ public class DepotHeadController {
*/
@GetMapping(value = "/findByMonth")
public BaseResponseInfo findByMonth(@RequestParam("monthTime") String monthTime,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -164,7 +164,7 @@ public class DepotHeadController {
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") String type,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -211,7 +211,7 @@ public class DepotHeadController {
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") String type,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -254,7 +254,7 @@ public class DepotHeadController {
@RequestParam("endTime") String endTime,
@RequestParam("organId") Integer organId,
@RequestParam("supType") String supType,
HttpServletRequest request) {
HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -338,7 +338,7 @@ public class DepotHeadController {
public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId,
@RequestParam("endTime") String endTime,
@RequestParam("supType") String supType,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -376,7 +376,7 @@ public class DepotHeadController {
*/
@GetMapping(value = "/getDetailByNumber")
public BaseResponseInfo getDetailByNumber(@RequestParam("number") String number,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
DepotHeadVo4List dhl = new DepotHeadVo4List();
try {
@@ -403,7 +403,7 @@ public class DepotHeadController {
* @param mode 合计或者金额
* @return
*/
public BigDecimal allMoney(String getS, String type, String subType, String mode, String endTime) {
public BigDecimal allMoney(String getS, String type, String subType, String mode, String endTime)throws Exception {
BigDecimal allMoney = BigDecimal.ZERO;
try {
Integer supplierId = Integer.valueOf(getS);

View File

@@ -51,7 +51,7 @@ public class DepotItemController {
@GetMapping(value = "/getHeaderIdByMaterial")
public BaseResponseInfo getHeaderIdByMaterial(@RequestParam("materialParam") String materialParam,
@RequestParam("depotIds") String depotIds,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
List<DepotItemVo4HeaderId> depotItemList = depotItemService.getHeaderIdByMaterial(materialParam, depotIds);
@@ -89,7 +89,7 @@ public class DepotItemController {
public String findDetailByTypeAndMaterialId(
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
@RequestParam("materialId") String mId, HttpServletRequest request) {
@RequestParam("materialId") String mId, HttpServletRequest request)throws Exception {
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
parameterMap.put("mId", mId);
PageQueryInfo queryInfo = new PageQueryInfo();
@@ -139,7 +139,7 @@ public class DepotItemController {
@RequestParam("projectId") Integer pid,
@RequestParam("materialId") String mId,
@RequestParam("monthTime") String monthTime,
HttpServletRequest request) {
HttpServletRequest request) throws Exception{
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
parameterMap.put("mId", mId);
parameterMap.put("monthTime", monthTime);
@@ -203,7 +203,7 @@ public class DepotItemController {
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
@RequestParam("materialId") String mId,
@RequestParam("monthTime") String monthTime,
HttpServletRequest request) {
HttpServletRequest request) throws Exception{
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
parameterMap.put("mId", mId);
parameterMap.put("monthTime", monthTime);
@@ -250,7 +250,7 @@ public class DepotItemController {
* @param mId
* @return
*/
public int sumNumberByMaterialId(String type, Long mId) {
public int sumNumberByMaterialId(String type, Long mId)throws Exception {
int allNumber = 0;
try {
allNumber = depotItemService.findByTypeAndMaterialId(type, mId);
@@ -291,7 +291,7 @@ public class DepotItemController {
*
* @return
*/
public String findUnitName(Long mId) {
public String findUnitName(Long mId)throws Exception {
String unitName = "";
try {
unitName = materialService.findUnitName(mId);
@@ -310,7 +310,7 @@ public class DepotItemController {
@GetMapping(value = "/getDetailList")
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
@RequestParam("mpList") String mpList,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -382,7 +382,7 @@ public class DepotItemController {
*
* @return
*/
public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx) {
public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx)throws Exception {
String materialOther = "";
for (int i = 0; i < mpArr.length; i++) {
if (mpArr[i].equals("颜色")) {
@@ -427,7 +427,7 @@ public class DepotItemController {
@RequestParam("headIds") String headIds,
@RequestParam("materialIds") String materialIds,
@RequestParam("mpList") String mpList,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -497,7 +497,7 @@ public class DepotItemController {
@RequestParam("monthTime") String monthTime,
@RequestParam("headIds") String headIds,
@RequestParam("materialIds") String materialIds,
HttpServletRequest request) {
HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -540,7 +540,7 @@ public class DepotItemController {
@RequestParam("headIds") String headIds,
@RequestParam("materialIds") String materialIds,
@RequestParam("mpList") String mpList,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -600,7 +600,7 @@ public class DepotItemController {
@RequestParam("headIds") String headIds,
@RequestParam("materialIds") String materialIds,
@RequestParam("mpList") String mpList,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
@@ -665,7 +665,7 @@ public class DepotItemController {
@RequestParam("monthTime") String monthTime,
@RequestParam("headIds") String headIds,
@RequestParam("materialIds") String materialIds,
HttpServletRequest request, HttpServletResponse response) {
HttpServletRequest request, HttpServletResponse response)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
String message = "成功";
@@ -731,7 +731,7 @@ public class DepotItemController {
* @param isPrev
* @return
*/
public BigDecimal sumNumber(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
public BigDecimal sumNumber(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception {
BigDecimal sumNumber = BigDecimal.ZERO;
try {
BigDecimal sum = depotItemService.findByType(type, ProjectId, MId, MonthTime, isPrev);
@@ -744,7 +744,7 @@ public class DepotItemController {
return sumNumber;
}
public BigDecimal assembleNumber(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
public BigDecimal assembleNumber(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws Exception{
BigDecimal assembleNumber = BigDecimal.ZERO;
try {
BigDecimal sum = depotItemService.findAssembleByType(subType, mType, ProjectId, MId, MonthTime, isPrev);
@@ -766,7 +766,7 @@ public class DepotItemController {
* @param isPrev
* @return
*/
public BigDecimal sumPrice(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
public BigDecimal sumPrice(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws Exception{
BigDecimal sumPrice = BigDecimal.ZERO;
try {
BigDecimal sum = depotItemService.findPriceByType(type, ProjectId, MId, MonthTime, isPrev);
@@ -779,7 +779,7 @@ public class DepotItemController {
return sumPrice;
}
public BigDecimal sumNumberBuyOrSale(String type, String subType, Long MId, String MonthTime) {
public BigDecimal sumNumberBuyOrSale(String type, String subType, Long MId, String MonthTime)throws Exception {
BigDecimal sumNumber = BigDecimal.ZERO;
String sumType = "Number";
try {
@@ -793,7 +793,7 @@ public class DepotItemController {
return sumNumber;
}
public BigDecimal sumPriceBuyOrSale(String type, String subType, Long MId, String MonthTime) {
public BigDecimal sumPriceBuyOrSale(String type, String subType, Long MId, String MonthTime)throws Exception {
BigDecimal sumPrice = BigDecimal.ZERO;
String sumType = "Price";
try {

View File

@@ -19,16 +19,16 @@ public class DepotItemComponent implements ICommonQuery {
private DepotItemService depotItemService;
@Override
public Object selectOne(String condition) {
public Object selectOne(String condition)throws Exception {
return null;
}
@Override
public List<?> select(Map<String, String> map) {
public List<?> select(Map<String, String> map)throws Exception {
return getDepotItemList(map);
}
private List<?> getDepotItemList(Map<String, String> map) {
private List<?> getDepotItemList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
@@ -38,7 +38,7 @@ public class DepotItemComponent implements ICommonQuery {
}
@Override
public Long counts(Map<String, String> map) {
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
@@ -47,27 +47,27 @@ public class DepotItemComponent implements ICommonQuery {
}
@Override
public int insert(String beanJson, HttpServletRequest request) {
public int insert(String beanJson, HttpServletRequest request)throws Exception {
return depotItemService.insertDepotItem(beanJson, request);
}
@Override
public int update(String beanJson, Long id) {
public int update(String beanJson, Long id)throws Exception {
return depotItemService.updateDepotItem(beanJson, id);
}
@Override
public int delete(Long id) {
public int delete(Long id)throws Exception {
return depotItemService.deleteDepotItem(id);
}
@Override
public int batchDelete(String ids) {
public int batchDelete(String ids)throws Exception {
return depotItemService.batchDeleteDepotItem(ids);
}
@Override
public int checkIsNameExist(Long id, String name) {
public int checkIsNameExist(Long id, String name)throws Exception {
return depotItemService.checkIsNameExist(id, name);
}

View File

@@ -60,175 +60,394 @@ public class DepotItemService {
@Resource
private LogService logService;
public DepotItem getDepotItem(long id) {
return depotItemMapper.selectByPrimaryKey(id);
public DepotItem getDepotItem(long id)throws Exception {
DepotItem result=null;
try{
result=depotItemMapper.selectByPrimaryKey(id);
}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<DepotItem> getDepotItem() {
public List<DepotItem> getDepotItem()throws Exception {
DepotItemExample example = new DepotItemExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return depotItemMapper.selectByExample(example);
List<DepotItem> list=null;
try{
list=depotItemMapper.selectByExample(example);
}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 list;
}
public List<DepotItem> select(String name, Integer type, String remark, int offset, int rows) {
return depotItemMapperEx.selectByConditionDepotItem(name, type, remark, offset, rows);
public List<DepotItem> select(String name, Integer type, String remark, int offset, int rows)throws Exception {
List<DepotItem> list=null;
try{
list=depotItemMapperEx.selectByConditionDepotItem(name, type, remark, offset, rows);
}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 list;
}
public Long countDepotItem(String name, Integer type, String remark) {
return depotItemMapperEx.countsByDepotItem(name, type, remark);
public Long countDepotItem(String name, Integer type, String remark) throws Exception{
Long result =null;
try{
result=depotItemMapperEx.countsByDepotItem(name, type, remark);
}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;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotItem(String beanJson, HttpServletRequest request) {
public int insertDepotItem(String beanJson, HttpServletRequest request)throws Exception {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
return depotItemMapper.insertSelective(depotItem);
int result =0;
try{
result=depotItemMapper.insertSelective(depotItem);
}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;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotItem(String beanJson, Long id) {
public int updateDepotItem(String beanJson, Long id)throws Exception {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
depotItem.setId(id);
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
int result =0;
try{
result=depotItemMapper.updateByPrimaryKeySelective(depotItem);
}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;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepotItem(Long id) {
return depotItemMapper.deleteByPrimaryKey(id);
public int deleteDepotItem(Long id)throws Exception {
int result =0;
try{
result=depotItemMapper.deleteByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotItem(String ids) {
public int batchDeleteDepotItem(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
DepotItemExample example = new DepotItemExample();
example.createCriteria().andIdIn(idList);
return depotItemMapper.deleteByExample(example);
int result =0;
try{
result=depotItemMapper.deleteByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
public int checkIsNameExist(Long id, String name) {
public int checkIsNameExist(Long id, String name)throws Exception {
DepotItemExample example = new DepotItemExample();
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<DepotItem> list = depotItemMapper.selectByExample(example);
return list.size();
List<DepotItem> list =null;
try{
list=depotItemMapper.selectByExample(example);
}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 list==null?0:list.size();
}
public List<DepotItemVo4HeaderId> getHeaderIdByMaterial(String materialParam, String depotIds) {
return depotItemMapperEx.getHeaderIdByMaterial(materialParam, depotIds);
public List<DepotItemVo4HeaderId> getHeaderIdByMaterial(String materialParam, String depotIds)throws Exception {
List<DepotItemVo4HeaderId> list =null;
try{
list = depotItemMapperEx.getHeaderIdByMaterial(materialParam, depotIds);
}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 list;
}
public List<DepotItemVo4DetailByTypeAndMId> findDetailByTypeAndMaterialIdList(Map<String, String> map) {
public List<DepotItemVo4DetailByTypeAndMId> findDetailByTypeAndMaterialIdList(Map<String, String> map)throws Exception {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
return depotItemMapperEx.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map));
List<DepotItemVo4DetailByTypeAndMId> list =null;
try{
list = depotItemMapperEx.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map));
}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 list;
}
public Long findDetailByTypeAndMaterialIdCounts(Map<String, String> map) {
public Long findDetailByTypeAndMaterialIdCounts(Map<String, String> map)throws Exception {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
return depotItemMapperEx.findDetailByTypeAndMaterialIdCounts(mId);
Long result =null;
try{
result = depotItemMapperEx.findDetailByTypeAndMaterialIdCounts(mId);
}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<DepotItemVo4Material> findStockNumByMaterialIdList(Map<String, String> map) {
public List<DepotItemVo4Material> findStockNumByMaterialIdList(Map<String, String> map)throws Exception {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
String monthTime = map.get("monthTime");
return depotItemMapperEx.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map));
List<DepotItemVo4Material> list =null;
try{
list = depotItemMapperEx.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map));
}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 list;
}
public Long findStockNumByMaterialIdCounts(Map<String, String> map) {
public Long findStockNumByMaterialIdCounts(Map<String, String> map)throws Exception {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
String monthTime = map.get("monthTime");
return depotItemMapperEx.findStockNumByMaterialIdCounts(mId, monthTime);
Long result =null;
try{
result = depotItemMapperEx.findStockNumByMaterialIdCounts(mId, monthTime);
}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;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotItemWithObj(DepotItem depotItem) {
return depotItemMapper.insertSelective(depotItem);
public int insertDepotItemWithObj(DepotItem depotItem)throws Exception {
int result =0;
try{
result = depotItemMapper.insertSelective(depotItem);
}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;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotItemWithObj(DepotItem depotItem) {
public int updateDepotItemWithObj(DepotItem depotItem)throws Exception {
int result =0;
try{
result = depotItemMapper.updateByPrimaryKeySelective(depotItem);
}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 depotItemMapper.updateByPrimaryKeySelective(depotItem);
}
public int findByTypeAndMaterialId(String type, Long mId) {
if(type.equals(TYPE)) {
return depotItemMapperEx.findByTypeAndMaterialIdIn(mId);
} else {
return depotItemMapperEx.findByTypeAndMaterialIdOut(mId);
}
}
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId) {
return depotItemMapperEx.getDetailList(headerId);
}
public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows) {
return depotItemMapperEx.findByAll(headIds, materialIds, offset, rows);
}
public int findByAllCount(String headIds, String materialIds) {
return depotItemMapperEx.findByAllCount(headIds, materialIds);
}
public BigDecimal findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapperEx.findByTypeInIsPrev(ProjectId, MId, MonthTime);
public int findByTypeAndMaterialId(String type, Long mId) throws Exception{
int result =0;
try{
if(type.equals(TYPE)) {
result= depotItemMapperEx.findByTypeAndMaterialIdIn(mId);
} else {
return depotItemMapperEx.findByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
return depotItemMapperEx.findByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapperEx.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
result= depotItemMapperEx.findByTypeAndMaterialIdOut(mId);
}
}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 BigDecimal findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapperEx.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapperEx.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
return depotItemMapperEx.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapperEx.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
}
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId)throws Exception {
List<DepotItemVo4WithInfoEx> list =null;
try{
list = depotItemMapperEx.getDetailList(headerId);
}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 list;
}
public BigDecimal findAssembleByType(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (isPrev) {
return depotItemMapperEx.findAssembleIsPrev(subType, mType, ProjectId, MId, MonthTime);
} else {
return depotItemMapperEx.findAssembleIsNotPrev(subType, mType, ProjectId, MId, MonthTime);
public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows)throws Exception {
List<DepotItemVo4WithInfoEx> list =null;
try{
list = depotItemMapperEx.findByAll(headIds, materialIds, offset, rows);
}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 list;
}
public BigDecimal buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) {
if (SUM_TYPE.equals(sumType)) {
return depotItemMapperEx.buyOrSaleNumber(type, subType, MId, MonthTime, sumType);
} else {
return depotItemMapperEx.buyOrSalePrice(type, subType, MId, MonthTime, sumType);
public int findByAllCount(String headIds, String materialIds)throws Exception {
int result=0;
try{
result = depotItemMapperEx.findByAllCount(headIds, materialIds);
}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 BigDecimal findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception {
BigDecimal result=null;
try{
if (TYPE.equals(type)) {
if (isPrev) {
result= depotItemMapperEx.findByTypeInIsPrev(ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
result= depotItemMapperEx.findByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
}
}
}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 BigDecimal findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception {
BigDecimal result=null;
try{
if (TYPE.equals(type)) {
if (isPrev) {
result= depotItemMapperEx.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
result= depotItemMapperEx.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
}
}
}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 BigDecimal findAssembleByType(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception {
BigDecimal result=null;
try{
if (isPrev) {
result= depotItemMapperEx.findAssembleIsPrev(subType, mType, ProjectId, MId, MonthTime);
} else {
result= depotItemMapperEx.findAssembleIsNotPrev(subType, mType, ProjectId, MId, MonthTime);
}
}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 BigDecimal buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) throws Exception{
BigDecimal result=null;
try{
if (SUM_TYPE.equals(sumType)) {
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, MonthTime, sumType);
} else {
result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, MonthTime, sumType);
}
}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;
}
/**
@@ -241,9 +460,16 @@ public class DepotItemService {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_ITEM,
BusinessConstants.LOG_OPERATION_TYPE_ADD,
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//查询单据主表信息
DepotHead depotHead=depotHeadMapper.selectByPrimaryKey(headerId);
DepotHead depotHead=null;
try{
depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
}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);
}
//获得当前操作人
User userInfo=userService.getCurrentUser();
//转为json
@@ -275,8 +501,8 @@ public class DepotItemService {
continue;
}
if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())){
serialNumberMapperEx.cancelSerialNumber(depotItem.getMaterialid(),depotItem.getHeaderid(),(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),
new Date(),userInfo==null?null:userInfo.getId());
serialNumberService.cancelSerialNumber(depotItem.getMaterialid(),depotItem.getHeaderid(),(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),
userInfo);
}
}
this.deleteDepotItem(tempDeletedJson.getLong("Id"));
@@ -416,8 +642,8 @@ public class DepotItemService {
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */
if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())) {
serialNumberMapperEx.cancelSerialNumber(depotItem.getMaterialid(), depotItem.getHeaderid(), (depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),
new Date(), userInfo == null ? null : userInfo.getId());
serialNumberService.cancelSerialNumber(depotItem.getMaterialid(), depotItem.getHeaderid(), (depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),
userInfo);
}
/**收回序列号的时候释放库存*/
depotItem.setOpernumber(BigDecimal.ZERO);
@@ -525,7 +751,7 @@ public class DepotItemService {
*
* @return
*/
public String findUnitName(Long mId) {
public String findUnitName(Long mId) throws Exception{
String unitName = "";
try {
unitName = materialService.findUnitName(mId);
@@ -544,7 +770,7 @@ public class DepotItemService {
* 查询商品当前库存数量是否充足,
*
* */
public int getCurrentInStock(Long materialId){
public int getCurrentInStock(Long materialId)throws Exception{
//入库数量
int inSum = findByTypeAndMaterialId(BusinessConstants.DEPOTHEAD_TYPE_STORAGE, materialId);
//出库数量
@@ -552,12 +778,21 @@ public class DepotItemService {
return (inSum-outSum);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotItemByIds(String ids) {
public int batchDeleteDepotItemByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_ITEM,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
return depotItemMapperEx.batchDeleteDepotItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
int result =0;
try{
result =depotItemMapperEx.batchDeleteDepotItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
}