|
|
@ -10,7 +10,12 @@ import com.yxt.common.base.utils.StringUtils; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import com.yxt.wms.biz.base.wmswarehouserack.WmsHouseInfoVo; |
|
|
|
import com.yxt.wms.biz.base.wmswarehouserack.WmsWarehouseRackService; |
|
|
|
import com.yxt.wms.biz.inventory.wmsansbill.WmsAnsBillVo; |
|
|
|
import com.yxt.wms.biz.inventory.wmsansbilldetail.WmsAnsListDetailsVo; |
|
|
|
import com.yxt.wms.biz.inventory.wmsgoodstag.WmsGoodsTag; |
|
|
|
import com.yxt.wms.biz.inventory.wmsgoodstag.WmsGoodsTagService; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventory.WmsInventorySaveDto; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventory.WmsInventoryService; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryrecord.WmsInventoryRecordDto; |
|
|
@ -22,8 +27,7 @@ import com.yxt.wms.biz.inventory.wmsreceiptbilldetail.WmsReceiptBillDetailDto2; |
|
|
|
import com.yxt.wms.biz.inventory.wmsreceiptbilldetail.WmsReceiptBillDetailService; |
|
|
|
import com.yxt.wms.biz.inventory.wmsreceiptbilldetailbatch.WmsReceiptBillDetailBatch; |
|
|
|
import com.yxt.wms.biz.inventory.wmsreceiptbilldetailbatch.WmsReceiptBillDetailBatchService; |
|
|
|
import com.yxt.wms.biz.inventory.wmsshelfbill.app.AppShelfBillListQuery; |
|
|
|
import com.yxt.wms.biz.inventory.wmsshelfbill.app.AppShelfBillListVo; |
|
|
|
import com.yxt.wms.biz.inventory.wmsshelfbill.app.*; |
|
|
|
import com.yxt.wms.biz.inventory.wmsshelfbilldetail.*; |
|
|
|
import com.yxt.wms.feign.base.basegoodssku.BaseGoodsSkuDetailsVo; |
|
|
|
import com.yxt.wms.feign.base.basegoodssku.BaseGoodsSkuFeign; |
|
|
@ -38,13 +42,11 @@ import com.yxt.wms.utils.Rule; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: |
|
|
@ -77,6 +79,11 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private WmsWarehouseRackService wmsWarehouseRackService; |
|
|
|
@Autowired |
|
|
|
private WmsGoodsTagService wmsGoodsTagService; |
|
|
|
|
|
|
|
public PagerVo<WmsShelfBillVo> listPage(PagerQuery<WmsShelfBillQuery> pq) { |
|
|
|
WmsShelfBillQuery query = pq.getParams(); |
|
|
|
QueryWrapper<WmsShelfBill> qw = new QueryWrapper<>(); |
|
|
@ -143,7 +150,7 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
if (StringUtils.isBlank(sid)) { |
|
|
|
WmsShelfBill wmsShelfBill = new WmsShelfBill(); |
|
|
|
if (StringUtils.isNotBlank(dto.getBillState())) { |
|
|
|
if (dto.getBillState().equals("新建")){ |
|
|
|
if (dto.getBillState().equals("新建")) { |
|
|
|
dto.setBillState("0"); |
|
|
|
} else if (dto.getBillState().equals("完成")) { |
|
|
|
dto.setBillState("1"); |
|
|
@ -160,7 +167,7 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
String applyCode = getApplyCode(dto.getCreateOrgSid()); |
|
|
|
wmsShelfBill.setBillNo(applyCode); |
|
|
|
if (StringUtils.isNotBlank(dto.getBillState())) { |
|
|
|
if (dto.getBillState().equals("0")){ |
|
|
|
if (dto.getBillState().equals("0")) { |
|
|
|
wmsShelfBill.setBillStateValue("新建"); |
|
|
|
} else if (dto.getBillState().equals("1")) { |
|
|
|
wmsShelfBill.setBillStateValue("完成"); |
|
|
@ -173,7 +180,7 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
return rb.setMsg("该单据不存在"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getBillState())) { |
|
|
|
if (dto.getBillState().equals("新建")){ |
|
|
|
if (dto.getBillState().equals("新建")) { |
|
|
|
dto.setBillState("0"); |
|
|
|
} else if (dto.getBillState().equals("完成")) { |
|
|
|
dto.setBillState("1"); |
|
|
@ -187,7 +194,7 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
wmsShelfBillDetailService.saveShelfDetails(sid, list); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getBillState())) { |
|
|
|
if (dto.getBillState().equals("0")){ |
|
|
|
if (dto.getBillState().equals("0")) { |
|
|
|
wmsShelfBill.setBillStateValue("新建"); |
|
|
|
} else if (dto.getBillState().equals("1")) { |
|
|
|
wmsShelfBill.setBillStateValue("完成"); |
|
|
@ -411,7 +418,7 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
AppShelfBillListQuery query = pq.getParams(); |
|
|
|
QueryWrapper<WmsShelfBill> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(query.getUserSid())) { |
|
|
|
qw.eq("wsb.upShelfSid",query.getUserSid()); |
|
|
|
qw.eq("wsb.upShelfSid", query.getUserSid()); |
|
|
|
} |
|
|
|
//ToDo:添加查询条件
|
|
|
|
if (StringUtils.isNotBlank(query.getName())) { |
|
|
@ -420,9 +427,212 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
.or().like("wsb.billStateValue", query.getName()) |
|
|
|
); |
|
|
|
} |
|
|
|
qw.ne("wsb.billStateValue", "已完成"); |
|
|
|
IPage<WmsShelfBill> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<AppShelfBillListVo> pagging = baseMapper.applistPage(page, qw); |
|
|
|
List<AppShelfBillListVo> records = pagging.getRecords(); |
|
|
|
if (!records.isEmpty()) { |
|
|
|
for (AppShelfBillListVo record : records) { |
|
|
|
if (!record.getShelvesState().equals("完成")) { |
|
|
|
record.setShelvesBtn(true); |
|
|
|
} |
|
|
|
if (!record.getShelvesState().equals("新建")) { |
|
|
|
record.setRecordBtn(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
PagerVo<AppShelfBillListVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<AppShelInitVo> shelvesOperaInit(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
AppShelInitVo vo = new AppShelInitVo(); |
|
|
|
WmsShelfBill wmsShelfBill = fetchBySid(sid); |
|
|
|
if (null != wmsShelfBill) { |
|
|
|
vo.setShelvesId(wmsShelfBill.getBillNo()); |
|
|
|
List<WmsShelfBillDetail> details = wmsShelfBillDetailService.selectByMainSid(sid); |
|
|
|
if (!details.isEmpty()) { |
|
|
|
List<AppShelInitVo.AppShelInitVoDetails> goods = new ArrayList<>(); |
|
|
|
for (WmsShelfBillDetail detail : details) { |
|
|
|
AppShelInitVo.AppShelInitVoDetails voDetails = new AppShelInitVo.AppShelInitVoDetails(); |
|
|
|
if (StringUtils.isNotBlank(detail.getGoodsSpuName())) { |
|
|
|
voDetails.setName(detail.getGoodsSpuName()); |
|
|
|
} |
|
|
|
BigDecimal count = new BigDecimal("0"); |
|
|
|
BigDecimal acCount = new BigDecimal("0"); |
|
|
|
if (null != detail.getCount()) { |
|
|
|
count = detail.getCount(); |
|
|
|
} |
|
|
|
if (null != detail.getActualCount()) { |
|
|
|
acCount = detail.getActualCount(); |
|
|
|
} |
|
|
|
String c = String.valueOf(count.subtract(acCount).intValue()); |
|
|
|
voDetails.setNumber(c); |
|
|
|
if (!c.equals("0")) { |
|
|
|
goods.add(voDetails); |
|
|
|
} |
|
|
|
} |
|
|
|
vo.setGoods(goods); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<AppScanVo> scan(String shelvesId, String content) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
AppScanVo vo = new AppScanVo(); |
|
|
|
if (StringUtils.isNotBlank(shelvesId)) { |
|
|
|
if (content.contains("#")) { |
|
|
|
String[] split = content.split("#"); |
|
|
|
String houseCode = split[0]; |
|
|
|
ResultBean<WmsHouseInfoVo> wmsHouseInfoVoResultBean = wmsWarehouseRackService.selHouseInfoByFullCode(houseCode); |
|
|
|
if (wmsHouseInfoVoResultBean.getSuccess()) { |
|
|
|
WmsHouseInfoVo houseInfoVo = wmsHouseInfoVoResultBean.getData(); |
|
|
|
if (null != houseInfoVo) { |
|
|
|
vo.setHouseCode(houseCode); |
|
|
|
vo.setHouseName(houseInfoVo.getWareAreaName() + "-" + houseInfoVo.getWarehouseRackName()); |
|
|
|
vo.setHouseAddress(houseInfoVo.getWarehouseRackCode()); |
|
|
|
vo.setType(1); |
|
|
|
} |
|
|
|
} else { |
|
|
|
return rb.setMsg("扫描库位码为空"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
vo.setType(0); |
|
|
|
WmsShelfBill wmsShelfBill = fetchBySid(shelvesId); |
|
|
|
String sourceBillSid = wmsShelfBill.getSourceBillSid(); |
|
|
|
//判断该商品ID是否属于该上架单对应的收货单
|
|
|
|
WmsGoodsTag wmsGoodsTag = wmsGoodsTagService.selByBillSidAndGoodsID(sourceBillSid, content); |
|
|
|
if (null != wmsGoodsTag) { |
|
|
|
vo.setGoodsID(wmsGoodsTag.getGoodsID()); |
|
|
|
vo.setGoodsName(wmsGoodsTag.getGoodsSpuName()); |
|
|
|
if (wmsGoodsTag.getState() == 1) { |
|
|
|
return rb.setMsg("该商品已上架完成"); |
|
|
|
} |
|
|
|
//获取该商品编码,判断此上架单是否有对应的商品编码
|
|
|
|
String goodsSkuCode = wmsGoodsTag.getGoodsSkuCode(); |
|
|
|
WmsShelfBillDetail shelfBillGoods = wmsShelfBillDetailService.selByBillSidAndSkuCode(shelvesId, goodsSkuCode); |
|
|
|
if (null == shelfBillGoods) { |
|
|
|
return rb.setMsg("该商品不属于您的上架单"); |
|
|
|
} |
|
|
|
BigDecimal count = new BigDecimal("0"); |
|
|
|
BigDecimal acCount = new BigDecimal("0"); |
|
|
|
if (null != shelfBillGoods.getCount()) { |
|
|
|
count = shelfBillGoods.getCount(); |
|
|
|
} |
|
|
|
if (null != shelfBillGoods.getActualCount()) { |
|
|
|
acCount = shelfBillGoods.getActualCount(); |
|
|
|
} |
|
|
|
BigDecimal subtractCount = count.subtract(acCount); |
|
|
|
if (subtractCount.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
if (wmsGoodsTag.getGoodsCount().compareTo(new BigDecimal("1")) == 0) { |
|
|
|
vo.setGoodsMax("1"); |
|
|
|
} else { |
|
|
|
vo.setGoodsMax(String.valueOf(subtractCount.intValue())); |
|
|
|
} |
|
|
|
} else { |
|
|
|
return rb.setMsg("您的上架单中的该商品已经上架完成"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
return rb.setMsg("该商品不属于您的收货单"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
vo.setUrl(""); |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean shelvesSave(AppSaveBillRecordDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String shelvesId = dto.getShelvesSid(); |
|
|
|
WmsShelfBill wmsShelfBill = fetchBySid(shelvesId); |
|
|
|
String sourceBillSid = wmsShelfBill.getSourceBillSid(); |
|
|
|
List<AppSaveBillRecordDto.AppSaveBillRecordDetailsDto> goodsList = dto.getGoodsList(); |
|
|
|
if (!goodsList.isEmpty()) { |
|
|
|
Map<String, BigDecimal> map = new HashMap<>(); |
|
|
|
for (AppSaveBillRecordDto.AppSaveBillRecordDetailsDto detailsDto : goodsList) { |
|
|
|
BigDecimal decimal = map.get(detailsDto.getGoodsID()); |
|
|
|
if (null != decimal) { |
|
|
|
map.put(detailsDto.getGoodsID(), decimal.add(new BigDecimal(detailsDto.getCount()))); |
|
|
|
} else { |
|
|
|
map.put(detailsDto.getGoodsID(), new BigDecimal(detailsDto.getCount())); |
|
|
|
} |
|
|
|
} |
|
|
|
for (AppSaveBillRecordDto.AppSaveBillRecordDetailsDto r : goodsList) { |
|
|
|
String goodsID = r.getGoodsID(); |
|
|
|
String houseCode = r.getHouseCode(); |
|
|
|
if (StringUtils.isBlank(goodsID)) { |
|
|
|
return rb.setMsg("请扫描商品码"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(houseCode)) { |
|
|
|
return rb.setMsg("请扫描库位码"); |
|
|
|
} |
|
|
|
WmsGoodsTag wmsGoodsTag = wmsGoodsTagService.selByBillSidAndGoodsID(sourceBillSid, goodsID); |
|
|
|
String goodsSkuCode = wmsGoodsTag.getGoodsSkuCode(); |
|
|
|
WmsShelfBillDetail shelfBillGoods = wmsShelfBillDetailService.selByBillSidAndSkuCode(shelvesId, goodsSkuCode); |
|
|
|
BigDecimal actualCount = shelfBillGoods.getActualCount(); |
|
|
|
BigDecimal subtract = shelfBillGoods.getCount().subtract(actualCount); |
|
|
|
if (subtract.compareTo(map.get(goodsID)) < 0) { |
|
|
|
return rb.setMsg("请勿超过商品上架最大数量"); |
|
|
|
} |
|
|
|
} |
|
|
|
for (AppSaveBillRecordDto.AppSaveBillRecordDetailsDto r : goodsList) { |
|
|
|
String count = r.getCount(); |
|
|
|
String goodsID = r.getGoodsID(); |
|
|
|
String houseCode = r.getHouseCode(); |
|
|
|
WmsGoodsTag wmsGoodsTag = wmsGoodsTagService.selByBillSidAndGoodsID(sourceBillSid, goodsID); |
|
|
|
String goodsSkuCode = wmsGoodsTag.getGoodsSkuCode(); |
|
|
|
WmsShelfBillDetail shelfBillGoods = wmsShelfBillDetailService.selByBillSidAndSkuCode(shelvesId, goodsSkuCode); |
|
|
|
BigDecimal actualCount = shelfBillGoods.getActualCount(); |
|
|
|
BigDecimal add = actualCount.add(new BigDecimal(count)); |
|
|
|
shelfBillGoods.setActualCount(add); |
|
|
|
wmsShelfBillDetailService.updateById(shelfBillGoods); |
|
|
|
if (wmsGoodsTag.getGoodsCount().compareTo(new BigDecimal("1")) == 0) { |
|
|
|
wmsGoodsTag.setState(1); |
|
|
|
wmsGoodsTagService.updateById(wmsGoodsTag); |
|
|
|
} |
|
|
|
} |
|
|
|
List<WmsShelfBillDetail> vos = wmsShelfBillDetailService.selectByMainSid(dto.getShelvesSid()); |
|
|
|
if (!vos.isEmpty()) { |
|
|
|
HashSet<Integer> integers = new HashSet<>(); |
|
|
|
for (WmsShelfBillDetail vo : vos) { |
|
|
|
if (vo.getActualCount().compareTo(vo.getCount()) >= 0) { |
|
|
|
integers.add(2); |
|
|
|
} else { |
|
|
|
integers.add(1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (integers.size() > 1) { |
|
|
|
wmsShelfBill.setBillState(2); |
|
|
|
wmsShelfBill.setBillStateValue("部分上架"); |
|
|
|
} else { |
|
|
|
wmsShelfBill.setBillState(1); |
|
|
|
wmsShelfBill.setBillStateValue("已完成"); |
|
|
|
for (Integer integer : integers) { |
|
|
|
if (integer == 1) { |
|
|
|
wmsShelfBill.setBillState(2); |
|
|
|
wmsShelfBill.setBillStateValue("部分上架"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
baseMapper.updateById(wmsShelfBill); |
|
|
|
for (AppSaveBillRecordDto.AppSaveBillRecordDetailsDto r : goodsList) { |
|
|
|
String goodsID = r.getGoodsID(); |
|
|
|
WmsGoodsTag wmsGoodsTag = wmsGoodsTagService.selByBillSidAndGoodsID(sourceBillSid, goodsID); |
|
|
|
String goodsSkuCode = wmsGoodsTag.getGoodsSkuCode(); |
|
|
|
if (wmsGoodsTag.getGoodsCount().compareTo(new BigDecimal("1")) > 0) { |
|
|
|
String count = wmsShelfBillDetailService.selAcCountBySourceBillSidAndSkuCode(sourceBillSid, goodsSkuCode); |
|
|
|
if (new BigDecimal(count).compareTo(wmsGoodsTag.getGoodsCount()) >= 0) { |
|
|
|
wmsGoodsTag.setState(1); |
|
|
|
wmsGoodsTagService.updateById(wmsGoodsTag); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |
|
|
|