no message

main
HUOJIN\92525 2024-07-17 16:49:29 +08:00
parent 76040e56a0
commit cf1b9ec238
29 changed files with 277 additions and 1675 deletions

View File

@ -1,66 +0,0 @@
/*
* 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;
import com.youchain.basicdata.domain.Item;
import com.youchain.modules.system.domain.Dept;
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.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author huojin
* @date 2024-06-06
**/
@Entity
@Data
@Table(name="data_gd")
public class Gd extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "ID")
private Long id;
@Column(name = "`code`",nullable = false)
@ApiModelProperty(value = "工单编号")
private String code;
@Column(name = "`name`",nullable = false)
@ApiModelProperty(value = "任务编号")
private String name;
@Column(name = "`status`")
@ApiModelProperty(value = "工单状态")
private String status;
@OneToOne
@JoinColumn(name = "`dept_id`",nullable = false)
@ApiModelProperty(value = "仓库")
private Dept dept;
public void copy(Gd source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -1,95 +0,0 @@
/*
* 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;
import com.youchain.basicdata.domain.BigItem;
import com.youchain.basicdata.domain.Item;
import com.youchain.modules.system.domain.Dept;
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 java.io.Serializable;
/**
* @author huojin
* @website https://eladmin.vip
* @description /
* @date 2024-06-06
**/
@Entity
@Data
@Table(name = "data_gd_detail")
public class GdDetail extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@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;
@OneToOne
@JoinColumn(name = "`item_id`", nullable = false)
@ApiModelProperty(value = "单品物料")
private Item item;
@Column(name = "`item_qty`")
@ApiModelProperty(value = "单品数量")
private Double itemQty = 0d;
@Column(name = "`order_qty`")
@ApiModelProperty(value = "未拆分数量")
private Double orderQty = 0d;
@OneToOne
@JoinColumn(name = "`big_item_id`")
@ApiModelProperty(value = "成套物料")
private BigItem bigItem;
@Column(name = "`big_item_qty`")
@ApiModelProperty(value = "总成套数")
private Double bigItemQty = 0d;
@Column(name = "`order_type`")
@ApiModelProperty(value = "单据类型")
private String orderType;
@OneToOne
@JoinColumn(name = "`dept_id`", nullable = false)
@ApiModelProperty(value = "仓库")
private Dept dept;
@Column(name = "`station`",nullable = false)
@ApiModelProperty(value = "需求工位")
private String station;
public void copy(GdDetail source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -83,6 +83,10 @@ public class Pick extends BaseEntity implements Serializable {
@ApiModelProperty(value = "是否叫料")
private Boolean isCall;
@Column(name = "`order_type`")
@ApiModelProperty(value = "单据类型")
private String orderType;
@Column(name = "`source_id`")
@ApiModelProperty(value = "来源ID")
private Long sourceId;

View File

@ -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;
@ -23,21 +23,22 @@ 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.NotNull;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author huojin
* @date 2023-08-16
**/
* @author huojin
* @website https://eladmin.vip
* @description /
* @date 2023-08-16
**/
@Entity
@Data
@Table(name="data_pick_detail")
public class PickDetail extends BaseEntity implements Serializable {
@Table(name = "data_pick_detail")
public class PickDetail extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ -46,13 +47,12 @@ public class PickDetail extends BaseEntity implements Serializable {
private Long id;
@OneToOne
@JoinColumn(name = "`pick_id`",nullable = false)
@NotNull
@JoinColumn(name = "`pick_id`")
@ApiModelProperty(value = "出库单")
private Pick pick;
@OneToOne
@JoinColumn(name = "`item_id`",nullable = false)
@JoinColumn(name = "`item_id`", nullable = false)
@NotNull
@ApiModelProperty(value = "物料")
private Item item;
@ -71,27 +71,27 @@ public class PickDetail extends BaseEntity implements Serializable {
@Column(name = "`order_qty`")
@ApiModelProperty(value = "订单数量")
private Double orderQty=0d;
private Double orderQty = 0d;
@Column(name = "`allocated_qty`")
@ApiModelProperty(value = "分配数量")
private Double allocatedQty=0d;
private Double allocatedQty = 0d;
@Column(name = "`picked_qty`")
@ApiModelProperty(value = "拣货数量")
private Double pickedQty=0d;
private Double pickedQty = 0d;
@Column(name = "`shipped_qty`")
@ApiModelProperty(value = "发运数量")
private Double shippedQty=0d;
private Double shippedQty = 0d;
@Column(name = "`weight`")
@ApiModelProperty(value = "重量")
private Double weight=0d;
private Double weight = 0d;
@Column(name = "`volume`")
@ApiModelProperty(value = "体积")
private Double volume=0d;
private Double volume = 0d;
@Column(name = "`remark`")
@ApiModelProperty(value = "备注")
@ -142,10 +142,11 @@ public class PickDetail extends BaseEntity implements Serializable {
@ApiModelProperty(value = "来源序号")
private Long sourceId;
public PickDetail(){
public PickDetail() {
}
public void copy(PickDetail source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
public void copy(PickDetail source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -1,39 +0,0 @@
/*
* 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.Gd;
import com.youchain.businessdata.domain.GdDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2024-06-06
**/
public interface GdDetailRepository extends JpaRepository<GdDetail, Long>, JpaSpecificationExecutor<GdDetail> {
@Query(value = "SELECT g FROM GdDetail g WHERE g.gd.id=?1 " +
" and (?2=null or g.bigItem.id=?2) and g.item.id=?3 and g.orderType=?4")
List<GdDetail> findRepeat(Long gdId, Long bigItemId, Long itemId,String orderType);
@Query(value = " FROM GdDetail g WHERE g.gd.id=?1 and g.orderQty>0")
List<GdDetail> findByGdAndQty(Long gdId);
@Query(value = "SELECT g FROM GdDetail g WHERE g.bigItem.id=?1 ")
List<GdDetail> findByBigItem(Long bigItemId);
}

View File

@ -1,38 +0,0 @@
/*
* 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.Gd;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
* @author huojin
* @website https://eladmin.vip
* @date 2024-06-06
**/
public interface GdRepository extends JpaRepository<Gd, Long>, JpaSpecificationExecutor<Gd> {
/**
* gd
* @param code
* @return
*/
@Query(value = " FROM Gd g WHERE g.code=:code ")
Gd findByGdCode(String code);
}

View File

@ -28,12 +28,13 @@ import java.util.List;
* @date 2024-06-11
**/
public interface PickRepository extends JpaRepository<Pick, Long>, JpaSpecificationExecutor<Pick> {
@Query(value = "SELECT p FROM Pick p WHERE p.id=?1 and p.lineNo=?2")
List<Pick> findRepeat(long gdDetailId, int no);
@Query(value = " FROM Pick p WHERE p.status in :status order by p.createTime,p.lineNo ")
List<Pick> findByPickStatus(List<String> status);
@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);
@Query(value = " from Pick p WHERE p.gdCode=:gdCode ")
List<Pick> findByPickGdCode(String gdCode);
}

View File

@ -1,94 +0,0 @@
/*
* 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.rest;
import com.youchain.annotation.Log;
import com.youchain.businessdata.domain.Gd;
import com.youchain.businessdata.service.GdService;
import com.youchain.businessdata.service.dto.GdQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author huojin
* @website https://eladmin.vip
* @date 2024-06-06
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "gd管理")
@RequestMapping("/api/gd")
public class GdController {
private final GdService gdService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('gd:list')")
public void exportGd(HttpServletResponse response, GdQueryCriteria criteria) throws IOException {
gdService.download(gdService.queryAll(criteria), response);
}
@GetMapping
@ApiOperation("查询工单")
@PreAuthorize("@el.check('gd:list')")
public ResponseEntity<Object> queryGd(GdQueryCriteria criteria, Pageable pageable) {
return new ResponseEntity<>(gdService.queryAll(criteria, pageable), HttpStatus.OK);
}
@GetMapping(value = "/queryAllGd")
@ApiOperation("查询All工单")
@PreAuthorize("@el.check('gd:list')")
public ResponseEntity<Object> queryAllGd(GdQueryCriteria criteria) {
return new ResponseEntity<>(gdService.queryAll(criteria), HttpStatus.OK);
}
@PostMapping
@Log("新增gd")
@ApiOperation("新增gd")
@PreAuthorize("@el.check('gd:add')")
public ResponseEntity<Object> createGd(@Validated @RequestBody Gd resources) {
return new ResponseEntity<>(gdService.create(resources), HttpStatus.CREATED);
}
@PutMapping
@Log("修改gd")
@ApiOperation("修改gd")
@PreAuthorize("@el.check('gd:edit')")
public ResponseEntity<Object> updateGd(@Validated @RequestBody Gd resources) {
gdService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@Log("删除gd")
@ApiOperation("删除gd")
@PreAuthorize("@el.check('gd:del')")
public ResponseEntity<Object> deleteGd(@RequestBody Long[] ids) {
gdService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -1,86 +0,0 @@
/*
* 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.rest;
import com.youchain.annotation.Log;
import com.youchain.businessdata.domain.GdDetail;
import com.youchain.businessdata.service.GdDetailService;
import com.youchain.businessdata.service.dto.GdDetailQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2024-06-06
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "gdDetail管理")
@RequestMapping("/api/gdDetail")
public class GdDetailController {
private final GdDetailService gdDetailService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('gdDetail:list')")
public void exportGdDetail(HttpServletResponse response, GdDetailQueryCriteria criteria) throws IOException {
gdDetailService.download(gdDetailService.queryAll(criteria), response);
}
@GetMapping
@ApiOperation("查询gdDetail")
@PreAuthorize("@el.check('gdDetail:list')")
public ResponseEntity<Object> queryGdDetail(GdDetailQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(gdDetailService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增gdDetail")
@ApiOperation("新增gdDetail")
@PreAuthorize("@el.check('gdDetail:add')")
public ResponseEntity<Object> createGdDetail(@Validated @RequestBody GdDetail resources){
return new ResponseEntity<>(gdDetailService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改gdDetail")
@ApiOperation("修改gdDetail")
@PreAuthorize("@el.check('gdDetail:edit')")
public ResponseEntity<Object> updateGdDetail(@Validated @RequestBody GdDetail resources){
gdDetailService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@Log("删除gdDetail")
@ApiOperation("删除gdDetail")
@PreAuthorize("@el.check('gdDetail:del')")
public ResponseEntity<Object> deleteGdDetail(@RequestBody Long[] ids) {
gdDetailService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -6,7 +6,6 @@ import org.springframework.http.HttpStatus;
import com.youchain.RequestData.*;
import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log;
import com.youchain.businessdata.service.GdService;
import com.youchain.businessdata.service.PickService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -25,7 +24,6 @@ import static org.springframework.http.HttpStatus.OK;
@RequestMapping("/api/mes")
@Slf4j
public class MesController {
private final GdService gdService;
private final PickService pickService;
private final StockService stockService;
@ -36,7 +34,7 @@ public class MesController {
@AnonymousAccess
public ResponseEntity<Object> yclbl(@Validated @RequestBody Yclbl yclbl) {
try {
gdService.materialBL(yclbl);
pickService.materialBL(yclbl);
return successResponse("备料成功!");
} catch (Exception e) {
return badResponse("备料失败:" + e.getMessage());

View File

@ -1,94 +0,0 @@
/*
* 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;
import com.youchain.basicdata.domain.BigItem;
import com.youchain.basicdata.domain.Item;
import com.youchain.businessdata.domain.Gd;
import com.youchain.businessdata.domain.GdDetail;
import com.youchain.businessdata.service.dto.GdDetailDto;
import com.youchain.businessdata.service.dto.GdDetailQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author huojin
* @website https://eladmin.vip
* @description
* @date 2024-06-06
**/
public interface GdDetailService {
/**
*
*
* @param criteria
* @param pageable
* @return Map<String, Object>
*/
Map<String, Object> queryAll(GdDetailQueryCriteria criteria, Pageable pageable);
/**
*
*
* @param criteria
* @return List<GdDetailDto>
*/
List<GdDetailDto> queryAll(GdDetailQueryCriteria criteria);
/**
* ID
*
* @param id ID
* @return GdDetailDto
*/
GdDetailDto findById(Long id);
/**
*
*
* @param resources /
* @return GdDetailDto
*/
GdDetailDto create(GdDetail resources);
/**
*
*
* @param resources /
*/
void update(GdDetail resources);
/**
*
*
* @param ids /
*/
void deleteAll(Long[] ids);
/**
*
*
* @param all
* @param response /
* @throws IOException /
*/
void download(List<GdDetailDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -1,109 +0,0 @@
/*
* 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;
import com.youchain.RequestData.Yclbl;
import com.youchain.businessdata.domain.Gd;
import com.youchain.businessdata.service.dto.GdDto;
import com.youchain.businessdata.service.dto.GdQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author huojin
* @website https://eladmin.vip
* @description
* @date 2024-06-06
**/
public interface GdService {
/**
*
*
* @param criteria
* @param pageable
* @return Map<String, Object>
*/
Map<String, Object> queryAll(GdQueryCriteria criteria, Pageable pageable);
/**
*
*
* @param criteria
* @return List<GdDto>
*/
List<GdDto> queryAll(GdQueryCriteria criteria);
/**
* ID
*
* @param id ID
* @return GdDto
*/
GdDto findById(Long id);
/**
*
*
* @param resources /
* @return GdDto
*/
GdDto create(Gd resources);
/**
*
*
* @param resources /
*/
void update(Gd resources);
/**
*
*
* @param ids /
*/
void deleteAll(Long[] ids);
/**
*
*
* @param all
* @param response /
* @throws IOException /
*/
void download(List<GdDto> all, HttpServletResponse response) throws IOException;
/**
*
*
* @param orderNo
* @param taskCode
* @return Gd
*/
Gd createGd(String orderNo, String taskCode);
/**
*
*
* @param yclbl
*/
void materialBL(Yclbl yclbl);
}

View File

@ -15,11 +15,8 @@
*/
package com.youchain.businessdata.service;
import com.youchain.basicdata.domain.Box;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.service.dto.BoxDto;
import com.youchain.businessdata.domain.GdDetail;
import com.youchain.businessdata.domain.Pick;
import com.youchain.businessdata.domain.PickDetail;
import com.youchain.businessdata.service.dto.PickDetailDto;
@ -127,14 +124,6 @@ public interface PickDetailService {
PickDetail createPickDetail(Item item, String po);
/**
*
*
* @param pick->
* @param gdDetails->
*/
void createPickDetail(Pick pick, List<GdDetail> gdDetails);
/**
*
*

View File

@ -15,9 +15,7 @@
*/
package com.youchain.businessdata.service;
import com.youchain.basicdata.domain.Point;
import com.youchain.businessdata.domain.Gd;
import com.youchain.businessdata.domain.GdDetail;
import com.youchain.RequestData.Yclbl;
import com.youchain.businessdata.domain.Pick;
import com.youchain.businessdata.service.dto.PickDto;
import com.youchain.businessdata.service.dto.PickQueryCriteria;
@ -92,8 +90,6 @@ public interface PickService {
*/
void download(List<PickDto> all, HttpServletResponse response) throws IOException;
Pick save(GdDetail gdDetail, int no);
/**
*
*
@ -115,16 +111,11 @@ public interface PickService {
void itemCall(String gdNo, String itemCode, String station, String pointCode);
/**
*
*
*
* @param gd->
* @param lineNo->
* @param cpCodeOrpCode->
* @param station->
* @param yclbl
*/
Pick createPick(Gd gd, int lineNo, String cpCodeOrpCode, String station);
void materialBL(Yclbl yclbl);
/**
*

View File

@ -1,98 +0,0 @@
/*
* 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.dto;
import com.youchain.basicdata.domain.BigItem;
import com.youchain.basicdata.domain.Item;
import com.youchain.businessdata.domain.Gd;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author huojin
* @website https://eladmin.vip
* @description /
* @date 2024-06-06
**/
@Data
public class GdDetailDto implements Serializable {
/**
* ID
*/
private Long id;
/**
*
*/
private String createBy;
/**
*
*/
private String updateBy;
/**
*
*/
private Timestamp createTime;
/**
*
*/
private Timestamp updateTime;
/**
*
*/
private int lineNo;
/**
*
*/
private Long itemId;
private Item item;
/**
*
*/
private Long itemQty;
/**
*
*/
private Long bigItemId;
private BigItem bigItem;
/**
*
*/
private Long bigItemQty;
private Gd gd;
private Double orderQty;
/**
*
*/
private String orderType;
/**
*
*/
private String station;
}

View File

@ -1,61 +0,0 @@
/*
* 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.dto;
import lombok.Data;
import java.util.List;
import com.youchain.annotation.Query;
/**
* @author huojin
* @website https://eladmin.vip
* @date 2024-06-06
**/
@Data
public class GdDetailQueryCriteria {
/**
*
*/
@Query(joinName = "gd>", propName = "code", type = Query.Type.INNER_LIKE)
private String gdCode;
/**
*
*/
@Query(joinName = "item>", propName = "code", type = Query.Type.INNER_LIKE)
private String itemCode;
/**
*
*/
@Query(joinName = "bigItem>", propName = "code", type = Query.Type.INNER_LIKE)
private String bigItemCode;
/**
*
*/
@Query
private String orderType;
/**
*
*/
@Query
private String station;
}

View File

@ -1,54 +0,0 @@
/*
* 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.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author huojin
* @date 2024-06-06
**/
@Data
public class GdDto implements Serializable {
/** ID */
private Long id;
/** 创建人 */
private String createBy;
/** 修改人 */
private String updateBy;
/** 创建时间 */
private Timestamp createTime;
/** 修改时间 */
private Timestamp updateTime;
/** 工单编号 */
private String code;
/** 任务编号 */
private String name;
/** 工单状态 */
private String status;
}

View File

@ -1,42 +0,0 @@
/*
* 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.dto;
import lombok.Data;
import java.util.List;
import com.youchain.annotation.Query;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2024-06-06
**/
@Data
public class GdQueryCriteria{
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String code;
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String name;
/** 精确 */
@Query
private String status;
}

View File

@ -75,6 +75,11 @@ public class PickDto implements Serializable {
*/
private Point callPoint;
/**
*
*/
private String orderType;
/**
*
*/

View File

@ -41,4 +41,22 @@ public class PickQueryCriteria {
@Query(type = Query.Type.EQUAL)
private String status;
/**
*
*/
@Query(type = Query.Type.INNER_LIKE)
private String station;
/**
*
*/
@Query(type = Query.Type.INNER_LIKE)
private String cpCodeOrDpCode;
/**
*
*/
@Query(type = Query.Type.EQUAL)
private String orderType;
}

View File

@ -1,113 +0,0 @@
/*
* 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;
import com.youchain.modules.system.service.DeptService;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
import com.youchain.businessdata.repository.GdDetailRepository;
import com.youchain.businessdata.service.GdDetailService;
import com.youchain.businessdata.service.dto.GdDetailDto;
import com.youchain.businessdata.service.dto.GdDetailQueryCriteria;
import com.youchain.businessdata.service.mapstruct.GdDetailMapper;
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;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author huojin
* @website https://eladmin.vip
* @description
* @date 2024-06-06
**/
@Service
@RequiredArgsConstructor
public class GdDetailServiceImpl implements GdDetailService {
private final GdDetailRepository gdDetailRepository;
private final GdDetailMapper gdDetailMapper;
private final DeptService deptService;
@Override
public Map<String, Object> queryAll(GdDetailQueryCriteria criteria, Pageable pageable) {
Page<GdDetail> page = gdDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return PageUtil.toPage(page.map(gdDetailMapper::toDto));
}
@Override
public List<GdDetailDto> queryAll(GdDetailQueryCriteria criteria) {
return gdDetailMapper.toDto(gdDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
@Transactional
public GdDetailDto findById(Long id) {
GdDetail gdDetail = gdDetailRepository.findById(id).orElseGet(GdDetail::new);
ValidationUtil.isNull(gdDetail.getId(), "GdDetail", "id", id);
return gdDetailMapper.toDto(gdDetail);
}
@Override
@Transactional(rollbackFor = Exception.class)
public GdDetailDto create(GdDetail resources) {
return gdDetailMapper.toDto(gdDetailRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(GdDetail resources) {
GdDetail gdDetail = gdDetailRepository.findById(resources.getId()).orElseGet(GdDetail::new);
ValidationUtil.isNull(gdDetail.getId(), "GdDetail", "id", resources.getId());
gdDetail.copy(resources);
gdDetailRepository.save(gdDetail);
}
@Override
public void deleteAll(Long[] ids) {
for (Long id : ids) {
gdDetailRepository.deleteById(id);
}
}
@Override
public void download(List<GdDetailDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (GdDetailDto gdDetail : all) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("创建人", gdDetail.getCreateBy());
map.put("修改人", gdDetail.getUpdateBy());
map.put("创建时间", gdDetail.getCreateTime());
map.put("修改时间", gdDetail.getUpdateTime());
map.put("行号", gdDetail.getLineNo());
map.put("关联物料", gdDetail.getItemId());
map.put("订单数量", gdDetail.getItemQty());
map.put("总成代码", gdDetail.getBigItemId());
map.put("总成套数", gdDetail.getBigItemQty());
map.put("单据类型", gdDetail.getOrderType());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -1,426 +0,0 @@
/*
* 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.RequestData.ItemDate;
import com.youchain.RequestData.Yclbl;
import com.youchain.RequestData.ZcData;
import com.youchain.basicdata.domain.BigItem;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.PackageCheck;
import com.youchain.basicdata.repository.BigItemRepository;
import com.youchain.basicdata.repository.ItemRepository;
import com.youchain.basicdata.repository.PackageCheckRepository;
import com.youchain.businessdata.domain.Gd;
import com.youchain.businessdata.domain.GdDetail;
import com.youchain.businessdata.domain.Pick;
import com.youchain.businessdata.service.PickDetailService;
import com.youchain.businessdata.service.PickService;
import com.youchain.config.thread.ThreadPoolExecutorUtil;
import com.youchain.modules.system.domain.Dept;
import com.youchain.modules.system.service.DeptService;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
import com.youchain.businessdata.repository.GdRepository;
import com.youchain.businessdata.service.GdService;
import com.youchain.businessdata.service.dto.GdDto;
import com.youchain.businessdata.service.dto.GdQueryCriteria;
import com.youchain.businessdata.service.mapstruct.GdMapper;
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.*;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
/**
* @author huojin
* @website https://eladmin.vip
* @description
* @date 2024-06-06
**/
@Service
@RequiredArgsConstructor
public class GdServiceImpl implements GdService {
private final GdRepository gdRepository;
private final BigItemRepository bigItemRepository;
private final ItemRepository itemRepository;
private final PickService pickService;
private final PickDetailService pickDetailService;
private final DeptService deptService;
private final GdMapper gdMapper;
private final RedisObjectUtils redisObjectUtils;
private final PackageCheckRepository packageCheckRepository;
private final BatchCreateOrUpdate batchCreateOrUpdate;
@Override
public Map<String, Object> queryAll(GdQueryCriteria criteria, Pageable pageable) {
Page<Gd> page = gdRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return PageUtil.toPage(page.map(gdMapper::toDto));
}
@Override
public List<GdDto> queryAll(GdQueryCriteria criteria) {
return gdMapper.toDto(gdRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
@Transactional
public GdDto findById(Long id) {
Gd gd = gdRepository.findById(id).orElseGet(Gd::new);
ValidationUtil.isNull(gd.getId(), "Gd", "id", id);
return gdMapper.toDto(gd);
}
@Override
@Transactional(rollbackFor = Exception.class)
public GdDto create(Gd resources) {
return gdMapper.toDto(gdRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(Gd resources) {
Gd gd = gdRepository.findById(resources.getId()).orElseGet(Gd::new);
ValidationUtil.isNull(gd.getId(), "Gd", "id", resources.getId());
gd.copy(resources);
gdRepository.save(gd);
}
@Override
public void deleteAll(Long[] ids) {
for (Long id : ids) {
gdRepository.deleteById(id);
}
}
@Override
public void download(List<GdDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (GdDto gd : all) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("创建人", gd.getCreateBy());
map.put("修改人", gd.getUpdateBy());
map.put("创建时间", gd.getCreateTime());
map.put("修改时间", gd.getUpdateTime());
map.put("工单编号", gd.getCode());
map.put("任务编号", gd.getName());
map.put("工单状态", gd.getStatus());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Gd createGd(String orderNo, String taskCode) {
Gd gd = new Gd();
gd.setCode(orderNo);
gd.setName(taskCode);
gd.setStatus(BizStatus.OPEN);
gd.setDept(deptService.getDefaultDept());
gdRepository.save(gd);
return gd;
}
/**
*
*
* @param yclbl ->
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void materialBL(Yclbl yclbl) {
/** 验证参数有效性 */
validateGd(yclbl);
/** 验证工单是否存在 */
checkIfGdExists(yclbl);
/** 创建工单 */
Gd gd = createGd(yclbl.getOrderNo(), yclbl.getTaskCode());
/** 创建工单明细 */
List<GdDetail> gdDetailList = createGdDetailsCPAndDP(gd, yclbl);
/** 添加出库单和出库明细 */
addPickAndPickDetail(gd, gdDetailList);
}
/**
*
*
* @param yclbl ->
*/
private void checkIfGdExists(Yclbl yclbl) {
Gd gd = gdRepository.findByGdCode(yclbl.getOrderNo());
if (gd != null) {
throw new IllegalArgumentException(yclbl.getOrderNo() + "备料工单已存在!");
}
}
/**
*
*
* @param yclbl ->
* @param gd ->
*/
private List<GdDetail> createGdDetailsCP(Yclbl yclbl, Gd gd) {
if (yclbl.getBlzc().isEmpty()) {
return null;
}
String orderType = BaseStatus.GD_TYPE_CT;
Dept dept = deptService.getDefaultDept();
List<GdDetail> gdDetailsCreate = yclbl.getBlzc().parallelStream()
.flatMap(zcData -> {
BigItem bigItem = validateBigItem(zcData.getCompleteCode()); // 验证成品是否存在
double completeQty = zcData.getCompleteQty();
AtomicInteger index = new AtomicInteger(1);
return zcData.getBlzcmx().stream()
.map(itemDate -> {
Item item = validateItem(itemDate.getItemCode()); // 验证单品是否存在
return createGdDetail(
gd,
index.getAndIncrement(),
item,
itemDate.getItemQty(),
bigItem,
completeQty,
orderType,
dept,
zcData.getStation()
);
});
})
.collect(Collectors.toList());
return gdDetailsCreate;
}
/**
*
*
* @param yclbl ->
* @param gd ->
*/
private List<GdDetail> createGdDetailsDP(Yclbl yclbl, Gd gd) {
if (yclbl.getBlzcmx().isEmpty()) {
return null;
}
String orderType = BaseStatus.GD_TYPE_DP;
Dept dept = deptService.getDefaultDept();
AtomicInteger index = new AtomicInteger(1);
List<GdDetail> gdDetailsCreate = yclbl.getBlzcmx().parallelStream()
.map(itemDate -> {
Item item = validateItem(itemDate.getItemCode()); // 验证单品是否存在
return createGdDetail(
gd,
index.getAndIncrement(),
item,
itemDate.getItemQty(),
null,
null,
orderType,
dept,
itemDate.getStation()
);
})
.collect(Collectors.toList());
return gdDetailsCreate;
}
/**
*
*
* @param gd ->
* @param yclbl ->
*/
private List<GdDetail> createGdDetailsCPAndDP(Gd gd, Yclbl yclbl) {
/** 添加成品工单明细集合 */
List<GdDetail> gdDetailsCreateCP = createGdDetailsCP(yclbl, gd);
/** 添加单品工单明细集合 */
List<GdDetail> gdDetailsCreateDP = createGdDetailsDP(yclbl, gd);
/** 把两个集合合并 */
List<GdDetail> gdDetailsCreate = new ArrayList<>(gdDetailsCreateCP);
gdDetailsCreate.addAll(gdDetailsCreateDP);
/** 批量保存工单明细 */
ExecutorService executor = ThreadPoolExecutorUtil.getPoll("gdDetail-create-job");
CompletableFuture<List<GdDetail>> future = CompletableFuture.supplyAsync(() -> {
batchCreateOrUpdate.batchCreate(gdDetailsCreate);
return gdDetailsCreate;
}, executor);
List<GdDetail> gdDetails = future.join();
executor.shutdown();// 关闭线程池
return gdDetails;// 返回结果
}
/**
*
*
* @param gd->
* @param lineNo ->
* @param item ->
* @param itemQty ->
* @param bigItem ->
* @param bigItemQty ->
* @param orderType ->
* @param dept ->
* @return
*/
private GdDetail createGdDetail(Gd gd, int lineNo, Item item, Double itemQty, BigItem bigItem, Double bigItemQty, String orderType, Dept dept, String station) {
GdDetail gdDetail = new GdDetail();
gdDetail.setGd(gd);
gdDetail.setLineNo(lineNo);
gdDetail.setItem(item);
gdDetail.setItemQty(itemQty);
gdDetail.setBigItem(bigItem);
gdDetail.setBigItemQty(bigItemQty);
gdDetail.setOrderType(orderType);
gdDetail.setDept(dept);
gdDetail.setStation(station);
return gdDetail;
}
/**
*
*
* @param yclbl ->
*/
private void validateGd(Yclbl yclbl) {
if (StringUtils.isEmpty(yclbl.getOrderNo())) {
throw new IllegalArgumentException("工单号必填!");
}
if (StringUtils.isEmpty(yclbl.getTaskCode())) {
throw new IllegalArgumentException("任务号必填!");
}
if (yclbl.getBlzc().isEmpty() && yclbl.getBlzcmx().isEmpty()) {
throw new IllegalArgumentException("成品明细和单品明细至少一项必填!");
}
if (!yclbl.getBlzc().isEmpty()) {
for (ZcData zcData : yclbl.getBlzc()) {
if (!StringUtils.isEmpty(zcData.getCompleteCode())) {
if (zcData.getCompleteQty() <= 0) {
throw new IllegalArgumentException("成品套数不能小于等于0!");
}
}
if (StringUtils.isEmpty(zcData.getStation())) {
throw new IllegalArgumentException("成品需求工位必填!");
}
for (ItemDate itemDate : zcData.getBlzcmx()) {
if (itemDate.getItemQty() == null || itemDate.getItemQty() <= 0) {
throw new IllegalArgumentException("单品套数不能小于等于0!");
}
}
}
}
if (!yclbl.getBlzcmx().isEmpty()) {
for (ItemDate itemDate : yclbl.getBlzcmx()) {
if (itemDate.getItemQty() == null || itemDate.getItemQty() <= 0) {
throw new IllegalArgumentException("单品套数不能小于等于0!");
}
if (StringUtils.isEmpty(itemDate.getStation())) {
throw new IllegalArgumentException("单品需求工位必填!");
}
}
}
}
/**
*
*
* @param completeCode ->
* @return
*/
private BigItem validateBigItem(String completeCode) {
BigItem bigItem = redisObjectUtils.getObjectFromCache(completeCode, () -> bigItemRepository.findByBigItemCode(completeCode), completeCode + "成品物料不存在,请维护!");
return bigItem;
}
/**
*
*
* @param itemCode ->
* @return
*/
private Item validateItem(String itemCode) {
Item item = redisObjectUtils.getObjectFromCache(itemCode, () -> itemRepository.findByItemCode(itemCode), itemCode + "单品物料不存在,请维护!");
return item;
}
/**
*
*
* @param code ->
* @return
*/
private PackageCheck validatePackageCheck(String code) {
PackageCheck packageCheck = redisObjectUtils.getObjectFromCache(code, () -> packageCheckRepository.findByCode(code), code + "翻包套数不存在,请维护!");
return packageCheck;
}
private void addPickAndPickDetail(Gd gd, List<GdDetail> gdDetailList) {
AtomicInteger lineNo = new AtomicInteger(1);
/** 成品工单明细集合 */
List<GdDetail> cpGdDetailList = gdDetailList.stream()
.filter(gdDetail -> BaseStatus.GD_TYPE_CT.equals(gdDetail.getOrderType()))
.collect(Collectors.toList());
/** 根据成品编码查出对应的工单明细集合 */
Map<String, List<GdDetail>> groupedByCpCodeMap = cpGdDetailList.stream()
.collect(Collectors.groupingBy(gdDetail -> gdDetail.getBigItem().getCode()));
/** 单品工单明细集合 */
List<GdDetail> dpGdDetailList = gdDetailList.stream()
.filter(gdDetail -> BaseStatus.GD_TYPE_DP.equals(gdDetail.getOrderType()))
.collect(Collectors.toList());
/** 根据单品编码查出对应的工单明细集合 */
Map<String, List<GdDetail>> groupedByDpCodeMap = dpGdDetailList.stream()
.collect(Collectors.groupingBy(gdDetail -> gdDetail.getItem().getCode()));
/** 根据成品工单明细生成出库单和出库单明细 */
createPickAndPickDetail(gd, groupedByCpCodeMap, lineNo);
/** 根据单品工单明细生成出库单和出库单明细 */
createPickAndPickDetail(gd, groupedByDpCodeMap, lineNo);
}
private void createPickAndPickDetail(Gd gd, Map<String, List<GdDetail>> groupedByDpCodeMap, AtomicInteger lineNo) {
groupedByDpCodeMap.forEach((code, gdDetails) -> {
Pick pick = pickService.createPick(gd, lineNo.getAndIncrement(), code, gdDetails.get(0).getStation());
pickDetailService.createPickDetail(pick, gdDetails);
});
}
}

View File

@ -307,27 +307,6 @@ public class PickDetailServiceImpl implements PickDetailService {
return d;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void createPickDetail(Pick pick, List<GdDetail> gdDetails) {
AtomicInteger lineNo = new AtomicInteger(1);
for (GdDetail gdDetail : gdDetails) {
PickDetail pickDetail = new PickDetail();
pickDetail.setPick(pick);
pickDetail.setItem(gdDetail.getItem());
pickDetail.setLineNo(lineNo.getAndIncrement());
pickDetail.setStatus(BizStatus.OPEN);
if (BaseStatus.GD_TYPE_CT.equals(gdDetail.getOrderType())) {
pickDetail.setOrderQty(gdDetail.getItemQty() * gdDetail.getBigItemQty());
} else {
pickDetail.setOrderQty(gdDetail.getItemQty());
}
pickDetail.setSourceId(gdDetail.getId());
pickDetail.setDept(gdDetail.getDept());
pickDetailRepository.save(pickDetail);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void allocatePick(Pick pick) {

View File

@ -15,12 +15,20 @@
*/
package com.youchain.businessdata.service.impl;
import com.youchain.RequestData.ItemDate;
import com.youchain.RequestData.Yclbl;
import com.youchain.RequestData.ZcData;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.repository.ItemRepository;
import com.youchain.basicdata.repository.PointRepository;
import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.repository.AgvTaskRepository;
import com.youchain.businessdata.repository.PickDetailRepository;
import com.youchain.businessdata.repository.TaskRepository;
import com.youchain.businessdata.service.AgvTaskService;
import com.youchain.config.thread.ThreadPoolExecutorUtil;
import com.youchain.modules.system.service.DeptService;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
import com.youchain.businessdata.repository.PickRepository;
@ -28,17 +36,20 @@ import com.youchain.businessdata.service.PickService;
import com.youchain.businessdata.service.dto.PickDto;
import com.youchain.businessdata.service.dto.PickQueryCriteria;
import com.youchain.businessdata.service.mapstruct.PickMapper;
import org.springframework.beans.factory.annotation.Autowired;
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.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author huojin
@ -51,11 +62,17 @@ import java.util.LinkedHashMap;
public class PickServiceImpl implements PickService {
private final PickRepository pickRepository;
private final PickDetailRepository pickDetailRepository;
private final TaskRepository taskRepository;
private final PointRepository pointRepository;
private final ItemRepository itemRepository;
private final AgvTaskRepository agvTaskRepository;
private final AgvTaskService agvTaskService;
private final DeptService deptService;
private final PickMapper pickMapper;
private final RedisObjectUtils redisObjectUtils;
private final BatchCreateOrUpdate batchCreateOrUpdate;
@Override
public Map<String, Object> queryAll(PickQueryCriteria criteria, Pageable pageable) {
@ -115,22 +132,6 @@ public class PickServiceImpl implements PickService {
FileUtil.downloadExcel(list, response);
}
@Override
public Pick save(GdDetail gdDetail, int no) {
Pick pick = new Pick();
List<Pick> pickList = pickRepository.findRepeat(gdDetail.getId(), no);
if (pickList.size() > 0) {
pick = pickList.get(0);
}
pick.setLineNo(no);
pick.setStatus(BizStatus.OPEN);
pick.setCode(gdDetail.getGd().getName() + "_" + no);
pick.setDept(UserUtils.isDept);
pickRepository.save(pick);
return pick;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void bigItemCall(String gdNo, String completeCode, String station, String pointCode) {
@ -177,18 +178,125 @@ public class PickServiceImpl implements PickService {
@Override
@Transactional(rollbackFor = Exception.class)
public Pick createPick(Gd gd, int lineNo, String cpCodeOrpCode, String station) {
public void materialBL(Yclbl yclbl) {
/** 验证参数有效性 */
validatePick(yclbl);
/** 验证出库单是否存在 */
checkIfGdExists(yclbl);
List<Pick> createPicks = new ArrayList<>();
List<PickDetail> createPickDetails = new ArrayList<>();
AtomicInteger lineNo = new AtomicInteger(1);
/** 合并两个循环,减少重复操作 */
yclbl.getBlzc().forEach(zcData -> {
Pick pick = createPick(yclbl.getOrderNo(), lineNo.getAndIncrement(), zcData.getCompleteCode(), zcData.getStation());
createPicks.add(pick);
zcData.getBlzcmx().forEach(itemDate -> {
Item item = validateItem(itemDate.getItemCode()); // 验证单品是否存在
PickDetail pickDetail = createPickDetail(pick, item, BaseStatus.GD_TYPE_CT, itemDate.getItemQty(), zcData.getCompleteQty());
createPickDetails.add(pickDetail);
});
});
yclbl.getBlzcmx().forEach(itemDate -> {
Pick pick = createPick(yclbl.getOrderNo(), lineNo.getAndIncrement(), itemDate.getItemCode(), itemDate.getStation());
createPicks.add(pick);
Item item = validateItem(itemDate.getItemCode()); // 验证单品是否存在
PickDetail pickDetail = createPickDetail(pick, item, BaseStatus.GD_TYPE_DP, itemDate.getItemQty(), null);
createPickDetails.add(pickDetail);
});
ExecutorService executor = ThreadPoolExecutorUtil.getPoll("materialBL-job");
try {
List<CompletableFuture<Void>> futures = new ArrayList<>();
/** 使用并行流批量保存 */
if (!createPicks.isEmpty()) {
futures.add(CompletableFuture.runAsync(() -> pickRepository.saveAll(createPicks), executor));
}
if (!createPickDetails.isEmpty()) {
futures.add(CompletableFuture.runAsync(() -> pickDetailRepository.saveAll(createPickDetails), executor));
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
} catch (Exception e) {
throw new RuntimeException("创建出库单失败!", e);
} finally {
executor.shutdown();
}
}
/**
*
*
* @param yclbl ->
*/
private void validatePick(Yclbl yclbl) {
if (StringUtils.isEmpty(yclbl.getOrderNo())) {
throw new IllegalArgumentException("工单号必填!");
}
if (StringUtils.isEmpty(yclbl.getTaskCode())) {
throw new IllegalArgumentException("任务号必填!");
}
if (yclbl.getBlzc().isEmpty() && yclbl.getBlzcmx().isEmpty()) {
throw new IllegalArgumentException("成品明细和单品明细至少一项必填!");
}
}
/**
*
*
* @param yclbl ->
*/
private void checkIfGdExists(Yclbl yclbl) {
List<Pick> pick = pickRepository.findByPickGdCode(yclbl.getOrderNo());
if (!pick.isEmpty()) {
throw new IllegalArgumentException(yclbl.getOrderNo() + "出库单已存在!");
}
}
/**
*
*
* @param itemCode ->
* @return
*/
private Item validateItem(String itemCode) {
Item item = redisObjectUtils.getObjectFromCache(itemCode, () -> itemRepository.findByItemCode(itemCode), itemCode + "单品物料不存在,请维护!");
return item;
}
public PickDetail createPickDetail(Pick pick, Item item, String orderType, Double itemQty, Double bigItemQty) {
AtomicInteger lineNo = new AtomicInteger(1);
PickDetail pickDetail = new PickDetail();
pickDetail.setPick(pick);
pickDetail.setItem(item);
pickDetail.setLineNo(lineNo.getAndIncrement());
pickDetail.setStatus(BizStatus.OPEN);
if (BaseStatus.GD_TYPE_CT.equals(orderType)) {
pickDetail.setOrderQty(itemQty * bigItemQty);
} else {
pickDetail.setOrderQty(itemQty);
}
pickDetail.setDept(pick.getDept());
return pickDetail;
}
public Pick createPick(String gdCode, int lineNo, String cpCodeOrpCode, String station) {
Pick pick = new Pick();
pick.setLineNo(lineNo);
pick.setCode(gd.getCode() + "_" + lineNo);
pick.setGdCode(gd.getCode());
pick.setCode(gdCode + "_" + lineNo);
pick.setGdCode(gdCode);
pick.setStation(station);
pick.setCpCodeOrDpCode(cpCodeOrpCode);
pick.setStatus(BizStatus.OPEN);
pick.setIsCall(false);
pick.setSourceId(gd.getId());
pick.setDept(gd.getDept());
pickRepository.save(pick);
pick.setDept(deptService.getDefaultDept());
return pick;
}

View File

@ -1,32 +0,0 @@
/*
* 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.mapstruct;
import com.youchain.base.BaseMapper;
import com.youchain.businessdata.domain.GdDetail;
import com.youchain.businessdata.service.dto.GdDetailDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2024-06-06
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface GdDetailMapper extends BaseMapper<GdDetailDto, GdDetail> {
}

View File

@ -1,32 +0,0 @@
/*
* 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.mapstruct;
import com.youchain.base.BaseMapper;
import com.youchain.businessdata.domain.Gd;
import com.youchain.businessdata.service.dto.GdDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2024-06-06
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface GdMapper extends BaseMapper<GdDto, Gd> {
}

View File

@ -1,12 +1,7 @@
package com.youchain.utils;
import cn.hutool.json.JSONUtil;
import com.youchain.businessdata.service.GdDetailService;
import com.youchain.modules.system.domain.Dept;
import com.youchain.modules.system.repository.DeptRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j

View File

@ -6,8 +6,8 @@ spring:
freemarker:
check-template-location: false
profiles:
active: prod
#active: dev
#active: prod
active: dev
jackson:
time-zone: GMT+8
data:
@ -31,11 +31,11 @@ spring:
redis:
#数据库索引
database: ${REDIS_DB:2}
host: ${REDIS_HOST:192.168.100.102}
password: ${REDIS_PWD:123456}
#host: ${REDIS_HOST:192.168.100.102}
#password: ${REDIS_PWD:123456}
#host: ${REDIS_HOST:localhost}
#password: ${REDIS_PWD:}
host: ${REDIS_HOST:localhost}
password: ${REDIS_PWD:}
port: ${REDIS_PORT:6379}
#连接超时时间
timeout: 5000

View File

@ -2,18 +2,13 @@ package com.youchain;
import com.youchain.basicdata.domain.BigItem;
import com.youchain.basicdata.vo.BarCodeVo;
import com.youchain.businessdata.domain.AgvTask;
import com.youchain.businessdata.domain.AsnDetail;
import com.youchain.businessdata.domain.GdDetail;
import com.youchain.businessdata.domain.PickDetail;
import com.youchain.config.thread.ThreadPoolExecutorUtil;
import com.youchain.utils.StringUtils;
import com.youchain.utils.BaseStatus;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ -24,6 +19,73 @@ public class EladminSystemApplicationTests {
}
public static void main(String[] args) {
GdDetail gdDetail1 = new GdDetail();
gdDetail1.setBigItem(null);
gdDetail1.setOrderType("单品");
GdDetail gdDetail2 = new GdDetail();
BigItem bigItem2 = new BigItem();
bigItem2.setCode("CT_001");
gdDetail2.setBigItem(bigItem2);
gdDetail2.setOrderType("成品");
gdDetail2.setBigItemQty(1d);
gdDetail2.setStation("OP1070-2");
GdDetail gdDetail3 = new GdDetail();
BigItem bigItem3 = new BigItem();
bigItem3.setCode("CT_001");
gdDetail3.setBigItem(bigItem3);
gdDetail3.setOrderType("成品");
gdDetail3.setBigItemQty(2d);
gdDetail3.setStation("OP1070-1");
GdDetail gdDetail4 = new GdDetail();
BigItem bigItem4 = new BigItem();
bigItem4.setCode("CT_002");
gdDetail4.setBigItem(bigItem4);
gdDetail4.setOrderType("成品");
gdDetail4.setBigItemQty(3d);
gdDetail4.setStation("OP2060");
GdDetail gdDetail5 = new GdDetail();
BigItem bigItem5 = new BigItem();
bigItem5.setCode("CT_002");
gdDetail5.setBigItem(bigItem5);
gdDetail5.setOrderType("成品");
gdDetail5.setBigItemQty(4d);
gdDetail5.setStation("OP1030");
List<GdDetail> gdDetailList = new ArrayList<>();
gdDetailList.add(gdDetail1);
gdDetailList.add(gdDetail2);
gdDetailList.add(gdDetail3);
gdDetailList.add(gdDetail4);
gdDetailList.add(gdDetail5);
Map<String, Map<String, List<GdDetail>>> groupedGdDetailMap = gdDetailList.stream()
.filter(gdDetail -> BaseStatus.GD_TYPE_CT.equals(gdDetail.getOrderType()))
.filter(gdDetail -> gdDetail.getBigItem() != null)
.collect(Collectors.groupingBy(
gdDetail -> gdDetail.getBigItem().getCode(),
Collectors.groupingBy(GdDetail::getStation)
));
groupedGdDetailMap.forEach((code, stationMap) -> {
stationMap.forEach((station, gdDetails) -> {
gdDetails.forEach(gdDetail -> {
System.out.println("Code: " + code + ", Station: " + station + ", GdDetail: " + gdDetail);
});
});
});
}
private static final int MAX_TASK_COUNT = 4;
private static final long TIMEOUT_MS = 600000; // 10分钟以毫秒为单位
private long lastTaskTime = System.currentTimeMillis();
private List<Integer> taskQueue = new ArrayList<>(MAX_TASK_COUNT);
void aa() {
List<String> list = new ArrayList<>();
list.add("物料库存不足,请先补充库存!");
list.add("数量已分配!");
@ -35,14 +97,6 @@ public class EladminSystemApplicationTests {
} else {
System.out.println("集合中不存在分配成功的信息!");
}
}
private static final int MAX_TASK_COUNT = 4;
private static final long TIMEOUT_MS = 600000; // 10分钟以毫秒为单位
private long lastTaskTime = System.currentTimeMillis();
private List<Integer> taskQueue = new ArrayList<>(MAX_TASK_COUNT);
void aa() {
CompletableFuture<Void> asnDetailFuture = CompletableFuture.runAsync(() -> {
System.out.println("新增asnDetail");
@ -130,69 +184,7 @@ public class EladminSystemApplicationTests {
double ckdQty=Math.ceil(xTaoQty/taoQty);//生成出库单数量
System.out.println(ckdQty);*/
GdDetail gdDetail = new GdDetail();
gdDetail.setBigItem(null);
gdDetail.setOrderType("DP");
GdDetail gdDetail2 = new GdDetail();
BigItem bigItem2 = new BigItem();
bigItem2.setCode("CT_001");
gdDetail2.setBigItem(bigItem2);
gdDetail2.setOrderType("CP");
gdDetail2.setBigItemQty(1d);
GdDetail gdDetail3 = new GdDetail();
BigItem bigItem3 = new BigItem();
bigItem3.setCode("CT_001");
gdDetail3.setBigItem(bigItem3);
gdDetail3.setOrderType("CP");
gdDetail3.setBigItemQty(2d);
GdDetail gdDetail4 = new GdDetail();
BigItem bigItem4 = new BigItem();
bigItem4.setCode("CT_002");
gdDetail4.setBigItem(bigItem4);
gdDetail4.setOrderType("CP");
gdDetail4.setBigItemQty(3d);
GdDetail gdDetail5 = new GdDetail();
BigItem bigItem5 = new BigItem();
bigItem5.setCode("CT_002");
gdDetail5.setBigItem(bigItem5);
gdDetail5.setOrderType("CP");
gdDetail5.setBigItemQty(4d);
List<GdDetail> list = new ArrayList<>();
list.add(gdDetail);
list.add(gdDetail2);
list.add(gdDetail3);
list.add(gdDetail4);
list.add(gdDetail5);
for (GdDetail gd : list) {
System.out.println("总集合:" + gd);
}
List<GdDetail> cpList = list.stream()
.filter(gd -> "CP".equals(gd.getOrderType()))
.collect(Collectors.toList());
List<GdDetail> dpList = list.stream()
.filter(gd -> "DP".equals(gd.getOrderType()))
.collect(Collectors.toList());
for (GdDetail gd : cpList) {
System.out.println("成品集合:" + gd);
}
for (GdDetail gd : dpList) {
System.out.println("单品集合:" + gd);
}
Map<String, List<GdDetail>> groupedByCode = cpList.stream()
.collect(Collectors.groupingBy(gd -> gd.getBigItem().getCode()));
groupedByCode.forEach((code, details) -> {
System.out.println("Code: " + code);
details.forEach(System.out::println);
});
}
@Test