From 46e476cc33f5f587409de82430f392d30068575b Mon Sep 17 00:00:00 2001 From: zhaoxl Date: Fri, 18 Aug 2023 16:41:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'op-modules/op-quality/src/main/java/com/op/quality'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/op/quality/BaseFile.java | 123 +++++++ .../com/op/quality/DynamicDatasource.java | 51 +++ .../main/java/com/op/quality/QcProCheck.java | 333 ++++++++++++++++++ .../java/com/op/quality/QuaController.java | 78 ++++ 4 files changed, 585 insertions(+) create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/BaseFile.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/DynamicDatasource.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/QcProCheck.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/QuaController.java diff --git a/op-modules/op-quality/src/main/java/com/op/quality/BaseFile.java b/op-modules/op-quality/src/main/java/com/op/quality/BaseFile.java new file mode 100644 index 00000000..78b9f4be --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/BaseFile.java @@ -0,0 +1,123 @@ +package com.op.quality.domain; + +import com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 附件对象 base_file + * + * @author Open Platform + * @date 2023-07-10 + */ +public class BaseFile extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 附件ID */ + private String fileId; + + /** 附件名称 */ + @Excel(name = "附件名称") + private String fileName; + + /** 附件地址 */ + @Excel(name = "附件地址") + private String fileAddress; + + /** 数据来源 */ + @Excel(name = "数据来源") + private String sourceId; + + /** 预留字段1 */ + @Excel(name = "预留字段1") + private String attr1; + + /** 预留字段2 */ + @Excel(name = "预留字段2") + private String attr2; + + /** 预留字段3 */ + @Excel(name = "预留字段3") + private Long attr3; + + /** 预留字段4 */ + @Excel(name = "预留字段4") + private Long attr4; + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getFileId() { + return fileId; + } + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFileName() { + return fileName; + } + public void setFileAddress(String fileAddress) { + this.fileAddress = fileAddress; + } + + public String getFileAddress() { + return fileAddress; + } + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getSourceId() { + return sourceId; + } + public void setAttr1(String attr1) { + this.attr1 = attr1; + } + + public String getAttr1() { + return attr1; + } + public void setAttr2(String attr2) { + this.attr2 = attr2; + } + + public String getAttr2() { + return attr2; + } + public void setAttr3(Long attr3) { + this.attr3 = attr3; + } + + public Long getAttr3() { + return attr3; + } + public void setAttr4(Long attr4) { + this.attr4 = attr4; + } + + public Long getAttr4() { + return attr4; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("fileId", getFileId()) + .append("fileName", getFileName()) + .append("fileAddress", getFileAddress()) + .append("sourceId", getSourceId()) + .append("remark", getRemark()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/DynamicDatasource.java b/op-modules/op-quality/src/main/java/com/op/quality/DynamicDatasource.java new file mode 100644 index 00000000..e15eb634 --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/DynamicDatasource.java @@ -0,0 +1,51 @@ +package com.op.quality.config; + +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; +import com.op.common.core.domain.R; +import com.op.common.datasource.creator.DynamicDatasourceCreator; +import com.op.system.api.RemoteUserService; +import com.op.system.api.domain.SysUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * 初始化动态数据源 + * + * @ClassName: DynamicDatasource + * @Description: TODO + * @author shichangzhou + * @date 2023年4月19日 下午1:01:30 + */ +@Component +public class DynamicDatasource { + + @Resource + private DynamicDatasourceCreator dynamicDatasourceCreator; + @Autowired + private RemoteUserService remoteUserService; + + @PostConstruct + public void init() { + // 加载sf-cloud库的sys_datasource + SysUser sysUser = new SysUser(); + sysUser.setUserId(1L); + R>> dateSources0 = remoteUserService.getPoolNameList(sysUser); + List> dateSources = dateSources0.getData(); + for (Map dateSource : dateSources) { + DataSourceProperty sdp = new DataSourceProperty(); + sdp.setUrl(dateSource.get("url")); + sdp.setUsername(dateSource.get("userName")); + sdp.setPassword(dateSource.get("password")); + sdp.setDriverClassName(dateSource.get("driveClassName")); + sdp.setPoolName(dateSource.get("poolName"));// 这是数据源的key + sdp.setLazy(false); + dynamicDatasourceCreator.createDynamicDataSource(sdp); + } + + } +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/QcProCheck.java b/op-modules/op-quality/src/main/java/com/op/quality/QcProCheck.java new file mode 100644 index 00000000..c1604737 --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/QcProCheck.java @@ -0,0 +1,333 @@ +package com.op.quality.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; + +import java.util.Date; + +/** + * @ClassName : qua + * @Description : + * @Author : + * @Date: 2023-08-17 10:18 + */ +public class QcProCheck extends BaseEntity { + + private static final long serialVersionUID = 1L; + @Excel(name = "id") + private String id; + + @Excel(name = "rfid") + private String rfid; + @Excel(name = "工厂id") + private String factoryId; + @Excel(name = "工厂编码") + private String factoryCode; + + @Excel(name = "工单id") + private String workorderId; + @Excel(name = "工厂编码") + private String workorderCode; + @Excel(name = "工厂名称") + private String workorderName; + + @Excel(name = "订单id") + private String orderId; + @Excel(name = "订单编码") + private String orderCode; + + @Excel(name = "机台id") + private String machineId; + @Excel(name = "机台编码") + private String machineCode; + + @Excel(name = "不良描述") + private String badMeg; + + @Excel(name = "产品id") + private String productId; + + private String productCode; + @Excel(name = "是否合格") + private String isqua; + + @Excel(name = "附件") + private String fileId; + + @Excel(name = "创建者") + private String createBy; + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + @Excel(name = "更新者") + private String updateBy; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + private String attr1; + private String attr2; + private String attr3; + private String attr4; + + public String getFactoryId() { + return factoryId; + } + + public void setFactoryId(String factoryId) { + this.factoryId = factoryId; + } + + public String getFactoryCode() { + return factoryCode; + } + + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRfid() { + return rfid; + } + + public void setRfid(String rfid) { + this.rfid = rfid; + } + + public String getWorkorderId() { + return workorderId; + } + + public void setWorkorderId(String workorderId) { + this.workorderId = workorderId; + } + + public String getWorkorderCode() { + return workorderCode; + } + + public void setWorkorderCode(String workorderCode) { + this.workorderCode = workorderCode; + } + + public String getWorkorderName() { + return workorderName; + } + + public void setWorkorderName(String workorderName) { + this.workorderName = workorderName; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getOrderCode() { + return orderCode; + } + + public void setOrderCode(String orderCode) { + this.orderCode = orderCode; + } + + public String getMachineId() { + return machineId; + } + + public void setMachineId(String machineId) { + this.machineId = machineId; + } + + public String getMachineCode() { + return machineCode; + } + + public void setMachineCode(String machineCode) { + this.machineCode = machineCode; + } + + public String getBadMeg() { + return badMeg; + } + + public void setBadMeg(String badMeg) { + this.badMeg = badMeg; + } + + public String getProductId() { + return productId; + } + + public void setProductId(String productId) { + this.productId = productId; + } + + public String getProductCode() { + return productCode; + } + + public void setProductCode(String productCode) { + this.productCode = productCode; + } + + public String getIsqua() { + return isqua; + } + + public void setIsqua(String isqua) { + this.isqua = isqua; + } + + public String getFileId() { + return fileId; + } + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + @Override + public String getCreateBy() { + return createBy; + } + + @Override + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + @Override + public Date getCreateTime() { + return createTime; + } + + @Override + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public String getUpdateBy() { + return updateBy; + } + + @Override + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + @Override + public Date getUpdateTime() { + return updateTime; + } + + @Override + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getAttr1() { + return attr1; + } + + public void setAttr1(String attr1) { + this.attr1 = attr1; + } + + public String getAttr2() { + return attr2; + } + + public void setAttr2(String attr2) { + this.attr2 = attr2; + } + + public String getAttr3() { + return attr3; + } + + public void setAttr3(String attr3) { + this.attr3 = attr3; + } + + public String getAttr4() { + return attr4; + } + + public void setAttr4(String attr4) { + this.attr4 = attr4; + } + + public QcProCheck(String id, String rfid, String factoryId, String factoryCode, String workorderId, String workorderCode, String workorderName, String orderId, String orderCode, String machineId, String machineCode, String badMeg, String productId, String productCode, String isqua, String fileId, String createBy, Date createTime, String updateBy, Date updateTime, String attr1, String attr2, String attr3, String attr4) { + this.id = id; + this.rfid = rfid; + this.factoryId = factoryId; + this.factoryCode = factoryCode; + this.workorderId = workorderId; + this.workorderCode = workorderCode; + this.workorderName = workorderName; + this.orderId = orderId; + this.orderCode = orderCode; + this.machineId = machineId; + this.machineCode = machineCode; + this.badMeg = badMeg; + this.productId = productId; + this.productCode = productCode; + this.isqua = isqua; + this.fileId = fileId; + this.createBy = createBy; + this.createTime = createTime; + this.updateBy = updateBy; + this.updateTime = updateTime; + this.attr1 = attr1; + this.attr2 = attr2; + this.attr3 = attr3; + this.attr4 = attr4; + } + + public QcProCheck() { + } + + @Override + public String toString() { + return "QcProCheck{" + + "id='" + id + '\'' + + ", rfid='" + rfid + '\'' + + ", factoryId='" + factoryId + '\'' + + ", factoryCode='" + factoryCode + '\'' + + ", workorderId='" + workorderId + '\'' + + ", workorderCode='" + workorderCode + '\'' + + ", workorderName='" + workorderName + '\'' + + ", orderId='" + orderId + '\'' + + ", orderCode='" + orderCode + '\'' + + ", machineId='" + machineId + '\'' + + ", machineCode='" + machineCode + '\'' + + ", badMeg='" + badMeg + '\'' + + ", productId='" + productId + '\'' + + ", productCode='" + productCode + '\'' + + ", isqua='" + isqua + '\'' + + ", fileId='" + fileId + '\'' + + ", createBy='" + createBy + '\'' + + ", createTime=" + createTime + + ", updateBy='" + updateBy + '\'' + + ", updateTime=" + updateTime + + ", attr1='" + attr1 + '\'' + + ", attr2='" + attr2 + '\'' + + ", attr3='" + attr3 + '\'' + + ", attr4='" + attr4 + '\'' + + '}'; + } +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/QuaController.java b/op-modules/op-quality/src/main/java/com/op/quality/QuaController.java new file mode 100644 index 00000000..b61e4c38 --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/QuaController.java @@ -0,0 +1,78 @@ +package com.op.quality.Controller; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.domain.R; +import com.op.common.core.utils.uuid.UUID; +import com.op.quality.domain.BaseFile; +import com.op.quality.domain.QcProCheck; +import com.op.quality.service.QcProCheckService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @ClassName : quaController + * @Description : + * @Author : + * @Date: 2023-08-17 10:28 + */ +@RestController +public class QuaController { + @Autowired + private QcProCheckService qcProCheckService; + + + @PostMapping("/saveQcProCheck") + public R saveQcProCheck(@RequestBody Map map) { +// System.out.println(qcProCheck); +// System.out.println(baseFile); + QcProCheck qcProCheck = map.keySet().iterator().next(); + BaseFile baseFile = map.values().iterator().next(); + + if (!qcProCheck.getFactoryId().isEmpty()){ + if (baseFile==null){ + baseFile = new BaseFile(); + qcProCheckService.saveQcProCheck(qcProCheck,baseFile); + } + + if (qcProCheck.getIsqua()=="1"){ + System.out.println("调用下一个接口"); + return R.ok(); + } + else{ + return R.ok(); + } + } + return R.fail(); + } + @PostMapping("/test") + public R test() { +// System.out.println(qcProCheck); +// System.out.println(baseFile); +// QcProCheck qcProCheck = map.keySet().iterator().next(); +// BaseFile baseFile = map.values().iterator().next(); + QcProCheck qcProCheck = new QcProCheck(); + BaseFile baseFile = new BaseFile(); + qcProCheck.setId("1232132132121321"); + qcProCheck.setFactoryId("qewqewqewq"); + qcProCheck.setIsqua("1"); + baseFile.setFileAddress("qwewqewqewqewqewqq"); + if (!qcProCheck.getFactoryId().isEmpty()){ + if (baseFile==null){ + baseFile = new BaseFile(); + qcProCheckService.saveQcProCheck(qcProCheck,baseFile); + } + + if (qcProCheck.getIsqua()=="1"){ + System.out.println("调用下一个接口"); + return R.ok(); + } + else{ + return R.ok(); + } + } + return R.fail(); + } + +}