From 5092706f3dc9ebcce050543af592f005ec7f7c9b Mon Sep 17 00:00:00 2001 From: swj <1211312234@qq.com> Date: Tue, 11 Oct 2022 22:14:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=8F=97=E6=A3=80=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E6=88=96=E9=87=87=E6=A0=B7=E5=8D=95=E4=BD=8D=E7=9A=84?= =?UTF-8?q?id=E6=B2=A1=E5=80=BC=EF=BC=8C=E4=BD=86=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=9C=89=E5=80=BC=EF=BC=8C=E9=9C=80=E8=A6=81=EF=BC=9A1.?= =?UTF-8?q?=E5=B0=86=E5=8F=97=E6=A3=80=E5=8D=95=E4=BD=8D=E6=88=96=E9=87=87?= =?UTF-8?q?=E6=A0=B7=E5=8D=95=E4=BD=8D=E5=85=A5=E5=BA=93=EF=BC=8C2.?= =?UTF-8?q?=E5=B0=86=E6=96=B0=E7=9A=84=E5=8F=97=E6=A3=80=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=88=96=E9=87=87=E6=A0=B7=E5=8D=95=E4=BD=8D=E7=9A=84id?= =?UTF-8?q?=E5=92=8C=E7=BB=99=E5=88=B0=E5=A7=94=E6=89=98=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E5=8F=97=E6=A3=80=E5=8D=95=E4=BD=8D=E6=88=96=E9=87=87=E6=A0=B7?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=AD=97=E6=AE=B5=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lims/controller/EntrustController.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/EntrustController.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/EntrustController.java index bb23917..827d1e4 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/EntrustController.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/EntrustController.java @@ -21,6 +21,7 @@ import com.spire.doc.documents.Paragraph; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import oracle.jdbc.proxy.annotation.Post; +import org.apache.commons.lang.math.RandomUtils; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springblade.common.utils.ZipCompressUtil; @@ -1612,6 +1613,8 @@ public class EntrustController extends BladeController { @PostMapping("/conserve") public Entrust conserve(@RequestBody Entrust entrust) { // 委托单入库 + + // 采样单位相关 Long entrustCustomerId = entrust.getEntrustCustomerId(); String entrustCustomerName = entrust.getEntrustCustomerName(); if (entrustCustomerName == null || "".equals(entrustCustomerName)) { @@ -1619,7 +1622,52 @@ public class EntrustController extends BladeController { EntrustCustomer byId = customerService.getById(entrustCustomerId); entrust.setEntrustCustomerName(byId.getName()); } + } else { + // 如果受检单位的id没值,但名称有值,需要:1.将受检单位入库,2.将新的受检单位的id和给到委托单的受检单位字段上 + if (entrustCustomerId == null || "".equals(entrustCustomerId)) { + // 1 + EntrustCustomer customer = new EntrustCustomer(); + long customerId = RandomUtils.nextLong(); + customer.setId(customerId); + customer.setName(entrustCustomerName); + customer.setAddress(entrust.getCustomeAddress()); + customer.setEmail(entrust.getPostalCode()); + customer.setPhone(entrust.getPhone()); + customer.setFax(entrust.getFacsimile()); + customer.setFullName(entrust.getSubmittedBy()); + customer.setStatus(1); + customerService.save(customer); + // 2 + entrust.setEntrustCustomerId(customerId); + } + } + + // 采样单位相关 + Long entrustTakeCompanyId = entrust.getTakeCompanyId(); + String takeCompany = entrust.getTakeCompany(); + if (takeCompany == null || "".equals(takeCompany)) { + if (entrustTakeCompanyId != null) { + EntrustCustomer byId = customerService.getById(entrustTakeCompanyId); + entrust.setEntrustCustomerName(byId.getName()); + } + } else { + // 如果采样单位的id没值,但名称有值,需要:1.将受检单位入库,2.将新的采样单位的id和给到委托单的采样单位字段上 + if (entrustTakeCompanyId == null || "".equals(entrustTakeCompanyId)) { + // 1 + EntrustCustomer takeCompanyObj = new EntrustCustomer(); + long takeCompanyId = RandomUtils.nextLong(); + takeCompanyObj.setId(takeCompanyId); + takeCompanyObj.setName(takeCompany); + takeCompanyObj.setAddress(entrust.getTakeCompanyAddress()); + takeCompanyObj.setPhone(entrust.getTakePhone()); + takeCompanyObj.setFullName(entrust.getTakePerson()); + takeCompanyObj.setStatus(2); + customerService.save(takeCompanyObj); + // 2 + entrust.setTakeCompanyId(takeCompanyId); + } } + if (entrust.getSampleReceiverId() != null && !"".equals(entrust.getSampleReceiverId())) { R userR = userClient.userInfoById(Long.valueOf(entrust.getSampleReceiverId())); User data = userR.getData();