feat: 药品关联关系功能

v3
chenhc 6 months ago
parent c5fed5f2aa
commit 7b0769acd6

@ -0,0 +1,94 @@
package com.glxp.udidl.admin.controller.collect;
import com.github.pagehelper.PageInfo;
import com.glxp.udidl.admin.entity.collect.RelCodeBatch;
import com.glxp.udidl.admin.req.collect.RelCodeBatchRequest;
import com.glxp.udidl.admin.req.collect.RelCodeDetailRequest;
import com.glxp.udidl.admin.res.BaseResponse;
import com.glxp.udidl.admin.res.PageSimpleResponse;
import com.glxp.udidl.admin.res.collect.RelCodeBatchResponse;
import com.glxp.udidl.admin.service.collect.RelCodeBatchService;
import com.glxp.udidl.admin.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@Slf4j
@RestController
public class RelCodeBatchController {
@Resource
private RelCodeBatchService relCodeBatchService;
/**
*
* @param relCodeBatchRequest
* @return
*/
@PostMapping("/udiwms/relCode/batch/add")
public BaseResponse add(@RequestBody @Valid RelCodeBatchRequest relCodeBatchRequest, BindingResult bindingResult) {
relCodeBatchService.add(relCodeBatchRequest);
return ResultVOUtils.success("添加成功!");
}
/**
*
* @param relCodeBatchRequest
* @return
*/
@PostMapping("/udiwms/relCode/batch/addList")
public BaseResponse addRelCodeSpellBox(@RequestBody @Valid List<RelCodeBatchRequest> relCodeBatchRequest,BindingResult bindingResult) {
relCodeBatchService.addRelCodeSpellBox(relCodeBatchRequest);
return ResultVOUtils.success("添加成功!");
}
@GetMapping("/udiwms/relCode/batch/filter")
public BaseResponse list(RelCodeBatchRequest relCodeBatchRequest, BindingResult bindingResult) {
List<RelCodeBatchResponse> relCodeBatchResponses = relCodeBatchService.filterList(relCodeBatchRequest);
PageInfo<RelCodeBatchResponse> pageInfo = new PageInfo<>(relCodeBatchResponses);
PageSimpleResponse<RelCodeBatchResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(relCodeBatchResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("/udiwms/relCode/batch/get")
public BaseResponse get(@RequestParam("id") Long id) {
RelCodeBatch relCodeBatch = relCodeBatchService.getById(id);
return ResultVOUtils.success(relCodeBatch);
}
@GetMapping("/udiwms/relCode/batch/delete")
public BaseResponse delete(@RequestParam("id") Long id) {
relCodeBatchService.delete(id);
return ResultVOUtils.success("删除成功");
}
@PostMapping("/udiwms/relCode/batch/update")
public BaseResponse update(@RequestBody @Valid RelCodeBatch relCodeBatch) {
relCodeBatchService.updateById(relCodeBatch);
return ResultVOUtils.success("修改成功!");
}
@GetMapping("/udiwms/relCode/batch/deleteDetail")
public BaseResponse deleteDetail(@RequestParam("curCode") String curCode) {
relCodeBatchService.deleteDetail(curCode);
return ResultVOUtils.success("删除成功");
}
@PostMapping("/udiwms/relCode/batch/deleteAllDetail")
public BaseResponse deleteAllDetail(@RequestBody List<RelCodeDetailRequest> detailList) {
relCodeBatchService.deleteAllDetail(detailList);
return ResultVOUtils.success("清空成功");
}
}

@ -0,0 +1,70 @@
//package com.glxp.udidl.admin.controller.collect;
//
//
//import com.github.pagehelper.PageInfo;
//import com.glxp.api.annotation.RepeatSubmit;
//import com.glxp.api.common.res.BaseResponse;
//import com.glxp.api.common.util.ResultVOUtils;
//import com.glxp.api.controller.BaseController;
//import com.glxp.api.entity.collect.RelCodeDetail;
//import com.glxp.api.req.collect.RelCodeDetailRequest;
//import com.glxp.api.res.PageSimpleResponse;
//import com.glxp.api.res.collect.RelCodeDetailResponse;
//import com.glxp.api.service.collect.RelCodeDetailService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.validation.BindingResult;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import javax.validation.Valid;
//import java.util.List;
//
//@Slf4j
//@RestController
//public class RelCodeDetailController extends BaseController {
//
// @Resource
// private RelCodeDetailService relCodeDetailService;
//
//
//
// /**
// * 扫码
// * @param relCodeDetailRequest
// * @return
// */
// @RepeatSubmit()
// @PostMapping("/udiwms/relCode/detail/scanCode")
// public BaseResponse scanCode(@RequestBody @Valid RelCodeDetailRequest relCodeDetailRequest, BindingResult bindingResult) {
// RelCodeDetailResponse relCodeDetailResponse = relCodeDetailService.scanCode(relCodeDetailRequest);
// return ResultVOUtils.success(relCodeDetailResponse);
// }
//
//
// @GetMapping("/udiwms/relCode/detail/filter")
// public BaseResponse list(RelCodeDetailRequest relCodeDetailRequest, BindingResult bindingResult) {
// List<RelCodeDetailResponse> relCodeDetailResponses = relCodeDetailService.filterList(relCodeDetailRequest);
// PageInfo<RelCodeDetailResponse> pageInfo = new PageInfo<>(relCodeDetailResponses);
// PageSimpleResponse<RelCodeDetailResponse> pageSimpleResponse = new PageSimpleResponse<>();
// pageSimpleResponse.setTotal(pageInfo.getTotal());
// pageSimpleResponse.setList(relCodeDetailResponses);
// return ResultVOUtils.success(pageSimpleResponse);
// }
//
//
// @GetMapping("/udiwms/relCode/detail/get")
// public BaseResponse get(Long id) {
// RelCodeDetail relCodeDetail = relCodeDetailService.getById(id);
// return ResultVOUtils.success(relCodeDetail);
// }
//
//
// @PostMapping("/udiwms/relCode/detail/update")
// public BaseResponse update(@RequestBody @Valid RelCodeDetail relCodeDetail) {
// relCodeDetailService.updateById(relCodeDetail);
// return ResultVOUtils.success("修改成功!");
// }
//}

@ -144,28 +144,39 @@ public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCode
*/
@Transactional(rollbackFor = Exception.class)
public void add(RelCodeBatchRequest relCodeBatchRequest) {
// List<RelCodeDetailRequest> detailList = relCodeBatchRequest.getDetailList();
// if(CollUtil.isEmpty(detailList)){
// throw new JsonException("关联明细不能为空!");
// }
// AuthAdmin user = customerService.getUserBean();
// RelCodeBatch relCodeBatch = new RelCodeBatch();
// BeanUtils.copyProperties(relCodeBatchRequest,relCodeBatch);
// relCodeBatch.setCreateTime(new Date());
// relCodeBatch.setCreateUser(user.getUserName());
// relCodeBatch.setUpdateTime(new Date());
// relCodeBatch.setUpdateUser(user.getUserName());
// this.save(relCodeBatch);
// List<RelCodeDetail> relCodeDetails = new ArrayList<>();
// for(RelCodeDetailRequest request : detailList){
// RelCodeDetail relCodeDetail = new RelCodeDetail();
// String parentCode = request.getParentCode();
// request.setParentCode(StrUtil.isNotBlank(parentCode)?parentCode:"0");
// BeanUtils.copyProperties(request,relCodeDetail);
// relCodeDetail.setBatchIdFk(relCodeBatch.getId());
// relCodeDetails.add(relCodeDetail);
// }
// relCodeDetailService.saveBatch(relCodeDetails);
String productCode = relCodeBatchRequest.getProductCode();
String subTypeNo = relCodeBatchRequest.getSubTypeNo();
String batchNo = relCodeBatchRequest.getBatchNo();
//如果不存在就添加
List<RelCodeBatch> list = this.list(new LambdaQueryWrapper<RelCodeBatch>()
.eq(RelCodeBatch::getProductCode, productCode)
.eq(StrUtil.isNotBlank(subTypeNo),RelCodeBatch::getSubTypeNo, subTypeNo)
.eq(RelCodeBatch::getBatchNo, batchNo))
;
if (CollUtil.isNotEmpty(list)){
throw new JsonException( "层级编码:【"+productCode + "】;类型编码:【" + subTypeNo + "】;批次号:【"+batchNo + "】已存在!");
}
List<RelCodeDetailRequest> detailList = relCodeBatchRequest.getDetailList();
if(CollUtil.isEmpty(detailList)){
throw new JsonException("关联明细不能为空!");
}
RelCodeBatch relCodeBatch = new RelCodeBatch();
BeanUtils.copyProperties(relCodeBatchRequest,relCodeBatch);
relCodeBatch.setCreateTime(new Date());
relCodeBatch.setUpdateTime(new Date());
relCodeBatch.setId(null);
this.save(relCodeBatch);
List<RelCodeDetail> relCodeDetails = new ArrayList<>();
for(RelCodeDetailRequest request : detailList){
RelCodeDetail relCodeDetail = new RelCodeDetail();
String parentCode = request.getParentCode();
request.setParentCode(StrUtil.isNotBlank(parentCode)?parentCode:"0");
BeanUtils.copyProperties(request,relCodeDetail);
relCodeDetail.setBatchIdFk(relCodeBatch.getId());
relCodeDetail.setId(null);
relCodeDetails.add(relCodeDetail);
}
relCodeDetailService.saveBatch(relCodeDetails);
}
public List<RelCodeBatchResponse> filterList(RelCodeBatchRequest relCodeBatchRequest) {

Loading…
Cancel
Save