|
|
@ -10,6 +10,7 @@ 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.inventory.wmsansbill.WmsAnsBillVo; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventory.WmsInventorySaveDto; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventory.WmsInventoryService; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryrecord.WmsInventoryRecordDto; |
|
|
@ -24,6 +25,13 @@ import com.yxt.wms.biz.inventory.wmsreceiptbilldetailbatch.WmsReceiptBillDetailB |
|
|
|
import com.yxt.wms.biz.inventory.wmsshelfbilldetail.*; |
|
|
|
import com.yxt.wms.feign.base.basegoodssku.BaseGoodsSkuDetailsVo; |
|
|
|
import com.yxt.wms.feign.base.basegoodssku.BaseGoodsSkuFeign; |
|
|
|
import com.yxt.wms.feign.portal.privilege.PrivilegeQuery; |
|
|
|
import com.yxt.wms.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.wms.feign.portal.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.wms.feign.portal.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.wms.feign.portal.sysuser.SysUserFeign; |
|
|
|
import com.yxt.wms.feign.portal.sysuser.SysUserVo; |
|
|
|
import com.yxt.wms.utils.BillNo; |
|
|
|
import com.yxt.wms.utils.Rule; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
@ -61,14 +69,58 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
private WmsReceiptBillDetailService wmsReceiptBillDetailService; |
|
|
|
@Autowired |
|
|
|
private WmsReceiptBillDetailBatchService wmsReceiptBillDetailBatchService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
public PagerVo<WmsShelfBillVo> listPage(PagerQuery<WmsShelfBillQuery> pq) { |
|
|
|
WmsShelfBillQuery query = pq.getParams(); |
|
|
|
QueryWrapper<WmsShelfBill> qw = new QueryWrapper<>(); |
|
|
|
PrivilegeQuery privilegeQuery = new PrivilegeQuery(); |
|
|
|
privilegeQuery.setOrgPath(query.getOrgPath()); |
|
|
|
privilegeQuery.setMenuUrl(query.getMenuUrl()); |
|
|
|
privilegeQuery.setUserSid(query.getUserSid()); |
|
|
|
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); |
|
|
|
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { |
|
|
|
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
|
|
|
|
String orgSidPath = query.getOrgPath(); |
|
|
|
orgSidPath = orgSidPath + "/"; |
|
|
|
int i1 = orgSidPath.indexOf("/"); |
|
|
|
int i2 = orgSidPath.indexOf("/", i1 + 1); |
|
|
|
int i3 = orgSidPath.indexOf("/", i2 + 1); |
|
|
|
int i4 = orgSidPath.indexOf("/", i3 + 1); |
|
|
|
String orgLevelKey = defaultIdReltBean.getData(); |
|
|
|
if ("1".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i1); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i2); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i3); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("4".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i4); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("5".equals(orgLevelKey)) { |
|
|
|
qw.eq("wsb.createBySid", query.getUserSid()); |
|
|
|
} else { |
|
|
|
PagerVo<WmsShelfBillVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} else { |
|
|
|
PagerVo<WmsShelfBillVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
//ToDo:添加查询条件
|
|
|
|
if (StringUtils.isNotBlank(query.getBillNo())) { |
|
|
|
qw.like("wsb.billNo", query.getBillNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getSourceBillNo())) { |
|
|
|
qw.like("wsb.sourceBillNo", query.getSourceBillNo()); |
|
|
|
} |
|
|
|
//单据日期开始时间-单据日期结束时间
|
|
|
|
qw.apply(StringUtils.isNotBlank(query.getCreateTimeStart()), "date_format (wsb.createTime,'%Y-%m-%d') >= date_format('" + query.getCreateTimeStart() + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(query.getCreateTimeEnd()), "date_format (wsb.createTime,'%Y-%m-%d') <= date_format('" + query.getCreateTimeEnd() + "','%Y-%m-%d')" |
|
|
@ -88,19 +140,36 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
String sid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(sid)) { |
|
|
|
WmsShelfBill wmsShelfBill = new WmsShelfBill(); |
|
|
|
if (StringUtils.isNotBlank(dto.getBillState())) { |
|
|
|
if (dto.getBillState().equals("新建")){ |
|
|
|
dto.setBillState("0"); |
|
|
|
} else if (dto.getBillState().equals("完成")) { |
|
|
|
dto.setBillState("1"); |
|
|
|
} |
|
|
|
} |
|
|
|
BeanUtil.copyProperties(dto, wmsShelfBill, "sid"); |
|
|
|
wmsShelfBill.setCreateBySid(dto.getUserSid()); |
|
|
|
List<WmsShelfBillDetailDto> list = dto.getList(); |
|
|
|
list.removeAll(Collections.singleton(null)); |
|
|
|
sid = wmsShelfBill.getSid(); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
wmsShelfBillDetailService.saveShelfDetails(sid, list); |
|
|
|
} |
|
|
|
String applyCode = getApplyCode(dto.getCreateOrgSid()); |
|
|
|
wmsShelfBill.setBillNo(applyCode); |
|
|
|
baseMapper.insert(wmsShelfBill); |
|
|
|
} else { |
|
|
|
WmsShelfBill wmsShelfBill = fetchBySid(sid); |
|
|
|
if (wmsShelfBill == null) { |
|
|
|
return rb.setMsg("该单据不存在"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getBillState())) { |
|
|
|
if (dto.getBillState().equals("新建")){ |
|
|
|
dto.setBillState("0"); |
|
|
|
} else if (dto.getBillState().equals("完成")) { |
|
|
|
dto.setBillState("1"); |
|
|
|
} |
|
|
|
} |
|
|
|
BeanUtil.copyProperties(dto, wmsShelfBill, "sid"); |
|
|
|
List<WmsShelfBillDetailDto> list = dto.getList(); |
|
|
|
list.removeAll(Collections.singleton(null)); |
|
|
@ -111,11 +180,29 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
baseMapper.updateById(wmsShelfBill); |
|
|
|
|
|
|
|
} |
|
|
|
saveWmsInventory(sid); |
|
|
|
// saveWmsInventory(sid);
|
|
|
|
|
|
|
|
return rb.success().setData(sid); |
|
|
|
} |
|
|
|
|
|
|
|
private String getApplyCode(String createOrgSid) { |
|
|
|
ResultBean<SysOrganizationVo> resultBean1 = sysOrganizationFeign.fetchBySid(createOrgSid); |
|
|
|
String orgCode = resultBean1.getData().getOrgCode(); |
|
|
|
BillNo b = new BillNo(); |
|
|
|
b.setOrgCode(orgCode); |
|
|
|
b.setBillType("SJD"); |
|
|
|
String bill = Rule.getBill(b); |
|
|
|
String i = baseMapper.selectCodeNum(bill); |
|
|
|
String billNo = ""; |
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(i)) { |
|
|
|
billNo = Rule.getBillNo(bill, Integer.valueOf(i).intValue()); |
|
|
|
} else { |
|
|
|
billNo = Rule.getBillNo(bill, 0); |
|
|
|
} |
|
|
|
return billNo; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void saveWmsInventory(String sid) { |
|
|
|
WmsShelfBill wmsShelfBill = fetchBySid(sid); |
|
|
|
List<WmsShelfBillDetailVos> detailList = wmsShelfBillDetailService.selectByBillSid(sid); |
|
|
@ -145,7 +232,7 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
dto.setSid(s.getInventorySid()); |
|
|
|
String inventorySid = wmsInventoryService.saveWmsInventory(dto).getData(); |
|
|
|
WmsShelfBillDetail wmsShelfBillDetail = wmsShelfBillDetailService.fetchBySid(s.getDetailsSid()); |
|
|
|
wmsShelfBillDetail.setInventorySid(inventorySid); |
|
|
|
// wmsShelfBillDetail.setInventorySid(inventorySid);
|
|
|
|
wmsShelfBillDetailService.updateById(wmsShelfBillDetail); |
|
|
|
WmsInventoryRecordDto wmsInventoryRecordDto = new WmsInventoryRecordDto(); |
|
|
|
wmsInventoryRecordDto.setInventorySid(inventorySid); |
|
|
@ -210,9 +297,21 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
if (shelfDetailsVo == null) { |
|
|
|
return rb.setMsg("该单据不存在"); |
|
|
|
} |
|
|
|
List<ShelfDetailsListVo> list = wmsShelfBillDetailService.details(sid); |
|
|
|
List<ShelfInitListVo> list = wmsShelfBillDetailService.selDetailsByMainSid(sid); |
|
|
|
list.removeAll(Collections.singleton(null)); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
for (ShelfInitListVo listVo : list) { |
|
|
|
BigDecimal count = new BigDecimal("0"); |
|
|
|
BigDecimal acCount = new BigDecimal("0"); |
|
|
|
if (StringUtils.isNotBlank(listVo.getCount())) { |
|
|
|
count = new BigDecimal(listVo.getCount()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(listVo.getActualCount())) { |
|
|
|
acCount = new BigDecimal(listVo.getActualCount()); |
|
|
|
} |
|
|
|
BigDecimal subtract = count.subtract(acCount); |
|
|
|
listVo.setNoShelfCount(subtract.toString()); |
|
|
|
} |
|
|
|
shelfDetailsVo.setList(list); |
|
|
|
} |
|
|
|
return rb.success().setData(shelfDetailsVo); |
|
|
@ -221,6 +320,37 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
public ResultBean<ShelfInitVo> getInit(String sid, String orgPath, String userSid) { |
|
|
|
ResultBean<ShelfInitVo> rb = ResultBean.fireFail(); |
|
|
|
ShelfInitVo shelfInitVo = new ShelfInitVo(); |
|
|
|
String deptName = ""; |
|
|
|
String deptSid = ""; |
|
|
|
String createOrgSid = ""; |
|
|
|
shelfInitVo.setUserSid(userSid); |
|
|
|
SysUserVo userVo = sysUserFeign.fetchBySid(userSid).getData(); |
|
|
|
shelfInitVo.setCreateByName(userVo.getName()); |
|
|
|
if (StringUtils.isNotBlank(orgPath)) { |
|
|
|
List<String> split = Arrays.asList(orgPath.split("/")); |
|
|
|
if (split.size() > 1) { |
|
|
|
//获取本级sid获取本级部门信息
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(split.size() - 2)).getData(); |
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
deptName = sysOrganization.getName() + "/" + sysOrganization1.getName(); |
|
|
|
deptName = sysOrganization1.getName(); |
|
|
|
deptSid = sysOrganization1.getSid(); |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptSid = sysOrganization.getSid(); |
|
|
|
} |
|
|
|
shelfInitVo.setDeptSid(deptSid); |
|
|
|
shelfInitVo.setDeptName(deptName); |
|
|
|
createOrgSid = sysStaffOrgFeign.getOrgSidByPath(orgPath).getData(); |
|
|
|
//创建组织使用组织
|
|
|
|
ResultBean<SysOrganizationVo> organizationResultBean = sysOrganizationFeign.fetchBySid(createOrgSid); |
|
|
|
if (organizationResultBean.getData() != null) { |
|
|
|
shelfInitVo.setCreateOrgSid(createOrgSid); |
|
|
|
shelfInitVo.setUseOrgSid(createOrgSid); |
|
|
|
} |
|
|
|
} |
|
|
|
//查询所有已上架的商品
|
|
|
|
List<String> stringList = wmsShelfBillDetailService.selectReceiptSidList(); |
|
|
|
stringList.removeAll(Collections.singleton(null)); |
|
|
@ -229,7 +359,7 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
shelfInitVo.setCreateTime(DateUtil.today());//单据日期
|
|
|
|
shelfInitVo.setSourceBillNo(wmsReceiptBill.getBillNo());//来源单编号
|
|
|
|
shelfInitVo.setSourceBillSid(wmsReceiptBill.getSid());//来源单sid
|
|
|
|
shelfInitVo.setBillState(0); |
|
|
|
shelfInitVo.setBillState("新建"); |
|
|
|
List<ShelfInitListVo> list = new ArrayList<>(); |
|
|
|
//获取收货单据的明细
|
|
|
|
List<WmsReceiptBillDetail> wmsReceiptBillDetailsList = wmsReceiptBillDetailService.selectByBillSid(sid, stringList); |
|
|
@ -237,13 +367,14 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
if (!wmsReceiptBillDetailsList.isEmpty()) { |
|
|
|
for (int i = 0; i < wmsReceiptBillDetailsList.size(); i++) { |
|
|
|
WmsReceiptBillDetail v = wmsReceiptBillDetailsList.get(i); |
|
|
|
WmsReceiptBillDetailBatch wmsReceiptBillDetailBatch = wmsReceiptBillDetailBatchService.selectByDetails(v.getSid()); |
|
|
|
// WmsReceiptBillDetailBatch wmsReceiptBillDetailBatch = wmsReceiptBillDetailBatchService.selectByDetails(v.getSid());
|
|
|
|
ShelfInitListVo shelfInitListVo = new ShelfInitListVo(); |
|
|
|
BeanUtil.copyProperties(v, shelfInitListVo, "sid"); |
|
|
|
shelfInitListVo.setBatchNumber(wmsReceiptBillDetailBatch.getBatchNumber()); |
|
|
|
shelfInitListVo.setReceiptDetailSid(v.getSid()); |
|
|
|
// shelfInitListVo.setBatchNumber(wmsReceiptBillDetailBatch.getBatchNumber());
|
|
|
|
// shelfInitListVo.setWarehouseSid(v.getWarehouseSid());
|
|
|
|
// shelfInitListVo.setWarehouseRackSid(v.getWarehouseRackSid());
|
|
|
|
shelfInitListVo.setWarehouseRackCode(""); |
|
|
|
// shelfInitListVo.setWarehouseRackCode("");
|
|
|
|
list.add(shelfInitListVo); |
|
|
|
} |
|
|
|
} |
|
|
@ -254,7 +385,7 @@ public class WmsShelfBillService extends MybatisBaseService<WmsShelfBillMapper, |
|
|
|
|
|
|
|
public ResultBean<String> confirm(WmsShelfBillDto dto) { |
|
|
|
ResultBean<String> rb = ResultBean.fireFail(); |
|
|
|
dto.setBillState(1); |
|
|
|
dto.setBillState("1"); |
|
|
|
ResultBean<String> resultBean = saveOrUpdateShelf(dto); |
|
|
|
String sid = resultBean.getData(); |
|
|
|
return rb.success().setData(sid); |
|
|
|