From e84239bee7f6555e6ff59789829be7ce4b7393d7 Mon Sep 17 00:00:00 2001 From: "HUOJIN\\92525" <925258474@qq.com> Date: Tue, 24 Sep 2024 16:11:30 +0800 Subject: [PATCH] no message --- .../com/youchain/basicdata/domain/Item.java | 4 + .../com/youchain/basicdata/domain/Point.java | 5 + .../basicdata/service/dto/PointDto.java | 6 +- .../service/impl/BoxServiceImpl.java | 2 +- .../businessdata/domain/AsnDetail.java | 8 +- .../youchain/businessdata/domain/ItemKey.java | 8 +- .../businessdata/inputJson/Zhengli.java | 26 ++ .../repository/InventoryRepository.java | 7 + .../rest/AsnDetailController.java | 243 ++++++++++-------- .../businessdata/rest/PickOutController.java | 4 +- .../rest/PickTicketController.java | 4 +- .../rest/XppRecordController.java | 4 +- .../service/AsnDetailService.java | 7 + .../service/InventoryService.java | 2 + .../businessdata/service/ItemKeyService.java | 4 +- .../service/dto/AsnDetailDto.java | 5 +- .../service/impl/AsnDetailServiceImpl.java | 204 ++++++++++----- .../service/impl/InventoryServiceImpl.java | 23 ++ .../service/impl/ItemKeyServiceImpl.java | 89 ++++--- .../service/impl/SparepartsServiceImpl.java | 4 +- .../service/impl/TaskServiceImpl.java | 2 +- 21 files changed, 413 insertions(+), 248 deletions(-) create mode 100644 youchain-system/src/main/java/com/youchain/businessdata/inputJson/Zhengli.java diff --git a/youchain-system/src/main/java/com/youchain/basicdata/domain/Item.java b/youchain-system/src/main/java/com/youchain/basicdata/domain/Item.java index c46d7ac..1a3684d 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/domain/Item.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/domain/Item.java @@ -134,6 +134,10 @@ public class Item extends BaseEntity implements Serializable { @ApiModelProperty(value = "是否SAP料号") private Boolean isSapMaterial=false; + @Column(name = "`is_inspection`") + @ApiModelProperty(value = "是否质检") + private Boolean isInspection=false; + @Column(name = "`heat_value`") @ApiModelProperty(value = "热度值") private Integer heatValue=0; diff --git a/youchain-system/src/main/java/com/youchain/basicdata/domain/Point.java b/youchain-system/src/main/java/com/youchain/basicdata/domain/Point.java index ff6ed95..1a0897c 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/domain/Point.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/domain/Point.java @@ -118,6 +118,11 @@ public class Point extends BaseEntity implements Serializable { @Column(name = "`sort_index`") @ApiModelProperty(value = "排序") private int sortIndex=0; + + @OneToOne + @JoinColumn(name = "`stock_id`") + @ApiModelProperty(value = "容器") + private Stock stock; public void copy(Point source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/dto/PointDto.java b/youchain-system/src/main/java/com/youchain/basicdata/service/dto/PointDto.java index 76b6a8c..6b7910d 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/service/dto/PointDto.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/dto/PointDto.java @@ -16,6 +16,7 @@ package com.youchain.basicdata.service.dto; import com.youchain.basicdata.domain.Point; +import com.youchain.basicdata.domain.Stock; import com.youchain.modules.system.service.dto.DeptSmallDto; import lombok.Data; import java.sql.Timestamp; @@ -59,6 +60,9 @@ public class PointDto implements Serializable { /** 仓库ID */ private DeptSmallDto dept; + /** 容器 */ + private Stock stock; + /** 坐标X */ private Double posX; @@ -95,4 +99,4 @@ public class PointDto implements Serializable { /** 修改时间 */ private Timestamp updateTime; -} \ No newline at end of file +} diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/BoxServiceImpl.java b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/BoxServiceImpl.java index 6d6b0bc..3e17164 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/BoxServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/BoxServiceImpl.java @@ -325,7 +325,7 @@ public class BoxServiceImpl implements BoxService { asnDetailService.create(asnDetail); //生成Itemkey - ItemKey itemKey = itemKeyService.getItemKey(item, asnDetail.getPropC1(), asnDetail.getPropD1()); + ItemKey itemKey = itemKeyService.getItemKey(item, asnDetail.getPropC1(), null, null, null, null, asnDetail.getPropD1()); //生成入库记录 diff --git a/youchain-system/src/main/java/com/youchain/businessdata/domain/AsnDetail.java b/youchain-system/src/main/java/com/youchain/businessdata/domain/AsnDetail.java index 43c077f..4890193 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/domain/AsnDetail.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/domain/AsnDetail.java @@ -118,19 +118,19 @@ public class AsnDetail extends BaseEntity implements Serializable { private String propC2; @Column(name = "`prop_c3`") - @ApiModelProperty(value = "厂家编号") + @ApiModelProperty(value = "工厂") private String propC3; @Column(name = "`prop_c4`") - @ApiModelProperty(value = "属性4") + @ApiModelProperty(value = "loc") private String propC4; @Column(name = "`prop_c5`") - @ApiModelProperty(value = "属性5") + @ApiModelProperty(value = "特殊标记") private String propC5; @Column(name = "`prop_c6`") - @ApiModelProperty(value = "属性6") + @ApiModelProperty(value = "供应商") private String propC6; @Column(name = "`prop_d1`") diff --git a/youchain-system/src/main/java/com/youchain/businessdata/domain/ItemKey.java b/youchain-system/src/main/java/com/youchain/businessdata/domain/ItemKey.java index f86a6be..58a7c01 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/domain/ItemKey.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/domain/ItemKey.java @@ -60,19 +60,19 @@ public class ItemKey extends BaseEntity implements Serializable { private String propC2; @Column(name = "`prop_c3`") - @ApiModelProperty(value = "属性4") + @ApiModelProperty(value = "工厂") private String propC3; @Column(name = "`prop_c4`") - @ApiModelProperty(value = "属性4") + @ApiModelProperty(value = "loc") private String propC4; @Column(name = "`prop_c5`") - @ApiModelProperty(value = "属性5") + @ApiModelProperty(value = "特殊标记") private String propC5; @Column(name = "`prop_c6`") - @ApiModelProperty(value = "属性6") + @ApiModelProperty(value = "供应商") private String propC6; @Column(name = "`prop_d1`") diff --git a/youchain-system/src/main/java/com/youchain/businessdata/inputJson/Zhengli.java b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/Zhengli.java new file mode 100644 index 0000000..d90046a --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/Zhengli.java @@ -0,0 +1,26 @@ +package com.youchain.businessdata.inputJson; + +import com.youchain.basicdata.domain.Area; +import com.youchain.basicdata.domain.Point; +import com.youchain.basicdata.domain.Stock; +import lombok.Data; + +/** + * @author huojin + * @date 2024-09-24 + * 整理入参 + */ +@Data +public class Zhengli { + Long id; + + Area area; + + Stock stock; + + Point point; + + double receivedQty; + + +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java b/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java index 077b7da..bf28fa0 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java @@ -43,4 +43,11 @@ public interface InventoryRepository extends JpaRepository, Jpa " order by inv.item_key_id in (select id from data_item_key where item_id = ?1 ORDER BY prop_d1 ) ", nativeQuery = true) List queryInventory(long itemId, long areaId); + @Query("from Inventory inv where inv.quantity > 0 " + + "and (:itemKeyId is null or inv.itemKey.id = :itemKeyId) " + + "and (:pointId is null or inv.point.id = :pointId) " + + "and (:stockId is null or inv.stock.id = :stockId) " + + "and (:deptId is null or inv.dept.id = :deptId)") + List findByInventory(Long itemKeyId, Long pointId, Long stockId, Long deptId); + } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/AsnDetailController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/AsnDetailController.java index 7420d14..6dcfc7a 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/AsnDetailController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/AsnDetailController.java @@ -34,6 +34,7 @@ import com.youchain.businessdata.inputJson.IRkConfirm; import com.youchain.businessdata.inputJson.IRkInv; import com.youchain.businessdata.inputJson.IRkPut; import com.youchain.businessdata.domain.*; +import com.youchain.businessdata.inputJson.Zhengli; import com.youchain.businessdata.inputJson.buttenJson.AsnDetailButton; import com.youchain.businessdata.repository.AsnDetailRepository; import com.youchain.businessdata.repository.InventoryRepository; @@ -166,7 +167,6 @@ public class AsnDetailController { } - @PutMapping @Log("修改asn_detail") @ApiOperation("修改asn_detail") @@ -195,24 +195,24 @@ public class AsnDetailController { @ApiOperation("APP现品票上架-单个") @AnonymousAccess public ResponseEntity putawayInvApp(@RequestBody IRkPut s) { - log.info("s:"+s); + log.info("s:" + s); String pointCode = s.getPointCode(); String ewm = s.getEwm(); - int seq=s.getSeq(); - XppRecord xppRecord =null; - Point point =null; + int seq = s.getSeq(); + XppRecord xppRecord = null; + Point point = null; RRkXpp map = new RRkXpp(); - AsnDetail d=null; + AsnDetail d = null; xppRecord = xppRecordRepository.findByCode(ewm); - if(xppRecord==null){ + if (xppRecord == null) { return new ResponseEntity<>(ewm + "未收货", BAD_REQUEST); } - d=xppRecord.getAsnDetailId(); - if(d.getReceivedQty()>0){ + d = xppRecord.getAsnDetailId(); + if (d.getReceivedQty() > 0) { return new ResponseEntity<>(ewm + "已上架,不能重复上架", BAD_REQUEST); } - if(seq==1){ - Item it=d.getItem(); + if (seq == 1) { + Item it = d.getItem(); map.setItemCode(it.getCode()); map.setItemName(it.getName()); map.setAc(xppRecord.getAc()); @@ -220,26 +220,26 @@ public class AsnDetailController { map.setNrs(xppRecord.getNrs()); map.setNrzsr(DateUtil.dateYmd(xppRecord.getNrDate())); map.setFzh(xppRecord.getFzh()); - map.setTjkw(it.getPoint()==null?null:it.getPoint().getCode()); + map.setTjkw(it.getPoint() == null ? null : it.getPoint().getCode()); return new ResponseEntity<>(map, HttpStatus.OK); } - if (seq==2) { - if(pointCode==null||!pointCode.equals("")){ - Point dstPoint=d.getItem().getPoint(); - if(dstPoint==null){ + if (seq == 2) { + if (pointCode == null || !pointCode.equals("")) { + Point dstPoint = d.getItem().getPoint(); + if (dstPoint == null) { return new ResponseEntity<>(d.getItem().getCode() + "品番未维护库位", BAD_REQUEST); } - point=dstPoint; - pointCode=dstPoint.getCode(); - }else { + point = dstPoint; + pointCode = dstPoint.getCode(); + } else { point = pointService.getPoint(pointCode, null, null, null); if (point == null) { return new ResponseEntity<>(pointCode + "库位不存在", BAD_REQUEST); } } - Area area=point.getArea(); - putawayInv(d.getId(),area.getId(),point.getId(),s.getQty(),ewm); - //直接上架确认 + Area area = point.getArea(); + putawayInv(d.getId(), area.getId(), point.getId(), s.getQty(), ewm); + //直接上架确认 } return new ResponseEntity<>("操作成功", HttpStatus.OK); } @@ -249,37 +249,37 @@ public class AsnDetailController { @ApiOperation("扫描现品票上架APP") @PreAuthorize("@el.check('super:man')") public ResponseEntity putawayXppApp(@RequestBody IRkPut s) { - int seq=s.getSeq(); - if(seq==1){ - XppRecord xppRecord =null; + int seq = s.getSeq(); + if (seq == 1) { + XppRecord xppRecord = null; String ewm = s.getEwm(); xppRecord = xppRecordRepository.findByCode(ewm); - if(xppRecord==null){ + if (xppRecord == null) { return new ResponseEntity<>(ewm + "二维码未采集", BAD_REQUEST); } - if(!xppRecord.getStatus().equals(BizStatus.RECEIVED)&&!xppRecord.getStatus().equals(BizStatus.RETENTION_IN)){ - throw new BadRequestException(xppRecord.getItem().getCode()+"现品票状态不正确"); + if (!xppRecord.getStatus().equals(BizStatus.RECEIVED) && !xppRecord.getStatus().equals(BizStatus.RETENTION_IN)) { + throw new BadRequestException(xppRecord.getItem().getCode() + "现品票状态不正确"); } - if(!xppRecord.getStatus().equals(BizStatus.RECEIVED)&&!xppRecord.getStatus().equals(BizStatus.RETENTION_IN)){ + if (!xppRecord.getStatus().equals(BizStatus.RECEIVED) && !xppRecord.getStatus().equals(BizStatus.RETENTION_IN)) { return new ResponseEntity<>("现品票状态不正确", BAD_REQUEST); } RRkXpp map = xppRecordService.xppAnalysis(xppRecord); return new ResponseEntity<>(map, HttpStatus.OK); } - if (seq==2) { + if (seq == 2) { String pointCode = s.getPointCode(); - if (pointCode == null||pointCode.equals("")) { - return new ResponseEntity<>( "库位不能为空", BAD_REQUEST); + if (pointCode == null || pointCode.equals("")) { + return new ResponseEntity<>("库位不能为空", BAD_REQUEST); } - Point point = pointService.getPoint(pointCode,null, null, null); + Point point = pointService.getPoint(pointCode, null, null, null); if (point == null) { return new ResponseEntity<>(pointCode + "库位不存在", BAD_REQUEST); } - Area area=point.getArea(); - for(String ewm:s.getEwms()){ - XppRecord xppRecord=xppRecordRepository.findByCode(ewm); + Area area = point.getArea(); + for (String ewm : s.getEwms()) { + XppRecord xppRecord = xppRecordRepository.findByCode(ewm); AsnDetail d = xppRecordService.addAsnDetail(xppRecord); - putawayInv(d.getId(), area.getId(), point.getId(), d.getOrderQty(),ewm); + putawayInv(d.getId(), area.getId(), point.getId(), d.getOrderQty(), ewm); } } return new ResponseEntity<>("操作成功", HttpStatus.OK); @@ -292,11 +292,11 @@ public class AsnDetailController { @PreAuthorize("@el.check('super:man')") @Transactional(rollbackFor = Exception.class) public ResponseEntity putawayConfirmXpp(@RequestBody HashMap rk) { - Long asnDetailId=Long.parseLong(rk.get("detailId").toString()); - AsnDetailDto dto= asnDetailService.findById(asnDetailId); - Double recQty=dto.getOrderQty()-dto.getReceivedQty(); + Long asnDetailId = Long.parseLong(rk.get("detailId").toString()); + AsnDetailDto dto = asnDetailService.findById(asnDetailId); + Double recQty = dto.getOrderQty() - dto.getReceivedQty(); putawayInv(asnDetailId, Long.parseLong(rk.get("areaId").toString()) - , Long.parseLong(rk.get("pointId").toString()),recQty,null); + , Long.parseLong(rk.get("pointId").toString()), recQty, null); return new ResponseEntity<>("操作成功", HttpStatus.OK); } @@ -306,24 +306,25 @@ public class AsnDetailController { @PreAuthorize("@el.check('super:man')") @Transactional public ResponseEntity cancelPut(@RequestBody Long[] ids) { - for (Long id:ids){ - XppRecord xppRecord = xppRecordService.getEntity(id); - AsnDetail ad=xppRecord.getAsnDetailId(); - if(ad==null){ - return new ResponseEntity("找不到上架记录", BAD_REQUEST); - } - if (!xppRecord.getStatus().equals(BizStatus.PUTAWAY)) { - throw new BadRequestException("上架状态才能取消上架"); - } - Task t=xppRecord.getRkTask(); + for (Long id : ids) { + XppRecord xppRecord = xppRecordService.getEntity(id); + AsnDetail ad = xppRecord.getAsnDetailId(); + if (ad == null) { + return new ResponseEntity("找不到上架记录", BAD_REQUEST); + } + if (!xppRecord.getStatus().equals(BizStatus.PUTAWAY)) { + throw new BadRequestException("上架状态才能取消上架"); + } + Task t = xppRecord.getRkTask(); // List ts=taskService.queryTask(ad.getId(),null,null,null); // for(Task t:ts) { - asnDetailService.cancelPut(t.getId(), xppRecord); + asnDetailService.cancelPut(t.getId(), xppRecord); // } - xppRecordRepository.delete(xppRecord); - } + xppRecordRepository.delete(xppRecord); + } return new ResponseEntity("取消成功", HttpStatus.OK); } + @Log("取消收货的操作") @ApiOperation("取消收货的操作") @PostMapping("/rkAndQxButtonQX") @@ -332,7 +333,7 @@ public class AsnDetailController { if (!asnDetailButton.getAsnDetailDataS().isEmpty()) { for (AsnDetail ad : asnDetailButton.getAsnDetailDataS()) { Asn asn = ad.getAsn(); - if (Objects.isNull(asn)){ + if (Objects.isNull(asn)) { throw new BadRequestException(HttpStatus.NOT_FOUND, ad.getItem().getCode() + "没有主单(订单序号)"); } AsnDto byId = asnMapper.toDto(asn); @@ -360,22 +361,22 @@ public class AsnDetailController { List inventoryDtos = invService.queryAll(inventoryQueryCriteria); if (!inventoryDtos.isEmpty()) { InventoryDto inventoryDto = inventoryDtos.get(0); - double pd = inventoryDto.getQuantity()-ad.getReceivedQty(); - if (pd>0){ - inventoryDto.setQuantity((int)pd); + double pd = inventoryDto.getQuantity() - ad.getReceivedQty(); + if (pd > 0) { + inventoryDto.setQuantity((int) pd); invService.update(inventoryMapper.toEntity(inventoryDto)); - }else if (pd==0d){ + } else if (pd == 0d) { inventoryRepository.deleteById(inventoryDto.getId()); - }else { - throw new BadRequestException(HttpStatus.NOT_FOUND, ad.getItem().getCode()+"库存数量不满,无法取消"); + } else { + throw new BadRequestException(HttpStatus.NOT_FOUND, ad.getItem().getCode() + "库存数量不满,无法取消"); } //生成库存日志 InventoryLog inventoryLog = invLogService.storeInventoryLog(BizStatus.RECEIVING_CANCEL, BizStatus.REDUCE, null, ad.getPoint().getArea(), inventoryDto.getItemKey(), - pointMapper.toEntity(inventoryDto.getPoint()) , dstPoint, ad.getStock(), ad.getStock(), ad.getReceivedQty(), ad.getReceivedQty(), null,null,BizStatus.ASN, ad.getId(), inventoryDto.getId(), ad.getRemark()); + pointMapper.toEntity(inventoryDto.getPoint()), dstPoint, ad.getStock(), ad.getStock(), ad.getReceivedQty(), ad.getReceivedQty(), null, null, BizStatus.ASN, ad.getId(), inventoryDto.getId(), ad.getRemark()); } // } - byId.setReceivedQuantity(byId.getReceivedQuantity()-ad.getReceivedQty()); + byId.setReceivedQuantity(byId.getReceivedQuantity() - ad.getReceivedQty()); ad.setReceivedQty(0d); asnDetailService.update(ad); asnService.update(asnMapper.toEntity(byId)); @@ -383,6 +384,7 @@ public class AsnDetailController { } return ApiResult.result(200, "操作成功", HttpStatus.OK); } + /** * 整单入库、单一入库、取消收货的操作 * @@ -410,10 +412,10 @@ public class AsnDetailController { throw new BadRequestException(HttpStatus.NOT_FOUND, asnId + "库区未填写"); } //查询 那个明细需要确认 - List asnDetails =asnDetailService.findAsnDetails(asnId,"1"); + List asnDetails = asnDetailService.findAsnDetails(asnId, "1"); if (!asnDetails.isEmpty()) { for (AsnDetail d : asnDetails) { - this.putawayInv(d.getId(), byId.getArea().getId(), d.getPoint()==null?null:d.getPoint().getId(),(d.getOrderQty()-d.getReceivedQty()),null); + this.putawayInv(d.getId(), byId.getArea().getId(), d.getPoint() == null ? null : d.getPoint().getId(), (d.getOrderQty() - d.getReceivedQty()), null); byId.setReceivedDate(new Timestamp(System.currentTimeMillis())); byId.setReceivedQuantity(byId.getReceivedQuantity() + d.getOrderQty()); @@ -428,7 +430,7 @@ public class AsnDetailController { } return ApiResult.result(200, "入库确认成功", HttpStatus.OK); } else if (asnDetailButton.getButton() == 2) { - double qty=asnDetailButton.getOneRNumber(); + double qty = asnDetailButton.getOneRNumber(); long id = asnDetailButton.getId(); AsnDto byId = asnService.findById(id); if (Objects.isNull(byId)) { @@ -441,15 +443,15 @@ public class AsnDetailController { // 通用异常,使用自定义状态码 throw new BadRequestException(HttpStatus.NOT_FOUND, id + "库区未填写"); } - putawayInv(id,area.getId(),asnDetailButton.getOneRPoint().getId(),qty,null); + putawayInv(id, area.getId(), asnDetailButton.getOneRPoint().getId(), qty, null); } else if (asnDetailButton.getButton() == 3) { long id = asnDetailButton.getId(); AsnDto byId = asnService.findById(id); if (!asnDetailButton.getAsnDetailDataS().isEmpty()) { for (AsnDetail ad : asnDetailButton.getAsnDetailDataS()) { - List ts=taskService.queryTask(ad.getId(),null,null,null,null); - for(Task t:ts) { - asnDetailService.cancelPut(t.getId(),null); + List ts = taskService.queryTask(ad.getId(), null, null, null, null); + for (Task t : ts) { + asnDetailService.cancelPut(t.getId(), null); } } } @@ -467,7 +469,7 @@ public class AsnDetailController { @Transactional(rollbackFor = Exception.class) public ApiResult invVerify(@RequestBody Long[] ids) { for (Long id : ids) { - Asn asn=asnService.getEntity(id); + Asn asn = asnService.getEntity(id); //AsnDto asnDto = asnService.findById(id); if (Objects.isNull(asn)) { // 通用异常,使用自定义状态码 @@ -479,14 +481,14 @@ public class AsnDetailController { // 通用异常,使用自定义状态码 throw new BadRequestException(HttpStatus.NOT_FOUND, id + "库区未填写"); } - BillType bt=asn.getBillType(); + BillType bt = asn.getBillType(); if (bt.getBezl() && asn.getZlBy() == null) { throw new BadRequestException(asn.getCode() + "该单子还未整理,请先整理"); } if (bt.getBecy() && asn.getCyBy() == null) { throw new BadRequestException(asn.getCode() + "该单子还未抽样,请先抽样"); } - if(bt.getBezj()&& asn.getZjBy() == null) { + if (bt.getBezj() && asn.getZjBy() == null) { throw new BadRequestException(asn.getCode() + "该单子还未质检,请先质检"); } // if (!area.getBesh()){ @@ -515,15 +517,15 @@ public class AsnDetailController { } ApiResult apiResult = null; - if (asnDetailData.getReceivedQty()>0){ + if (asnDetailData.getReceivedQty() > 0) { // 通用异常,使用自定义状态码 throw new BadRequestException(HttpStatus.NOT_FOUND, id + "的副表" + asnDetailData.getId() + "的物料已经单一入库无法使用整单入库"); } - Point p=asnDetailData.getPoint(); - if(p==null){ - p=pointRepository.findByCode("MR-CH"); + Point p = asnDetailData.getPoint(); + if (p == null) { + p = pointRepository.findByCode("MR-CH"); } - apiResult=this.putawayInv(asnDetailData.getId(), asn.getArea().getId(), p.getId(),(asnDetailData.getOrderQty()-asnDetailData.getReceivedQty()),null); + apiResult = this.putawayInv(asnDetailData.getId(), asn.getArea().getId(), p.getId(), (asnDetailData.getOrderQty() - asnDetailData.getReceivedQty()), null); if (apiResult.getStatus() == 200) { //收货日期改成当前日期 数量累计 asn.setReceivedDate(new Timestamp(System.currentTimeMillis())); @@ -546,56 +548,56 @@ public class AsnDetailController { } - public ApiResult putawayInv(@RequestBody Long asnDetailId, Long areaId, Long pointId,double recQty,String ewm) { + public ApiResult putawayInv(@RequestBody Long asnDetailId, Long areaId, Long pointId, double recQty, String ewm) { AsnDetail d = asnDetailService.getEntity(asnDetailId); Area area = areaService.findEntityById(areaId); Point point = null; - if(pointId!=null){ + if (pointId != null) { point = pointService.findEntityById(pointId); - }else{ - point =pointRepository.findByCode("MR-CH"); + } else { + point = pointRepository.findByCode("MR-CH"); } - Point zzkw=null; - if(area.getBexb()){ - point= pointService.getPoint(area.getPointCode(), null, BaseStatus.HCKW, null);//取默认线边库位 - zzkw=d.getPoint(); - if(zzkw==null){ + Point zzkw = null; + if (area.getBexb()) { + point = pointService.getPoint(area.getPointCode(), null, BaseStatus.HCKW, null);//取默认线边库位 + zzkw = d.getPoint(); + if (zzkw == null) { //取默认制造库位 - zzkw= pointService.getPoint("ZZKW", null, null, null); + zzkw = pointService.getPoint("ZZKW", null, null, null); } } - if(point==null){ + if (point == null) { throw new BadRequestException("请选择入库库位"); } - double unRecQty=d.getOrderQty() - d.getReceivedQty(); - if ( recQty<=unRecQty ) { - String pc1=null; + double unRecQty = d.getOrderQty() - d.getReceivedQty(); + if (recQty <= unRecQty) { + String pc1 = null; //现品票确认将任务id回写到现品票表中 XppRecord xppRecord = xppRecordRepository.findByCode(ewm); - ItemKey ik=null; - if(xppRecord!=null){ - if(!xppRecord.getStatus().equals(BizStatus.RECEIVED)&&!xppRecord.getStatus().equals(BizStatus.RETENTION_IN)){ - throw new BadRequestException(d.getItem().getCode()+"现品票状态不正确"); + ItemKey ik = null; + if (xppRecord != null) { + if (!xppRecord.getStatus().equals(BizStatus.RECEIVED) && !xppRecord.getStatus().equals(BizStatus.RETENTION_IN)) { + throw new BadRequestException(d.getItem().getCode() + "现品票状态不正确"); } - pc1=DateUtil.dateYmd(new Date()); - ik=xppRecord.getItemKey(); + pc1 = DateUtil.dateYmd(new Date()); + ik = xppRecord.getItemKey(); } - if(ik==null){ - ik = itemKeyService.getItemKey(d.getItem(), pc1, null); + if (ik == null) { + ik = itemKeyService.getItemKey(d.getItem(), pc1, null, null, null, null, null); } - Task t = taskService.storeTask(d, null, area, ik, point, point,recQty); - if(xppRecord!=null) { + Task t = taskService.storeTask(d, null, area, ik, point, point, recQty); + if (xppRecord != null) { xppRecord.setRkTask(t); xppRecord.setInvPoint(point); xppRecord.setStatus(BizStatus.PUTAWAY); xppRecord.setItemKey(ik); - ewm=xppRecord.getEwm(); + ewm = xppRecord.getEwm(); xppRecordService.update(xppRecord); } - d.setReceivedQty(d.getReceivedQty()+recQty); - if(d.getReceivedQty().intValue()>=d.getOrderQty().intValue()){ + d.setReceivedQty(d.getReceivedQty() + recQty); + if (d.getReceivedQty().intValue() >= d.getOrderQty().intValue()) { d.setStatus(BizStatus.PUTAWAY); - }else if(d.getReceivedQty().intValue()>0){ + } else if (d.getReceivedQty().intValue() > 0) { d.setStatus(BizStatus.PUTAWAY); } asnDetailService.update(d); @@ -607,23 +609,36 @@ public class AsnDetailController { double srcQty = inv.getQuantity(); inv.addQty(recQty); invService.update(inv); - String billCode=null; - if(d.getAsn()!=null){ - Asn asn=d.getAsn(); - billCode=asn.getCode(); - asn.setReceivedQuantity(asn.getReceivedQuantity()+recQty); - if(asn.getReceivedQuantity().intValue()>=asn.getOrderQuantity().intValue()) { + String billCode = null; + if (d.getAsn() != null) { + Asn asn = d.getAsn(); + billCode = asn.getCode(); + asn.setReceivedQuantity(asn.getReceivedQuantity() + recQty); + if (asn.getReceivedQuantity().intValue() >= asn.getOrderQuantity().intValue()) { asnService.update(asn); } } Point srcPoint = pointService.getPoint(null, null, BaseStatus.SHZC, null); - InventoryLog log=invLogService.storeInventoryLog(BizStatus.RECEIVING_UP, BizStatus.ADD, billCode, area, ik, srcPoint, point, zzkw, srcQty, recQty,ewm, + InventoryLog log = invLogService.storeInventoryLog(BizStatus.RECEIVING_UP, BizStatus.ADD, billCode, area, ik, srcPoint, point, zzkw, srcQty, recQty, ewm, BizStatus.ASN, d.getId(), inv.getId(), d.getRemark()); } else { throw new BadRequestException(d.getItem().getCode() + "收货数量不能大于未收数量"); } - return ApiResult.result(200,"" , HttpStatus.OK); + return ApiResult.result(200, "", HttpStatus.OK); } + @PostMapping("/zhengli") + @Log("明细整理") + @ApiOperation("明细整理") + @PreAuthorize("@el.check('super:man')") + public ResponseEntity zhengli(@RequestBody Zhengli zhengli) { + try { + asnDetailService.zhengli(zhengli); + return new ResponseEntity<>(ApiResult.success("整理成功", null), HttpStatus.OK); + } catch (Exception e) { + return new ResponseEntity<>(ApiResult.fail(HttpStatus.BAD_REQUEST.value(), "整理失败:" + e.getMessage(), null), HttpStatus.BAD_REQUEST); + } + } + } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/PickOutController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/PickOutController.java index 1d867ae..e437c9c 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/PickOutController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/PickOutController.java @@ -520,7 +520,7 @@ public class PickOutController { Point point=pointService.findEntityById(pickDetail.getShArea().getPointId()); Dept dept= UserUtils.getDept(); //线边接收不需要管理到批次,重新生成itemKey - ItemKey itemKey=itemKeyService.getItemKey(log.getItemKey().getItem(),null,null); + ItemKey itemKey=itemKeyService.getItemKey(log.getItemKey().getItem(),null,null,null,null,null,null); Inventory inventory=inventoryService.getInventory(itemKey,pickDetail.getShArea(),point,pickDetail.getPoint(),dept,BizStatus.SL_ALL); double srcQty=inventory.getQuantity(); inventory.setQuantity(inventory.getQuantity()+log.getSlQty()); @@ -638,4 +638,4 @@ public class PickOutController { return new ResponseEntity<>(map,HttpStatus.OK); } -} \ No newline at end of file +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/PickTicketController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/PickTicketController.java index c7022fa..d23874b 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/PickTicketController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/PickTicketController.java @@ -371,7 +371,7 @@ public class PickTicketController { Point point=pointService.findEntityById(pt.getShArea().getPointId()); Dept dept= UserUtils.getDept(); //线边接收不需要管理到批次,重新生成itemKey - ItemKey itemKey=itemKeyService.getItemKey(log.getItemKey().getItem(),null,null); + ItemKey itemKey=itemKeyService.getItemKey(log.getItemKey().getItem(),null,null,null,null,null,null); Inventory inventory=inventoryService.getInventory(itemKey,pt.getShArea(),point,pickDetail.getPoint(),dept,BizStatus.SL_ALL); double srcQty=inventory.getQuantity(); inventory.setQuantity(inventory.getQuantity()+log.getSlQty()); @@ -414,4 +414,4 @@ public class PickTicketController { return new ResponseEntity<>(map,HttpStatus.OK); } -} \ No newline at end of file +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/XppRecordController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/XppRecordController.java index deb25cd..8c1a72e 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/XppRecordController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/XppRecordController.java @@ -425,7 +425,7 @@ public class XppRecordController { } } String pc1=DateUtil.dateYmd(new Date()); - ItemKey ik = itemKeyService.getItemKey(xppRecord.getItem(), pc1, null); + ItemKey ik = itemKeyService.getItemKey(xppRecord.getItem(), pc1, null,null,null,null,null); xppRecord.setItemKey(ik); if(type==1) { inventoryLogService.storeInventoryLog(BizStatus.RECEIVING, BizStatus.ADD, "现品票采集", area, ik, srcPoint, srcPoint, null, 0d, xppRecord.getNrs() + 0d, ewm, @@ -707,4 +707,4 @@ public class XppRecordController { xppRecordService.update(xpp); return new ResponseEntity<>("操作成功", HttpStatus.OK); } -} \ No newline at end of file +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/AsnDetailService.java b/youchain-system/src/main/java/com/youchain/businessdata/service/AsnDetailService.java index 5a7de33..a79d032 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/AsnDetailService.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/AsnDetailService.java @@ -21,6 +21,7 @@ import com.youchain.basicdata.domain.Stock; import com.youchain.basicdata.service.dto.StockDto; import com.youchain.businessdata.domain.AsnDetail; import com.youchain.businessdata.domain.XppRecord; +import com.youchain.businessdata.inputJson.Zhengli; import com.youchain.businessdata.service.dto.AsnDetailDto; import com.youchain.businessdata.service.dto.AsnDetailQueryCriteria; import org.springframework.data.domain.Pageable; @@ -128,4 +129,10 @@ public interface AsnDetailService { * @return */ List findAsnDetails(Long asnId,String type); + + /** + * 明细整理 + * @param zhengli + */ + void zhengli(Zhengli zhengli); } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java b/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java index 3ae0dc2..6598142 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java @@ -142,4 +142,6 @@ public interface InventoryService { * @return */ List queryInvApp(String code); + + Inventory getInventory(ItemKey itemKey, Point point, Stock stock, Dept dept, String type); } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/ItemKeyService.java b/youchain-system/src/main/java/com/youchain/businessdata/service/ItemKeyService.java index 46ffd65..dbf35d2 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/ItemKeyService.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/ItemKeyService.java @@ -86,7 +86,7 @@ public interface ItemKeyService { */ void download(List all, HttpServletResponse response) throws Exception, Exception; - ItemKey getItemKey(Item item, String propC1, Date propD1); + ItemKey getItemKey(Item item, String propC1,String propC3,String propC4,String propC5,String propC6, Date propD1); -} \ No newline at end of file +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/AsnDetailDto.java b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/AsnDetailDto.java index 07491ff..8136370 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/AsnDetailDto.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/AsnDetailDto.java @@ -17,6 +17,7 @@ package com.youchain.businessdata.service.dto; import com.youchain.basicdata.domain.Item; import com.youchain.basicdata.domain.Stock; +import com.youchain.basicdata.service.dto.ItemDto; import com.youchain.basicdata.service.dto.ItemSmallDto; import com.youchain.basicdata.service.dto.PointDto; import com.youchain.basicdata.service.dto.StockDto; @@ -42,7 +43,7 @@ public class AsnDetailDto implements Serializable { private AsnDto asn; /** 物料 */ - private ItemSmallDto item; + private ItemDto item; /** 容器 */ private StockDto stock; @@ -126,4 +127,4 @@ public class AsnDetailDto implements Serializable { /** 修改时间 */ private Timestamp updateTime; -} \ No newline at end of file +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/AsnDetailServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/AsnDetailServiceImpl.java index 714de4c..9ee3e8b 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/AsnDetailServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/AsnDetailServiceImpl.java @@ -1,36 +1,36 @@ /* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.youchain.businessdata.service.impl; +import com.youchain.basicdata.domain.Area; import com.youchain.basicdata.domain.Item; import com.youchain.basicdata.domain.Point; import com.youchain.basicdata.domain.Stock; import com.youchain.basicdata.service.StockService; import com.youchain.businessdata.domain.*; +import com.youchain.businessdata.inputJson.Zhengli; import com.youchain.businessdata.repository.TaskRepository; -import com.youchain.businessdata.service.AsnService; -import com.youchain.businessdata.service.InventoryLogService; -import com.youchain.businessdata.service.InventoryService; +import com.youchain.businessdata.repository.XppRecordRepository; +import com.youchain.businessdata.service.*; import com.youchain.businessdata.service.dto.AsnDto; import com.youchain.businessdata.service.mapstruct.AsnMapper; import com.youchain.exception.BadRequestException; import com.youchain.utils.*; import lombok.RequiredArgsConstructor; import com.youchain.businessdata.repository.AsnDetailRepository; -import com.youchain.businessdata.service.AsnDetailService; import com.youchain.businessdata.service.dto.AsnDetailDto; import com.youchain.businessdata.service.dto.AsnDetailQueryCriteria; import com.youchain.businessdata.service.mapstruct.AsnDetailMapper; @@ -38,6 +38,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; + import java.util.List; import java.util.Map; import java.io.IOException; @@ -48,40 +49,43 @@ import java.util.ArrayList; import java.util.LinkedHashMap; /** -* @website https://eladmin.vip -* @description 服务实现 -* @author hjl -* @date 2023-08-14 -**/ + * @author hjl + * @website https://eladmin.vip + * @description 服务实现 + * @date 2023-08-14 + **/ @Service @RequiredArgsConstructor public class AsnDetailServiceImpl implements AsnDetailService { private final AsnDetailRepository asnDetailRepository; + private final TaskRepository taskRepository; + private final XppRecordRepository xppRecordRepository; private final AsnDetailMapper asnDetailMapper; private final EntityManager entityMapper; - private final TaskRepository taskRepository; private final AsnService asnService; private final AsnMapper asnMapper; private final InventoryService inventoryService; private final InventoryLogService inventoryLogService; + private final ItemKeyService itemKeyService; + private final TaskService taskService; @Override - public Map queryAll(AsnDetailQueryCriteria criteria, Pageable pageable){ - Page page = asnDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + public Map queryAll(AsnDetailQueryCriteria criteria, Pageable pageable) { + Page page = asnDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); return PageUtil.toPage(page.map(asnDetailMapper::toDto)); } @Override - public List queryAll(AsnDetailQueryCriteria criteria){ - return asnDetailMapper.toDto(asnDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + public List queryAll(AsnDetailQueryCriteria criteria) { + return asnDetailMapper.toDto(asnDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder))); } @Override @Transactional public AsnDetailDto findById(Long id) { AsnDetail asnDetail = asnDetailRepository.findById(id).orElseGet(AsnDetail::new); - ValidationUtil.isNull(asnDetail.getId(),"AsnDetail","id",id); + ValidationUtil.isNull(asnDetail.getId(), "AsnDetail", "id", id); return asnDetailMapper.toDto(asnDetail); } @@ -102,7 +106,7 @@ public class AsnDetailServiceImpl implements AsnDetailService { @Transactional(rollbackFor = Exception.class) public void update(AsnDetail resources) { AsnDetail asnDetail = asnDetailRepository.findById(resources.getId()).orElseGet(AsnDetail::new); - ValidationUtil.isNull( asnDetail.getId(),"AsnDetail","id",resources.getId()); + ValidationUtil.isNull(asnDetail.getId(), "AsnDetail", "id", resources.getId()); asnDetail.copy(resources); asnDetailRepository.save(asnDetail); } @@ -111,53 +115,54 @@ public class AsnDetailServiceImpl implements AsnDetailService { public void deleteAll(Long[] ids) { for (Long id : ids) { AsnDetail asnDetail = asnDetailRepository.getById(id); - if (asnDetail.getStatus().equals("OPEN")){ + if (asnDetail.getStatus().equals("OPEN")) { //修改容器状态 //删除关联表的数据 入库单明细(data_asn_detail) - if (taskRepository.getAsnDetailIdToId(id)!=null){ + if (taskRepository.getAsnDetailIdToId(id) != null) { taskRepository.deleteById(taskRepository.getAsnDetailIdToId(id)); } //扣入库表的订单数量 Double orderQty = asnDetail.getOrderQty(); AsnDto byId = asnService.findById(asnDetail.getAsn().getId()); - byId.setOrderQuantity(byId.getOrderQuantity()-orderQty); + byId.setOrderQuantity(byId.getOrderQuantity() - orderQty); asnService.update(asnMapper.toEntity(byId)); } asnDetailRepository.deleteById(id); } } + @Override @Transactional(rollbackFor = Exception.class) public void cancelPut(Long taskId, XppRecord xppRecord) { - Task t=taskRepository.getById(taskId); - AsnDetail d=t.getAsnDetail(); - Asn asn=d.getAsn(); - String ewm=null; - if(t.getPlanQty()>0){ - Point srcPoint=t.getDstPoint(); - if(xppRecord!=null){ - ewm=xppRecord.getEwm(); - srcPoint=xppRecord.getInvPoint(); + Task t = taskRepository.getById(taskId); + AsnDetail d = t.getAsnDetail(); + Asn asn = d.getAsn(); + String ewm = null; + if (t.getPlanQty() > 0) { + Point srcPoint = t.getDstPoint(); + if (xppRecord != null) { + ewm = xppRecord.getEwm(); + srcPoint = xppRecord.getInvPoint(); } - Inventory inventory=inventoryService.getInventory(t.getItemKey(),t.getArea(),srcPoint,t.getAsnDetail().getPoint(),t.getArea().getDept(),BizStatus.RECEIVING_CANCEL); - if(inventory==null){ + Inventory inventory = inventoryService.getInventory(t.getItemKey(), t.getArea(), srcPoint, t.getAsnDetail().getPoint(), t.getArea().getDept(), BizStatus.RECEIVING_CANCEL); + if (inventory == null) { throw new BadRequestException("找不到对应库存"); } - if((inventory.getQuantity().intValue()- inventory.getQueuedQty().intValue()) all, HttpServletResponse response) throws Exception { - List> list=ExcelDownUtils.CreateMap(all,"AsnDetail"); + List> list = ExcelDownUtils.CreateMap(all, "AsnDetail"); FileUtil.downloadExcel(list, response); } @Override - public AsnDetail toEntity(AsnDetailDto detailDto) { + public AsnDetail toEntity(AsnDetailDto detailDto) { return asnDetailMapper.toEntity(detailDto); } + @Override - public AsnDetail findByStock(String code){ - String hql="select d from AsnDetail d where d.stock.code='"+code+"' and d.status='"+ BizStatus.OPEN+"'"; - Query query=entityMapper.createQuery(hql); - List ts=query.getResultList(); - if(ts.size()>0){ + public AsnDetail findByStock(String code) { + String hql = "select d from AsnDetail d where d.stock.code='" + code + "' and d.status='" + BizStatus.OPEN + "'"; + Query query = entityMapper.createQuery(hql); + List ts = query.getResultList(); + if (ts.size() > 0) { return ts.get(0); } - return null; + return null; } @Override - public AsnDetail createAsnDetail(Item item, Stock stock, Point srcPoint,String propC1,String gdh){ + public AsnDetail createAsnDetail(Item item, Stock stock, Point srcPoint, String propC1, String gdh) { AsnDetail asnDetail = new AsnDetail(); asnDetail.setItem(item); asnDetail.setLineNo(1L); @@ -202,17 +208,77 @@ public class AsnDetailServiceImpl implements AsnDetailService { asnDetail.setPoint(srcPoint); asnDetail.setPropC1(propC1); asnDetail.setOrderNumber(gdh); - return asnDetail; + return asnDetail; } @Override - public List findAsnDetails(Long asnId,String type) { - String hql =" from AsnDetail ad where ad.asn.id="+asnId; - if(type.equals("1")){//整单收货,查询未收货数据 - hql+=" and ad.receivedQty findAsnDetails(Long asnId, String type) { + String hql = " from AsnDetail ad where ad.asn.id=" + asnId; + if (type.equals("1")) {//整单收货,查询未收货数据 + hql += " and ad.receivedQty ds=query.getResultList(); + Query query = entityMapper.createQuery(hql); + List ds = query.getResultList(); return ds; } + + @Override + @Transactional(rollbackFor = Exception.class) + public void zhengli(Zhengli zhengli) { + AsnDetail asnDetail = asnDetailRepository.findById(zhengli.getId()).get(); + Item item = asnDetail.getItem(); + if (item.getIsInspection()) { + throw new BadRequestException("该商品需要质检,请先完成质检!"); + } + + //生成Itemkey + ItemKey itemKey = itemKeyService.getItemKey(item, asnDetail.getPropC1(), asnDetail.getPropC3(), asnDetail.getPropC4(), asnDetail.getPropC5(), asnDetail.getPropC6(), asnDetail.getPropD1()); + + //生成入库记录 + Task task = taskService.storeTask(asnDetail, null, zhengli.getArea(), itemKey, null, zhengli.getPoint(), zhengli.getReceivedQty()); + task.setSrcStockCode(zhengli.getStock().getCode()); + task.setSrcStock(zhengli.getStock()); + taskRepository.save(task); + + //生成库存记录 + Inventory inventory = inventoryService.getInventory(itemKey, asnDetail.getPoint(), zhengli.getStock(), item.getDept(), BizStatus.ASN); + inventory.setStatus("待入库"); + inventoryService.update(inventory); + + //是序列号的商品,生成序列号记录 + if (item.getIsSerial()) { + XppRecord xppRecord = new XppRecord(); + xppRecord.setRkTask(task); + xppRecord.setItemKey(itemKey); + xppRecord.setInvPoint(asnDetail.getPoint()); + xppRecordRepository.save(xppRecord); + } + + //回写收货数量 + asnDetail.setStock(zhengli.getStock()); + asnDetail.setPoint(zhengli.getPoint()); + asnDetail.setReceivedQty(asnDetail.getReceivedQty()+zhengli.getReceivedQty()); + asnDetailRepository.save(asnDetail); + + //刷新单头状态 + updateAsnStatus(asnDetail.getAsn()); + } + + private void updateAsnStatus(Asn asn) { + double orderQty = 0; + double receivedQty = 0; + List asnDetails = asnDetailRepository.queryByAsnId(asn.getId()); + for (AsnDetail detail : asnDetails) { + orderQty += detail.getOrderQty(); + receivedQty += detail.getReceivedQty(); + } + if (orderQty == receivedQty) { + asn.setStatus(BizStatus.RECEIVED); + } else if (receivedQty > 0 && receivedQty < orderQty) { + asn.setStatus(BizStatus.RECEIVING); + } else if (receivedQty == 0) { + asn.setStatus(BizStatus.OPEN); + } + asnService.update(asn); + } } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java index d485379..a16f866 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java @@ -392,4 +392,27 @@ public class InventoryServiceImpl implements InventoryService { List list = JSON.parseArray(JSON.toJSONString(ts),RInvQuery.class); return list; } + + @Override + @Transactional(rollbackFor = Exception.class) + public Inventory getInventory(ItemKey itemKey, Point point, Stock stock, Dept dept, String type) { + List inventoryList = inventoryRepository.findByInventory(itemKey.getId(), point.getId(), stock.getId(), dept.getId()); + Inventory inventory = null; + if (inventoryList.size() > 0) { + inventory = inventoryList.get(0); + } else { + //创建Inventory + if (type.equals(BizStatus.ASN)) { + inventory = new Inventory(); + inventory.setItemKey(itemKey); + inventory.setPoint(point); + inventory.setPointCode(point.getCode()); + inventory.setStock(stock); + inventory.setStockCode(stock.getCode()); + inventory.setDept(dept); + inventoryRepository.save(inventory); + } + } + return inventory; + } } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/ItemKeyServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/ItemKeyServiceImpl.java index bcc5f00..e5a68fb 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/ItemKeyServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/ItemKeyServiceImpl.java @@ -1,18 +1,18 @@ /* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.youchain.businessdata.service.impl; import com.youchain.basicdata.domain.Item; @@ -40,11 +40,11 @@ import javax.persistence.Query; import javax.servlet.http.HttpServletResponse; /** -* @website https://eladmin.vip -* @description 服务实现 -* @author houjianlan -* @date 2023-08-21 -**/ + * @author houjianlan + * @website https://eladmin.vip + * @description 服务实现 + * @date 2023-08-21 + **/ @Service @RequiredArgsConstructor @Slf4j @@ -121,38 +121,43 @@ public class ItemKeyServiceImpl implements ItemKeyService { @Override @Transactional(rollbackFor = Exception.class) - public ItemKey getItemKey(Item item, String propC1, Date propD1) { + public ItemKey getItemKey(Item item, String propC1, String propC3, String propC4, String propC5, String propC6, Date propD1) { //生成itemKey - String hql = " from ItemKey ik where 1=1 "; - if (item != null) { - hql += " and ik.item.id=" + item.getId() + " "; - } - if (propC1 != null && propC1.length() > 0) { - hql += " and ik.propC1='" + propC1 + "' "; - }else{ - hql += " and ik.propC1 is null"; - } -// if (propD1 != null) { -// hql += " and DATE(ik.propD1) ='" + propD1 +"'"; -// }else{ -// hql += " and ik.propD1 is null"; -// } + String hql = "from ItemKey " + + "where " + + "item = :item " + + "and propC1 = :propC1 " + + "and propC3 = :propC3 " + + "and propC4 = :propC4 " + + "and propC5 = :propC5 " + + "and propC6 = :propC6 " + + "and propD1 = :propD1"; Query query = entityManager.createQuery(hql); + query.setParameter("item", item); + query.setParameter("propC1", propC1); + query.setParameter("propC3", propC3); + query.setParameter("propC4", propC4); + query.setParameter("propC5", propC5); + query.setParameter("propC6", propC6); + query.setParameter("propD1", propD1); List itemKeyList = query.getResultList(); - ItemKey itemKey = null; - if (itemKeyList.size() > 0) { - itemKey = itemKeyList.get(0); - } else { + if (itemKeyList.isEmpty()) { //创建ItemKey - itemKey = new ItemKey(); + ItemKey itemKey = new ItemKey(); itemKey.setItem(item); itemKey.setDept(item.getDept()); itemKey.setPropC1(propC1); + itemKey.setPropC3(propC3); + itemKey.setPropC4(propC4); + itemKey.setPropC5(propC5); + itemKey.setPropC6(propC6); itemKey.setPropD1(propD1); - this.create(itemKey); + itemKeyRepository.save(itemKey); + return itemKey; + } else { + return itemKeyList.get(0); } - return itemKey; } -} \ No newline at end of file +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/SparepartsServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/SparepartsServiceImpl.java index 25eb965..0dbeeec 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/SparepartsServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/SparepartsServiceImpl.java @@ -173,7 +173,7 @@ public class SparepartsServiceImpl implements SparepartsService { if(point==null){ throw new BadRequestException(ba.getRArea().getCode()+"库区无对应待投料库位"); } - ItemKey itemKey=itemKeyService.getItemKey(ba.getItem(),null,null); + ItemKey itemKey=itemKeyService.getItemKey(ba.getItem(),null,null,null,null,null,null); Inventory inventory = new Inventory(); inventory.setItemKey(itemKey); inventory.setPoint(point); @@ -195,4 +195,4 @@ public class SparepartsServiceImpl implements SparepartsService { s.setHyTime(new Timestamp(new Date().getTime())); this.update(s); } -} \ No newline at end of file +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/TaskServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/TaskServiceImpl.java index 08edca4..96132af 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/TaskServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/TaskServiceImpl.java @@ -189,7 +189,7 @@ public class TaskServiceImpl implements TaskService { t.setDstPoint(dstPoint); t.setDstPointCode(dstPoint.getCode()); } - this.create(t); + taskRepository.save(t); return t; } @Override