no message

main
HUOJIN\92525 2024-06-24 15:58:49 +08:00
parent 7a418eda87
commit 0bc5829e0a
30 changed files with 729 additions and 310 deletions

View File

@ -48,7 +48,7 @@ import org.springframework.web.bind.annotation.RestController;
@Api(hidden = true)
@SpringBootApplication
@EnableTransactionManagement
@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
@EnableAutoConfiguration(exclude = {MongoAutoConfiguration.class})
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
@Slf4j
public class AppRun {
@ -60,9 +60,7 @@ public class AppRun {
springApplication.addListeners(new ApplicationPidFileWriter());
springApplication.addListeners(new MyApiDictListener());
springApplication.run(args);
log.error(JSONUtil.toJsonStr(LicenseValidate.getDeviceInfo()));
log.info(JSONUtil.toJsonStr(LicenseValidate.getDeviceInfo()));
}
@Bean

View File

@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
import java.util.List;
/**
*
* @description: ApplicationListener
* @copyright: @Copyright (c) 2022
* @company: Aiocloud
@ -27,22 +26,18 @@ import java.util.List;
@Slf4j
public class MyApiDictListener implements ApplicationListener<ContextRefreshedEvent> {
public static boolean isCanRun=true;
public static boolean isCanRun = true;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
// 在这里处理特定的事件逻辑
if (event.getApplicationContext().getParent() == null) {
if(isCanRun){
isCanRun=false;
System.out.println("收到应用程序事件:" + event.toString());
System.out.println("收到应用程序事件2" + event.toString());
ApiDictQueryCriteria dict=new ApiDictQueryCriteria();
if (isCanRun) {
isCanRun = false;
ApiDictQueryCriteria dict = new ApiDictQueryCriteria();
ApiDictServiceImpl apiDictServiceImpl = SpringContextHolder.getBean(ApiDictServiceImpl.class);
// 在这里写入加载数据的逻辑
apiDictServiceImpl.queryAllToSave();
apiDictServiceImpl.queryAllToSave();
}
// 确保只启动一次
// 在这里编写你的逻辑代码

View File

@ -46,15 +46,9 @@ public class PackageCheck extends BaseEntity implements Serializable {
@Column(name = "`code`", unique = true, nullable = false)
@NotBlank
@ApiModelProperty(value = "成套代码")
@ApiModelProperty(value = "代码")
private String code;
@OneToOne
@JoinColumn(name = "`item_id`", nullable = false)
@NotNull
@ApiModelProperty(value = "物料")
private Item item;
@OneToOne
@JoinColumn(name = "dept_id")
@ApiModelProperty(value = "仓库")

View File

@ -1,34 +1,37 @@
/*
* 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.basicdata.repository;
import com.youchain.basicdata.domain.PackageCheck;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2024-06-13
**/
* @author huojin
* @website https://eladmin.vip
* @date 2024-06-13
**/
public interface PackageCheckRepository extends JpaRepository<PackageCheck, Long>, JpaSpecificationExecutor<PackageCheck> {
/**
* Code
* @param code /
* @return /
*/
* Code
*
* @param code /
* @return /
*/
@Query(" from PackageCheck p where p.code = ?1")
PackageCheck findByCode(String code);
}
}

View File

@ -59,7 +59,7 @@ public class BigItemController {
return new ResponseEntity<>(bigItemService.queryAll(criteria, pageable), HttpStatus.OK);
}
@GetMapping("/All")
@GetMapping("/queryAllBigItem")
@ApiOperation("查询所有bigitem")
public ResponseEntity<Object> queryAllBigItem(BigItemQueryCriteria criteria) {
return new ResponseEntity<>(bigItemService.queryAll(criteria), HttpStatus.OK);

View File

@ -41,15 +41,10 @@ public class PackageCheckDto implements Serializable {
private Long id;
/**
*
*
*/
private String code;
/**
*
*/
private ItemDto item;
/**
*
*/

View File

@ -34,9 +34,4 @@ public class PackageCheckQueryCriteria {
@Query(type = Query.Type.INNER_LIKE)
private String code;
/**
*
*/
@Query(propName = "code", joinName = "item")
private String itemCode;
}

View File

@ -98,8 +98,7 @@ public class PackageCheckServiceImpl implements PackageCheckService {
List<Map<String, Object>> list = new ArrayList<>();
for (PackageCheckDto packageCheck : all) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("成套代码", packageCheck.getCode());
map.put("物料", packageCheck.getItem().getCode());
map.put("代码", packageCheck.getCode());
map.put("套数", packageCheck.getQuantity());
map.put("创建人", packageCheck.getCreateBy());
map.put("修改人", packageCheck.getUpdateBy());

View File

@ -59,6 +59,7 @@ public class Gd extends BaseEntity implements Serializable {
@Column(name = "`station`",nullable = false)
@ApiModelProperty(value = "需求工位")
private String station;
@OneToOne
@JoinColumn(name = "`dept_id`",nullable = false)
@ApiModelProperty(value = "仓库")

View File

@ -18,27 +18,25 @@ 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.basicdata.domain.Point;
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;
/**
* @author huojin
* @website https://eladmin.vip
* @description /
* @author huojin
* @date 2024-06-06
**/
@Entity
@Data
@Table(name="data_gd_detail")
public class GdDetail extends BaseEntity implements Serializable {
@Table(name = "data_gd_detail")
public class GdDetail extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ -47,7 +45,7 @@ public class GdDetail extends BaseEntity implements Serializable {
private Long id;
@OneToOne
@JoinColumn(name = "`gd_id`",nullable = false)
@JoinColumn(name = "`gd_id`", nullable = false)
@ApiModelProperty(value = "工单")
private Gd gd;
@ -56,35 +54,37 @@ public class GdDetail extends BaseEntity implements Serializable {
private int lineNo;
@OneToOne
@JoinColumn(name = "`item_id`",nullable = false)
@JoinColumn(name = "`item_id`", nullable = false)
@ApiModelProperty(value = "单品物料")
private Item item;
@Column(name = "`item_qty`")
@ApiModelProperty(value = "单品数量")
private Double itemQty=0d;
private Double itemQty = 0d;
@Column(name = "`order_qty`")
@ApiModelProperty(value = "未拆分数量")
private Double orderQty=0d;
private Double orderQty = 0d;
@OneToOne
@JoinColumn(name = "`big_item_id`",nullable = false)
@JoinColumn(name = "`big_item_id`")
@ApiModelProperty(value = "成套物料")
private BigItem bigItem;
@Column(name = "`big_item_qty`")
@ApiModelProperty(value = "总成套数")
private Double bigItemQty=0d;
private Double bigItemQty = 0d;
@Column(name = "`order_type`")
@ApiModelProperty(value = "单据类型")
private String orderType;
@OneToOne
@JoinColumn(name = "`dept_id`",nullable = false)
@JoinColumn(name = "`dept_id`", nullable = false)
@ApiModelProperty(value = "仓库")
private Dept dept;
public void copy(GdDetail source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
public void copy(GdDetail source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -44,38 +44,51 @@ public class Pick extends BaseEntity implements Serializable {
@ApiModelProperty(value = "ID")
private Long id;
@Column(name = "`line_no`")
@ApiModelProperty(value = "序号")
private int lineNo;
@Column(name = "`code`",nullable = false)
@ApiModelProperty(value = "出库单号")
private String code;
@Column(name = "`gd_code`",nullable = false)
@ApiModelProperty(value = "工单号")
private String gdCode;
@Column(name = "`station`",nullable = false)
@ApiModelProperty(value = "需求工位")
private String station;
@Column(name = "`cp_code_or_dp_code`",nullable = false)
@ApiModelProperty(value = "成品代码或单品代码")
private String cpCodeOrDpCode;
@Column(name = "`status`")
@ApiModelProperty(value = "状态")
private String status;
@OneToOne
@JoinColumn(name = "`point_id`")
@ApiModelProperty(value = "备料点位")
@NotNull
private Point point;
@Column(name = "`is_call`")
@ApiModelProperty(value = "是否叫料")
private Boolean isCall;
@Column(name = "`source_id`")
@ApiModelProperty(value = "来源ID")
private Long sourceId;
@OneToOne
@JoinColumn(name = "`dept_id`", nullable = false)
@NotNull
@ApiModelProperty(value = "仓库")
private Dept dept;
@Column(name = "`code`")
@ApiModelProperty(value = "出库单头")
private String code;
@Column(name = "`line_no`")
@ApiModelProperty(value = "序号")
private int lineNo;
@Column(name = "`status`")
@ApiModelProperty(value = "状态")
private String status;
@OneToOne
@JoinColumn(name = "`point_id`", nullable = false)
@ApiModelProperty(value = "备料点位")
@NotNull
private Point point;
@OneToOne
@JoinColumn(name = "`gd_detail_id`", nullable = false)
@NotNull
@ApiModelProperty(value = "关联工单明细")
private GdDetail gdDetail;
@Column(name = "`be_call`")
@ApiModelProperty(value = "是否叫料")
private Boolean beCall;
public void copy(Pick source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -58,7 +58,7 @@ public class PickDetail extends BaseEntity implements Serializable {
private Item item;
@Column(name = "`line_no`")
@ApiModelProperty(value = "封包系数")
@ApiModelProperty(value = "行号")
private int lineNo;
@Column(name = "`po`")

View File

@ -30,10 +30,10 @@ import java.util.List;
**/
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", nativeQuery = false)
" 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 = "SELECT g FROM GdDetail g WHERE g.gd.id=?1 and g.orderQty>0", nativeQuery = false)
@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 ", nativeQuery = false)
@Query(value = "SELECT g FROM GdDetail g WHERE g.bigItem.id=?1 ")
List<GdDetail> findByBigItem(Long bigItemId);
}
}

View File

@ -28,7 +28,7 @@ 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.gdDetail.id=?1 and p.lineNo=?2")
@Query(value = "SELECT p FROM Pick p WHERE p.id=?1 and p.lineNo=?2")
List<Pick> findRepeat(long gdDetailId, int no);
@Query(value = "SELECT p FROM Pick p WHERE p.status=?1 ")

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.rest;
import com.youchain.annotation.Log;
@ -27,14 +27,15 @@ 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
**/
* @author huojin
* @website https://eladmin.vip
* @date 2024-06-06
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "gd管理")
@ -52,26 +53,32 @@ public class GdController {
}
@GetMapping
@Log("查询gd")
@ApiOperation("查询gd")
@ApiOperation("查询工单")
@PreAuthorize("@el.check('gd:list')")
public ResponseEntity<Object> queryGd(GdQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(gdService.queryAll(criteria,pageable),HttpStatus.OK);
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);
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){
public ResponseEntity<Object> updateGd(@Validated @RequestBody Gd resources) {
gdService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@ -84,4 +91,4 @@ public class GdController {
gdService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}
}

View File

@ -9,31 +9,21 @@ import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.repository.BigBomRepository;
import com.youchain.basicdata.repository.BigItemRepository;
import com.youchain.basicdata.repository.ItemRepository;
import com.youchain.basicdata.service.BigBomService;
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;
import com.youchain.modules.system.service.DeptService;
import com.youchain.utils.BaseStatus;
import com.youchain.utils.BizStatus;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
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;
@ -44,7 +34,6 @@ import static org.springframework.http.HttpStatus.OK;
@Slf4j
public class MesController {
private final GdService gdService;
private final GdDetailService gdDetailService;
private final DeptService deptService;
private final ItemRepository itemRepository;
private final BigBomRepository bigBomRepository;
@ -56,21 +45,29 @@ public class MesController {
@ApiOperation("mes-原材料备料")
@AnonymousAccess
public ResponseEntity<Object> yclbl(@Validated @RequestBody Yclbl yclbl) {
/* 添加工单单头*/
try {
gdService.materialBL(yclbl);
return successResponse("备料成功!");
}catch (Exception e){
return badResponse("备料失败:"+e.getMessage());
}
/* *//* 添加工单单头*//*
Gd gd = gdService.createGd(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());
if (yclbl.getBlzc() != null) {
String orderType = BaseStatus.GD_TYPE_CT;
Set<ZcData> blzc = yclbl.getBlzc();
for (ZcData zcData : blzc) {
/* 验证成套 物料*/
*//* 验证成套 物料*//*
BigItem bigItem = verifiedBigItem(zcData.getCompleteCode());
Set<ItemDate> itemDates = zcData.getBlzcmx();
for (ItemDate itemDate : itemDates) {
/* 验证单品 物料*/
*//* 验证单品 物料*//*
Item item = verifiedItem(itemDate.getItemCode());
/* 验证BOM*/
*//* 验证BOM*//*
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());
}
}
@ -79,16 +76,16 @@ public class MesController {
String orderType = BaseStatus.GD_TYPE_DP;
Set<ItemDate> itemDateList = yclbl.getBlzcmx();
for (ItemDate itemDate : itemDateList) {
/* 验证单品物料*/
*//* 验证单品物料*//*
Item item = verifiedItem(itemDate.getItemCode());
/* 添加工单明细*/
*//* 添加工单明细*//*
GdDetail gdDetail = gdDetailService.save(itemDate.getLineNo(), gd, orderType, null, null, item, itemDate.getItemQty(), itemDate.getItemQty());
}
}
/* 生成 出库明细*/
*//* 生成 出库明细*//*
gdService.addPickDetail(gd);
ApiResult apiResult = ApiResult.result(200, "成功", null);
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));*/
}
@ -114,7 +111,7 @@ public class MesController {
pickService.itemCall(orderNo, itemCode, station, pointCode);
return successResponse("叫料成功!");
} catch (Exception e) {
return badResponse("叫料失败!");
return badResponse("叫料失败!"+e.getMessage());
}
}
@ -184,7 +181,7 @@ public class MesController {
bigBom.setBigItem(bigItem);
bigBom.setItem(item);
bigBom.setQuantity(itemQty);
bigBom.setDept(deptService.isDept());
bigBom.setDept(deptService.getDefaultDept());
bigBomRepository.save(bigBom);
return bigBom;
}

View File

@ -19,6 +19,7 @@ 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;
@ -117,4 +118,11 @@ public interface PickDetailService {
PickDetail createPickDetail(Item item,String po);
void save(Pick pick);
/**
*
* @param pick->
* @param gdDetails->
*/
void createPickDetail(Pick pick, List<GdDetail> gdDetails);
}

View File

@ -15,6 +15,8 @@
*/
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.businessdata.domain.Pick;
import com.youchain.businessdata.service.dto.PickDto;
@ -101,4 +103,12 @@ public interface PickService {
* @param pointCode->
*/
void itemCall(String gdNo,String itemCode,String station,String pointCode);
/**
*
* @param gd->
* @param lineNo->
* @param cpCodeOrpCode->
*/
Pick createPick(Gd gd, int lineNo, String cpCodeOrpCode);
}

View File

@ -1,33 +1,55 @@
/*
* 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.dto;
import lombok.Data;
import java.util.List;
import com.youchain.annotation.Query;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2024-06-06
**/
* @author huojin
* @website https://eladmin.vip
* @date 2024-06-06
**/
@Data
public class GdDetailQueryCriteria{
public class GdDetailQueryCriteria {
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private Long itemId;
}
/**
*
*/
@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;
}

View File

@ -1,70 +1,109 @@
/*
* 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.dto;
import com.youchain.basicdata.domain.Point;
import com.youchain.businessdata.domain.GdDetail;
import com.youchain.modules.system.service.dto.DeptDto;
import com.youchain.modules.system.domain.Dept;
import lombok.Data;
import java.sql.Timestamp;
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
**/
@Data
public class PickDto implements Serializable {
/** ID */
/**
* ID
*/
private Long id;
/** 创建人 */
private String createBy;
/**
*
*/
private int lineNo;
/** 修改人 */
private String updateBy;
/** 创建时间 */
private Timestamp createTime;
/** 修改时间 */
private Timestamp updateTime;
/** 仓库ID */
private Long deptId;
private DeptDto dept;
/** 出库单头 */
/**
*
*/
private String code;
/** 序号 */
private String lineNo;
/**
*
*/
private String gdCode;
/** 状态 */
/**
*
*/
private String station;
/**
*
*/
private String cpCodeOrDpCode;
/**
*
*/
private String status;
/** 关联工单明细 */
private Long gdDetailId;
private GdDetail gdDetail;
/** 关联备料点位 */
/**
*
*/
private Point point;
/** 是否叫料 */
private Boolean beCall;
/**
*
*/
private Boolean isCall;
/**
* ID
*/
private Long sourceId;
/**
*
*/
private Dept dept;
/**
*
*/
private String createBy;
/**
*
*/
private String updateBy;
/**
*
*/
private Timestamp createTime;
/**
*
*/
private Timestamp updateTime;
}

View File

@ -31,7 +31,4 @@ public class PickQueryCriteria{
@Query(type = Query.Type.INNER_LIKE)
private String code;
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String gdDetaiId;
}
}

View File

@ -132,9 +132,9 @@ public class GdDetailServiceImpl implements GdDetailService {
gdDetail.setOrderQty(orderQty);
gdDetail.setBigItem(bigItem);
gdDetail.setBigItemQty(completeQty);
gdDetail.setDept(deptService.isDept());
gdDetail.setDept(deptService.getDefaultDept());
gdDetail.setOrderType(orderType);
gdDetailRepository.save(gdDetail);
return gdDetail;
}
}
}

View File

@ -20,9 +20,11 @@ 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.domain.Point;
import com.youchain.basicdata.repository.BigItemRepository;
import com.youchain.basicdata.repository.ItemRepository;
import com.youchain.basicdata.repository.PackageCheckRepository;
import com.youchain.basicdata.repository.PointRepository;
import com.youchain.businessdata.domain.Gd;
import com.youchain.businessdata.domain.GdDetail;
@ -31,7 +33,7 @@ import com.youchain.businessdata.repository.GdDetailRepository;
import com.youchain.businessdata.repository.PickRepository;
import com.youchain.businessdata.service.PickDetailService;
import com.youchain.businessdata.service.PickService;
import com.youchain.exception.BadRequestException;
import com.youchain.modules.system.domain.Dept;
import com.youchain.modules.system.service.DeptService;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
@ -40,7 +42,6 @@ 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.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
@ -48,6 +49,9 @@ import org.springframework.data.domain.Pageable;
import java.util.*;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
/**
@ -71,6 +75,8 @@ public class GdServiceImpl implements GdService {
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) {
@ -139,7 +145,7 @@ public class GdServiceImpl implements GdService {
gd.setName(taskCode);
gd.setStation(station);
gd.setStatus(BizStatus.OPEN);
gd.setDept(deptService.isDept());
gd.setDept(deptService.getDefaultDept());
gdRepository.save(gd);
return gd;
}
@ -174,33 +180,168 @@ public class GdServiceImpl implements GdService {
}
}
/**
*
*
* @param yclbl ->
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void materialBL(Yclbl yclbl) {
/** 验证参数有效性 */
validateGd(yclbl);
validateGd(yclbl);//验证参数有效性
Gd gd = gdRepository.findByGdList(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());//查询备料工单是否存在
if (gd != null) {
throw new IllegalArgumentException(yclbl.getOrderNo() + "备料工单已存在!");
}
this.createGd(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());//创建备料工单
/** 验证工单是否存在 */
checkIfGdExists(yclbl);
//添加备料明细
if (!yclbl.getBlzc().isEmpty()) {
String orderType = BaseStatus.GD_TYPE_CT;
Set<ZcData> blzc = yclbl.getBlzc();
for (ZcData zcData : blzc) {
BigItem bigItem = validateBigItem(zcData.getCompleteCode());//验证成品是否存在
Set<ItemDate> itemDates = zcData.getBlzcmx();
for (ItemDate itemDate : itemDates) {
Item item = validateItem(itemDate.getItemCode());//验证单品是否存在
}
/** 创建工单 */
Gd gd = createGd(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());
}
}
/** 创建工单明细 */
List<GdDetail> gdDetailList = createGdDetailsCPAndDP(gd, yclbl);
/** 创建出库单和出库明细 */
createPickAndPickDetail(gd, gdDetailList);
}
/**
*
*
* @param yclbl ->
*/
private void checkIfGdExists(Yclbl yclbl) {
Gd gd = gdRepository.findByGdList(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());
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
);
});
})
.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
);
})
.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);
/** 批量保存工单明细 */
CompletableFuture<List<GdDetail>> future = CompletableFuture.supplyAsync(() -> {
batchCreateOrUpdate.batchCreate(gdDetailsCreate);
return gdDetailsCreate;
});
return future.join();// 返回结果
}
/**
*
*
* @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) {
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);
return gdDetail;
}
/**
*
*
* @param yclbl ->
*/
private void validateGd(Yclbl yclbl) {
if (StringUtils.isEmpty(yclbl.getOrderNo())) {
throw new IllegalArgumentException("工单号不能为空!");
@ -217,21 +358,101 @@ public class GdServiceImpl implements GdService {
if (!yclbl.getBlzc().isEmpty()) {
for (ZcData zcData : yclbl.getBlzc()) {
if (zcData.getBlzcmx().isEmpty()) {
throw new IllegalArgumentException("成品明细里面的单品明细不能为空!");
if (!StringUtils.isEmpty(zcData.getCompleteCode())) {
if (zcData.getCompleteQty() <= 0) {
throw new IllegalArgumentException("成品套数不能小于等于0!");
}
}
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!");
}
}
}
}
/**
*
*
* @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 createPickAndPickDetail(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()));
/** 根据工单明细生成出库单和出库单明细 */
groupedByCpCodeMap.forEach((code, gdDetails) -> {
PackageCheck packageCheck = validatePackageCheck(code);// 验证翻包套数是否存在
double xqTaoQty = gdDetails.get(0).getBigItemQty();//需求套数
double fbTaoQty = packageCheck.getQuantity();//翻包套数
double chkQty = Math.ceil(xqTaoQty / fbTaoQty);//生成出库单数量
for (int i = 0; i < chkQty; i++) {
Pick pick = pickService.createPick(gd, lineNo.getAndIncrement(), code);
pickDetailService.createPickDetail(pick, gdDetails);
}
});
/** 单品工单明细集合 */
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()));
/** 根据工单明细生成出库单和出库单明细 */
groupedByDpCodeMap.forEach((code, gdDetails) -> {
Pick pick = pickService.createPick(gd, lineNo.getAndIncrement(), code);
pickDetailService.createPickDetail(pick, gdDetails);
});
}
}

View File

@ -49,6 +49,7 @@ import org.springframework.data.domain.Pageable;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.servlet.http.HttpServletResponse;
@ -140,20 +141,20 @@ public class PickDetailServiceImpl implements PickDetailService {
@Override
@Transactional(rollbackFor = Exception.class)
public synchronized void allocate(long id, double quantity,String areaName) {
if (areaName==null){
areaName="大件存储区,小件存储区";
public synchronized void allocate(long id, double quantity, String areaName) {
if (areaName == null) {
areaName = "大件存储区,小件存储区";
}
PickDetailDto pickDetailDto = findById(id);
PickDetail pd = toEntity(pickDetailDto);//Dto转实体
ItemDto itemDto = pickDetailDto.getItem();
Item item = itemService.toEntity(itemDto);
Dept dept = item.getDept();//仓库
Pick pick=pd.getPick();
Pick pick = pd.getPick();
// Box box = boxRepository.getBoxByItem(item.getId());
Point endPoint = pick.getPoint();//目标点位
if (pd.getOrderQty() > pd.getAllocatedQty()) {
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(),areaName);
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaName);
if (Inventorys.size() > 0) {
double allocateQty = 0;
double unQty = quantity;//未分配数量
@ -180,12 +181,12 @@ public class PickDetailServiceImpl implements PickDetailService {
}
pickDetailRepository.save(pd);
/* 更新出库单状态*/
List<PickDetail> pickDetailList=pickDetailRepository.findByAllocate(pick.getId());
if (pickDetailList.size()<1){
List<PickDetail> pickDetailList = pickDetailRepository.findByAllocate(pick.getId());
if (pickDetailList.size() < 1) {
pick.setStatus(BizStatus.ALLOCATE);
pickRepository.save(pick);
}else {
if (pick.getStatus().equals(BizStatus.OPEN)){
} else {
if (pick.getStatus().equals(BizStatus.OPEN)) {
pick.setStatus(BizStatus.ASSIGN);
pickRepository.save(pick);
}
@ -215,8 +216,8 @@ public class PickDetailServiceImpl implements PickDetailService {
// task.setAgvTask(agvTask);
taskService.create(task);
}
}else {
throw new BadRequestException(HttpStatus.NOT_IMPLEMENTED, "库存不足:"+item.getCode());
} else {
throw new BadRequestException(HttpStatus.NOT_IMPLEMENTED, "库存不足:" + item.getCode());
}
} else {
throw new RuntimeException("已分配,请勿重复操作!");
@ -226,13 +227,13 @@ public class PickDetailServiceImpl implements PickDetailService {
@Override
@Transactional(rollbackFor = Exception.class)
public synchronized void allocateAll(long id, Point endPoint,String areaName) throws Exception {
public synchronized void allocateAll(long id, Point endPoint, String areaName) throws Exception {
PickDetailDto pickDetailDto = findById(id);
PickDetail pd = toEntity(pickDetailDto);//Dto转实体
ItemDto itemDto = pickDetailDto.getItem();
Item item = itemService.toEntity(itemDto);
Dept dept = item.getDept();//仓库
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(),areaName);
List<Inventory> Inventorys = inventoryService.queryInventory(item.getId(), areaName);
if (Inventorys.size() > 0) {
Inventory inv = Inventorys.get(0);
//库存冻结状态不允许出库
@ -288,7 +289,7 @@ public class PickDetailServiceImpl implements PickDetailService {
for (Task task : Tasks) {
//根据Taskz找到对应的库存
InventoryDto inventoryDto = inventoryService.findById(task.getInventory().getId());
Inventory inv=inventoryService.toEntity(inventoryDto);
Inventory inv = inventoryService.toEntity(inventoryDto);
inv.setQueuedQty(inv.getQueuedQty() - pd.getAllocatedQty());
inventoryService.update(inv);
@ -315,34 +316,34 @@ public class PickDetailServiceImpl implements PickDetailService {
return pickDetailMapper.toEntity(pickDetailDto);
}
public List<Object[]> queryOut(String type,String date){
String hql="";
if(type.equals("Day")){
hql="select sum(d.orderQty),sum(d.pickedQty) from PickDetail d " +
public List<Object[]> queryOut(String type, String date) {
String hql = "";
if (type.equals("Day")) {
hql = "select sum(d.orderQty),sum(d.pickedQty) from PickDetail d " +
" where DATE_FORMAT(d.createTime,'%Y-%m-%d')=DATE_FORMAT(now(),'%Y-%m-%d')";
}else if(type.equals("Month")){
hql="select sum(d.orderQty),sum(d.pickedQty) from PickDetail d " +
} else if (type.equals("Month")) {
hql = "select sum(d.orderQty),sum(d.pickedQty) from PickDetail d " +
" where DATE_FORMAT(d.createTime,'%Y-%m')=DATE_FORMAT(now(),'%Y-%m')";
}else if(type.equals("InOutDay")){
hql="select DATE_FORMAT(d.createTime,'%Y-%m-%d'),sum(d.pickedQty) from PickDetail d " +
" where DATE_FORMAT(d.createTime,'%Y-%m-%d')>='"+date+"' " +
} else if (type.equals("InOutDay")) {
hql = "select DATE_FORMAT(d.createTime,'%Y-%m-%d'),sum(d.pickedQty) from PickDetail d " +
" where DATE_FORMAT(d.createTime,'%Y-%m-%d')>='" + date + "' " +
" group by DATE_FORMAT(d.createTime,'%Y-%m-%d')";
}
Query query=entityMapper.createQuery(hql);
List<Object[]> ts=query.getResultList();
return ts;
Query query = entityMapper.createQuery(hql);
List<Object[]> ts = query.getResultList();
return ts;
}
@Override
public PickDetail createPickDetail(Item item,String po) {
PickDetail d= new PickDetail();
public PickDetail createPickDetail(Item item, String po) {
PickDetail d = new PickDetail();
d.setItem(item);
d.setLineNo(1);
d.setStatus(BizStatus.OPEN);
d.setOrderQty(item.getExtendD1());
d.setDept(item.getDept());
if(StringUtils.isEmpty(po)){
po= TimeNumberUtils.getCKCode();
if (StringUtils.isEmpty(po)) {
po = TimeNumberUtils.getCKCode();
}
d.setPo(po);
pickDetailRepository.save(d);
@ -352,37 +353,53 @@ public class PickDetailServiceImpl implements PickDetailService {
@Override
public void save(Pick pick) {
List<GdDetail> gdDetailList;
if (pick.getGdDetail().getBigItem()!=null) {
if (pick != null) {
/* 成套物料 */
gdDetailList = gdDetailRepository.findByBigItem(pick.getGdDetail().getBigItem().getId());
}else {
gdDetailList = gdDetailRepository.findByBigItem(pick.getId());
} else {
/* 单品物料*/
gdDetailList=new ArrayList<>();
gdDetailList.add(pick.getGdDetail());
gdDetailList = new ArrayList<>();
}
for (GdDetail gdDetail:gdDetailList){
int fb=1;//封包系数
PickDetail pickDetail=new PickDetail();
List<PickDetail> pickDetailList = pickDetailRepository.findRepeat(pick.getId(),gdDetail.getItem().getId());
if (pickDetailList.size()>0){
pickDetail=pickDetailList.get(0);
for (GdDetail gdDetail : gdDetailList) {
int fb = 1;//封包系数
PickDetail pickDetail = new PickDetail();
List<PickDetail> pickDetailList = pickDetailRepository.findRepeat(pick.getId(), gdDetail.getItem().getId());
if (pickDetailList.size() > 0) {
pickDetail = pickDetailList.get(0);
}
pickDetail.setDept(UserUtils.isDept);
pickDetail.setStatus(BizStatus.OPEN);
pickDetail.setPick(pick);
pickDetail.setItem(gdDetail.getItem());
if (gdDetail.getBigItem()==null){
if (gdDetail.getBigItem() == null) {
/*如果为单品物料 默认封包系数10*/
fb=10;
pickDetail.setOrderQty(1d*fb);
}else {
pickDetail.setOrderQty(gdDetail.getItemQty()*fb);
fb = 10;
pickDetail.setOrderQty(1d * fb);
} else {
pickDetail.setOrderQty(gdDetail.getItemQty() * fb);
}
pickDetail.setLineNo(fb);
pickDetailRepository.save(pickDetail);
/*更新待拆分数量*/
gdDetail.setOrderQty(gdDetail.getOrderQty()-pickDetail.getOrderQty());
gdDetail.setOrderQty(gdDetail.getOrderQty() - pickDetail.getOrderQty());
gdDetailRepository.save(gdDetail);
}
}
@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);
pickDetail.setOrderQty(gdDetail.getItemQty());
pickDetail.setSourceId(gdDetail.getId());
pickDetail.setDept(gdDetail.getDept());
pickDetailRepository.save(pickDetail);
}
}
}

View File

@ -15,8 +15,11 @@
*/
package com.youchain.businessdata.service.impl;
import com.youchain.basicdata.domain.Point;
import com.youchain.businessdata.domain.Gd;
import com.youchain.businessdata.domain.GdDetail;
import com.youchain.businessdata.domain.Pick;
import com.youchain.businessdata.domain.PickDetail;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
import com.youchain.businessdata.repository.PickRepository;
@ -35,6 +38,7 @@ import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author huojin
@ -114,7 +118,6 @@ public class PickServiceImpl implements PickService {
if (pickList.size() > 0) {
pick = pickList.get(0);
}
pick.setGdDetail(gdDetail);
pick.setLineNo(no);
pick.setStatus(BizStatus.OPEN);
pick.setCode(gdDetail.getGd().getName() + "_" + no);
@ -131,10 +134,10 @@ public class PickServiceImpl implements PickService {
if (pick == null) {
throw new IllegalArgumentException(gdNo + "工单未备料,叫料失败!");
}
if (pick.getBeCall()) {
if (pick.getIsCall()) {
throw new IllegalArgumentException(gdNo + "工单已叫料,请勿重复叫料!");
}
pick.setBeCall(true);
pick.setIsCall(true);
pickRepository.save(pick);
}
@ -145,10 +148,27 @@ public class PickServiceImpl implements PickService {
if (pick == null) {
throw new IllegalArgumentException(gdNo + "工单未备料,叫料失败!");
}
if (pick.getBeCall()) {
if (pick.getIsCall()) {
throw new IllegalArgumentException(gdNo + "工单已叫料,请勿重复叫料!");
}
pick.setBeCall(true);
pick.setIsCall(true);
pickRepository.save(pick);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Pick createPick(Gd gd, int lineNo, String cpCodeOrpCode) {
Pick pick = new Pick();
pick.setLineNo(lineNo);
pick.setCode(gd.getCode() + "_" + lineNo);
pick.setGdCode(gd.getCode());
pick.setStation(gd.getStation());
pick.setCpCodeOrDpCode(cpCodeOrpCode);
pick.setStatus(BizStatus.OPEN);
pick.setIsCall(false);
pick.setSourceId(gd.getId());
pick.setDept(gd.getDept());
pickRepository.save(pick);
return pick;
}
}

View File

@ -122,5 +122,5 @@ public interface DeptService {
*/
void verification(Set<DeptDto> deptDtos);
/** 获取默认仓库*/
Dept isDept();
}
Dept getDefaultDept();
}

View File

@ -247,7 +247,7 @@ public class DeptServiceImpl implements DeptService {
}
@Override
public Dept isDept() {
public Dept getDefaultDept() {
Dept dept = redisObjectUtils.getObjectFromCache("dept", () -> deptMapper.toEntity(findById(7L)), "系统无此仓库!");
return dept;
}

View File

@ -42,8 +42,8 @@ public class BaseStatus {
*/
public static String EMPTY = "EMPTY";
/** 工单类型 成*/
public static String GD_TYPE_CT = "成";
/** 工单类型 成*/
public static String GD_TYPE_CT = "成";
/** 工单类型 单品*/
public static String GD_TYPE_DP = "单品";
}

View File

@ -32,6 +32,10 @@ public class RedisObjectUtils {
object = getOrThrow(Optional.ofNullable(serviceSupplier.get()), errorMessage);
redisUtils.set(cacheKey, object);
}
if (object == null) {
object = getOrThrow(Optional.ofNullable(serviceSupplier.get()), errorMessage);
redisUtils.set(cacheKey, object);
}
return object;
}

View File

@ -1,12 +1,18 @@
package com.youchain;
import com.youchain.basicdata.domain.BigItem;
import com.youchain.businessdata.domain.AgvTask;
import com.youchain.businessdata.domain.GdDetail;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class EladminSystemApplicationTests {
@ -16,6 +22,13 @@ public class EladminSystemApplicationTests {
}
public static void main(String[] args) {
List<Integer> list1 = Arrays.asList();
List<Integer> list2 = Arrays.asList();
List<Integer> list3 = new ArrayList<>(list1);
list3.addAll(list2);
System.out.println(list3); // 输出: [1, 2, 3, 4, 5]
}
private static final int MAX_TASK_COUNT = 4;
@ -23,6 +36,77 @@ public class EladminSystemApplicationTests {
private long lastTaskTime = System.currentTimeMillis();
private List<Integer> taskQueue = new ArrayList<>(MAX_TASK_COUNT);
void aa(){
/*double taoQty=2;//基础套数
double xTaoQty=3;//需求套数
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
public void test(){
List<Integer> taskLists=new ArrayList<>();