New file |
| | |
| | | package com.zy.asrs.common.domain.dto; |
| | | |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/8/18 |
| | | */ |
| | | @Data |
| | | public class OrderDto { |
| | | |
| | | private String orderNo; |
| | | |
| | | private String matnr; |
| | | |
| | | private Double anfme; |
| | | |
| | | public OrderDto(String orderNo, String matnr, Double anfme) { |
| | | this.orderNo = orderNo; |
| | | this.matnr = matnr; |
| | | this.anfme = anfme; |
| | | } |
| | | |
| | | public static boolean has(List<OrderDto> list, OrderDto dto) { |
| | | if (Cools.isEmpty(list)) { |
| | | return false; |
| | | } |
| | | for (OrderDto orderDto : list) { |
| | | if (dto.getOrderNo().equals(orderDto.getOrderNo()) && dto.getMatnr().equals(orderDto.getMatnr())) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static OrderDto find(List<OrderDto> list, OrderDto dto) { |
| | | if (Cools.isEmpty(list)) { |
| | | return null; |
| | | } |
| | | for (OrderDto orderDto : list) { |
| | | if (dto.getOrderNo().equals(orderDto.getOrderNo()) && dto.getMatnr().equals(orderDto.getMatnr())) { |
| | | return orderDto; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.domain.dto; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.wms.entity.LocDetl; |
| | | import com.zy.asrs.common.wms.service.LocDetlService; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import lombok.Data; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/3/28 |
| | | */ |
| | | @Data |
| | | public class TaskDto { |
| | | |
| | | private String locNo; |
| | | |
| | | private Integer staNo; |
| | | |
| | | private Long hostId; |
| | | |
| | | private List<LocDto> locDtos; |
| | | |
| | | { |
| | | locDtos = new ArrayList<>(); |
| | | } |
| | | |
| | | public TaskDto(String locNo, Integer staNo, Long hostId) { |
| | | this.locNo = locNo; |
| | | this.staNo = staNo; |
| | | this.hostId = hostId; |
| | | } |
| | | |
| | | public TaskDto(String locNo, Integer staNo, LocDto locDto, Long hostId) { |
| | | this.locNo = locNo; |
| | | this.staNo = staNo; |
| | | this.locDtos.add(locDto); |
| | | this.hostId = hostId; |
| | | } |
| | | |
| | | public TaskDto(String locNo, Integer staNo, List<LocDto> locDtos, Long hostId) { |
| | | this.locNo = locNo; |
| | | this.staNo = staNo; |
| | | this.locDtos = locDtos; |
| | | this.hostId = hostId; |
| | | } |
| | | |
| | | public static boolean has(List<TaskDto> list, TaskDto dto) { |
| | | if (Cools.isEmpty(list)) { |
| | | return false; |
| | | } |
| | | for (TaskDto taskDto : list) { |
| | | if (dto.getLocNo().equals(taskDto.getLocNo()) && taskDto.getStaNo().equals(dto.getStaNo())) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static TaskDto find(List<TaskDto> list, TaskDto dto) { |
| | | if (Cools.isEmpty(list)) { |
| | | return null; |
| | | } |
| | | for (TaskDto taskDto : list) { |
| | | if (dto.getLocNo().equals(taskDto.getLocNo()) && taskDto.getStaNo().equals(dto.getStaNo())) { |
| | | return taskDto; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public boolean isAll(){ |
| | | // 汇总不考虑序列码 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | for (LocDto locDto : this.getLocDtos()) { |
| | | DetlDto dto = new DetlDto(locDto.getMatnr(), locDto.getBatch(), locDto.getAnfme()); |
| | | if (DetlDto.has(detlDtos, dto)) { |
| | | DetlDto detlDto = DetlDto.find(detlDtos, locDto.getMatnr(), dto.getBatch()); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + locDto.getAnfme()); |
| | | } else { |
| | | detlDtos.add(new DetlDto(locDto.getMatnr(), locDto.getBatch(), locDto.getAnfme())); |
| | | } |
| | | } |
| | | |
| | | // 查询当前库位号所有的库存明细 |
| | | LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); |
| | | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, this.locNo).eq(LocDetl::getHostId, hostId)); |
| | | if (locDetls == null || locDetls.isEmpty()){ |
| | | throw new CoolException("检索库存明细失败,库位号=" + this.locNo); |
| | | } |
| | | int sameNumber = 0; |
| | | for (LocDetl locDetl : locDetls) { |
| | | Iterator<DetlDto> iterator = detlDtos.iterator(); |
| | | while (iterator.hasNext()) { |
| | | DetlDto dto = iterator.next(); |
| | | if (!dto.getMatnr().equals(locDetl.getMatnr())) { |
| | | continue; |
| | | } |
| | | if (Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) { |
| | | continue; |
| | | } |
| | | if (!Cools.isEmpty(dto.getBatch()) && Cools.isEmpty(locDetl.getBatch())) { |
| | | continue; |
| | | } |
| | | if (!Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) { |
| | | if (!dto.getBatch().equals(locDetl.getBatch())) { |
| | | continue; |
| | | } |
| | | } |
| | | if (dto.getAnfme() > locDetl.getAnfme()) { |
| | | throw new CoolException("服务器内部错误"); |
| | | } |
| | | if (dto.getAnfme().equals(locDetl.getAnfme())) { |
| | | sameNumber++; |
| | | iterator.remove(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return sameNumber == locDetls.size(); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | public interface StaDescService extends IService<StaDesc> { |
| | | |
| | | List<Integer> queryOutStaNosByLocNo(String locNo, Integer typeNo); |
| | | List<Integer> queryOutStaNosByLocNo(String locNo, Integer typeNo, Long hostId); |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.common.sys.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.wms.mapper.StaDescMapper; |
| | | import com.zy.asrs.common.domain.entity.StaDesc; |
| | | import com.zy.asrs.common.sys.service.StaDescService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Service("staDescService") |
| | | public class StaDescServiceImpl extends ServiceImpl<StaDescMapper, StaDesc> implements StaDescService { |
| | | |
| | | @Override |
| | | public List<Integer> queryOutStaNosByLocNo(String locNo, Integer typeNo) { |
| | | return this.baseMapper.queryOutStaNosByLocNo(locNo, typeNo); |
| | | public List<Integer> queryOutStaNosByLocNo(String locNo, Integer typeNo, Long hostId) { |
| | | ArrayList<Integer> list = new ArrayList<>(); |
| | | LambdaQueryWrapper<StaDesc> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(StaDesc::getTypeNo, typeNo); |
| | | wrapper.eq(StaDesc::getHostId, hostId); |
| | | for (StaDesc staDesc : this.list(wrapper)) { |
| | | list.add(staDesc.getStnNo()); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | Integer sum(); |
| | | |
| | | List<LocDetl> queryStock(@Param("matnr")String matnr, @Param("no") Integer no, @Param("orderBy") String orderBy, @Param("bay") Integer bay); |
| | | |
| | | List<QueryStockPreDo> queryStockPre(@Param("matnr")String matnr); |
| | | List<LocDetl> queryStock(@Param("matnr") String matnr, @Param("batch") String batch, @Param("hostId") Long hostId); |
| | | |
| | | LocDetl selectItem(@Param("locNo") String locNo, @Param("matnr") String matnr, @Param("batch") String batch, @Param("hostId") Long hostId); |
| | | |
| | |
| | | @Repository |
| | | public interface StaDescMapper extends BaseMapper<StaDesc> { |
| | | |
| | | List<Integer> queryOutStaNosByLocNo(@Param("locNo") String locNo, @Param("typeNo") Integer typeNo); |
| | | |
| | | } |
| | |
| | | |
| | | Integer sum(); |
| | | |
| | | List<LocDetl> queryStock(String matnr, String batch, String lgort, Set<String> locNos); |
| | | List<LocDetl> queryStock(String matnr, String batch, Long hostId); |
| | | |
| | | LocDetl selectItem(String locNo, String matnr, String batch, Long hostId); |
| | | |
| | |
| | | package com.zy.asrs.common.wms.service; |
| | | |
| | | import com.zy.asrs.common.domain.dto.LocDetlDto; |
| | | import com.zy.asrs.common.domain.dto.TaskDto; |
| | | import com.zy.asrs.common.domain.enums.IoWorkType; |
| | | import com.zy.asrs.common.domain.param.FullStoreParam; |
| | | import com.zy.asrs.common.domain.param.LocDetlAdjustParam; |
| | |
| | | |
| | | void stockOut(Integer staNo, List<LocDetlDto> locDetls, IoWorkType ioWorkType, Long userId, Long hostId); |
| | | |
| | | void stockOut(Integer staNo, TaskDto taskDto, Long userId, Long hostId); |
| | | |
| | | /** |
| | | * 库存明细调整 |
| | | */ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<LocDetl> queryStock(String matnr, String batch, String orderNo, Set<String> locNos) { |
| | | List<LocDetl> result = new ArrayList<>(); |
| | | List<QueryStockPreDo> preDos = this.baseMapper.queryStockPre(matnr); |
| | | for (QueryStockPreDo preDo : preDos) { |
| | | List<LocDetl> locDetls = this.baseMapper.queryStock(matnr, preDo.getNo(), preDo.getOrderBy(), preDo.getBay()); |
| | | result.addAll(locDetls); |
| | | } |
| | | public List<LocDetl> queryStock(String matnr, String batch, Long hostId) { |
| | | List<LocDetl> result = this.baseMapper.queryStock(matnr, batch, hostId); |
| | | return result; |
| | | } |
| | | |
| | |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private AdjDetlService adjDetlService; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setHostId(hostId); |
| | | wrkDetl.setWrkMastId(wrkMast.getId()); |
| | | if (!wrkDetlService.save(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut(Integer staNo, TaskDto taskDto, Long userId, Long hostId) { |
| | | Date now = new Date(); |
| | | List<LocDto> locDtos = taskDto.getLocDtos(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (!taskDto.getLocNo().equals(locDto.getLocNo()) && !taskDto.getStaNo().equals(locDto.getStaNo())) { |
| | | throw new CoolException("订单出库异常,请联系管理员"); |
| | | } |
| | | } |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocNo, taskDto.getLocNo()) |
| | | .eq(LocMast::getHostId, hostId)); |
| | | // 获取路径 |
| | | int ioType = taskDto.isAll() ? 101 : 103; |
| | | // 获取路径 |
| | | StaDesc staDesc = staDescService.getOne(new LambdaQueryWrapper<StaDesc>().eq(StaDesc::getTypeNo, ioType).eq(StaDesc::getDeviceStn, staNo).eq(StaDesc::getHostId, hostId)); |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(101L); // 工作状态:101.生成出库 |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setSourceStaNo(staDesc.getDeviceStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(taskDto.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | wrkMast.setAppeUser(String.valueOf(userId)); // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(String.valueOf(userId)); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setHostId(hostId); |
| | | if (!wrkMastService.save(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+taskDto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; } |
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getOrderNo, locDto.getOrderNo()) |
| | | .eq(Order::getHostId, hostId)); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), locDto.getBatch()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), null); |
| | | } |
| | | LocDetl locDetl = locDetlService.selectItem(locDto.getLocNo(), locDto.getMatnr(), locDto.getBatch(), hostId); |
| | | if (locDetl == null || locDetl.getAnfme() < locDto.getAnfme()) { |
| | | throw new CoolException(locDto.getLocNo() + "库位中" + locDto.getMatnr() + "商品库存不足!"); |
| | | } |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(orderDetl); |
| | | wrkDetl.setZpallet(wrkMast.getBarcode()); |
| | | wrkDetl.setIoTime(now); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setBatch(locDto.getBatch()); |
| | | wrkDetl.setOrderNo(locDto.getOrderNo()); |
| | | wrkDetl.setAnfme(locDto.getAnfme()); // 数量 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setHostId(hostId); |
| | | wrkDetl.setWrkMastId(wrkMast.getId()); |
| | | if (!wrkDetlService.save(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | // 修改订单明细 |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), hostId, orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId, hostId); |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocNo, taskDto.getLocNo()) |
| | | .eq(LocMast::getHostId, hostId)); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+taskDto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(taskDto.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void completeWrkMast(String workNo, Long userId, Long hostId) { |
| | | WrkMast wrkMast = wrkMastService.getOne(new LambdaQueryWrapper<WrkMast>().eq(WrkMast::getWrkNo, workNo).eq(WrkMast::getHostId, hostId)); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | |
| | | select |
| | | a.* |
| | | from wms_loc_detl a |
| | | left join common_loc_mast b on a.loc_no = b.loc_no |
| | | left join common_loc_mast b on a.loc_no = b.loc_no and a.host_id = b.host_id |
| | | where 1=1 |
| | | <if test="no!=null and no == 1"> |
| | | and b.row1 >= 31 |
| | | and b.row1 <= 32 |
| | | </if> |
| | | <if test="no!=null and no == 2"> |
| | | and b.row1 >= 2 |
| | | and b.row1 <= 17 |
| | | </if> |
| | | <if test="no!=null and no == 3"> |
| | | and b.row1 >= 18 |
| | | and b.row1 <= 30 |
| | | </if> |
| | | and a.matnr = #{matnr} |
| | | and b.bay1 = #{bay} |
| | | <if test="batch!=null and batch!=''"> |
| | | and a.batch = #{batch} |
| | | </if> |
| | | and b.host_id = #{hostId} |
| | | and b.loc_sts = 'F' |
| | | order by b.row1 |
| | | <if test="orderBy != null and orderBy != '' and orderBy == 'false'"> |
| | | desc |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="queryStockPre" resultType="com.zy.asrs.common.domain.dto.QueryStockPreDo"> |
| | | select |
| | | * |
| | | from |
| | | ( |
| | | select |
| | | no = 1, |
| | | orderBy = 'true', |
| | | b.bay1 as bay, |
| | | sum(anfme) as count |
| | | from wms_loc_detl a |
| | | left join common_loc_mast b on a.loc_no = b.loc_no |
| | | where 1=1 |
| | | and b.loc_sts = 'F' |
| | | and a.matnr = #{matnr} |
| | | and b.row1 >= 31 |
| | | and b.row1 <= 32 |
| | | group by b.bay1 |
| | | union |
| | | select |
| | | no = 2, |
| | | orderBy = 'true', |
| | | b.bay1 as bay, |
| | | sum(anfme) as count |
| | | from wms_loc_detl a |
| | | left join common_loc_mast b on a.loc_no = b.loc_no |
| | | where 1=1 |
| | | and b.loc_sts = 'F' |
| | | and a.matnr = #{matnr} |
| | | and b.row1 >= 2 |
| | | and b.row1 <= 17 |
| | | group by b.bay1 |
| | | union |
| | | select |
| | | no = 3, |
| | | orderBy = 'false', |
| | | b.bay1 as bay, |
| | | sum(anfme) as count |
| | | from wms_loc_detl a |
| | | left join common_loc_mast b on a.loc_no = b.loc_no |
| | | where 1=1 |
| | | and b.loc_sts = 'F' |
| | | and a.matnr = #{matnr} |
| | | and b.row1 >= 18 |
| | | and b.row1 <= 30 |
| | | group by b.bay1 |
| | | ) a |
| | | order by no, count desc |
| | | </select> |
| | | |
| | | <select id="selectItem" resultType="com.zy.asrs.common.wms.entity.LocDetl"> |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.common.wms.mapper.StaDescMapper"> |
| | | |
| | | <select id="queryOutStaNosByLocNo" resultType="integer"> |
| | | select |
| | | distinct asd.stn_no |
| | | from wms_sta_desc asd |
| | | left join wms_loc_mast alm on asd.crn_no = alm.crn_no |
| | | where 1=1 |
| | | and alm.loc_no = #{locNo} |
| | | <if test="typeNo != null and typeNo !=''"> |
| | | and asd.type_no = #{typeNo} |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | wrkQty = wrkQty + orderDetl.getQty(); |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | if (issued > 0.0) { |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getOrigin(), null); |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), hostId); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | issued = issued - locDetl.getAnfme(); |
| | |
| | | package com.zy.asrs.wms.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.domain.dto.LocDto; |
| | | import com.zy.asrs.common.domain.dto.OrderDto; |
| | | import com.zy.asrs.common.domain.dto.TaskDto; |
| | | import com.zy.asrs.common.sys.service.StaDescService; |
| | | import com.zy.asrs.common.web.BaseController; |
| | | import com.zy.asrs.common.wms.entity.LocDetl; |
| | | import com.zy.asrs.common.wms.entity.OrderDetl; |
| | | import com.zy.asrs.common.wms.entity.*; |
| | | import com.zy.asrs.common.wms.service.*; |
| | | import com.zy.asrs.framework.annotations.ManagerAuth; |
| | | import com.zy.asrs.framework.common.BaseRes; |
| | |
| | | if (Cools.isEmpty(ids)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | Long hostId = getHostId(); |
| | | List<OrderDetl> orderDetls = orderDetlService.listByIds(ids); |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | |
| | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { continue; } |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getOrigin(), exist); |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), hostId); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (!Cools.isEmpty(locDetl.getMemo())){ |
| | | continue; |
| | |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103, hostId); |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | |
| | | return R.ok().add(locDtos); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout/auth") |
| | | @ManagerAuth(memo = "订单出库") |
| | | public synchronized R pakout(@RequestBody List<LocDto> locDtos) throws InterruptedException { |
| | | if (Cools.isEmpty(locDtos)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | Long hostId = getHostId(); |
| | | boolean lack = true; |
| | | for (LocDto locDto : locDtos) { |
| | | if (!locDto.isLack()) { |
| | | lack = false; |
| | | break; |
| | | } |
| | | } |
| | | if (lack) { |
| | | return R.error("库存不足"); |
| | | } |
| | | |
| | | Thread.sleep(500L); |
| | | |
| | | // 订单预校验 ===>> 1.订单状态; 2.订单带出数量 |
| | | List<OrderDto> orderDtos = new ArrayList<>(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (Cools.isEmpty(locDto.getOrderNo())) { continue; } |
| | | OrderDto orderDto = new OrderDto(locDto.getOrderNo(), locDto.getMatnr(), locDto.getAnfme()); |
| | | if (OrderDto.has(orderDtos, orderDto)) { |
| | | OrderDto dto = OrderDto.find(orderDtos, orderDto); |
| | | assert dto != null; |
| | | dto.setAnfme(dto.getAnfme() + orderDto.getAnfme()); |
| | | } else { |
| | | orderDtos.add(orderDto); |
| | | } |
| | | } |
| | | for (OrderDto orderDto : orderDtos) { |
| | | Order order = orderService.selectByNo(orderDto.getOrderNo(), hostId); |
| | | if (order.getSettle() > 2) { |
| | | return R.error(orderDto.getOrderNo() + "订单已失效,请及时刷新页面"); |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), orderDto.getMatnr(), null); |
| | | if (orderDetl.getAnfme() - orderDetl.getQty() < orderDto.getAnfme()) { |
| | | return R.ok(orderDto.getOrderNo() + "订单已作业,请及时刷新页面"); |
| | | } |
| | | } |
| | | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.isLack()) { continue; } |
| | | //2022-08-04 Add,防止前端页面提取库位信息后,在其他地方对该库位生成了出库任务(库位状态非F状态) |
| | | LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocNo, locDto.getLocNo()) |
| | | .eq(LocMast::getHostId, hostId)); |
| | | if(!Cools.isEmpty(locMast) && !locMast.getLocSts().equals("F")){ |
| | | return R.error("库位号非在库状态,请重新选择出库库位===>>" + locDto.getLocNo()); |
| | | } |
| | | |
| | | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getStaNo(), locDto, hostId); |
| | | if (TaskDto.has(taskDtos, taskDto)) { |
| | | TaskDto dto = TaskDto.find(taskDtos, taskDto); |
| | | assert dto != null; |
| | | dto.getLocDtos().addAll(taskDto.getLocDtos()); |
| | | } else { |
| | | taskDtos.add(taskDto); |
| | | } |
| | | } |
| | | // ----------------------------------------------------------------------------------------------- |
| | | for (TaskDto taskDto : taskDtos) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo(), false, hostId); |
| | | workService.stockOut(staNo.getDevNo(), taskDto, getUserId(), hostId); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |