| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.BaseRes; |
| | |
| | | import com.zy.asrs.entity.param.FullStoreParam; |
| | | import com.zy.asrs.entity.param.LocDetlAdjustParam; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.entity.result.PakoutVo; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.common.model.*; |
| | |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.service.wms.Result; |
| | | import com.zy.common.service.wms.WmsService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | /** |
| | | * Created by vincent on 2020/6/11 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class WorkServiceImpl implements WorkService { |
| | | |
| | |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getDevpNo(), true); |
| | | // 检索库位 |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | log.info(JSON.toJSONString(locTypeDto)); |
| | | log.info("{}入库口尺寸检测:{}", param.getDevpNo(), locTypeDto.getLocType1()==1?"低规格库位":"高规格库位"); |
| | | List<String> matNos = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatNo).distinct().collect(Collectors.toList()); |
| | | StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 1, param.getDevpNo(), matNos, locTypeDto, 0); |
| | | // 生成工作号 |
| | |
| | | // 出库 ===>> F.在库 |
| | | if (wrkMast.getIoType() > 100 && wrkMast.getIoType() != 110) { |
| | | locSts = "F"; |
| | | // 销售单关联,则生成新的出库任务 |
| | | if (wrkMast.getPdcType().equals("Y")) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", workNo)); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | Double sumAnfme = Optional.ofNullable(locDetlService.getSumAnfme(wrkDetl.getMatnr())).orElse(0.0D); |
| | | if (sumAnfme < wrkDetl.getAnfme()) { |
| | | throw new CoolException("取消失败!库存不足以重新生成出库作业"); |
| | | } |
| | | } |
| | | // 生成新的出库作业 |
| | | stockOutRe(wrkMast, wrkDetls); |
| | | } |
| | | // 空板出库 ===>> D.空桶/空栈板 |
| | | } else if (wrkMast.getIoType() == 110) { |
| | | locSts = "D"; |
| | |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | private boolean pickSite = false; |
| | | private void stockOutRe(WrkMast wrkMast, List<WrkDetl> wrkDetls) { |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | List<LocDetl> locDetls = locDetlService.selectPakoutByRule(wrkDetl.getMatnr()); |
| | | double issued = wrkDetl.getAnfme(); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | // 生成出库工作档 |
| | | // 全板 |
| | | if (issued>=locDetl.getAnfme()) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(103); |
| | | List<LocDetlDto> detlDtos = new ArrayList<>(); |
| | | LocDetlDto dto = new LocDetlDto(); |
| | | dto.setLocDetl(locDetl); |
| | | dto.setCount(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); |
| | | detlDtos.add(dto); |
| | | stockOut(staNo, detlDtos, 101, 9527L, null, true, null); |
| | | // 拣料 |
| | | } else { |
| | | int priorCount = jdbcTemplate.queryForObject("select isnull(count(*),0) from man_prior where 1=1 and matnr = '" + wrkDetl.getMatnr() + "'", Integer.class); |
| | | if (priorCount > 0) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(103); |
| | | List<LocDetlDto> detlDtos = new ArrayList<>(); |
| | | LocDetlDto dto = new LocDetlDto(); |
| | | dto.setLocDetl(locDetl); |
| | | dto.setCount(locDetl.getAnfme()); |
| | | detlDtos.add(dto); |
| | | stockOut(staNo, detlDtos, 101, 9527L,null, true,locDetl.getAnfme()-issued); |
| | | } else { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(pickSite?113:109); |
| | | List<LocDetlDto> detlDtos = new ArrayList<>(); |
| | | LocDetlDto dto = new LocDetlDto(); |
| | | dto.setLocDetl(locDetl); |
| | | dto.setCount(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); |
| | | detlDtos.add(dto); |
| | | stockOut(staNo, detlDtos, 103, 9527L, null, true, null); |
| | | } |
| | | |
| | | } |
| | | |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } |
| | | } |
| | | } |
| | | pickSite = !pickSite; |
| | | } |
| | | |
| | | } |