|
|
|
|
@@ -1,12 +1,10 @@
|
|
|
|
|
package com.ruoyi.out.outStockout.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.ruoyi.api.service.IToWcsService;
|
|
|
|
|
import com.ruoyi.bas.basJobId.service.IBasJobIdService;
|
|
|
|
|
import com.ruoyi.common.annotation.DataScope;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
import com.ruoyi.common.utils.MessageUtils;
|
|
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
|
import com.ruoyi.common.utils.uuid.UUID;
|
|
|
|
|
import com.ruoyi.out.outStockout.domain.OutStockout;
|
|
|
|
|
@@ -16,6 +14,7 @@ import com.ruoyi.out.outStockout.service.IOutStockoutService;
|
|
|
|
|
import com.ruoyi.out.outStockoutDetail.domain.OutStockoutDetail;
|
|
|
|
|
import com.ruoyi.out.outStockoutDetail.mapper.OutStockoutDetailMapper;
|
|
|
|
|
import com.ruoyi.out.outStockoutDetail.service.IOutStockoutDetailService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -34,8 +33,8 @@ import java.util.List;
|
|
|
|
|
* @date 2025-05-20
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
{
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class OutStockoutServiceImpl implements IOutStockoutService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private OutStockoutMapper outStockoutMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
@@ -55,8 +54,7 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
* @return 出库主单
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public OutStockout selectOutStockoutByStockoutGuid(String stockoutGuid)
|
|
|
|
|
{
|
|
|
|
|
public OutStockout selectOutStockoutByStockoutGuid(String stockoutGuid) {
|
|
|
|
|
return outStockoutMapper.selectOutStockoutByStockoutGuid(stockoutGuid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -67,8 +65,7 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
* @return 出库主单
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<OutStockout> selectOutStockoutList(OutStockout outStockout)
|
|
|
|
|
{
|
|
|
|
|
public List<OutStockout> selectOutStockoutList(OutStockout outStockout) {
|
|
|
|
|
/*if (!"admin".equals(SecurityUtils.getUsername())){
|
|
|
|
|
outStockout.setDepartmentNo(Convert.toStr(SecurityUtils.getDeptId()));
|
|
|
|
|
}*/
|
|
|
|
|
@@ -82,8 +79,7 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int insertOutStockout(OutStockout outStockout)
|
|
|
|
|
{
|
|
|
|
|
public int insertOutStockout(OutStockout outStockout) {
|
|
|
|
|
return outStockoutMapper.insertOutStockout(outStockout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -94,8 +90,7 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int updateOutStockout(OutStockout outStockout)
|
|
|
|
|
{
|
|
|
|
|
public int updateOutStockout(OutStockout outStockout) {
|
|
|
|
|
return outStockoutMapper.updateOutStockout(outStockout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -106,8 +101,7 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteOutStockoutByStockoutGuids(String[] stockoutGuids)
|
|
|
|
|
{
|
|
|
|
|
public int deleteOutStockoutByStockoutGuids(String[] stockoutGuids) {
|
|
|
|
|
return outStockoutMapper.deleteOutStockoutByStockoutGuids(stockoutGuids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -118,49 +112,62 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteOutStockoutByStockoutGuid(String stockoutGuid)
|
|
|
|
|
{
|
|
|
|
|
public int deleteOutStockoutByStockoutGuid(String stockoutGuid) {
|
|
|
|
|
return outStockoutMapper.deleteOutStockoutByStockoutGuid(stockoutGuid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public String saveBill(OutStockoutVo outStockoutVo) {
|
|
|
|
|
OutStockout outStockout = outStockoutVo.getOutStockout();
|
|
|
|
|
List<OutStockoutDetail> detailList = outStockoutVo.getDetailList();
|
|
|
|
|
String stockOutId = basJobIdService.getJobId("CKD");
|
|
|
|
|
outStockout.setStockoutId(stockOutId);
|
|
|
|
|
outStockout.setStockoutGuid(UUID.randomUUID().toString());
|
|
|
|
|
outStockout.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
|
String username = SecurityContextHolder.getContext().getAuthentication().getName();
|
|
|
|
|
outStockout.setCreateManId(username);
|
|
|
|
|
outStockout.setStatus("1");
|
|
|
|
|
outStockout.setStockoutSource(outStockoutVo.getOutStockout().getStockoutSource());
|
|
|
|
|
outStockout.setDepartmentNo(SecurityUtils.getDeptId().toString());
|
|
|
|
|
// outStockout.setWarehouseId("01");
|
|
|
|
|
for (int i = 0; i < detailList.size(); i++) {
|
|
|
|
|
OutStockoutDetail outStockoutDetail = detailList.get(i);
|
|
|
|
|
outStockoutDetail.setStockoutDetailId(stockOutId + "-" + (i + 1));
|
|
|
|
|
outStockoutDetail.setStockoutGuid(outStockout.getStockoutGuid());
|
|
|
|
|
outStockoutDetail.setStockoutId(stockOutId);
|
|
|
|
|
outStockoutDetail.setAllotQuantity(BigDecimal.ZERO);
|
|
|
|
|
outStockoutDetail.setAssignNum(BigDecimal.ZERO);
|
|
|
|
|
outStockoutDetailMapper.insertOutStockoutDetail(outStockoutDetail);
|
|
|
|
|
OutStockout outStockout = outStockoutVo.getOutStockout();
|
|
|
|
|
List<OutStockoutDetail> detailList = outStockoutVo.getDetailList();
|
|
|
|
|
String stockOutId = basJobIdService.getJobId("CKD");
|
|
|
|
|
outStockout.setStockoutId(stockOutId);
|
|
|
|
|
outStockout.setStockoutGuid(UUID.randomUUID().toString());
|
|
|
|
|
outStockout.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
|
String username = SecurityContextHolder.getContext().getAuthentication().getName();
|
|
|
|
|
outStockout.setCreateManId(username);
|
|
|
|
|
outStockout.setStatus("1");
|
|
|
|
|
outStockout.setStockoutSource(outStockoutVo.getOutStockout().getStockoutSource());
|
|
|
|
|
try {
|
|
|
|
|
if ("1".equals(outStockoutVo.getOutStockout().getStockoutSource())) {
|
|
|
|
|
outStockout.setCreateManId(com.ruoyi.common.core.text.Convert.toStr(SecurityUtils.getUserId()));
|
|
|
|
|
outStockout.setDepartmentNo(Convert.toStr(SecurityUtils.getDeptId()));
|
|
|
|
|
} else if ("2".equals(outStockoutVo.getOutStockout().getStockoutSource())) {
|
|
|
|
|
outStockout.setCreateManId("1");
|
|
|
|
|
outStockout.setDepartmentNo("103");
|
|
|
|
|
} else if ("3".equals(outStockoutVo.getOutStockout().getStockoutSource())) {
|
|
|
|
|
outStockout.setCreateManId("1");
|
|
|
|
|
outStockout.setDepartmentNo("104");
|
|
|
|
|
}
|
|
|
|
|
outStockoutMapper.insertOutStockout(outStockout);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("入库单保存异常,无用户信息");
|
|
|
|
|
}
|
|
|
|
|
// outStockout.setWarehouseId("01");
|
|
|
|
|
for (int i = 0; i < detailList.size(); i++) {
|
|
|
|
|
OutStockoutDetail outStockoutDetail = detailList.get(i);
|
|
|
|
|
outStockoutDetail.setStockoutDetailId(stockOutId + "-" + (i + 1));
|
|
|
|
|
outStockoutDetail.setStockoutGuid(outStockout.getStockoutGuid());
|
|
|
|
|
outStockoutDetail.setStockoutId(stockOutId);
|
|
|
|
|
outStockoutDetail.setAllotQuantity(BigDecimal.ZERO);
|
|
|
|
|
outStockoutDetail.setAssignNum(BigDecimal.ZERO);
|
|
|
|
|
outStockoutDetailMapper.insertOutStockoutDetail(outStockoutDetail);
|
|
|
|
|
}
|
|
|
|
|
outStockoutMapper.insertOutStockout(outStockout);
|
|
|
|
|
|
|
|
|
|
return stockOutId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String updateOutStockoutStatus(String[] stockoutIds, String status, String newStatus,String exitId) {
|
|
|
|
|
public String updateOutStockoutStatus(String[] stockoutIds, String status, String newStatus, String exitId) {
|
|
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
|
for(String stockoutId:stockoutIds){
|
|
|
|
|
map.put("outStockId",stockoutId);
|
|
|
|
|
map.put("status",status);
|
|
|
|
|
map.put("newStatus",newStatus);
|
|
|
|
|
map.put("exitId",exitId);
|
|
|
|
|
for (String stockoutId : stockoutIds) {
|
|
|
|
|
map.put("outStockId", stockoutId);
|
|
|
|
|
map.put("status", status);
|
|
|
|
|
map.put("newStatus", newStatus);
|
|
|
|
|
map.put("exitId", exitId);
|
|
|
|
|
outStockoutMapper.updateOutStockoutStatus(map);
|
|
|
|
|
stringBuilder.append(",").append(map.get("v_resultString"));
|
|
|
|
|
}
|
|
|
|
|
@@ -171,10 +178,10 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
public AjaxResult autoAllot(String stockoutId) {
|
|
|
|
|
|
|
|
|
|
OutStockout outStockout = outStockoutMapper.selectOutStockoutByStockoutId(stockoutId);
|
|
|
|
|
if (outStockout == null){
|
|
|
|
|
if (outStockout == null) {
|
|
|
|
|
return AjaxResult.warn("单据不存在,请检查!");
|
|
|
|
|
}
|
|
|
|
|
if ("1".equals(outStockout.getStatus())){
|
|
|
|
|
if ("1".equals(outStockout.getStatus())) {
|
|
|
|
|
return AjaxResult.warn("单据未审核,请审核无误后再分配!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -184,16 +191,16 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
outStockoutDetail.setStockoutId(stockoutId);
|
|
|
|
|
List<OutStockoutDetail> outStockoutDetails = outStockoutDetailService.selectOutStockoutDetailList(outStockoutDetail);
|
|
|
|
|
for (OutStockoutDetail detail : outStockoutDetails) {
|
|
|
|
|
if (detail.getAllotQuantity().compareTo(detail.getQuantity()) < 0){
|
|
|
|
|
map.put("v_stockout_detail_id", detail.getStockoutDetailId());
|
|
|
|
|
if (detail.getAllotQuantity().compareTo(detail.getQuantity()) < 0) {
|
|
|
|
|
map.put("v_stockout_detail_id", detail.getStockoutDetailId());
|
|
|
|
|
outStockoutMapper.autoAllot(map);
|
|
|
|
|
toWcsService.pushOutMydoJob();
|
|
|
|
|
if (!"10".equals(map.get("v_result"))){
|
|
|
|
|
if (!"10".equals(map.get("v_result"))) {
|
|
|
|
|
stringBuilder.append(",").append(map.get("v_resultString"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!StrUtil.isEmpty(stringBuilder.toString())){
|
|
|
|
|
if (!StrUtil.isEmpty(stringBuilder.toString())) {
|
|
|
|
|
return AjaxResult.warn(stringBuilder.toString());
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
@@ -213,11 +220,11 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
|
|
|
|
map.put("v_stock_id", stock);
|
|
|
|
|
outStockoutMapper.manualAllot(map);
|
|
|
|
|
toWcsService.pushOutMydoJob();
|
|
|
|
|
if (!"10".equals(map.get("v_result"))){
|
|
|
|
|
if (!"10".equals(map.get("v_result"))) {
|
|
|
|
|
stringBuilder.append(",").append(map.get("v_resultString"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!StrUtil.isEmpty(stringBuilder.toString())){
|
|
|
|
|
if (!StrUtil.isEmpty(stringBuilder.toString())) {
|
|
|
|
|
return AjaxResult.warn(stringBuilder.toString());
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
|