Merge branch 'test' of https://git.will-way.cn/zgty/zt-qms into test

This commit is contained in:
2026-01-29 19:05:01 +08:00
22 changed files with 348 additions and 53 deletions

View File

@@ -1,5 +1,6 @@
package com.zt.plat.module.qms.resource.device.controller.admin; package com.zt.plat.module.qms.resource.device.controller.admin;
import com.alibaba.fastjson.JSONObject;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyPageReqVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyRespVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyRespVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplySaveReqVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplySaveReqVO;
@@ -66,6 +67,19 @@ public class DeviceApplyController extends AbstractFileUploadController implemen
return deviceApplyService.saveDeviceApply(createReqVO); return deviceApplyService.saveDeviceApply(createReqVO);
} }
@RequestMapping("/addDetail")
@Operation(summary = "增加明细")
public CommonResult<Boolean> addDetail(@RequestBody JSONObject param) {
return deviceApplyService.addDetail(param);
}
@RequestMapping("/removeDetail")
@Operation(summary = "删除明细")
public CommonResult<Boolean> removeDetail(@RequestBody JSONObject param) {
return deviceApplyService.removeDetail(param);
}
@PutMapping("/update") @PutMapping("/update")
@Operation(summary = "更新设备通用流程,验收、降级、停用、报废、还原、启用") @Operation(summary = "更新设备通用流程,验收、降级、停用、报废、还原、启用")
// @PreAuthorize("@ss.hasPermission('qms:device-apply:update')") // @PreAuthorize("@ss.hasPermission('qms:device-apply:update')")

View File

@@ -1,8 +1,7 @@
package com.zt.plat.module.qms.resource.device.controller.admin; package com.zt.plat.module.qms.resource.device.controller.admin;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailPageReqVO; import com.zt.plat.module.qms.resource.device.controller.vo.*;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailRespVO; import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceApplyDO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailSaveReqVO;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@@ -55,6 +54,13 @@ public class DeviceApplyDetailController extends AbstractFileUploadController im
@Resource @Resource
private DeviceApplyDetailService deviceApplyDetailService; private DeviceApplyDetailService deviceApplyDetailService;
@GetMapping("/list")
@Operation(summary = "获得设备通用流程分页")
public CommonResult<List<DeviceApplyDetailRespVO>> list(DeviceApplyDetailPageReqVO reqVO) {
List<DeviceApplyDetailDO> list = deviceApplyDetailService.selectList(reqVO);
return success(BeanUtils.toBean(list, DeviceApplyDetailRespVO.class));
}
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建设备通用流程明细") @Operation(summary = "创建设备通用流程明细")
@PreAuthorize("@ss.hasPermission('qms:device-apply-detail:create')") @PreAuthorize("@ss.hasPermission('qms:device-apply-detail:create')")

View File

@@ -55,14 +55,14 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建设备通用流程配置") @Operation(summary = "创建设备通用流程配置")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:create')") // @PreAuthorize("@ss.hasPermission('qms:device-config-flow:create')")
public CommonResult<DeviceConfigFlowRespVO> createDeviceConfigFlow(@Valid @RequestBody DeviceConfigFlowSaveReqVO createReqVO) { public CommonResult<DeviceConfigFlowRespVO> createDeviceConfigFlow(@Valid @RequestBody DeviceConfigFlowSaveReqVO createReqVO) {
return success(deviceConfigFlowService.createDeviceConfigFlow(createReqVO)); return success(deviceConfigFlowService.createDeviceConfigFlow(createReqVO));
} }
@PutMapping("/update") @PutMapping("/update")
@Operation(summary = "更新设备通用流程配置") @Operation(summary = "更新设备通用流程配置")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:update')") // @PreAuthorize("@ss.hasPermission('qms:device-config-flow:update')")
public CommonResult<Boolean> updateDeviceConfigFlow(@Valid @RequestBody DeviceConfigFlowSaveReqVO updateReqVO) { public CommonResult<Boolean> updateDeviceConfigFlow(@Valid @RequestBody DeviceConfigFlowSaveReqVO updateReqVO) {
deviceConfigFlowService.updateDeviceConfigFlow(updateReqVO); deviceConfigFlowService.updateDeviceConfigFlow(updateReqVO);
return success(true); return success(true);
@@ -71,7 +71,7 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@DeleteMapping("/delete") @DeleteMapping("/delete")
@Operation(summary = "删除设备通用流程配置") @Operation(summary = "删除设备通用流程配置")
@Parameter(name = "id", description = "编号", required = true) @Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:delete')") // @PreAuthorize("@ss.hasPermission('qms:device-config-flow:delete')")
public CommonResult<Boolean> deleteDeviceConfigFlow(@RequestParam("id") Long id) { public CommonResult<Boolean> deleteDeviceConfigFlow(@RequestParam("id") Long id) {
deviceConfigFlowService.deleteDeviceConfigFlow(id); deviceConfigFlowService.deleteDeviceConfigFlow(id);
return success(true); return success(true);
@@ -80,7 +80,7 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@DeleteMapping("/delete-list") @DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true) @Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除设备通用流程配置") @Operation(summary = "批量删除设备通用流程配置")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:delete')") // @PreAuthorize("@ss.hasPermission('qms:device-config-flow:delete')")
public CommonResult<Boolean> deleteDeviceConfigFlowList(@RequestBody BatchDeleteReqVO req) { public CommonResult<Boolean> deleteDeviceConfigFlowList(@RequestBody BatchDeleteReqVO req) {
deviceConfigFlowService.deleteDeviceConfigFlowListByIds(req.getIds()); deviceConfigFlowService.deleteDeviceConfigFlowListByIds(req.getIds());
return success(true); return success(true);
@@ -89,7 +89,7 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@GetMapping("/get") @GetMapping("/get")
@Operation(summary = "获得设备通用流程配置") @Operation(summary = "获得设备通用流程配置")
@Parameter(name = "id", description = "编号", required = true, example = "1024") @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:query')") // @PreAuthorize("@ss.hasPermission('qms:device-config-flow:query')")
public CommonResult<DeviceConfigFlowRespVO> getDeviceConfigFlow(@RequestParam("id") Long id) { public CommonResult<DeviceConfigFlowRespVO> getDeviceConfigFlow(@RequestParam("id") Long id) {
DeviceConfigFlowDO deviceConfigFlow = deviceConfigFlowService.getDeviceConfigFlow(id); DeviceConfigFlowDO deviceConfigFlow = deviceConfigFlowService.getDeviceConfigFlow(id);
return success(BeanUtils.toBean(deviceConfigFlow, DeviceConfigFlowRespVO.class)); return success(BeanUtils.toBean(deviceConfigFlow, DeviceConfigFlowRespVO.class));
@@ -104,7 +104,7 @@ public class DeviceConfigFlowController implements BusinessControllerMarker {
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出设备通用流程配置 Excel") @Operation(summary = "导出设备通用流程配置 Excel")
@PreAuthorize("@ss.hasPermission('qms:device-config-flow:export')") // @PreAuthorize("@ss.hasPermission('qms:device-config-flow:export')")
@ApiAccessLog(operateType = EXPORT) @ApiAccessLog(operateType = EXPORT)
public void exportDeviceConfigFlowExcel(@Valid DeviceConfigFlowPageReqVO pageReqVO, public void exportDeviceConfigFlowExcel(@Valid DeviceConfigFlowPageReqVO pageReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {

View File

@@ -35,4 +35,7 @@ public class DeviceApplyDetailPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
//扩展字段
@Schema(description = "设备id列表")
private List<Long> deviceInfoIdList;
} }

View File

@@ -7,6 +7,8 @@ import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceApplyDetailDO
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailPageReqVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailPageReqVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/** /**
* 设备通用流程明细 Mapper * 设备通用流程明细 Mapper
* *
@@ -27,4 +29,18 @@ public interface DeviceApplyDetailMapper extends BaseMapperX<DeviceApplyDetailDO
.orderByDesc(DeviceApplyDetailDO::getId)); .orderByDesc(DeviceApplyDetailDO::getId));
} }
default List<DeviceApplyDetailDO> selectList(DeviceApplyDetailPageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<DeviceApplyDetailDO>()
.eqIfPresent(DeviceApplyDetailDO::getApplyId, reqVO.getApplyId())
.eqIfPresent(DeviceApplyDetailDO::getDeviceInfomationId, reqVO.getDeviceInfomationId())
.inIfPresent(DeviceApplyDetailDO::getDeviceInfomationId, reqVO.getDeviceInfoIdList())
.eqIfPresent(DeviceApplyDetailDO::getDeviceBorrowDetailId, reqVO.getDeviceBorrowDetailId())
.eqIfPresent(DeviceApplyDetailDO::getFormData, reqVO.getFormData())
.eqIfPresent(DeviceApplyDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
.eqIfPresent(DeviceApplyDetailDO::getRemark, reqVO.getRemark())
.betweenIfPresent(DeviceApplyDetailDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(DeviceApplyDetailDO::getId));
}
} }

View File

@@ -16,6 +16,10 @@ import com.zt.plat.framework.common.pojo.PageResult;
*/ */
public interface DeviceApplyDetailService { public interface DeviceApplyDetailService {
List<DeviceApplyDetailDO> selectList(DeviceApplyDetailPageReqVO reqVO);
void insertBatch(List<DeviceApplyDetailDO> list);
/** /**
* 创建设备通用流程明细 * 创建设备通用流程明细
* *

View File

@@ -6,6 +6,7 @@ import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailRes
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailSaveReqVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailSaveReqVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.*; import java.util.*;
@@ -32,6 +33,17 @@ public class DeviceApplyDetailServiceImpl implements DeviceApplyDetailService {
@Resource @Resource
private DeviceApplyDetailMapper deviceApplyDetailMapper; private DeviceApplyDetailMapper deviceApplyDetailMapper;
@Override
public List<DeviceApplyDetailDO> selectList(DeviceApplyDetailPageReqVO reqVO) {
return deviceApplyDetailMapper.selectList(reqVO);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void insertBatch(List<DeviceApplyDetailDO> list) {
deviceApplyDetailMapper.insertBatch(list);
}
@Override @Override
public DeviceApplyDetailRespVO createDeviceApplyDetail(DeviceApplyDetailSaveReqVO createReqVO) { public DeviceApplyDetailRespVO createDeviceApplyDetail(DeviceApplyDetailSaveReqVO createReqVO) {
// 插入 // 插入

View File

@@ -2,6 +2,7 @@ package com.zt.plat.module.qms.resource.device.service;
import java.util.*; import java.util.*;
import com.alibaba.fastjson.JSONObject;
import com.zt.plat.framework.common.pojo.CommonResult; import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyPageReqVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyRespVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyRespVO;
@@ -28,6 +29,12 @@ public interface DeviceApplyService {
//创建临时数据 //创建临时数据
CommonResult<DeviceApplyRespVO> createTempData(@Valid DeviceApplySaveReqVO createReqVO); CommonResult<DeviceApplyRespVO> createTempData(@Valid DeviceApplySaveReqVO createReqVO);
//增加明细
CommonResult<Boolean> addDetail(JSONObject param);
//删除明细
CommonResult<Boolean> removeDetail(JSONObject param);
CommonResult<Boolean> saveDeviceApply(@Valid DeviceApplySaveReqVO updateReqVO); CommonResult<Boolean> saveDeviceApply(@Valid DeviceApplySaveReqVO updateReqVO);
/** /**

View File

@@ -13,10 +13,13 @@ import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO;
import com.zt.plat.module.qms.common.data.service.DataCollectionService; import com.zt.plat.module.qms.common.data.service.DataCollectionService;
import com.zt.plat.module.qms.common.data.service.DataTemplateService; import com.zt.plat.module.qms.common.data.service.DataTemplateService;
import com.zt.plat.module.qms.enums.QmsCommonConstant; import com.zt.plat.module.qms.enums.QmsCommonConstant;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyDetailPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyPageReqVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyRespVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplyRespVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplySaveReqVO; import com.zt.plat.module.qms.resource.device.controller.vo.DeviceApplySaveReqVO;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceApplyDetailDO;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceConfigFlowDO; import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceConfigFlowDO;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceInfomationDO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -27,6 +30,7 @@ import org.springframework.validation.annotation.Validated;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceApplyDO; import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceApplyDO;
import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.PageResult;
@@ -50,6 +54,8 @@ public class DeviceApplyServiceImpl implements DeviceApplyService {
@Resource private DeviceApplyMapper deviceApplyMapper; @Resource private DeviceApplyMapper deviceApplyMapper;
@Resource private DeviceConfigFlowService deviceConfigFlowService; @Resource private DeviceConfigFlowService deviceConfigFlowService;
@Resource private DeviceInfomationService deviceInfomationService;
@Resource private DeviceApplyDetailService deviceApplyDetailService;
@Resource private DataCollectionService dataCollectionService; @Resource private DataCollectionService dataCollectionService;
@Resource private DataTemplateService dataTemplateService; @Resource private DataTemplateService dataTemplateService;
@@ -96,6 +102,55 @@ public class DeviceApplyServiceImpl implements DeviceApplyService {
return CommonResult.success(BeanUtils.toBean(deviceApply, DeviceApplyRespVO.class)); return CommonResult.success(BeanUtils.toBean(deviceApply, DeviceApplyRespVO.class));
} }
//增加明细
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResult<Boolean> addDetail(JSONObject param) {
String deviceIds = param.getString("deviceIds");
String applyId = param.getString("applyId");
if(ObjectUtils.isEmpty(deviceIds))
return CommonResult.error(DEVICE_APPLY_NOT_EXISTS.getCode(), "请选择设备");
if(ObjectUtils.isEmpty(applyId))
return CommonResult.error(DEVICE_APPLY_NOT_EXISTS.getCode(), "缺少申请id参数请刷新后重试");
List<DeviceInfomationDO> deviceList = deviceInfomationService.getListByIds(deviceIds);
if(deviceList.isEmpty())
return CommonResult.error(DEVICE_APPLY_NOT_EXISTS.getCode(), "设备不存在");
List<Long> deviceInfoIdList = new ArrayList<>();
for (DeviceInfomationDO device : deviceList) {
deviceInfoIdList.add(device.getId());
}
//查询已有明细,避免重复添加
DeviceApplyDetailPageReqVO detailPageReqVO = new DeviceApplyDetailPageReqVO();
detailPageReqVO.setApplyId(Long.valueOf(applyId));
detailPageReqVO.setDeviceInfoIdList(deviceInfoIdList);
List<DeviceApplyDetailDO> detailList = deviceApplyDetailService.selectList(detailPageReqVO);
//过滤已添加设备
List<DeviceInfomationDO> addDeviceList = deviceList.stream().filter(device ->
detailList.stream().noneMatch(detail -> detail.getDeviceInfomationId().equals(device.getId()))).toList();
List<DeviceApplyDetailDO> detailDOList = new ArrayList<>();
for (DeviceInfomationDO device : addDeviceList) {
DeviceApplyDetailDO detail = new DeviceApplyDetailDO();
detail.setApplyId(Long.valueOf(applyId));
detail.setDeviceInfomationId(device.getId());
detailDOList.add(detail);
}
deviceApplyDetailService.insertBatch(detailDOList);
return CommonResult.success(true);
}
@Override
public CommonResult<Boolean> removeDetail(JSONObject param) {
String detailIds = param.getString("detailIds");
if(ObjectUtils.isEmpty(detailIds))
return CommonResult.error(DEVICE_APPLY_NOT_EXISTS.getCode(), "请选择需要删除的明细数据");
List<Long> detailIdList = Arrays.stream(detailIds.split(",")).map(Long::valueOf).toList();
deviceApplyDetailService.deleteDeviceApplyDetailListByIds(detailIdList);
return CommonResult.success(true);
}
//保存 //保存
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)

View File

@@ -27,6 +27,7 @@ public interface DeviceInfomationService {
DeviceInfomationDO getByCode(String code); DeviceInfomationDO getByCode(String code);
List<DeviceInfomationDO> getListByProductIdList(List<Long> productIds); List<DeviceInfomationDO> getListByProductIdList(List<Long> productIds);
List<DeviceInfomationDO> getListByIds(String ids);
List<Long> getIdListByProductIdList(List<Long> productIds); List<Long> getIdListByProductIdList(List<Long> productIds);
@@ -47,11 +48,7 @@ public interface DeviceInfomationService {
// CommonResult<Boolean> updateDeviceAcceptFlag(Long deviceId, String acceptFlag); // CommonResult<Boolean> updateDeviceAcceptFlag(Long deviceId, String acceptFlag);
// CommonResult<Boolean> updateDeviceLendFlag(Long deviceId, Integer lendFlag); // CommonResult<Boolean> updateDeviceLendFlag(Long deviceId, Integer lendFlag);
void updateBatch(List<DeviceInfomationDO> updateList);
/** /**
* 创建设备-设备信息 * 创建设备-设备信息

View File

@@ -25,9 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
@@ -201,6 +199,11 @@ public class DeviceInfomationServiceImpl implements DeviceInfomationService {
deviceInfomationMapper.update(updateWrapper); deviceInfomationMapper.update(updateWrapper);
} }
@Override
public void updateBatch(List<DeviceInfomationDO> updateList) {
deviceInfomationMapper.updateBatch(updateList);
}
@Override @Override
public DeviceInfomationDO getByCode(String code) { public DeviceInfomationDO getByCode(String code) {
LambdaQueryWrapper<DeviceInfomationDO> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DeviceInfomationDO> query = new LambdaQueryWrapper<>();
@@ -215,6 +218,14 @@ public class DeviceInfomationServiceImpl implements DeviceInfomationService {
return deviceInfomationMapper.selectList(query); return deviceInfomationMapper.selectList(query);
} }
@Override
public List<DeviceInfomationDO> getListByIds(String ids) {
if(ObjectUtils.isEmpty(ids))
return Collections.emptyList();
List< Long> idsList = Arrays.asList(ids.split(",")).stream().map(Long::parseLong).toList();
return deviceInfomationMapper.selectByIds(idsList);
}
@Override @Override
public List<Long> getIdListByProductIdList(List<Long> productIds) { public List<Long> getIdListByProductIdList(List<Long> productIds) {
List<DeviceInfomationDO> list = getListByProductIdList(productIds); List<DeviceInfomationDO> list = getListByProductIdList(productIds);

View File

@@ -93,8 +93,9 @@ public class MaterialBatchController implements BusinessControllerMarker {
@Operation(summary = "获得物料批次分页") @Operation(summary = "获得物料批次分页")
// @PreAuthorize("@ss.hasPermission('qms:material-batch:query')") // @PreAuthorize("@ss.hasPermission('qms:material-batch:query')")
public CommonResult<PageResult<MaterialBatchRespVO>> getMaterialBatchPage(@Valid MaterialBatchPageReqVO pageReqVO) { public CommonResult<PageResult<MaterialBatchRespVO>> getMaterialBatchPage(@Valid MaterialBatchPageReqVO pageReqVO) {
PageResult<MaterialBatchDO> pageResult = materialBatchService.getMaterialBatchPage(pageReqVO); PageResult<MaterialBatchRespVO> pageResult = materialBatchService.getMaterialBatchPageWithPdtInfo(pageReqVO);
return success(BeanUtils.toBean(pageResult, MaterialBatchRespVO.class)); // return success(BeanUtils.toBean(pageResult, MaterialBatchRespVO.class));
return success(pageResult);
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@@ -117,6 +118,14 @@ public class MaterialBatchController implements BusinessControllerMarker {
return success(materialBatchService.assignMaterialBatchGongduan(createReqVOs)); return success(materialBatchService.assignMaterialBatchGongduan(createReqVOs));
} }
@PutMapping("/submit")
@Operation(summary = "提交物料批次")
@Parameter(name = "id", required = true)
public CommonResult<Boolean> submitMaterialBatch(@RequestParam("id") Long id) {
return success(materialBatchService.submitMaterialBatch(id));
}
@GetMapping("gongduan-page") @GetMapping("gongduan-page")
@Operation(summary = "获取工段列表") @Operation(summary = "获取工段列表")
@Parameter(name = "id", description = "物料批次 id", required = true, example = "1054") @Parameter(name = "id", description = "物料批次 id", required = true, example = "1054")

View File

@@ -19,6 +19,9 @@ public class MaterialBatchPageReqVO extends PageParam {
@Schema(description = "物料大类id", example = "9381") @Schema(description = "物料大类id", example = "9381")
private Long productId; private Long productId;
@Schema(description = "是否需要组装 children")
private Boolean children = false;
@Schema(description = "批次编号") @Schema(description = "批次编号")
private String batchNo; private String batchNo;

View File

@@ -7,6 +7,8 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import com.alibaba.excel.annotation.*; import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 物料批次 Response VO") @Schema(description = "管理后台 - 物料批次 Response VO")
@@ -26,6 +28,18 @@ public class MaterialBatchRespVO {
@ExcelProperty("物料大类id") @ExcelProperty("物料大类id")
private Long productId; private Long productId;
@Schema(description = "物料大类名称")
@ExcelProperty("物料大类名称")
private String productName;
@Schema(description = "物料大类编码")
@ExcelProperty("物料大类编码")
private String productCode;
@Schema(description = "物料大类型号")
@ExcelProperty("物料大类型号")
private String productModelNo;
@Schema(description = "批次编号") @Schema(description = "批次编号")
@ExcelProperty("批次编号") @ExcelProperty("批次编号")
private String batchNo; private String batchNo;
@@ -44,11 +58,11 @@ public class MaterialBatchRespVO {
@Schema(description = "生产日期") @Schema(description = "生产日期")
@ExcelProperty("生产日期") @ExcelProperty("生产日期")
private LocalDate manufacturerDate; private LocalDateTime manufacturerDate;
@Schema(description = "到期日期") @Schema(description = "到期日期")
@ExcelProperty("到期日期") @ExcelProperty("到期日期")
private LocalDate dueDate; private LocalDateTime dueDate;
@Schema(description = "分配部门id") @Schema(description = "分配部门id")
@ExcelProperty("分配部门id") @ExcelProperty("分配部门id")
@@ -90,4 +104,7 @@ public class MaterialBatchRespVO {
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "子批次-工段")
private List<MaterialBatchRespVO> children;
} }

View File

@@ -1,5 +1,6 @@
package com.zt.plat.module.qms.resource.material.controller.vo; package com.zt.plat.module.qms.resource.material.controller.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zt.plat.module.qms.resource.material.valid.AddGroup; import com.zt.plat.module.qms.resource.material.valid.AddGroup;
import com.zt.plat.module.qms.resource.material.valid.UpdateGroup; import com.zt.plat.module.qms.resource.material.valid.UpdateGroup;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@@ -10,6 +11,7 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 物料批次新增/修改 Request VO") @Schema(description = "管理后台 - 物料批次新增/修改 Request VO")
@Data @Data
@@ -43,10 +45,10 @@ public class MaterialBatchSaveReqVO {
@Schema(description = "生产日期") @Schema(description = "生产日期")
@NotNull(groups = AddGroup.class, message = "生产日期不能为空") @NotNull(groups = AddGroup.class, message = "生产日期不能为空")
private LocalDate manufacturerDate; private LocalDateTime manufacturerDate;
@Schema(description = "到期日期") @Schema(description = "到期日期")
private LocalDate dueDate; private LocalDateTime dueDate;
@Schema(description = "分配部门id") @Schema(description = "分配部门id")
private Long assignDepartmentId; private Long assignDepartmentId;

View File

@@ -1,19 +1,18 @@
package com.zt.plat.module.qms.resource.material.dal.mapper; package com.zt.plat.module.qms.resource.material.dal.mapper;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@@ -25,7 +24,6 @@ import java.util.List;
public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> { public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
default PageResult<MaterialBatchDO> selectPage(MaterialBatchPageReqVO reqVO) { default PageResult<MaterialBatchDO> selectPage(MaterialBatchPageReqVO reqVO) {
// TODO 需要层级穿透 分类-物料sku-批次
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialBatchDO>() return selectPage(reqVO, new LambdaQueryWrapperX<MaterialBatchDO>()
.eqIfPresent(MaterialBatchDO::getProductId, reqVO.getProductId()) .eqIfPresent(MaterialBatchDO::getProductId, reqVO.getProductId())
.likeIfPresent(MaterialBatchDO::getBatchNo, reqVO.getBatchNo()) .likeIfPresent(MaterialBatchDO::getBatchNo, reqVO.getBatchNo())
@@ -45,4 +43,30 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
.orderByDesc(MaterialBatchDO::getId)); .orderByDesc(MaterialBatchDO::getId));
} }
default PageResult<MaterialBatchRespVO> selectPage(MaterialBatchPageReqVO reqVO, List<Long> pdtIds) {
MPJLambdaWrapper<MaterialBatchDO> wrapper = new MPJLambdaWrapperX<MaterialBatchDO>()
.selectAll(MaterialBatchDO.class)
.selectAs(MaterialProductDO::getName, MaterialBatchRespVO::getProductName)
.selectAs(MaterialProductDO::getCode, MaterialBatchRespVO::getProductCode)
.selectAs(MaterialProductDO::getModelNo, MaterialBatchRespVO::getProductModelNo)
.leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialBatchDO::getProductId)
.in(CollUtil.isNotEmpty(pdtIds), MaterialBatchDO::getProductId, pdtIds)
.eq(CollUtil.isEmpty(pdtIds) && reqVO.getProductId() != null, MaterialBatchDO::getProductId, reqVO.getProductId())
.likeIfExists(MaterialBatchDO::getBatchNo, reqVO.getBatchNo())
.likeIfExists(MaterialBatchDO::getLocation, reqVO.getLocation())
.likeIfExists(MaterialBatchDO::getSupplierId, reqVO.getSupplierId())
// .betweenIfPresent(MaterialBatchDO::getManufacturerDate, reqVO.getManufacturerDate())
// .betweenIfPresent(MaterialBatchDO::getDueDate, reqVO.getDueDate())
.eqIfExists(MaterialBatchDO::getAssignDepartmentId, reqVO.getAssignDepartmentId())
.likeIfExists(MaterialBatchDO::getAssignDepartmentName, reqVO.getAssignDepartmentName())
.eqIfExists(MaterialBatchDO::getAcceptanceStatus, reqVO.getAcceptanceStatus())
.eqIfExists(MaterialBatchDO::getAssayFlag, reqVO.getAssayFlag())
.eqIfExists(MaterialBatchDO::getAssayStatus, reqVO.getAssayStatus())
.eqIfExists(MaterialBatchDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
.eqIfExists(MaterialBatchDO::getRemark, reqVO.getRemark())
// .betweenIfPresent(MaterialBatchDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MaterialBatchDO::getId);
return selectJoinPage(reqVO, MaterialBatchRespVO.class, wrapper);
}
} }

View File

@@ -3,11 +3,15 @@ package com.zt.plat.module.qms.resource.material.dal.mapper;
import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.zt.plat.module.qms.core.constant.DataTypeConstant; import com.zt.plat.module.qms.core.constant.DataTypeConstant;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/** /**
* 物料大类 Mapper * 物料大类 Mapper
* *
@@ -52,4 +56,17 @@ public interface MaterialProductMapper extends BaseMapperX<MaterialProductDO> {
.orderByDesc(MaterialProductDO::getId)); .orderByDesc(MaterialProductDO::getId));
} }
default boolean checkIsExistsBatchByPdt(Long id){
MPJLambdaWrapperX<MaterialProductDO> wrapperX = new MPJLambdaWrapperX<MaterialProductDO>()
.leftJoin(MaterialBatchDO.class, MaterialBatchDO::getProductId, MaterialProductDO::getId)
.eq(MaterialBatchDO::getProductId, id);
return this.exists(wrapperX);
}
default boolean checkIsExistsDataByPdts(List<Long> ids){
MPJLambdaWrapperX<MaterialProductDO> wrapperX = new MPJLambdaWrapperX<MaterialProductDO>()
.leftJoin(MaterialBatchDO.class, MaterialBatchDO::getProductId, MaterialProductDO::getId)
.in(MaterialBatchDO::getProductId, ids);
return this.exists(wrapperX);
}
} }

View File

@@ -61,6 +61,14 @@ public interface MaterialBatchService {
*/ */
PageResult<MaterialBatchDO> getMaterialBatchPage(MaterialBatchPageReqVO pageReqVO); PageResult<MaterialBatchDO> getMaterialBatchPage(MaterialBatchPageReqVO pageReqVO);
/**
* 获得物料批次分页-可根据物料分类和大类级联查询
*
* @param pageReqVO 分页查询
* @return 物料批次分页
*/
PageResult<MaterialBatchRespVO> getMaterialBatchPageWithPdtInfo(MaterialBatchPageReqVO pageReqVO);
/** /**
* 批次工段拆分 * 批次工段拆分
* *
@@ -92,4 +100,12 @@ public interface MaterialBatchService {
* @return 工段列表 * @return 工段列表
*/ */
List<MaterialBatchDO> getMaterialBatchGongduanList(Long batId); List<MaterialBatchDO> getMaterialBatchGongduanList(Long batId);
/**
* 提交物料批次
*
* @param id 批次id
* @return 是否
*/
Boolean submitMaterialBatch(Long id);
} }

View File

@@ -3,14 +3,16 @@ package com.zt.plat.module.qms.resource.material.service;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.protobuf.ServiceException;
import com.zt.plat.framework.common.exception.ErrorCode; import com.zt.plat.framework.common.exception.ErrorCode;
import com.zt.plat.framework.common.exception.ServiceException;
import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.qms.core.code.SequenceUtil; import com.zt.plat.module.qms.core.code.SequenceUtil;
import com.zt.plat.module.qms.enums.ErrorCodeConstants;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchSaveReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchSaveReqVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
@@ -44,6 +46,9 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
@Autowired @Autowired
private SequenceUtil sequenceUtil; private SequenceUtil sequenceUtil;
@Autowired
private MaterialProductService materialProductService;
private final String sequenceKey = "QMS_MATERIAL_BATCH_NO"; private final String sequenceKey = "QMS_MATERIAL_BATCH_NO";
@Override @Override
@@ -79,13 +84,11 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
@Override @Override
public void deleteMaterialBatch(Long id) { public void deleteMaterialBatch(Long id) {
// 校验存在
validateMaterialBatchExists(id);
// 已经拆分的批次不可删除 MaterialBatchDO batchDO = materialBatchMapper.selectById(id);
List<MaterialBatchDO> asnDOs = materialBatchMapper.selectList(Wrappers.lambdaQuery(MaterialBatchDO.class) if (batchDO == null) throw exception(MATERIAL_BATCH_NOT_EXISTS);
.eq(MaterialBatchDO::getParentId, id)); if (batchDO.getSubmitStatus() == 1)
if (CollUtil.isNotEmpty(asnDOs)) throw exception(MATERIAL_BATCH_ASSIGN_END); throw new ServiceException(1_032_160_000, "批次已经提交,不可删除");
// 删除 // 删除
materialBatchMapper.deleteById(id); materialBatchMapper.deleteById(id);
@@ -94,11 +97,15 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
@Override @Override
public void deleteMaterialBatchListByIds(List<Long> ids) { public void deleteMaterialBatchListByIds(List<Long> ids) {
// 校验存在 // 校验存在
validateMaterialBatchExists(ids); List<MaterialBatchDO> list = materialBatchMapper.selectByIds(ids);
// 已经拆分的批次不可删除 if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
List<MaterialBatchDO> asnDOs = materialBatchMapper.selectList(Wrappers.lambdaQuery(MaterialBatchDO.class) throw exception(MATERIAL_BATCH_NOT_EXISTS);
.in(MaterialBatchDO::getParentId, ids)); }
if (CollUtil.isNotEmpty(asnDOs)) throw exception(MATERIAL_BATCH_ASSIGN_END); // 存在已经提交的批次时,不可删除
for (MaterialBatchDO batch : list) {
if (batch.getSubmitStatus() == 1)
throw new ServiceException(1_032_160_000, "存在已经提交的批次,不可删除");
}
// 删除 // 删除
materialBatchMapper.deleteByIds(ids); materialBatchMapper.deleteByIds(ids);
} }
@@ -126,6 +133,32 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
return materialBatchMapper.selectPage(pageReqVO); return materialBatchMapper.selectPage(pageReqVO);
} }
@Override
public PageResult<MaterialBatchRespVO> getMaterialBatchPageWithPdtInfo(MaterialBatchPageReqVO pageReqVO) {
Long pdtId = pageReqVO.getProductId();
PageResult<MaterialBatchRespVO> pageResult;
if (pdtId == null) {
pageResult = materialBatchMapper.selectPage(pageReqVO, List.of());
} else {
List<MaterialProductDO> mtrlDos = materialProductService.getMaterialProductsByLikeIdPath(pdtId);
if (CollUtil.isEmpty(mtrlDos)) {
pageResult = materialBatchMapper.selectPage(pageReqVO, List.of());
} else {
List<Long> pdtIds = mtrlDos.stream().map(MaterialProductDO::getId).toList();
pageResult = materialBatchMapper.selectPage(pageReqVO, pdtIds);
}
}
if (!pageReqVO.getChildren()) return pageResult;
List<MaterialBatchRespVO> voList = pageResult.getList();
if (CollUtil.isNotEmpty(voList)) {
List<MaterialBatchRespVO> treeVos = this.listTransTree(voList, 0L);
pageResult.setList(treeVos);
}
return pageResult;
}
/** /**
* 批次工段拆分 * 批次工段拆分
* *
@@ -134,8 +167,7 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
public List<MaterialBatchRespVO> assignMaterialBatchGongduan(List<MaterialBatchSaveReqVO> createReqVOs) { public List<MaterialBatchRespVO> assignMaterialBatchGongduan(List<MaterialBatchSaveReqVO> createReqVOs) {
// 是否已经拆分过 // 是否已经拆分过
Long batId = createReqVOs.get(0).getParentId(); Long batId = createReqVOs.get(0).getParentId();
List<MaterialBatchDO> asnDOs = materialBatchMapper.selectList(Wrappers.lambdaQuery(MaterialBatchDO.class)
.eq(MaterialBatchDO::getParentId, batId));
// 1. 所属的批次需要是同一个 // 1. 所属的批次需要是同一个
Set<Long> pIds = createReqVOs.stream().map(MaterialBatchSaveReqVO::getParentId).collect(Collectors.toSet()); Set<Long> pIds = createReqVOs.stream().map(MaterialBatchSaveReqVO::getParentId).collect(Collectors.toSet());
if (pIds.size() > 1) throw exception(GONGDUAN_BELONG_MATERIAL_BATCH_NOT_EQUAL); if (pIds.size() > 1) throw exception(GONGDUAN_BELONG_MATERIAL_BATCH_NOT_EQUAL);
@@ -148,18 +180,24 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
for (MaterialBatchSaveReqVO batAsn : createReqVOs) { for (MaterialBatchSaveReqVO batAsn : createReqVOs) {
total = total.add(batAsn.getInboundQuantity()); total = total.add(batAsn.getInboundQuantity());
} }
if (!total.equals(mtrlBat.getInboundQuantity())) if (total.compareTo(mtrlBat.getInboundQuantity()) != 0)
throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL); throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL);
// 修改工段 // 修改工段
if (CollUtil.isNotEmpty(asnDOs)) { boolean exists = materialBatchMapper.exists(Wrappers.lambdaQuery(MaterialBatchDO.class)
// 删除之前的拆分数据TODO 需要检查是否可以删除 .eq(MaterialBatchDO::getParentId, batId));
if (exists) {
if (mtrlBat.getSubmitStatus() == 1) throw new ServiceException(1_032_160_000, "批次已经提交,禁止修改");
// 删除之前的拆分数据
materialBatchMapper.delete(Wrappers.lambdaQuery(MaterialBatchDO.class) materialBatchMapper.delete(Wrappers.lambdaQuery(MaterialBatchDO.class)
.eq(MaterialBatchDO::getParentId, batId)); .eq(MaterialBatchDO::getParentId, batId));
} }
// 3. 保存工段 // 3. 保存工段
List<MaterialBatchDO> gongEts = createReqVOs.stream().map( List<MaterialBatchDO> gongEts = createReqVOs.stream().map(batAsn -> {
batAsn -> BeanUtils.toBean(batAsn, MaterialBatchDO.class)).toList(); MaterialBatchDO bean = BeanUtils.toBean(batAsn, MaterialBatchDO.class);
bean.setProductId(mtrlBat.getProductId());
return bean;
}).toList();
materialBatchMapper.insertBatch(gongEts); materialBatchMapper.insertBatch(gongEts);
return gongEts.stream().map( return gongEts.stream().map(
@@ -194,4 +232,32 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
.ne(MaterialBatchDO::getParentId, 0)); .ne(MaterialBatchDO::getParentId, 0));
} }
@Override
public Boolean submitMaterialBatch(Long id) {
MaterialBatchDO batchDO = materialBatchMapper.selectById(id);
if (batchDO == null) throw exception(MATERIAL_BATCH_NOT_EXISTS);
if (batchDO.getSubmitStatus() == 1) throw new ServiceException(1_032_160_000, "批次已经提交过");
boolean exists = materialBatchMapper.exists(Wrappers.lambdaQuery(MaterialBatchDO.class)
.eq(MaterialBatchDO::getParentId, id));
if (!exists) throw new ServiceException(1_032_160_000, "批次还未拆分,不可提交");
batchDO.setSubmitStatus(1);
materialBatchMapper.updateById(batchDO);
return true;
}
/**
* 组装物料批次树
*
*/
private List<MaterialBatchRespVO> listTransTree(List<MaterialBatchRespVO> voList, Long parentId) {
// 获取父级节点
List<MaterialBatchRespVO> parentVOs = voList.stream().filter(vo ->
vo.getParentId().equals(parentId)).collect(Collectors.toList());
// 设置响应的子节点
parentVOs.forEach(vo -> vo.setChildren(listTransTree(voList, vo.getId())));
return parentVOs;
}
} }

View File

@@ -99,4 +99,11 @@ public interface MaterialProductService {
* @return 物料大类分页 * @return 物料大类分页
*/ */
PageResult<MaterialProductRespVO> getMaterialInventoryPage(@Valid MaterialProductPageReqVO pageReqVO); PageResult<MaterialProductRespVO> getMaterialInventoryPage(@Valid MaterialProductPageReqVO pageReqVO);
/**
* 获取id在 idPath中的全部数据
* @param pdtId id
* @return 物料数据
*/
List<MaterialProductDO> getMaterialProductsByLikeIdPath(Long pdtId);
} }

View File

@@ -40,8 +40,8 @@ public class MaterialProductServiceImpl implements MaterialProductService {
@Resource @Resource
private MaterialProductMapper materialProductMapper; private MaterialProductMapper materialProductMapper;
@Autowired // @Autowired
private MaterialBatchService materialBatchService; // private MaterialBatchService materialBatchService;
@Autowired @Autowired
private MaterialInfomationService materialInfomationService; private MaterialInfomationService materialInfomationService;
@@ -238,9 +238,6 @@ public class MaterialProductServiceImpl implements MaterialProductService {
// 分类 // 分类
if (DataTypeConstant.DATA_TYPE_CATEGORY.equals(pdtDo.getNodeType())) { if (DataTypeConstant.DATA_TYPE_CATEGORY.equals(pdtDo.getNodeType())) {
// 分类下有子分类或大类时不可删除 // 分类下有子分类或大类时不可删除
// boolean exists = materialProductMapper.exists(Wrappers.lambdaQuery(MaterialProductDO.class)
// .like(MaterialProductDO::getIdPath, id)
// .ne(MaterialProductDO::getId, id));
boolean exists = materialProductMapper.exists(Wrappers.lambdaQuery(MaterialProductDO.class) boolean exists = materialProductMapper.exists(Wrappers.lambdaQuery(MaterialProductDO.class)
.eq(MaterialProductDO::getParentId, id)); .eq(MaterialProductDO::getParentId, id));
if (exists) throw exception(MATERIAL_CATEGORY_EXISTS_CHILDREN); if (exists) throw exception(MATERIAL_CATEGORY_EXISTS_CHILDREN);
@@ -249,7 +246,7 @@ public class MaterialProductServiceImpl implements MaterialProductService {
else { else {
// 大类下有批次时不可删除 // 大类下有批次时不可删除
// TODO 以及其他不可删除的情况,如库存记录、物料实例、使用记录等 // TODO 以及其他不可删除的情况,如库存记录、物料实例、使用记录等
boolean exists = materialBatchService.checkIsExistsDataByPdt(id); boolean exists = materialProductMapper.checkIsExistsBatchByPdt(id);
if (exists) throw exception(MATERIAL_PRODUCT_EXISTS_BATCH); if (exists) throw exception(MATERIAL_PRODUCT_EXISTS_BATCH);
} }
materialProductMapper.deleteById(id); materialProductMapper.deleteById(id);
@@ -267,7 +264,7 @@ public class MaterialProductServiceImpl implements MaterialProductService {
if (CollUtil.isNotEmpty(mtCtgList)) throw exception(MATERIAL_PRODUCTS_EXISTS_CATEGORY); if (CollUtil.isNotEmpty(mtCtgList)) throw exception(MATERIAL_PRODUCTS_EXISTS_CATEGORY);
// 检查是否可删除 大类下有批次时不可删除 // 检查是否可删除 大类下有批次时不可删除
// TODO 以及其他不可删除的情况,如库存记录、物料实例、使用记录等 // TODO 以及其他不可删除的情况,如库存记录、物料实例、使用记录等
boolean exists = materialBatchService.checkIsExistsDataByPdts(ids); boolean exists = materialProductMapper.checkIsExistsDataByPdts(ids);
if (exists) throw exception(MATERIAL_PRODUCT_EXISTS_BATCH); if (exists) throw exception(MATERIAL_PRODUCT_EXISTS_BATCH);
// 删除 // 删除
materialProductMapper.deleteByIds(ids); materialProductMapper.deleteByIds(ids);
@@ -339,4 +336,12 @@ public class MaterialProductServiceImpl implements MaterialProductService {
return new PageResult<>(voList, pageResult.getTotal()); return new PageResult<>(voList, pageResult.getTotal());
} }
@Override
public List<MaterialProductDO> getMaterialProductsByLikeIdPath(Long pdtId) {
return materialProductMapper.selectList(Wrappers.lambdaQuery(MaterialProductDO.class)
.like(MaterialProductDO::getIdPath, "/" + pdtId + "/")
.eq(MaterialProductDO::getNodeType, DataTypeConstant.DATA_TYPE_DATA));
}
} }

View File

@@ -0,0 +1,4 @@
package com.zt.plat.module.qms.resource.material.service.assist;
public class MaterialProductBatchService {
}