|
@@ -19,6 +19,7 @@ import com.usoftchina.saas.document.entities.Product;
|
|
|
import com.usoftchina.saas.exception.BizException;
|
|
import com.usoftchina.saas.exception.BizException;
|
|
|
import com.usoftchina.saas.page.PageDefault;
|
|
import com.usoftchina.saas.page.PageDefault;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
|
|
+import com.usoftchina.saas.purchase.api.PurchaseService;
|
|
|
import com.usoftchina.saas.sale.dto.*;
|
|
import com.usoftchina.saas.sale.dto.*;
|
|
|
import com.usoftchina.saas.sale.mapper.*;
|
|
import com.usoftchina.saas.sale.mapper.*;
|
|
|
import com.usoftchina.saas.sale.po.Sale;
|
|
import com.usoftchina.saas.sale.po.Sale;
|
|
@@ -29,6 +30,7 @@ import com.usoftchina.saas.sale.service.SaleService;
|
|
|
import com.usoftchina.saas.storage.po.ProdIODetail;
|
|
import com.usoftchina.saas.storage.po.ProdIODetail;
|
|
|
import com.usoftchina.saas.storage.po.ProdInOut;
|
|
import com.usoftchina.saas.storage.po.ProdInOut;
|
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
|
|
|
+import io.swagger.models.auth.In;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -61,6 +63,8 @@ public class SaleServiceImpl implements SaleService{
|
|
|
private ProdInOutService prodInOutService;
|
|
private ProdInOutService prodInOutService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CommonService commonService;
|
|
private CommonService commonService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PurchaseService purchaseService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public PageInfo<SaleList> getListData(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
|
|
public PageInfo<SaleList> getListData(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
|
|
@@ -285,6 +289,12 @@ public class SaleServiceImpl implements SaleService{
|
|
|
if (num > 0) {
|
|
if (num > 0) {
|
|
|
throw new BizException(BizExceptionCode.SALEOUT_UNAUDIT_ERROR);
|
|
throw new BizException(BizExceptionCode.SALEOUT_UNAUDIT_ERROR);
|
|
|
}
|
|
}
|
|
|
|
|
+ //检查是否转采购订单
|
|
|
|
|
+ String purchaseCode = saleMapper.checkIsTurnPurchase(id,BaseContextHolder.getCompanyId());
|
|
|
|
|
+ if (purchaseCode != null && purchaseCode.length()>0){
|
|
|
|
|
+ throw new BizException(BizExceptionCode.SALE_EXISTS_PURCHASE.getCode(),
|
|
|
|
|
+ String.format(BizExceptionCode.SALE_EXISTS_PURCHASE.getMessage(),purchaseCode));
|
|
|
|
|
+ }
|
|
|
singleUnAudit(id);
|
|
singleUnAudit(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -404,6 +414,7 @@ public class SaleServiceImpl implements SaleService{
|
|
|
Integer count = 0;
|
|
Integer count = 0;
|
|
|
double pdQty = 0;
|
|
double pdQty = 0;
|
|
|
double pdYqty = 0;
|
|
double pdYqty = 0;
|
|
|
|
|
+ DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
Sale sale = saleMapper.selectByPrimaryKey(id);
|
|
Sale sale = saleMapper.selectByPrimaryKey(id);
|
|
|
List<SaleDetail> details = saledetailMapper.selectByFK(id);
|
|
List<SaleDetail> details = saledetailMapper.selectByFK(id);
|
|
@@ -478,7 +489,7 @@ public class SaleServiceImpl implements SaleService{
|
|
|
//获取物料默认仓库
|
|
//获取物料默认仓库
|
|
|
Map<String, Object> warehouse = getWareHouseByCode(saleDetail.getSd_prodcode());
|
|
Map<String, Object> warehouse = getWareHouseByCode(saleDetail.getSd_prodcode());
|
|
|
if (null != warehouse) {
|
|
if (null != warehouse) {
|
|
|
- prodIODetail.setPd_whid(warehouse.get("pr_whid") == null ? 0 : Integer.valueOf(warehouse.get("pr_whid").toString()));
|
|
|
|
|
|
|
+ prodIODetail.setPd_whid(warehouse.get("pr_whid") == null ? 0 : Long.valueOf(warehouse.get("pr_whid").toString()));
|
|
|
prodIODetail.setPd_whcode(warehouse.get("pr_whcode") == null ? null : warehouse.get("pr_whcode").toString());
|
|
prodIODetail.setPd_whcode(warehouse.get("pr_whcode") == null ? null : warehouse.get("pr_whcode").toString());
|
|
|
prodIODetail.setPd_whname(warehouse.get("pr_whname") == null ? null : warehouse.get("pr_whname").toString());
|
|
prodIODetail.setPd_whname(warehouse.get("pr_whname") == null ? null : warehouse.get("pr_whname").toString());
|
|
|
}
|
|
}
|
|
@@ -492,8 +503,12 @@ public class SaleServiceImpl implements SaleService{
|
|
|
prodIODetailMapper.updatePDSaleOut(pi_id);
|
|
prodIODetailMapper.updatePDSaleOut(pi_id);
|
|
|
prodInOutMapper.updatePiTotal(pi_id);
|
|
prodInOutMapper.updatePiTotal(pi_id);
|
|
|
//日志记录
|
|
//日志记录
|
|
|
- DocBaseDTO baseDTO = new DocBaseDTO(id, sale.getSa_code(), BillCodeSeq.SALEOUT.getCaller());
|
|
|
|
|
- messageLogService.customizeLog(baseDTO, Operation.TURNPRODOUT);
|
|
|
|
|
|
|
+ DocBaseDTO log = new DocBaseDTO(id, sale.getSa_code(), BillCodeSeq.SALEOUT.getCaller());
|
|
|
|
|
+ messageLogService.customizeLog(log, Operation.TURNPRODOUT);
|
|
|
|
|
+
|
|
|
|
|
+ baseDTO.setId(pi_id);
|
|
|
|
|
+ baseDTO.setCode(pi_inoutno);
|
|
|
|
|
+ baseDTO.setName(BillCodeSeq.SALEOUT.getName());
|
|
|
return baseDTO;
|
|
return baseDTO;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -529,12 +544,22 @@ public class SaleServiceImpl implements SaleService{
|
|
|
Sale sale = saleMapper.selectByPrimaryKey(id);
|
|
Sale sale = saleMapper.selectByPrimaryKey(id);
|
|
|
List<SaleList> dateilList = saleListMapper.selectSaleListByCondition("sa_id="+id,BaseContextHolder.getCompanyId());
|
|
List<SaleList> dateilList = saleListMapper.selectSaleListByCondition("sa_id="+id,BaseContextHolder.getCompanyId());
|
|
|
|
|
|
|
|
|
|
+ //判断是否已转采购单
|
|
|
|
|
+ String purchaseCode = saleMapper.checkIsTurnPurchase(id,BaseContextHolder.getCompanyId());
|
|
|
|
|
+ if (purchaseCode != null && purchaseCode.length()>0){
|
|
|
|
|
+ throw new BizException(BizExceptionCode.SALE_EXISTS_PURCHASE.getCode(),
|
|
|
|
|
+ String.format(BizExceptionCode.SALE_EXISTS_PURCHASE.getMessage(),purchaseCode));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
PurchaseDTO purchase = new PurchaseDTO();
|
|
PurchaseDTO purchase = new PurchaseDTO();
|
|
|
List<PurchaseDetailDTO> listPurchaseDetail = new ArrayList<PurchaseDetailDTO>();
|
|
List<PurchaseDetailDTO> listPurchaseDetail = new ArrayList<PurchaseDetailDTO>();
|
|
|
-
|
|
|
|
|
|
|
+ DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
//销售主表转采购主表
|
|
//销售主表转采购主表
|
|
|
- Result<String> result = maxnumberService.getMaxnumber(BillCodeSeq.PURCHASE.getCaller(),false);
|
|
|
|
|
- purchase.setPu_code(result.getData());
|
|
|
|
|
|
|
+ // Result<String> result = maxnumberService.getMaxnumber(BillCodeSeq.PURCHASE.getCaller(),false);
|
|
|
|
|
+ baseDTO.setId(0l);
|
|
|
|
|
+ baseDTO.setName(BillCodeSeq.PURCHASE.getCaller());
|
|
|
|
|
+ String result = purchaseService.getPurchaseCode(baseDTO);
|
|
|
|
|
+ purchase.setPu_code(result);
|
|
|
purchase.setPu_status(Status.UNAUDITED.getDisplay());
|
|
purchase.setPu_status(Status.UNAUDITED.getDisplay());
|
|
|
purchase.setPu_statuscode(Status.UNAUDITED.toString());
|
|
purchase.setPu_statuscode(Status.UNAUDITED.toString());
|
|
|
purchase.setCompanyId(BaseContextHolder.getCompanyId());
|
|
purchase.setCompanyId(BaseContextHolder.getCompanyId());
|
|
@@ -545,35 +570,31 @@ public class SaleServiceImpl implements SaleService{
|
|
|
|
|
|
|
|
Long purchaseId = purchase.getId();
|
|
Long purchaseId = purchase.getId();
|
|
|
for (SaleList detail : dateilList){
|
|
for (SaleList detail : dateilList){
|
|
|
- PurchaseDetailDTO purchaseDetailDTO = new PurchaseDetailDTO();
|
|
|
|
|
|
|
+ PurchaseDetailDTO purchaseDetail = new PurchaseDetailDTO();
|
|
|
Double taxPrice = detail.getPr_purcprice()==null?new Double(0):Double.valueOf(detail.getPr_purcprice());
|
|
Double taxPrice = detail.getPr_purcprice()==null?new Double(0):Double.valueOf(detail.getPr_purcprice());
|
|
|
Double taxrate = detail.getSd_taxrate()==null?new Double(0):detail.getSd_taxrate();
|
|
Double taxrate = detail.getSd_taxrate()==null?new Double(0):detail.getSd_taxrate();
|
|
|
Double qty = detail.getSd_qty()==null?new Double(0):detail.getSd_qty();
|
|
Double qty = detail.getSd_qty()==null?new Double(0):detail.getSd_qty();
|
|
|
- purchaseDetailDTO.setPd_prodid(Long.valueOf(String.valueOf(detail.getSd_prodid())));
|
|
|
|
|
- purchaseDetailDTO.setPd_prodcode(detail.getSd_prodcode());
|
|
|
|
|
- purchaseDetailDTO.setPd_detno(detail.getSd_detno());
|
|
|
|
|
- purchaseDetailDTO.setPd_qty(detail.getSd_qty());
|
|
|
|
|
- purchaseDetailDTO.setPd_price(taxPrice/(1+taxrate));
|
|
|
|
|
- purchaseDetailDTO.setPd_salecode(sale.getSa_code());
|
|
|
|
|
- purchaseDetailDTO.setPd_saledetno(detail.getSd_detno());
|
|
|
|
|
- purchaseDetailDTO.setPd_taxrate(taxrate);
|
|
|
|
|
- purchaseDetailDTO.setPd_taxprice(taxPrice);
|
|
|
|
|
- purchaseDetailDTO.setPd_taxtotal(taxPrice*qty);
|
|
|
|
|
- purchaseDetailDTO.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
|
|
- purchaseDetailDTO.setCreatorId(BaseContextHolder.getUserId());
|
|
|
|
|
- purchaseDetailDTO.setCreateTime(new Date());
|
|
|
|
|
- purchaseDetailDTO.setCreatorName(BaseContextHolder.getUserName());
|
|
|
|
|
- purchaseDetailDTO.setPd_puid(purchaseId);
|
|
|
|
|
- purchaseDetailDTO.setPd_code(result.getData());
|
|
|
|
|
- listPurchaseDetail.add(purchaseDetailDTO);
|
|
|
|
|
|
|
+ purchaseDetail.setPd_prodid(Long.valueOf(String.valueOf(detail.getSd_prodid())));
|
|
|
|
|
+ purchaseDetail.setPd_prodcode(detail.getSd_prodcode());
|
|
|
|
|
+ purchaseDetail.setPd_detno(detail.getSd_detno());
|
|
|
|
|
+ purchaseDetail.setPd_qty(detail.getSd_qty());
|
|
|
|
|
+ purchaseDetail.setPd_price(taxPrice/(1+taxrate));
|
|
|
|
|
+ purchaseDetail.setPd_salecode(sale.getSa_code());
|
|
|
|
|
+ purchaseDetail.setPd_saledetno(detail.getSd_detno());
|
|
|
|
|
+ purchaseDetail.setPd_saleid(sale.getId());
|
|
|
|
|
+ purchaseDetail.setPd_taxrate(taxrate);
|
|
|
|
|
+ purchaseDetail.setPd_taxprice(taxPrice);
|
|
|
|
|
+ purchaseDetail.setPd_taxtotal(taxPrice*qty);
|
|
|
|
|
+ purchaseDetail.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
|
|
+ purchaseDetail.setCreatorId(BaseContextHolder.getUserId());
|
|
|
|
|
+ purchaseDetail.setCreateTime(new Date());
|
|
|
|
|
+ purchaseDetail.setCreatorName(BaseContextHolder.getUserName());
|
|
|
|
|
+ purchaseDetail.setPd_puid(purchaseId);
|
|
|
|
|
+ purchaseDetail.setPd_code(result);
|
|
|
|
|
+ listPurchaseDetail.add(purchaseDetail);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
saleMapper.turnPurchaseDetail(listPurchaseDetail);
|
|
saleMapper.turnPurchaseDetail(listPurchaseDetail);
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
|
|
- baseDTO.setCode(result.getData());
|
|
|
|
|
|
|
+ baseDTO.setCode(result);
|
|
|
baseDTO.setId(Long.valueOf(String.valueOf(purchaseId)));
|
|
baseDTO.setId(Long.valueOf(String.valueOf(purchaseId)));
|
|
|
baseDTO.setName(BillCodeSeq.PURCHASE.getName());
|
|
baseDTO.setName(BillCodeSeq.PURCHASE.getName());
|
|
|
return baseDTO;
|
|
return baseDTO;
|