|
@@ -2,11 +2,18 @@ package com.ruoyi.system.service.impl;
|
|
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.system.domain.Bills;
|
|
|
+import com.ruoyi.system.domain.BillsDetails;
|
|
|
+import com.ruoyi.system.domain.Goods;
|
|
|
import com.ruoyi.system.mapper.BillsMapper;
|
|
|
+import com.ruoyi.system.service.IBillsDetailsService;
|
|
|
import com.ruoyi.system.service.IBillsService;
|
|
|
+import com.ruoyi.system.service.IGoodsService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -20,6 +27,12 @@ public class BillsServiceImpl implements IBillsService
|
|
|
@Resource
|
|
|
private BillsMapper billsMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IBillsDetailsService billsDetailsService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IGoodsService goodsService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询单据
|
|
|
*
|
|
@@ -63,10 +76,46 @@ public class BillsServiceImpl implements IBillsService
|
|
|
* @param bills 单据
|
|
|
* @return 结果
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public int updateBills(Bills bills)
|
|
|
{
|
|
|
bills.setUpdateTime(DateUtils.getNowDate());
|
|
|
+
|
|
|
+ // 查询单据详情
|
|
|
+ BillsDetails billsDetails = new BillsDetails();
|
|
|
+ billsDetails.setBillsId(bills.getId());
|
|
|
+ List<BillsDetails> billsDetailsList = billsDetailsService.selectBillsDetailsList(billsDetails);
|
|
|
+
|
|
|
+ List<BillsDetails> updateBillsDetailsList = new ArrayList<>();
|
|
|
+ List<Goods> goodsList = new ArrayList<>();
|
|
|
+ for (BillsDetails details : billsDetailsList) {
|
|
|
+ Goods goods = new Goods();
|
|
|
+ goods.setGoodsCode(details.getGoodsCode());
|
|
|
+ goods.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ BillsDetails updateBillsDetails = new BillsDetails();
|
|
|
+ updateBillsDetails.setBillsId(details.getBillsId());
|
|
|
+ updateBillsDetails.setUpdateTime(new Date());
|
|
|
+ // 入库单据
|
|
|
+ if (bills.getBillsType().equals("0")){
|
|
|
+ goods.setGoodsStatus("0");
|
|
|
+ updateBillsDetails.setGoodsStatus("0");
|
|
|
+ }else if (bills.getBillsType().equals("1")){
|
|
|
+ // 出库单据
|
|
|
+ goods.setGoodsStatus("1");
|
|
|
+ updateBillsDetails.setGoodsStatus("1");
|
|
|
+ }else {
|
|
|
+ // 出调单据
|
|
|
+ goods.setGoodsStatus("2");
|
|
|
+ updateBillsDetails.setGoodsStatus("2");
|
|
|
+ }
|
|
|
+ goodsList.add(goods);
|
|
|
+ updateBillsDetailsList.add(updateBillsDetails);
|
|
|
+ }
|
|
|
+ goodsService.updateBatchByGoodsCode(goodsList);
|
|
|
+ billsDetailsService.updateBatchByBillsId(updateBillsDetailsList);
|
|
|
+
|
|
|
return billsMapper.updateBills(bills);
|
|
|
}
|
|
|
|