解决入库单被删之后,关联的订单状态不变的bug
This commit is contained in:
@@ -37,7 +37,7 @@ public class BusinessConstants {
|
|||||||
* 单据主表出入库类型 type 入库 出库
|
* 单据主表出入库类型 type 入库 出库
|
||||||
* depothead
|
* depothead
|
||||||
* */
|
* */
|
||||||
public static final String DEPOTHEAD_TYPE_STORAGE = "入库";
|
public static final String DEPOTHEAD_TYPE_IN = "入库";
|
||||||
public static final String DEPOTHEAD_TYPE_OUT = "出库";
|
public static final String DEPOTHEAD_TYPE_OUT = "出库";
|
||||||
/**
|
/**
|
||||||
* 付款类型 payType //现付/预付款
|
* 付款类型 payType //现付/预付款
|
||||||
|
|||||||
@@ -330,6 +330,12 @@ public class ExceptionConstants {
|
|||||||
//单据删除-只有未审核的单据才能删除
|
//单据删除-只有未审核的单据才能删除
|
||||||
public static final int DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_CODE = 8500011;
|
public static final int DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_CODE = 8500011;
|
||||||
public static final String DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_MSG = "抱歉,只有未审核的单据才能删除";
|
public static final String DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_MSG = "抱歉,只有未审核的单据才能删除";
|
||||||
|
//单据审核-只有未审核的单据才能审核
|
||||||
|
public static final int DEPOT_HEAD_UN_AUDIT_TO_AUDIT_FAILED_CODE = 8500012;
|
||||||
|
public static final String DEPOT_HEAD_UN_AUDIT_TO_AUDIT_FAILED_MSG = "抱歉,只有未审核的单据才能审核";
|
||||||
|
//单据反审核-只有已审核的单据才能反审核
|
||||||
|
public static final int DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_CODE = 8500013;
|
||||||
|
public static final String DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_MSG = "抱歉,只有已审核的单据才能反审核";
|
||||||
/**
|
/**
|
||||||
* 单据明细信息
|
* 单据明细信息
|
||||||
* type = 90
|
* type = 90
|
||||||
|
|||||||
@@ -284,15 +284,28 @@ public class DepotHeadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**删除单据子表数据*/
|
//删除单据子表数据
|
||||||
depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long[]{depotHead.getId()});
|
depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long[]{depotHead.getId()});
|
||||||
|
//删除单据主表信息
|
||||||
|
batchDeleteDepotHeadByIds(depotHead.getId().toString());
|
||||||
|
//将关联的订单置为审核状态-针对采购入库和销售出库
|
||||||
|
if(StringUtil.isNotEmpty(depotHead.getLinkNumber())){
|
||||||
|
if((BusinessConstants.DEPOTHEAD_TYPE_IN.equals(depotHead.getType()) &&
|
||||||
|
BusinessConstants.SUB_TYPE_PURCHASE.equals(depotHead.getSubType()))
|
||||||
|
|| (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType()) &&
|
||||||
|
BusinessConstants.SUB_TYPE_SALES.equals(depotHead.getSubType()))) {
|
||||||
|
DepotHead dh = new DepotHead();
|
||||||
|
dh.setStatus(BusinessConstants.BILLS_STATUS_AUDIT);
|
||||||
|
DepotHeadExample example = new DepotHeadExample();
|
||||||
|
example.createCriteria().andNumberEqualTo(depotHead.getLinkNumber());
|
||||||
|
depotHeadMapper.updateByExampleSelective(dh, example);
|
||||||
|
}
|
||||||
|
}
|
||||||
//更新当前库存
|
//更新当前库存
|
||||||
List<DepotItem> list = depotItemService.getListByHeaderId(depotHead.getId());
|
List<DepotItem> list = depotItemService.getListByHeaderId(depotHead.getId());
|
||||||
for (DepotItem depotItem : list) {
|
for (DepotItem depotItem : list) {
|
||||||
depotItemService.updateCurrentStock(depotItem);
|
depotItemService.updateCurrentStock(depotItem);
|
||||||
}
|
}
|
||||||
/**删除单据主表信息*/
|
|
||||||
batchDeleteDepotHeadByIds(depotHead.getId().toString());
|
|
||||||
} else {
|
} else {
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_CODE,
|
||||||
String.format(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_MSG));
|
String.format(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_MSG));
|
||||||
@@ -350,32 +363,32 @@ public class DepotHeadService {
|
|||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int batchSetStatus(String status, String depotHeadIDs)throws Exception {
|
public int batchSetStatus(String status, String depotHeadIDs)throws Exception {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
try{
|
List<Long> dhIds = new ArrayList<>();
|
||||||
List<Long> dhIds = new ArrayList<>();
|
List<Long> ids = StringUtil.strToLongList(depotHeadIDs);
|
||||||
List<Long> ids = StringUtil.strToLongList(depotHeadIDs);
|
for(Long id: ids) {
|
||||||
for(Long id: ids) {
|
DepotHead depotHead = getDepotHead(id);
|
||||||
DepotHead depotHead = getDepotHead(id);
|
if("0".equals(status)){
|
||||||
if("0".equals(status)){
|
if("1".equals(depotHead.getStatus())) {
|
||||||
if("1".equals(depotHead.getStatus())) {
|
dhIds.add(id);
|
||||||
dhIds.add(id);
|
} else {
|
||||||
}
|
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_CODE,
|
||||||
} else if("1".equals(status)){
|
String.format(ExceptionConstants.DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_MSG));
|
||||||
if("0".equals(depotHead.getStatus())) {
|
}
|
||||||
dhIds.add(id);
|
} else if("1".equals(status)){
|
||||||
}
|
if("0".equals(depotHead.getStatus())) {
|
||||||
|
dhIds.add(id);
|
||||||
|
} else {
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_TO_AUDIT_FAILED_CODE,
|
||||||
|
String.format(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_TO_AUDIT_FAILED_MSG));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(dhIds.size()>0) {
|
}
|
||||||
DepotHead depotHead = new DepotHead();
|
if(dhIds.size()>0) {
|
||||||
depotHead.setStatus(status);
|
DepotHead depotHead = new DepotHead();
|
||||||
DepotHeadExample example = new DepotHeadExample();
|
depotHead.setStatus(status);
|
||||||
example.createCriteria().andIdIn(dhIds);
|
DepotHeadExample example = new DepotHeadExample();
|
||||||
result = depotHeadMapper.updateByExampleSelective(depotHead, example);
|
example.createCriteria().andIdIn(dhIds);
|
||||||
} else {
|
result = depotHeadMapper.updateByExampleSelective(depotHead, example);
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
JshException.writeFail(logger, e);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user