优化序列号逻辑,主要针对退货和编辑页面的接口
This commit is contained in:
parent
489040d104
commit
0b5556a0a8
@ -87,6 +87,7 @@ public class BusinessConstants {
|
||||
public static final String SUB_TYPE_PURCHASE_RETURN = "采购退货";
|
||||
public static final String SUB_TYPE_OTHER = "其它";
|
||||
public static final String SUB_TYPE_RETAIL = "零售";
|
||||
public static final String SUB_TYPE_RETAIL_RETURN = "零售退货";
|
||||
public static final String SUB_TYPE_SALES_ORDER = "销售订单";
|
||||
public static final String SUB_TYPE_SALES = "销售";
|
||||
public static final String SUB_TYPE_SALES_RETURN = "销售退货";
|
||||
|
||||
@ -390,6 +390,8 @@ public class DepotItemService {
|
||||
public void saveDetials(String rows, Long headerId, String actionType, HttpServletRequest request) throws Exception{
|
||||
//查询单据主表信息
|
||||
DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
|
||||
//删除序列号和回收序列号
|
||||
deleteOrCancelSerialNumber(actionType, depotHead, headerId);
|
||||
//删除单据的明细
|
||||
deleteDepotItemHeadId(headerId);
|
||||
JSONArray rowArr = JSONArray.parseArray(rows);
|
||||
@ -687,6 +689,37 @@ public class DepotItemService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除序列号和回收序列号
|
||||
* @param actionType
|
||||
* @throws Exception
|
||||
*/
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void deleteOrCancelSerialNumber(String actionType, DepotHead depotHead, Long headerId) throws Exception {
|
||||
if(actionType.equals("update")) {
|
||||
User userInfo = userService.getCurrentUser();
|
||||
if(BusinessConstants.DEPOTHEAD_TYPE_IN.equals(depotHead.getType())){
|
||||
//入库逻辑
|
||||
String number = depotHead.getNumber();
|
||||
SerialNumberExample example = new SerialNumberExample();
|
||||
example.createCriteria().andInBillNoEqualTo(number);
|
||||
serialNumberService.deleteByExample(example);
|
||||
} else if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){
|
||||
//出库逻辑
|
||||
DepotItemExample example = new DepotItemExample();
|
||||
example.createCriteria().andHeaderIdEqualTo(headerId).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<DepotItem> depotItemList = depotItemMapper.selectByExample(example);
|
||||
if(null != depotItemList && depotItemList.size() > 0){
|
||||
for (DepotItem depotItem : depotItemList){
|
||||
if(StringUtil.isNotEmpty(depotItem.getSnList())){
|
||||
serialNumberService.cancelSerialNumber(depotItem.getMaterialId(), depotHead.getNumber(), (depotItem.getBasicNumber() == null ? 0 : depotItem.getBasicNumber()).intValue(), userInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public List<DepotItemStockWarningCount> findStockWarningCount(Integer offset, Integer rows, String materialParam, List<Long> depotList) {
|
||||
List<DepotItemStockWarningCount> list = null;
|
||||
|
||||
@ -398,7 +398,8 @@ public class SerialNumberService {
|
||||
//录入序列号的时候不能重复
|
||||
if ((BusinessConstants.SUB_TYPE_PURCHASE.equals(subType) ||
|
||||
BusinessConstants.SUB_TYPE_OTHER.equals(subType) ||
|
||||
BusinessConstants.SUB_TYPE_SALES_RETURN.equals(subType)) &&
|
||||
BusinessConstants.SUB_TYPE_SALES_RETURN.equals(subType)||
|
||||
BusinessConstants.SUB_TYPE_RETAIL_RETURN.equals(subType)) &&
|
||||
BusinessConstants.DEPOTHEAD_TYPE_IN.equals(type)) {
|
||||
//将中文的逗号批量替换为英文逗号
|
||||
snList = snList.replaceAll(",", ",");
|
||||
@ -406,7 +407,7 @@ public class SerialNumberService {
|
||||
for (String sn : snArr) {
|
||||
List<SerialNumber> list = new ArrayList<>();
|
||||
SerialNumberExample example = new SerialNumberExample();
|
||||
example.createCriteria().andMaterialIdEqualTo(materialId).andSerialNumberEqualTo(sn)
|
||||
example.createCriteria().andMaterialIdEqualTo(materialId).andSerialNumberEqualTo(sn).andIsSellEqualTo("0")
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
list = serialNumberMapper.selectByExample(example);
|
||||
//判断如果不存在重复序列号就新增
|
||||
@ -432,4 +433,12 @@ public class SerialNumberService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接删除序列号
|
||||
* @param example
|
||||
*/
|
||||
public void deleteByExample(SerialNumberExample example) {
|
||||
serialNumberMapper.deleteByExample(example);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user