Merge remote-tracking branch 'origin/tzskasrs-2' into tzskasrs-2
 
	
	
	
	
	
	
	
	
	
	
	
	
	
 |  |  | 
 |  |  |         // 更新目标库位状态 | 
 |  |  |         LocMast locMast = locMastService.selectById(dto.getLocNo()); | 
 |  |  |         if (locMast.getLocSts().equals("O")){ | 
 |  |  |             log.warn("Flag - 1,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "S"); | 
 |  |  |             locMast.setLocSts("S"); // S.入库预约 | 
 |  |  |             locMast.setModiUser(userId); | 
 |  |  |             locMast.setModiTime(now); | 
 |  |  | 
 |  |  |             // 修改库位状态:   F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 | 
 |  |  |             locMast = locMastService.selectById(dto.getLocNo()); | 
 |  |  |             if (locMast.getLocSts().equals("F")) { | 
 |  |  |                 log.warn("Flag - 2,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), ioType==101?"R":"P"); | 
 |  |  |                 locMast.setLocSts(ioType==101?"R":"P"); | 
 |  |  |                 locMast.setModiUser(userId); | 
 |  |  |                 locMast.setModiTime(now); | 
 |  |  | 
 |  |  |         // 修改库位状态:   F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 | 
 |  |  |         locMast = locMastService.selectById(taskDto.getLocNo()); | 
 |  |  |         if (locMast.getLocSts().equals("F")) { | 
 |  |  |             log.warn("Flag - 3,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), ioType==101?"R":"P"); | 
 |  |  |             locMast.setLocSts(ioType==101?"R":"P"); | 
 |  |  |             locMast.setModiUser(userId); | 
 |  |  |             locMast.setModiTime(now); | 
 |  |  | 
 |  |  |         // 更新目标库位状态 | 
 |  |  |         LocMast locMast = locMastService.selectById(dto.getLocNo()); | 
 |  |  |         if (locMast.getLocSts().equals("O")){ | 
 |  |  |             log.warn("Flag - 4,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "S"); | 
 |  |  |             locMast.setLocSts("S"); // S.入库预约 | 
 |  |  |             locMast.setModiUser(userId); | 
 |  |  |             locMast.setModiTime(new Date()); | 
 |  |  | 
 |  |  |             } | 
 |  |  |             // 更新库位状态 D.空板 -> R.出库预约 | 
 |  |  |             if (locMast.getLocSts().equals("D")){ | 
 |  |  |                 log.warn("Flag - 5,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "R"); | 
 |  |  |                 locMast.setLocSts("R"); | 
 |  |  |                 locMast.setModiUser(userId); | 
 |  |  |                 locMast.setModiTime(new Date()); | 
 |  |  | 
 |  |  |         } | 
 |  |  |         // 修改源库位状态 | 
 |  |  |         if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) { | 
 |  |  |             log.warn("Flag - 6,{}库位状态变更,{} => {}", sourceLoc.getLocNo(), sourceLoc.getLocSts(), "R"); | 
 |  |  |             sourceLoc.setLocSts("R"); // R.出库预约 | 
 |  |  |             sourceLoc.setModiUser(userId); | 
 |  |  |             sourceLoc.setModiTime(now); | 
 |  |  | 
 |  |  |         } | 
 |  |  |         // 修改目标库位状态 | 
 |  |  |         if (loc.getLocSts().equals("O")) { | 
 |  |  |             log.warn("Flag - 7,{}库位状态变更,{} => {}", loc.getLocNo(), loc.getLocSts(), "S"); | 
 |  |  |             loc.setLocSts("S"); // S.入库预约 | 
 |  |  |             loc.setModiTime(now); | 
 |  |  |             loc.setModiUser(userId); | 
 |  |  | 
 |  |  |         int count = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo())); | 
 |  |  |         if (locMast.getLocSts().equals("F")) { | 
 |  |  |             if (count == 0) { | 
 |  |  |                 log.warn("Flag - 8,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "D"); | 
 |  |  |                 locMast.setLocSts("D"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if (locMast.getLocSts().equals("D") || locMast.getLocSts().equals("O")) { | 
 |  |  |             if (count > 0) { | 
 |  |  |                 log.warn("Flag - 9,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "F"); | 
 |  |  |                 locMast.setLocSts("F"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  | 
 |  |  |                 if (Cools.isEmpty(locMast)) { | 
 |  |  |                     throw new CoolException("取消库位转移失败,源库位不存在:" + wrkMast.getSourceLocNo()); | 
 |  |  |                 } | 
 |  |  |                 log.warn("Flag - 9,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "F"); | 
 |  |  |                 locMast.setLocSts("F"); | 
 |  |  |                 locMast.setModiTime(new Date()); | 
 |  |  |                 locMast.setModiUser(userId); | 
 |  |  | 
 |  |  |                 if (Cools.isEmpty(locMast)) { | 
 |  |  |                     throw new CoolException("取消库位转移失败,目标库位不存在:" + wrkMast.getSourceLocNo()); | 
 |  |  |                 } | 
 |  |  |                 log.warn("Flag - 10,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "O"); | 
 |  |  |                 locMast.setLocSts("O"); | 
 |  |  |                 locMast.setModiTime(new Date()); | 
 |  |  |                 locMast.setModiUser(userId); | 
 |  |  | 
 |  |  |         if (Cools.isEmpty(locMast)) { | 
 |  |  |             throw new CoolException("取消工作档失败,库位不存在:"+ locNo); | 
 |  |  |         } | 
 |  |  |         log.warn("Flag - 11,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), locSts); | 
 |  |  |         locMast.setLocSts(locSts); | 
 |  |  |         locMast.setModiTime(new Date()); | 
 |  |  |         locMast.setModiUser(userId); | 
 |  |  | 
 |  |  |         } | 
 |  |  |         // 修改库位状态 Q.拣料/盘点/并板再入库 | 
 |  |  |         LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); | 
 |  |  |         log.warn("Flag - 12,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "Q"); | 
 |  |  |         locMast.setLocSts("Q"); | 
 |  |  |         locMast.setModiTime(new Date()); | 
 |  |  |         locMast.setModiUser(userId); | 
 
 |  |  | 
 |  |  | import com.zy.asrs.utils.Utils; | 
 |  |  | import com.zy.common.model.enums.WorkNoType; | 
 |  |  | import com.zy.common.service.CommonService; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.BeanUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | 
 |  |  | import java.util.*; | 
 |  |  | import java.util.stream.Collectors; | 
 |  |  |  | 
 |  |  | @Slf4j | 
 |  |  | @Service | 
 |  |  | public class AutoReplenishmentHandler extends AbstractHandler<String> { | 
 |  |  |  | 
 |  |  | 
 |  |  |             List<LocDetl> locDetls = locDetlService.selectByLocNo(locNo); | 
 |  |  |             createWrkDetl(locDetls, wrkMast,order.getOrderNo(),now); | 
 |  |  |             //修改库位状态 | 
 |  |  |             log.warn("Flag - 24,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "R"); | 
 |  |  |             locMast.setLocSts("R"); | 
 |  |  |             locMastService.updateByLocNo(locMast); | 
 |  |  |         } | 
 
 |  |  | 
 |  |  |                         if (!Cools.isEmpty(wrkMast.getBarcode())) { | 
 |  |  |                             locMast.setBarcode(wrkMast.getBarcode()); | 
 |  |  |                         } | 
 |  |  |                         log.warn("Flag - 13,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "D"); | 
 |  |  |                         locMast.setLocSts("D"); | 
 |  |  |                         locMast.setIoTime(now); | 
 |  |  |                         locMast.setModiTime(now); | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                     // 修改库位状态 S ====>> F | 
 |  |  |                     if (locMast.getLocSts().equals("S")) { | 
 |  |  |                         log.warn("Flag - 14,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "F"); | 
 |  |  |                         locMast.setLocSts("F"); | 
 |  |  |                         locMast.setBarcode(wrkMast.getBarcode()); | 
 |  |  |                         locMast.setIoTime(now); | 
 |  |  | 
 |  |  |  | 
 |  |  |                     // 修改库位状态 Q ====>> F | 
 |  |  |                     if (locMast.getLocSts().equals("Q")) { | 
 |  |  |                         log.warn("Flag - 15,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "F"); | 
 |  |  |                         locMast.setLocSts("F"); | 
 |  |  |                         locMast.setBarcode(wrkMast.getBarcode()); | 
 |  |  |                         locMast.setIoTime(now); | 
 |  |  | 
 |  |  |                     //清空源库位数据 P ====>> O | 
 |  |  |                     LocMast locMast1 = locMastService.selectByLoc(wrkMast.getSourceLocNo()); | 
 |  |  |                     if (locMast1.getLocSts().equals("P")) { | 
 |  |  |                         log.warn("Flag - 16,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "O"); | 
 |  |  |                         locMast1.setLocSts("O"); // 清空库位 | 
 |  |  |                         locMast1.setModiTime(new Date()); | 
 |  |  |                         if (!locMastService.updateById(locMast1)) { | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                     // 修改库位状态 Q ====>> F | 
 |  |  |                     if (locMast.getLocSts().equals("Q")) { | 
 |  |  |                         log.warn("Flag - 17,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "F"); | 
 |  |  |                         locMast.setLocSts("F"); | 
 |  |  |                         locMast.setBarcode(wrkMast.getBarcode()); | 
 |  |  |                         locMast.setIoTime(now); | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                     // 修改库位状态 S ====>> F | 
 |  |  |                     if (locMast.getLocSts().equals("S")) { | 
 |  |  |                         log.warn("Flag - 18,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), wrkMast.getFullPlt().equals("Y")?"F":"D"); | 
 |  |  |                         locMast.setLocSts(wrkMast.getFullPlt().equals("Y")?"F":"D"); | 
 |  |  |                         locMast.setBarcode(wrkMast.getBarcode()); | 
 |  |  |                         locMast.setIoTime(now); | 
 |  |  | 
 |  |  |                     // 修改源库位状态 ==> O | 
 |  |  |                     LocMast sourceLoc = locMastService.selectById(wrkMast.getSourceLocNo()); | 
 |  |  |                     if (null != sourceLoc) { | 
 |  |  |                         log.warn("Flag - 19,{}库位状态变更,{} => {}", sourceLoc.getLocNo(), sourceLoc.getLocSts(), "O"); | 
 |  |  |                         sourceLoc.setBarcode(""); | 
 |  |  |                         sourceLoc.setLocSts("O"); | 
 |  |  |                         sourceLoc.setModiTime(now); | 
 |  |  | 
 |  |  |                         locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no",locMast.getLocNo())); | 
 |  |  |                     } | 
 |  |  |                     // 修改目标库位状态 ==> .locSts | 
 |  |  |                     log.warn("Flag - 20,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), locSts); | 
 |  |  |                     locMast.setLocSts(locSts); | 
 |  |  |                     locMast.setBarcode(wrkMast.getBarcode()); | 
 |  |  |                     locMast.setIoTime(now); | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                     // 修改源库位状态 R ===>> O | 
 |  |  |                     if (locMast.getLocSts().equals("R")) { | 
 |  |  |                         log.warn("Flag - 21,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "O"); | 
 |  |  |                         locMast.setLocSts("O"); | 
 |  |  |                         locMast.setBarcode(""); | 
 |  |  |                         locMast.setModiTime(now); | 
 |  |  | 
 |  |  |                 case 107: | 
 |  |  |                     // 修改库位状态 R ===>> O | 
 |  |  |                     if (locMast.getLocSts().equals("P")) { | 
 |  |  |                         log.warn("Flag - 22,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "O"); | 
 |  |  |                         locMast.setLocSts("O"); | 
 |  |  |                         locMast.setBarcode(""); | 
 |  |  |                         locMast.setModiTime(now); | 
 |  |  | 
 |  |  |                 case 110: | 
 |  |  |                     // 修改库位状态 R ===>> O | 
 |  |  |                     if (locMast.getLocSts().equals("R")) { | 
 |  |  |                         log.warn("Flag - 23,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "O"); | 
 |  |  |                         locMast.setLocSts("O"); | 
 |  |  |                         locMast.setBarcode(""); | 
 |  |  |                         locMast.setModiTime(now); | 
 
 |  |  | 
 |  |  |         // 更新目标库位状态 | 
 |  |  |         LocMast locMast = locMastService.selectById(dto.getLocNo()); | 
 |  |  |         if (locMast.getLocSts().equals("O")) { | 
 |  |  |             log.warn("Flag - 25,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "S"); | 
 |  |  |             locMast.setLocSts("S"); // S.入库预约 | 
 |  |  |             locMast.setModiTime(now); | 
 |  |  |             if (!locMastService.updateById(locMast)) { | 
 |  |  | 
 |  |  |         // 更新目标库位状态 | 
 |  |  |         LocMast locMast = locMastService.selectById(dto.getLocNo()); | 
 |  |  |         if (locMast.getLocSts().equals("O")) { | 
 |  |  |             log.warn("Flag - 26,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "S"); | 
 |  |  |             locMast.setLocSts("S"); // S.入库预约 | 
 |  |  |             locMast.setModiTime(new Date()); | 
 |  |  |             if (!locMastService.updateById(locMast)) { | 
 |  |  | 
 |  |  |         // 更新目标库位状态 | 
 |  |  |         LocMast locMast = locMastService.selectById(dto.getLocNo()); | 
 |  |  |         if (locMast.getLocSts().equals("O")) { | 
 |  |  |             log.warn("Flag - 27,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "S"); | 
 |  |  |             locMast.setLocSts("S"); // S.入库预约 | 
 |  |  |             locMast.setModiTime(new Date()); | 
 |  |  |             if (!locMastService.updateById(locMast)) { | 
 |  |  | 
 |  |  |         // 更新目标库位状态 | 
 |  |  |         LocMast locMast = locMastService.selectById(dto.getLocNo()); | 
 |  |  |         if (locMast.getLocSts().equals("O")) { | 
 |  |  |             log.warn("Flag - 28,{}库位状态变更,{} => {}", locMast.getLocNo(), locMast.getLocSts(), "Q"); | 
 |  |  |             locMast.setLocSts("Q"); // Q.拣料再入库 | 
 |  |  |             locMast.setModiTime(new Date()); | 
 |  |  |             if (!locMastService.updateById(locMast)) { |