From c3dcafc53fd3b72e255c0f78ad318abd50aa7c3d Mon Sep 17 00:00:00 2001 From: "HUOJIN\\92525" <925258474@qq.com> Date: Fri, 21 Jun 2024 15:21:12 +0800 Subject: [PATCH] no message --- .../java/com/youchain/RequestData/ZpjlCt.java | 6 + .../java/com/youchain/RequestData/ZpjlZj.java | 6 + .../com/youchain/businessdata/domain/Gd.java | 6 +- .../businessdata/domain/GdDetail.java | 7 +- .../youchain/businessdata/domain/Pick.java | 58 +++++---- .../repository/PickRepository.java | 48 ++++---- .../businessdata/rest/MesController.java | 116 ++++++++++++------ .../businessdata/service/PickService.java | 20 ++- .../businessdata/service/dto/PickDto.java | 5 +- .../service/impl/PickServiceImpl.java | 93 +++++++++----- 10 files changed, 239 insertions(+), 126 deletions(-) diff --git a/youchain-system/src/main/java/com/youchain/RequestData/ZpjlCt.java b/youchain-system/src/main/java/com/youchain/RequestData/ZpjlCt.java index 732a0e4..3153d48 100644 --- a/youchain-system/src/main/java/com/youchain/RequestData/ZpjlCt.java +++ b/youchain-system/src/main/java/com/youchain/RequestData/ZpjlCt.java @@ -9,16 +9,22 @@ import lombok.Data; public class ZpjlCt { @ApiModelProperty(value ="任务号",required = true,example = "任务号") String taskCode; + @ApiModelProperty(value ="工单号",required = true,example = "工单号") String orderNo; + @ApiModelProperty(value ="下发时间",required = true,example = "2023-07-03 00:00:00") String createTime; + @ApiModelProperty(value ="总成代码",required = true) String completeCode; + @ApiModelProperty(value ="总成名称",required = true) String completeName; + @ApiModelProperty(value ="需求工位",required = true) String station; + @ApiModelProperty(value ="需求点位",required = true) String pointCode; diff --git a/youchain-system/src/main/java/com/youchain/RequestData/ZpjlZj.java b/youchain-system/src/main/java/com/youchain/RequestData/ZpjlZj.java index 39a636d..0d37a29 100644 --- a/youchain-system/src/main/java/com/youchain/RequestData/ZpjlZj.java +++ b/youchain-system/src/main/java/com/youchain/RequestData/ZpjlZj.java @@ -9,16 +9,22 @@ import lombok.Data; public class ZpjlZj { @ApiModelProperty(value ="任务号",required = true,example = "任务号") String taskCode; + @ApiModelProperty(value ="工单号",required = true,example = "工单号") String orderNo; + @ApiModelProperty(value ="下发时间",required = true,example = "2023-07-03 00:00:00") String createTime; + @ApiModelProperty(value ="物料代码",required = true,example = "物料代码") String itemCode; + @ApiModelProperty(value ="物料名称",required = true,example = "物料名称") String itemName; + @ApiModelProperty(value ="需求工位",required = true) String station; + @ApiModelProperty(value ="需求点位",required = true) String pointCode; diff --git a/youchain-system/src/main/java/com/youchain/businessdata/domain/Gd.java b/youchain-system/src/main/java/com/youchain/businessdata/domain/Gd.java index a3e22fe..ae196c0 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/domain/Gd.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/domain/Gd.java @@ -44,11 +44,11 @@ public class Gd extends BaseEntity implements Serializable { @ApiModelProperty(value = "ID") private Long id; - @Column(name = "`code`") + @Column(name = "`code`",nullable = false) @ApiModelProperty(value = "工单编号") private String code; - @Column(name = "`name`") + @Column(name = "`name`",nullable = false) @ApiModelProperty(value = "任务编号") private String name; @@ -56,7 +56,7 @@ public class Gd extends BaseEntity implements Serializable { @ApiModelProperty(value = "工单状态") private String status; - @Column(name = "`station`") + @Column(name = "`station`",nullable = false) @ApiModelProperty(value = "需求工位") private String station; @OneToOne diff --git a/youchain-system/src/main/java/com/youchain/businessdata/domain/GdDetail.java b/youchain-system/src/main/java/com/youchain/businessdata/domain/GdDetail.java index b6f1e47..ea0d806 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/domain/GdDetail.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/domain/GdDetail.java @@ -45,10 +45,12 @@ public class GdDetail extends BaseEntity implements Serializable { @Column(name = "`id`") @ApiModelProperty(value = "ID") private Long id; + @OneToOne @JoinColumn(name = "`gd_id`",nullable = false) @ApiModelProperty(value = "工单") private Gd gd; + @Column(name = "`line_no`") @ApiModelProperty(value = "行号") private int lineNo; @@ -57,6 +59,7 @@ public class GdDetail extends BaseEntity implements Serializable { @JoinColumn(name = "`item_id`",nullable = false) @ApiModelProperty(value = "单品物料") private Item item; + @Column(name = "`item_qty`") @ApiModelProperty(value = "单品数量") private Double itemQty=0d; @@ -65,9 +68,10 @@ public class GdDetail extends BaseEntity implements Serializable { private Double orderQty=0d; @OneToOne - @JoinColumn(name = "`big_item_id`",nullable = true) + @JoinColumn(name = "`big_item_id`",nullable = false) @ApiModelProperty(value = "成套物料") private BigItem bigItem; + @Column(name = "`big_item_qty`") @ApiModelProperty(value = "总成套数") private Double bigItemQty=0d; @@ -75,6 +79,7 @@ public class GdDetail extends BaseEntity implements Serializable { @Column(name = "`order_type`") @ApiModelProperty(value = "单据类型") private String orderType; + @OneToOne @JoinColumn(name = "`dept_id`",nullable = false) @ApiModelProperty(value = "仓库") diff --git a/youchain-system/src/main/java/com/youchain/businessdata/domain/Pick.java b/youchain-system/src/main/java/com/youchain/businessdata/domain/Pick.java index 8aab806..a29c35f 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/domain/Pick.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/domain/Pick.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.domain; import com.youchain.base.BaseEntity; @@ -22,20 +22,21 @@ import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; + import javax.persistence.*; import javax.validation.constraints.*; import java.io.Serializable; /** -* @website https://eladmin.vip -* @description / -* @author huojin -* @date 2024-06-11 -**/ + * @author huojin + * @website https://eladmin.vip + * @description / + * @date 2024-06-11 + **/ @Entity @Data -@Table(name="data_pick") -public class Pick extends BaseEntity implements Serializable { +@Table(name = "data_pick") +public class Pick extends BaseEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -44,10 +45,11 @@ public class Pick extends BaseEntity implements Serializable { private Long id; @OneToOne - @JoinColumn(name = "`dept_id`",nullable = false) + @JoinColumn(name = "`dept_id`", nullable = false) @NotNull @ApiModelProperty(value = "仓库") private Dept dept; + @Column(name = "`code`") @ApiModelProperty(value = "出库单头") private String code; @@ -60,17 +62,21 @@ public class Pick extends BaseEntity implements Serializable { @ApiModelProperty(value = "状态") private String status; @OneToOne - @JoinColumn(name = "`point_id`",nullable = false) + @JoinColumn(name = "`point_id`", nullable = false) @ApiModelProperty(value = "备料点位") @NotNull private Point point; @OneToOne - @JoinColumn(name = "`gd_detail_id`",nullable = false) + @JoinColumn(name = "`gd_detail_id`", nullable = false) @NotNull @ApiModelProperty(value = "关联工单明细") private GdDetail gdDetail; - public void copy(Pick source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + @Column(name = "`be_call`") + @ApiModelProperty(value = "是否叫料") + private Boolean beCall; + + public void copy(Pick source) { + BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); } } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/repository/PickRepository.java b/youchain-system/src/main/java/com/youchain/businessdata/repository/PickRepository.java index aac77ee..74a9771 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/repository/PickRepository.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/repository/PickRepository.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.repository; import com.youchain.businessdata.domain.Pick; @@ -23,13 +23,17 @@ import org.springframework.data.jpa.repository.Query; import java.util.List; /** -* @website https://eladmin.vip -* @author huojin -* @date 2024-06-11 -**/ + * @author huojin + * @website https://eladmin.vip + * @date 2024-06-11 + **/ public interface PickRepository extends JpaRepository, JpaSpecificationExecutor { - @Query(value = "SELECT p FROM Pick p WHERE p.gdDetail.id=?1 and p.lineNo=?2", nativeQuery = false) - List findRepeat(long gdDetailId,int no); - @Query(value = "SELECT p FROM Pick p WHERE p.status=?1 ", nativeQuery = false) + @Query(value = "SELECT p FROM Pick p WHERE p.gdDetail.id=?1 and p.lineNo=?2") + List findRepeat(long gdDetailId, int no); + + @Query(value = "SELECT p FROM Pick p WHERE p.status=?1 ") List findByStatus(String status); -} \ No newline at end of file + + @Query(value = " FROM Pick p WHERE p.code=?1 and p.code=?2 and p.code=?3 ") + Pick findByPick(String gdNo, String completeCode, String station); +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/MesController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/MesController.java index 0ed283a..7354b63 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/MesController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/MesController.java @@ -14,6 +14,7 @@ import com.youchain.businessdata.domain.Gd; import com.youchain.businessdata.domain.GdDetail; import com.youchain.businessdata.service.GdDetailService; import com.youchain.businessdata.service.GdService; +import com.youchain.businessdata.service.PickService; import com.youchain.businessdata.service.dto.TaskQueryCriteria; import com.youchain.exception.BadRequestException; import com.youchain.exception.handler.ApiResult; @@ -33,6 +34,9 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Set; +import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.OK; + @RestController @RequiredArgsConstructor @Api(tags = "mes接口管理") @@ -42,47 +46,48 @@ public class MesController { private final GdService gdService; private final GdDetailService gdDetailService; private final DeptService deptService; - private final BigBomService bigBomService; private final ItemRepository itemRepository; private final BigBomRepository bigBomRepository; private final BigItemRepository bigItemRepository; + private final PickService pickService; + @PostMapping("/yclbl") @Log("mes-原材料备料") @ApiOperation("mes-原材料备料") @AnonymousAccess - public ResponseEntity yclbl(@Validated @RequestBody Yclbl yclbl){ + public ResponseEntity yclbl(@Validated @RequestBody Yclbl yclbl) { /* 添加工单单头*/ - Gd gd = gdService.save(yclbl.getOrderNo(),yclbl.getTaskCode(),yclbl.getStation()); - if (yclbl.getBlzc()!=null){ + Gd gd = gdService.save(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation()); + if (yclbl.getBlzc() != null) { String orderType = BaseStatus.GD_TYPE_CT; Set blzc = yclbl.getBlzc(); for (ZcData zcData : blzc) { /* 验证成套 物料*/ - BigItem bigItem=verifiedBigItem(zcData.getCompleteCode(),zcData.getCompleteName()); - Set itemDates=zcData.getBlzcmx(); + BigItem bigItem = verifiedBigItem(zcData.getCompleteCode(), zcData.getCompleteName()); + Set itemDates = zcData.getBlzcmx(); for (ItemDate itemDate : itemDates) { /* 验证单品 物料*/ - Item item=verifiedItem(itemDate.getItemCode(),itemDate.getItemName()); + Item item = verifiedItem(itemDate.getItemCode(), itemDate.getItemName()); /* 验证BOM*/ - BigBom bigBom=verifiedBigBom(bigItem,item,itemDate.getItemQty()); + BigBom bigBom = verifiedBigBom(bigItem, item, itemDate.getItemQty()); /* 添加工单明细*/ - GdDetail gdDetail = gdDetailService.save(zcData.getLineNo(),gd,orderType,bigItem,zcData.getCompleteQty(),item,itemDate.getItemQty(),itemDate.getItemQty()*zcData.getCompleteQty()); + GdDetail gdDetail = gdDetailService.save(zcData.getLineNo(), gd, orderType, bigItem, zcData.getCompleteQty(), item, itemDate.getItemQty(), itemDate.getItemQty() * zcData.getCompleteQty()); } } } - if (yclbl.getBlzcmx()!=null){ + if (yclbl.getBlzcmx() != null) { String orderType = BaseStatus.GD_TYPE_DP; - Set itemDateList=yclbl.getBlzcmx(); - for (ItemDate itemDate:itemDateList){ + Set itemDateList = yclbl.getBlzcmx(); + for (ItemDate itemDate : itemDateList) { /* 验证单品物料*/ - Item item=verifiedItem(itemDate.getItemCode(),itemDate.getItemName()); + Item item = verifiedItem(itemDate.getItemCode(), itemDate.getItemName()); /* 添加工单明细*/ - GdDetail gdDetail = gdDetailService.save(itemDate.getLineNo(),gd,orderType,null,null,item,itemDate.getItemQty(),itemDate.getItemQty()); + GdDetail gdDetail = gdDetailService.save(itemDate.getLineNo(), gd, orderType, null, null, item, itemDate.getItemQty(), itemDate.getItemQty()); } } /* 生成 出库明细*/ gdService.addPickDetail(gd); - ApiResult apiResult=ApiResult.result(200,"成功",null); + ApiResult apiResult = ApiResult.result(200, "成功", null); return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus())); } @@ -91,68 +96,91 @@ public class MesController { @Log("mes-散件BOM同步") @ApiOperation("mes-散件BOM同步") @AnonymousAccess - public ResponseEntity sjBom(@Validated @RequestBody SjBom sjBom){ + public ResponseEntity sjBom(@Validated @RequestBody SjBom sjBom) { - return new ResponseEntity<>(ApiResult.result(200,"成功",null), HttpStatus.OK); + return new ResponseEntity<>(ApiResult.result(200, "成功", null), HttpStatus.OK); } + @PostMapping("/zpjlZj") @Log("mes-其他整件叫料") @ApiOperation("mes-其他整件叫料") @AnonymousAccess - public ResponseEntity zpjlZj(@Validated @RequestBody ZpjlZj zpjlZj){ - - return new ResponseEntity<>(ApiResult.result(200,"成功",null), HttpStatus.OK); + public ResponseEntity zpjlZj(@Validated @RequestBody ZpjlZj zpjlZj) { + try { + String orderNo = zpjlZj.getOrderNo();//工单号 + String itemCode = zpjlZj.getItemCode();//物料代码 + String station = zpjlZj.getStation();//需求工位 + String pointCode = zpjlZj.getPointCode();//需求点位 + pickService.itemCall(orderNo, itemCode, station, pointCode); + return successResponse("叫料成功!"); + } catch (Exception e) { + return badResponse("叫料失败!"); + } } + @PostMapping("/zpjlCt") @Log("mes-成套叫料") @ApiOperation("mes-成套叫料") @AnonymousAccess - public ResponseEntity zpjlCt(@Validated @RequestBody ZpjlCt zpjlCt){ - - return new ResponseEntity<>(ApiResult.result(200,"成功",null), HttpStatus.OK); + public ResponseEntity zpjlCt(@Validated @RequestBody ZpjlCt zpjlCt) { + try { + String orderNo = zpjlCt.getOrderNo();//工单号 + String completeCode = zpjlCt.getCompleteCode();//成套代码 + String station = zpjlCt.getStation();//需求工位 + String pointCode = zpjlCt.getPointCode();//需求点位 + pickService.bigItemCall(orderNo, completeCode, station, pointCode); + return successResponse("叫料成功!"); + } catch (Exception e) { + return badResponse("叫料失败!"); + } } + @PostMapping("/zpjlJj") @Log("mes-紧急叫料") @ApiOperation("mes-紧急叫料") @AnonymousAccess - public ResponseEntity zpjlJj(@Validated @RequestBody ZpjlJj zpjlJj){ + public ResponseEntity zpjlJj(@Validated @RequestBody ZpjlJj zpjlJj) { - return new ResponseEntity<>(ApiResult.result(200,"成功",null), HttpStatus.OK); + return new ResponseEntity<>(ApiResult.result(200, "成功", null), HttpStatus.OK); } + @PostMapping("/transTask") @Log("mes-搬运任务") @ApiOperation("mes-搬运任务") @AnonymousAccess - public ResponseEntity transTask(@Validated @RequestBody TransTask transTask){ + public ResponseEntity transTask(@Validated @RequestBody TransTask transTask) { - return new ResponseEntity<>(ApiResult.result(200,"成功",null), HttpStatus.OK); + return new ResponseEntity<>(ApiResult.result(200, "成功", null), HttpStatus.OK); } - /** 验证成套物料*/ + /** + * 验证成套物料 + */ private BigItem verifiedBigItem(String completeCode, String completeName) { - List bigItemList = bigItemRepository.findRepeat(completeCode,completeName); - if (bigItemList.size()>0){ + List bigItemList = bigItemRepository.findRepeat(completeCode, completeName); + if (bigItemList.size() > 0) { return bigItemList.get(0); - }else { - throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护成套物料"+completeCode); + } else { + throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护成套物料" + completeCode); } } + private Item verifiedItem(String itemCode, String itemName) { - List itemList = itemRepository.findRepeat(itemCode,itemName); - if (itemList.size()>0){ + List itemList = itemRepository.findRepeat(itemCode, itemName); + if (itemList.size() > 0) { return itemList.get(0); - }else { - throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护单品物料"+itemCode); + } else { + throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护单品物料" + itemCode); } } private BigBom verifiedBigBom(BigItem bigItem, Item item, Double itemQty) { - List bigBomList = bigBomRepository.findRepeat(bigItem.getId(),item.getId()); - if (bigBomList.size()>0){ + List bigBomList = bigBomRepository.findRepeat(bigItem.getId(), item.getId()); + if (bigBomList.size() > 0) { return bigBomList.get(0); - }else { + } else { // 添加BOM - BigBom bigBom= new BigBom(); + BigBom bigBom = new BigBom(); bigBom.setBigItem(bigItem); bigBom.setItem(item); bigBom.setQuantity(itemQty); @@ -161,4 +189,12 @@ public class MesController { return bigBom; } } + + private ResponseEntity badResponse(String message) { + return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), message, ""), HttpStatus.BAD_REQUEST); + } + + private ResponseEntity successResponse(String message) { + return new ResponseEntity<>(ApiResult.fail(OK.value(), message, ""), HttpStatus.OK); + } } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/PickService.java b/youchain-system/src/main/java/com/youchain/businessdata/service/PickService.java index a2c53c3..82ba752 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/PickService.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/PickService.java @@ -83,4 +83,22 @@ public interface PickService { void download(List all, HttpServletResponse response) throws IOException; Pick save(GdDetail gdDetail, int no); -} \ No newline at end of file + + /** + * 成品叫料 + * @param gdNo->订单号 + * @param completeCode->成套代码 + * @param station->需求工位 + * @param pointCode->需求点位 + */ + void bigItemCall(String gdNo,String completeCode,String station,String pointCode); + + /** + * 单品叫料 + * @param gdNo->订单号 + * @param itemCode->物料代码 + * @param station->需求工位 + * @param pointCode->需求点位 + */ + void itemCall(String gdNo,String itemCode,String station,String pointCode); +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/PickDto.java b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/PickDto.java index 0f72dde..7959a93 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/PickDto.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/PickDto.java @@ -64,4 +64,7 @@ public class PickDto implements Serializable { private GdDetail gdDetail; /** 关联备料点位 */ private Point point; -} \ No newline at end of file + + /** 是否叫料 */ + private Boolean beCall; +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/PickServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/PickServiceImpl.java index 69926ee..eb9f654 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/PickServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/PickServiceImpl.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.businessdata.domain.GdDetail; @@ -28,6 +28,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; @@ -36,11 +37,11 @@ import java.util.ArrayList; import java.util.LinkedHashMap; /** -* @website https://eladmin.vip -* @description 服务实现 -* @author huojin -* @date 2024-06-11 -**/ + * @author huojin + * @website https://eladmin.vip + * @description 服务实现 + * @date 2024-06-11 + **/ @Service @RequiredArgsConstructor public class PickServiceImpl implements PickService { @@ -49,21 +50,21 @@ public class PickServiceImpl implements PickService { private final PickMapper pickMapper; @Override - public Map queryAll(PickQueryCriteria criteria, Pageable pageable){ - Page page = pickRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + public Map queryAll(PickQueryCriteria criteria, Pageable pageable) { + Page page = pickRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); return PageUtil.toPage(page.map(pickMapper::toDto)); } @Override - public List queryAll(PickQueryCriteria criteria){ - return pickMapper.toDto(pickRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + public List queryAll(PickQueryCriteria criteria) { + return pickMapper.toDto(pickRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder))); } @Override @Transactional public PickDto findById(Long id) { Pick pick = pickRepository.findById(id).orElseGet(Pick::new); - ValidationUtil.isNull(pick.getId(),"Pick","id",id); + ValidationUtil.isNull(pick.getId(), "Pick", "id", id); return pickMapper.toDto(pick); } @@ -77,7 +78,7 @@ public class PickServiceImpl implements PickService { @Transactional(rollbackFor = Exception.class) public void update(Pick resources) { Pick pick = pickRepository.findById(resources.getId()).orElseGet(Pick::new); - ValidationUtil.isNull( pick.getId(),"Pick","id",resources.getId()); + ValidationUtil.isNull(pick.getId(), "Pick", "id", resources.getId()); pick.copy(resources); pickRepository.save(pick); } @@ -93,7 +94,7 @@ public class PickServiceImpl implements PickService { public void download(List all, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (PickDto pick : all) { - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); map.put("创建人", pick.getCreateBy()); map.put("修改人", pick.getUpdateBy()); map.put("创建时间", pick.getCreateTime()); @@ -108,18 +109,46 @@ public class PickServiceImpl implements PickService { @Override public Pick save(GdDetail gdDetail, int no) { - Pick pick=new Pick(); - List pickList = pickRepository.findRepeat(gdDetail.getId(),no); - if (pickList.size()>0){ - pick=pickList.get(0); + Pick pick = new Pick(); + List pickList = pickRepository.findRepeat(gdDetail.getId(), no); + if (pickList.size() > 0) { + pick = pickList.get(0); } pick.setGdDetail(gdDetail); pick.setLineNo(no); pick.setStatus(BizStatus.OPEN); - pick.setCode(gdDetail.getGd().getName()+"_"+no); + pick.setCode(gdDetail.getGd().getName() + "_" + no); pick.setDept(UserUtils.isDept); pickRepository.save(pick); return pick; } -} \ No newline at end of file + + @Override + @Transactional(rollbackFor = Exception.class) + public void bigItemCall(String gdNo, String completeCode, String station, String pointCode) { + Pick pick = pickRepository.findByPick(gdNo, completeCode, station); + if (pick == null) { + throw new IllegalArgumentException(gdNo + "工单未备料,叫料失败!"); + } + if (pick.getBeCall()) { + throw new IllegalArgumentException(gdNo + "工单已叫料,请勿重复叫料!"); + } + pick.setBeCall(true); + pickRepository.save(pick); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void itemCall(String gdNo, String itemCode, String station, String pointCode) { + Pick pick = pickRepository.findByPick(gdNo, itemCode, station); + if (pick == null) { + throw new IllegalArgumentException(gdNo + "工单未备料,叫料失败!"); + } + if (pick.getBeCall()) { + throw new IllegalArgumentException(gdNo + "工单已叫料,请勿重复叫料!"); + } + pick.setBeCall(true); + pickRepository.save(pick); + } +}