no message

main
暴炳林 2024-06-07 09:44:49 +08:00
parent c96bf84bf0
commit 6884b7b96a
23 changed files with 1158 additions and 3 deletions

View File

@ -20,4 +20,6 @@ public class Yclbl {
String createTime;
@ApiModelProperty(value ="总成明细",required = true)
Set<ZcData> blzc;
@ApiModelProperty(value ="单品明细",required = true)
Set<ItemDate> blzcmx;
}

View File

@ -18,6 +18,9 @@ package com.youchain.basicdata.repository;
import com.youchain.basicdata.domain.Item;
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
@ -25,4 +28,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @date 2023-08-16
**/
public interface ItemRepository extends JpaRepository<Item, Long>, JpaSpecificationExecutor<Item> {
@Query(value = "SELECT i FROM Item i WHERE i.code = ?1 and i.name=?2", nativeQuery = false)
List<Item> findRepeat(String code, String name);
}

View File

@ -0,0 +1,85 @@
/*
* 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 = "`create_by`")
@ApiModelProperty(value = "创建人")
private String createBy;
@Column(name = "`update_by`")
@ApiModelProperty(value = "修改人")
private String updateBy;
@Column(name = "`create_time`")
@ApiModelProperty(value = "创建时间")
private Timestamp createTime;
@Column(name = "`update_time`")
@ApiModelProperty(value = "修改时间")
private Timestamp updateTime;
@Column(name = "`code`")
@ApiModelProperty(value = "工单编号")
private String code;
@Column(name = "`name`")
@ApiModelProperty(value = "任务编号")
private String name;
@Column(name = "`status`")
@ApiModelProperty(value = "工单状态")
private String status;
@Column(name = "`station`")
@ApiModelProperty(value = "需求工位")
private String station;
@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

@ -0,0 +1,88 @@
/*
* 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 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_detail")
public class GdDetail extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "ID")
private Long id;
@Column(name = "`create_by`")
@ApiModelProperty(value = "创建人")
private String createBy;
@Column(name = "`update_by`")
@ApiModelProperty(value = "修改人")
private String updateBy;
@Column(name = "`create_time`")
@ApiModelProperty(value = "创建时间")
private Timestamp createTime;
@Column(name = "`update_time`")
@ApiModelProperty(value = "修改时间")
private Timestamp updateTime;
@Column(name = "`line_no`")
@ApiModelProperty(value = "行号")
private Long lineNo;
@Column(name = "`item_id`")
@ApiModelProperty(value = "关联物料")
private Long itemId;
@Column(name = "`item_qty`")
@ApiModelProperty(value = "订单数量")
private Long itemQty;
@Column(name = "`big_item_id`")
@ApiModelProperty(value = "总成代码")
private Long bigItemId;
@Column(name = "`big_item_qty`")
@ApiModelProperty(value = "总成套数")
private Long bigItemQty;
@Column(name = "`order_type`")
@ApiModelProperty(value = "单据类型")
private Long orderType;
public void copy(GdDetail source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,28 @@
/*
* 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.GdDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2024-06-06
**/
public interface GdDetailRepository extends JpaRepository<GdDetail, Long>, JpaSpecificationExecutor<GdDetail> {
}

View File

@ -0,0 +1,34 @@
/*
* 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;
/**
* @website https://eladmin.vip
* @author huojin
* @date 2024-06-06
**/
public interface GdRepository extends JpaRepository<Gd, Long>, JpaSpecificationExecutor<Gd> {
/** 查询重复数据*/
@Query(value = "SELECT g FROM Gd g WHERE g.code=?1 and g.name=?2 and g.station=?3 ", nativeQuery = false)
List<Gd> findRepeat(String code, String name, String station);
}

View File

@ -0,0 +1,87 @@
/*
* 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;
/**
* @website https://eladmin.vip
* @author huojin
* @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
@Log("查询gd")
@ApiOperation("查询gd")
@PreAuthorize("@el.check('gd:list')")
public ResponseEntity<Object> queryGd(GdQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(gdService.queryAll(criteria,pageable),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

@ -0,0 +1,87 @@
/*
* 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
@Log("查询gdDetail")
@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

@ -3,8 +3,17 @@ package com.youchain.businessdata.rest;
import com.youchain.RequestData.*;
import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.repository.ItemRepository;
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.dto.TaskQueryCriteria;
import com.youchain.exception.BadRequestException;
import com.youchain.exception.handler.ApiResult;
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;
@ -15,21 +24,46 @@ 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;
@RestController
@RequiredArgsConstructor
@Api(tags = "mes接口管理")
@RequestMapping("/api/mes")
@Slf4j
public class MesController {
private final GdService gdService;
private final ItemRepository itemRepository;
@PostMapping("/yclbl")
@Log("mes-原材料备料")
@ApiOperation("mes-原材料备料")
@AnonymousAccess
public ResponseEntity<Object> yclbl(@Validated @RequestBody Yclbl yclbl){
log.info(ApiResult.result(200,"成功",null).toString());
return new ResponseEntity<>(HttpStatus.OK);
/* 添加工单单头*/
Gd gd = gdService.save(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) {
*//* 验证成套 物料*//*
Item bigItem=verifiedBigItem(zcData.getCompleteCode(),zcData.getCompleteName());
Set<ItemDate> itemDates=zcData.getBlzcmx();
for (ItemDate itemDate : itemDates) {
*//* 验证单品 物料*//*
Item item=verifiedItem(itemDate.getItemCode(),itemDate.getItemName());
*//* 添加工单明细*//*
// GdDetail gdDetail = gdDetailService.save(gd.getId(),yc(),yclbl.getStation());
}
}*/
}else if (yclbl.getBlzcmx()!=null){
String orderType = BaseStatus.GD_TYPE_DP;
}
ApiResult apiResult=ApiResult.result(200,"成功",null);
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
}
@PostMapping("/sjBom")
@Log("mes-散件BOM同步")
@ApiOperation("mes-散件BOM同步")
@ -70,4 +104,22 @@ public class MesController {
return new ResponseEntity<>(ApiResult.result(200,"成功",null), HttpStatus.OK);
}
/** 验证成套物料*/
private Item verifiedBigItem(String completeCode, String completeName) {
List<Item> itemList = itemRepository.findRepeat(completeCode,completeName);
if (itemList.size()>0){
return itemList.get(0);
}else {
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护成套物料"+completeCode);
}
}
private Item verifiedItem(String itemCode, String itemName) {
List<Item> itemList = itemRepository.findRepeat(itemCode,itemName);
if (itemList.size()>0){
return itemList.get(0);
}else {
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护单品物料"+itemCode);
}
}
}

View File

@ -0,0 +1,83 @@
/*
* 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.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;
/**
* @website https://eladmin.vip
* @description
* @author huojin
* @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

@ -0,0 +1,85 @@
/*
* 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.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;
/**
* @website https://eladmin.vip
* @description
* @author huojin
* @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;
Gd save(String orderNo, String taskCode, String station);
}

View File

@ -0,0 +1,63 @@
/*
* 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 GdDetailDto implements Serializable {
/** ID */
private Long id;
/** 创建人 */
private String createBy;
/** 修改人 */
private String updateBy;
/** 创建时间 */
private Timestamp createTime;
/** 修改时间 */
private Timestamp updateTime;
/** 行号 */
private Long lineNo;
/** 关联物料 */
private Long itemId;
/** 订单数量 */
private Long itemQty;
/** 总成代码 */
private Long bigItemId;
/** 总成套数 */
private Long bigItemQty;
/** 单据类型 */
private Long orderType;
}

View File

@ -0,0 +1,33 @@
/*
* 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 GdDetailQueryCriteria{
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private Long itemId;
}

View File

@ -0,0 +1,57 @@
/*
* 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;
/** 需求工位 */
private String station;
}

View File

@ -0,0 +1,45 @@
/*
* 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;
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String station;
}

View File

@ -0,0 +1,113 @@
/*
* 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.utils.FileUtil;
import com.youchain.utils.PageUtil;
import com.youchain.utils.QueryHelp;
import com.youchain.utils.ValidationUtil;
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;
/**
* @website https://eladmin.vip
* @description
* @author huojin
* @date 2024-06-06
**/
@Service
@RequiredArgsConstructor
public class GdDetailServiceImpl implements GdDetailService {
private final GdDetailRepository gdDetailRepository;
private final GdDetailMapper gdDetailMapper;
@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

@ -0,0 +1,128 @@
/*
* 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.Gd;
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.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description
* @author huojin
* @date 2024-06-06
**/
@Service
@RequiredArgsConstructor
public class GdServiceImpl implements GdService {
private final GdRepository gdRepository;
private final DeptService deptService;
private final GdMapper gdMapper;
@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());
map.put("需求工位", gd.getStation());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
@Override
public Gd save(String orderNo, String taskCode, String station) {
List<Gd> gdList=gdRepository.findRepeat(orderNo,taskCode,station);
if (gdList.size()>0){
return gdList.get(0);
}else {
Gd gd=new Gd();
gd.setCode(orderNo);
gd.setName(taskCode);
gd.setStation(station);
gd.setStatus(BizStatus.OPEN);
gd.setDept(deptService.isDept());
gdRepository.save(gd);
return gd;
}
}
}

View File

@ -0,0 +1,32 @@
/*
* 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

@ -0,0 +1,32 @@
/*
* 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

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

View File

@ -49,7 +49,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
@CacheConfig(cacheNames = "dept")
public class DeptServiceImpl implements DeptService {
private final RedisObjectUtils redisObjectUtils;
private final DeptRepository deptRepository;
private final DeptMapper deptMapper;
private final UserRepository userRepository;
@ -246,6 +246,12 @@ public class DeptServiceImpl implements DeptService {
}
}
@Override
public Dept isDept() {
Dept dept = redisObjectUtils.getObjectFromCache("dept", () -> deptMapper.toEntity(findById(7L)), "系统无此仓库!");
return dept;
}
private void updateSubCnt(Long deptId){
if(deptId != null){
int count = deptRepository.countByPid(deptId);

View File

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

View File

@ -1,8 +1,12 @@
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