增加销售订单与采购订单的关联
This commit is contained in:
@@ -67,6 +67,12 @@ public class BusinessConstants {
|
||||
public static final String BILLS_STATUS_AUDIT = "1";
|
||||
public static final String BILLS_STATUS_SKIPED = "2";
|
||||
public static final String BILLS_STATUS_SKIPING = "3";
|
||||
/**
|
||||
* 单据-采购状态 purchaseStatus '0'未采购、'2'完成采购、'3'部分采购
|
||||
* */
|
||||
public static final String PURCHASE_STATUS_UN_AUDIT = "0";
|
||||
public static final String PURCHASE_STATUS_SKIPED = "2";
|
||||
public static final String PURCHASE_STATUS_SKIPING = "3";
|
||||
/**
|
||||
* 出入库分类
|
||||
*采购、采购退货、其它、零售、销售、调拨、盘点复盘等
|
||||
|
||||
@@ -168,6 +168,7 @@ public class DepotItemController {
|
||||
@ApiOperation(value = "单据明细列表")
|
||||
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
|
||||
@RequestParam("mpList") String mpList,
|
||||
@RequestParam(value = "linkType", required = false) String linkType,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
@@ -183,6 +184,7 @@ public class DepotItemController {
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", diEx.getId());
|
||||
item.put("materialExtendId", diEx.getMaterialExtendId() == null ? "" : diEx.getMaterialExtendId());
|
||||
item.put("barCode", diEx.getBarCode());
|
||||
item.put("name", diEx.getMName());
|
||||
@@ -212,7 +214,7 @@ public class DepotItemController {
|
||||
item.put("operNumber", diEx.getOperNumber());
|
||||
item.put("basicNumber", diEx.getBasicNumber());
|
||||
item.put("preNumber", diEx.getOperNumber()); //原数量
|
||||
item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialExtendId(), diEx.getHeaderId(), unitInfo, materialUnit)); //已入库|已出库
|
||||
item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialExtendId(), diEx.getHeaderId(), unitInfo, materialUnit, linkType)); //已入库|已出库
|
||||
item.put("unitPrice", diEx.getUnitPrice());
|
||||
item.put("taxUnitPrice", diEx.getTaxUnitPrice());
|
||||
item.put("allPrice", diEx.getAllPrice());
|
||||
|
||||
@@ -54,6 +54,8 @@ public class DepotHead {
|
||||
|
||||
private String status;
|
||||
|
||||
private String purchaseStatus;
|
||||
|
||||
private String linkNumber;
|
||||
|
||||
private Long tenantId;
|
||||
@@ -260,6 +262,14 @@ public class DepotHead {
|
||||
this.status = status == null ? null : status.trim();
|
||||
}
|
||||
|
||||
public String getPurchaseStatus() {
|
||||
return purchaseStatus;
|
||||
}
|
||||
|
||||
public void setPurchaseStatus(String purchaseStatus) {
|
||||
this.purchaseStatus = purchaseStatus == null ? null : purchaseStatus.trim();
|
||||
}
|
||||
|
||||
public String getLinkNumber() {
|
||||
return linkNumber;
|
||||
}
|
||||
|
||||
@@ -1726,6 +1726,76 @@ public class DepotHeadExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusIsNull() {
|
||||
addCriterion("purchase_status is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusIsNotNull() {
|
||||
addCriterion("purchase_status is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusEqualTo(String value) {
|
||||
addCriterion("purchase_status =", value, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusNotEqualTo(String value) {
|
||||
addCriterion("purchase_status <>", value, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusGreaterThan(String value) {
|
||||
addCriterion("purchase_status >", value, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("purchase_status >=", value, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusLessThan(String value) {
|
||||
addCriterion("purchase_status <", value, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusLessThanOrEqualTo(String value) {
|
||||
addCriterion("purchase_status <=", value, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusLike(String value) {
|
||||
addCriterion("purchase_status like", value, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusNotLike(String value) {
|
||||
addCriterion("purchase_status not like", value, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusIn(List<String> values) {
|
||||
addCriterion("purchase_status in", values, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusNotIn(List<String> values) {
|
||||
addCriterion("purchase_status not in", values, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusBetween(String value1, String value2) {
|
||||
addCriterion("purchase_status between", value1, value2, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseStatusNotBetween(String value1, String value2) {
|
||||
addCriterion("purchase_status not between", value1, value2, "purchaseStatus");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkNumberIsNull() {
|
||||
addCriterion("link_number is null");
|
||||
return (Criteria) this;
|
||||
|
||||
@@ -23,6 +23,8 @@ public class SystemConfig {
|
||||
|
||||
private String minusStockFlag;
|
||||
|
||||
private String purchaseBySaleFlag;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
private String deleteFlag;
|
||||
@@ -115,6 +117,14 @@ public class SystemConfig {
|
||||
this.minusStockFlag = minusStockFlag == null ? null : minusStockFlag.trim();
|
||||
}
|
||||
|
||||
public String getPurchaseBySaleFlag() {
|
||||
return purchaseBySaleFlag;
|
||||
}
|
||||
|
||||
public void setPurchaseBySaleFlag(String purchaseBySaleFlag) {
|
||||
this.purchaseBySaleFlag = purchaseBySaleFlag == null ? null : purchaseBySaleFlag.trim();
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
@@ -864,6 +864,76 @@ public class SystemConfigExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagIsNull() {
|
||||
addCriterion("purchase_by_sale_flag is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagIsNotNull() {
|
||||
addCriterion("purchase_by_sale_flag is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagEqualTo(String value) {
|
||||
addCriterion("purchase_by_sale_flag =", value, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagNotEqualTo(String value) {
|
||||
addCriterion("purchase_by_sale_flag <>", value, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagGreaterThan(String value) {
|
||||
addCriterion("purchase_by_sale_flag >", value, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("purchase_by_sale_flag >=", value, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagLessThan(String value) {
|
||||
addCriterion("purchase_by_sale_flag <", value, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagLessThanOrEqualTo(String value) {
|
||||
addCriterion("purchase_by_sale_flag <=", value, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagLike(String value) {
|
||||
addCriterion("purchase_by_sale_flag like", value, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagNotLike(String value) {
|
||||
addCriterion("purchase_by_sale_flag not like", value, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagIn(List<String> values) {
|
||||
addCriterion("purchase_by_sale_flag in", values, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagNotIn(List<String> values) {
|
||||
addCriterion("purchase_by_sale_flag not in", values, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagBetween(String value1, String value2) {
|
||||
addCriterion("purchase_by_sale_flag between", value1, value2, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPurchaseBySaleFlagNotBetween(String value1, String value2) {
|
||||
addCriterion("purchase_by_sale_flag not between", value1, value2, "purchaseBySaleFlag");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdIsNull() {
|
||||
addCriterion("tenant_id is null");
|
||||
return (Criteria) this;
|
||||
|
||||
@@ -325,6 +325,23 @@ public class DepotHeadService {
|
||||
depotHeadMapper.updateByExampleSelective(dh, example);
|
||||
}
|
||||
}
|
||||
//将关联的销售订单单据置为未采购状态-针对销售订单转采购订单的情况
|
||||
if(StringUtil.isNotEmpty(depotHead.getLinkNumber())){
|
||||
if(BusinessConstants.DEPOTHEAD_TYPE_OTHER.equals(depotHead.getType()) &&
|
||||
BusinessConstants.SUB_TYPE_PURCHASE_ORDER.equals(depotHead.getSubType())) {
|
||||
DepotHead dh = new DepotHead();
|
||||
//获取分批操作后单据的商品和商品数量(汇总)
|
||||
List<DepotItemVo4MaterialAndSum> batchList = depotItemMapperEx.getBatchBillDetailMaterialSum(depotHead.getLinkNumber(), depotHead.getType());
|
||||
if(batchList.size()>0) {
|
||||
dh.setPurchaseStatus(BusinessConstants.PURCHASE_STATUS_SKIPING);
|
||||
} else {
|
||||
dh.setPurchaseStatus(BusinessConstants.PURCHASE_STATUS_UN_AUDIT);
|
||||
}
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
example.createCriteria().andNumberEqualTo(depotHead.getLinkNumber());
|
||||
depotHeadMapper.updateByExampleSelective(dh, example);
|
||||
}
|
||||
}
|
||||
//更新当前库存
|
||||
for (DepotItem depotItem : list) {
|
||||
depotItemService.updateCurrentStock(depotItem);
|
||||
@@ -713,6 +730,7 @@ public class DepotHeadService {
|
||||
depotHead.setCreator(userInfo==null?null:userInfo.getId());
|
||||
depotHead.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
|
||||
depotHead.setPurchaseStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
|
||||
depotHead.setPayType(depotHead.getPayType()==null?"现付":depotHead.getPayType());
|
||||
if(StringUtil.isNotEmpty(depotHead.getAccountIdList())){
|
||||
depotHead.setAccountIdList(depotHead.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", ""));
|
||||
|
||||
@@ -566,6 +566,13 @@ public class DepotItemService {
|
||||
changeBillStatus(depotHead, billStatus);
|
||||
}
|
||||
}
|
||||
//如果关联单据号非空则更新订单的状态,此处针对销售订单转采购订单的场景
|
||||
if(BusinessConstants.SUB_TYPE_PURCHASE_ORDER.equals(depotHead.getSubType())) {
|
||||
if(StringUtil.isNotEmpty(depotHead.getLinkNumber())) {
|
||||
String billStatus = getBillStatusByParam(depotHead);
|
||||
changeBillPurchaseStatus(depotHead, billStatus);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_ROW_FAILED_CODE,
|
||||
String.format(ExceptionConstants.DEPOT_HEAD_ROW_FAILED_MSG));
|
||||
@@ -623,6 +630,27 @@ public class DepotItemService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新单据状态,此处针对销售订单转采购订单的场景
|
||||
* @param depotHead
|
||||
* @param billStatus
|
||||
*/
|
||||
public void changeBillPurchaseStatus(DepotHead depotHead, String billStatus) {
|
||||
DepotHead depotHeadOrders = new DepotHead();
|
||||
depotHeadOrders.setPurchaseStatus(billStatus);
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
List<String> linkNumberList = StringUtil.strToStringList(depotHead.getLinkNumber());
|
||||
example.createCriteria().andNumberIn(linkNumberList);
|
||||
try{
|
||||
depotHeadMapper.updateByExampleSelective(depotHeadOrders, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void deleteDepotItemHeadId(Long headerId)throws Exception {
|
||||
try{
|
||||
@@ -810,15 +838,27 @@ public class DepotItemService {
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public BigDecimal getFinishNumber(Long meId, Long headerId, Unit unitInfo, String materialUnit) {
|
||||
public BigDecimal getFinishNumber(Long meId, Long headerId, Unit unitInfo, String materialUnit, String linkType) {
|
||||
String goToType = "";
|
||||
DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
|
||||
String linkNumber = depotHead.getNumber(); //订单号
|
||||
if(BusinessConstants.SUB_TYPE_PURCHASE_ORDER.equals(depotHead.getSubType())) {
|
||||
goToType = BusinessConstants.SUB_TYPE_PURCHASE;
|
||||
}
|
||||
if(BusinessConstants.SUB_TYPE_SALES_ORDER.equals(depotHead.getSubType())) {
|
||||
goToType = BusinessConstants.SUB_TYPE_SALES;
|
||||
if("purchase".equals(linkType)) {
|
||||
if(BusinessConstants.SUB_TYPE_SALES_ORDER.equals(depotHead.getSubType())) {
|
||||
goToType = BusinessConstants.SUB_TYPE_PURCHASE_ORDER;
|
||||
}
|
||||
} else {
|
||||
if(BusinessConstants.PURCHASE_STATUS_SKIPING.equals(depotHead.getPurchaseStatus())) {
|
||||
if(BusinessConstants.SUB_TYPE_SALES_ORDER.equals(depotHead.getSubType())) {
|
||||
goToType = BusinessConstants.SUB_TYPE_PURCHASE_ORDER;
|
||||
}
|
||||
} else {
|
||||
if(BusinessConstants.SUB_TYPE_PURCHASE_ORDER.equals(depotHead.getSubType())) {
|
||||
goToType = BusinessConstants.SUB_TYPE_PURCHASE;
|
||||
}
|
||||
if(BusinessConstants.SUB_TYPE_SALES_ORDER.equals(depotHead.getSubType())) {
|
||||
goToType = BusinessConstants.SUB_TYPE_SALES;
|
||||
}
|
||||
}
|
||||
}
|
||||
BigDecimal count = depotItemMapperEx.getFinishNumber(meId, linkNumber, goToType);
|
||||
//根据多单位情况进行数量的转换
|
||||
|
||||
Reference in New Issue
Block a user