diff --git a/haiwei-activiti/src/main/java/com/haiwei/activiti/controller/ExperimentRequestController.java b/haiwei-activiti/src/main/java/com/haiwei/activiti/controller/ExperimentRequestController.java index 10e3a67..6898e03 100644 --- a/haiwei-activiti/src/main/java/com/haiwei/activiti/controller/ExperimentRequestController.java +++ b/haiwei-activiti/src/main/java/com/haiwei/activiti/controller/ExperimentRequestController.java @@ -1,6 +1,9 @@ package com.haiwei.activiti.controller; import java.util.List; + +import com.haiwei.activiti.domain.ExperimentRequestRelation; +import com.haiwei.activiti.service.IExperimentRequestRelationService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -21,9 +24,9 @@ import com.haiwei.common.core.page.TableDataInfo; /** * 实验申请信息Controller - * + * * @author wangg - * @date 2024-09-25 + * @date 2024-12-31 */ @Controller @RequestMapping("/activiti/experiment_request") @@ -34,6 +37,9 @@ public class ExperimentRequestController extends BaseController @Autowired private IExperimentRequestService experimentRequestService; + @Autowired + private IExperimentRequestRelationService experimentRequestRelationService; + @RequiresPermissions("activiti:experiment_request:view") @GetMapping() public String experiment_request() @@ -89,18 +95,60 @@ public class ExperimentRequestController extends BaseController return toAjax(experimentRequestService.insertExperimentRequest(experimentRequest)); } + + /** - * 修改实验申请信息 + * 删除实验申请信息 */ + @RequiresPermissions("activiti:experiment_request:remove") + @Log(title = "实验申请信息", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(experimentRequestService.deleteExperimentRequestByIds(ids)); + } + +/* *//** + * 删除实验申请信息 + *//* + @RequiresPermissions("activiti:experiment_request:remove") + @Log(title = "实验申请信息", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(Long id) + { + return toAjax(experimentRequestService.deleteExperimentRequestById(id)); + }*/ + + + + /** + * 查询实验时间列表 + */ + @RequiresPermissions("activiti:experiment_request:list") + @PostMapping("/getTimeList/{objid}") + @ResponseBody + public AjaxResult getTimeList(@PathVariable("objid") Long objid) + { + ExperimentRequestRelation experimentRequestRelation = new ExperimentRequestRelation(); + experimentRequestRelation.setPojectId(objid); + List timeList = experimentRequestRelationService.selectExperimentRequestRelationList(experimentRequestRelation); + return AjaxResult.success(timeList); + } + + +/* *//** + * 修改实验申请信息 + *//* @GetMapping("/edit/{objid}") public String edit(@PathVariable("objid") Long objid, ModelMap mmap) { ExperimentRequest experimentRequest = experimentRequestService.selectExperimentRequestById(objid); mmap.put("experimentRequest", experimentRequest); - return prefix + "/edit"; - } - - /** + return prefix + "/editDesc"; + }*/ +/** * 修改保存实验申请信息 */ @RequiresPermissions("activiti:experiment_request:edit") @@ -112,15 +160,64 @@ public class ExperimentRequestController extends BaseController return toAjax(experimentRequestService.updateExperimentRequest(experimentRequest)); } + /** - * 删除实验申请信息 + * 修改实验申请信息 */ - @RequiresPermissions("activiti:experiment_request:remove") - @Log(title = "实验申请信息", businessType = BusinessType.DELETE) - @PostMapping( "/remove") - @ResponseBody - public AjaxResult remove(String ids) + @GetMapping("/edit/{objid}") + public String edit(@PathVariable("objid") Long objid, ModelMap mmap) { - return toAjax(experimentRequestService.deleteExperimentRequestByIds(ids)); + ExperimentRequest experimentRequest = experimentRequestService.selectExperimentRequestById(objid); + mmap.put("experimentRequest", experimentRequest); + return prefix + "/edit"; + } + + /** + * 修改实验申请信息 + */ + @GetMapping("/editDesc/{objid}") + public String editDesc(@PathVariable("objid") Long objid, ModelMap mmap) + { + ExperimentRequest experimentRequest = experimentRequestService.selectExperimentRequestById(objid); + experimentRequest.setStatus(2L); + mmap.put("experimentRequest", experimentRequest); + return prefix + "/editDesc"; } + + /** + * 修改实验申请信息 + */ + @GetMapping("/editExperimentContent/{objid}") + public String editExperimentContent(@PathVariable("objid") Long objid, ModelMap mmap) + { + ExperimentRequest experimentRequest = experimentRequestService.selectExperimentRequestById(objid); + experimentRequest.setStatus(1L); + mmap.put("experimentRequest", experimentRequest); + return prefix + "/editExperimentContent"; + } + + /** + * 修改实验申请信息 + */ + @GetMapping("/editCommunicationContent/{objid}") + public String editCommunicationContent(@PathVariable("objid") Long objid, ModelMap mmap) + { + ExperimentRequest experimentRequest = experimentRequestService.selectExperimentRequestById(objid); + experimentRequest.setStatus(4L); + mmap.put("experimentRequest", experimentRequest); + return prefix + "/editCommunicationContent"; + } + + /** + * 修改实验申请信息 + */ + @GetMapping("/editTools/{objid}") + public String editTools(@PathVariable("objid") Long objid, ModelMap mmap) + { + ExperimentRequest experimentRequest = experimentRequestService.selectExperimentRequestById(objid); + experimentRequest.setStatus(3L); + mmap.put("experimentRequest", experimentRequest); + return prefix + "/editTools"; + } + } diff --git a/haiwei-activiti/src/main/java/com/haiwei/activiti/domain/ExperimentRequest.java b/haiwei-activiti/src/main/java/com/haiwei/activiti/domain/ExperimentRequest.java index c2c7cbd..91da31d 100644 --- a/haiwei-activiti/src/main/java/com/haiwei/activiti/domain/ExperimentRequest.java +++ b/haiwei-activiti/src/main/java/com/haiwei/activiti/domain/ExperimentRequest.java @@ -8,9 +8,9 @@ import com.haiwei.common.core.domain.BaseEntity; /** * 实验申请信息对象 experiment_request - * + * * @author wangg - * @date 2024-09-25 + * @date 2024-12-31 */ public class ExperimentRequest extends BaseEntity { @@ -38,112 +38,171 @@ public class ExperimentRequest extends BaseEntity /** 使用的设备名称 */ @Excel(name = "使用的设备名称") private String deviceName; - private String device2Name; - /** 实验内容 */ - @Excel(name = "实验内容") + /** 实验方案 */ + @Excel(name = "实验方案") private String experimentDesc; /** 实验申请流程ID */ private Long processId; + /** 实验设备2 */ + private String device2Name; - public String getDevice2Name() { - return device2Name; - } + /** 实验内容 */ + @Excel(name = "实验内容") + private String experimentContent; - public void setDevice2Name(String device2Name) { - this.device2Name = device2Name; - } + /** 准备工具 */ + @Excel(name = "准备工具") + private String preparationTools; + + /** 交流内容 */ + @Excel(name = "交流内容") + private String communicationContent; + + /** 实验请求状态 */ + @Excel(name = "实验请求状态") + private Long status; public void setObjid(Long objid) { this.objid = objid; } - public Long getObjid() + public Long getObjid() { return objid; } - public void setCustomerName(String customerName) + public void setCustomerName(String customerName) { this.customerName = customerName; } - public String getCustomerName() + public String getCustomerName() { return customerName; } - public void setProjectName(String projectName) + public void setProjectName(String projectName) { this.projectName = projectName; } - public String getProjectName() + public String getProjectName() { return projectName; } - public void setCreationTime(Date creationTime) + public void setCreationTime(Date creationTime) { this.creationTime = creationTime; } - public Date getCreationTime() + public Date getCreationTime() { return creationTime; } - public void setExecutionTime(Date executionTime) + public void setExecutionTime(Date executionTime) { this.executionTime = executionTime; } - public Date getExecutionTime() + public Date getExecutionTime() { return executionTime; } - public void setDeviceName(String deviceName) + public void setDeviceName(String deviceName) { this.deviceName = deviceName; } - public String getDeviceName() + public String getDeviceName() { return deviceName; } - public void setExperimentDesc(String experimentDesc) + public void setExperimentDesc(String experimentDesc) { this.experimentDesc = experimentDesc; } - public String getExperimentDesc() + public String getExperimentDesc() { return experimentDesc; } - public void setProcessId(Long processId) + public void setProcessId(Long processId) { this.processId = processId; } - public Long getProcessId() + public Long getProcessId() { return processId; } + public void setDevice2Name(String device2Name) + { + this.device2Name = device2Name; + } + + public String getDevice2Name() + { + return device2Name; + } + public void setExperimentContent(String experimentContent) + { + this.experimentContent = experimentContent; + } + + public String getExperimentContent() + { + return experimentContent; + } + public void setPreparationTools(String preparationTools) + { + this.preparationTools = preparationTools; + } + + public String getPreparationTools() + { + return preparationTools; + } + public void setCommunicationContent(String communicationContent) + { + this.communicationContent = communicationContent; + } + + public String getCommunicationContent() + { + return communicationContent; + } + public void setStatus(Long status) + { + this.status = status; + } + + public Long getStatus() + { + return status; + } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("objid", getObjid()) - .append("customerName", getCustomerName()) - .append("projectName", getProjectName()) - .append("creationTime", getCreationTime()) - .append("executionTime", getExecutionTime()) - .append("deviceName", getDeviceName()) - .append("experimentDesc", getExperimentDesc()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("processId", getProcessId()) - .toString(); + .append("objid", getObjid()) + .append("customerName", getCustomerName()) + .append("projectName", getProjectName()) + .append("creationTime", getCreationTime()) + .append("executionTime", getExecutionTime()) + .append("deviceName", getDeviceName()) + .append("experimentDesc", getExperimentDesc()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("processId", getProcessId()) + .append("device2Name", getDevice2Name()) + .append("experimentContent", getExperimentContent()) + .append("preparationTools", getPreparationTools()) + .append("communicationContent", getCommunicationContent()) + .append("status", getStatus()) + .toString(); } } diff --git a/haiwei-activiti/src/main/java/com/haiwei/activiti/service/impl/ExperimentRequestServiceImpl.java b/haiwei-activiti/src/main/java/com/haiwei/activiti/service/impl/ExperimentRequestServiceImpl.java index 8e2224f..588bfd8 100644 --- a/haiwei-activiti/src/main/java/com/haiwei/activiti/service/impl/ExperimentRequestServiceImpl.java +++ b/haiwei-activiti/src/main/java/com/haiwei/activiti/service/impl/ExperimentRequestServiceImpl.java @@ -1,6 +1,11 @@ package com.haiwei.activiti.service.impl; +import java.util.Date; import java.util.List; +import java.util.Objects; + +import com.haiwei.activiti.domain.ExperimentRequestRelation; +import com.haiwei.activiti.mapper.ExperimentRequestRelationMapper; import com.haiwei.common.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -9,21 +14,28 @@ import com.haiwei.activiti.domain.ExperimentRequest; import com.haiwei.activiti.service.IExperimentRequestService; import com.haiwei.common.core.text.Convert; +import com.haiwei.framework.util.ShiroUtils; +import org.apache.shiro.subject.Subject; +import org.springframework.transaction.annotation.Transactional; + /** * 实验申请信息Service业务层处理 - * + * * @author wangg * @date 2024-09-25 */ @Service -public class ExperimentRequestServiceImpl implements IExperimentRequestService +public class ExperimentRequestServiceImpl implements IExperimentRequestService { @Autowired private ExperimentRequestMapper experimentRequestMapper; + @Autowired + private ExperimentRequestRelationMapper experimentRequestRelationMapper; + /** * 查询实验申请信息 - * + * * @param objid 实验申请信息ID * @return 实验申请信息 */ @@ -35,7 +47,7 @@ public class ExperimentRequestServiceImpl implements IExperimentRequestService /** * 查询实验申请信息列表 - * + * * @param experimentRequest 实验申请信息 * @return 实验申请信息 */ @@ -47,51 +59,132 @@ public class ExperimentRequestServiceImpl implements IExperimentRequestService /** * 新增实验申请信息 - * + * * @param experimentRequest 实验申请信息 * @return 结果 */ + /** + * 插入实验请求的方法 + * @param experimentRequest 实验请求对象 + * @return 插入操作的结果,返回影响的行数 + */ + @Transactional @Override - public int insertExperimentRequest(ExperimentRequest experimentRequest) - { + public int insertExperimentRequest(ExperimentRequest experimentRequest) { + // 设置实验请求的状态为1 + experimentRequest.setStatus(1L); + // 设置实验请求的创建时间为当前时间 experimentRequest.setCreationTime(DateUtils.getNowDate()); - return experimentRequestMapper.insertExperimentRequest(experimentRequest); + +/* + useGeneratedKeys="true":表示启用主键回填。 + keyProperty="objid":指定将生成的主键值回填到 ExperimentRequest 对象的 objid 属性。*/ + // experimentRequest的主键objId为null,将实验请求插入数据库,objId主键自动生成 + int i = experimentRequestMapper.insertExperimentRequest(experimentRequest); + // 获取第一个实验请求的主键objId + Long obj = experimentRequest.getObjid(); + + + // 创建实验请求关系对象 + ExperimentRequestRelation experimentRequestRelation = new ExperimentRequestRelation(); + // 设置项目ID为查询到的对象ID + experimentRequestRelation.setPojectId(obj); + // 设置实验请求关系的状态为1(表示新建) + experimentRequestRelation.setStatus(1L); + // 设置实验请求关系的更新时间为实验请求的创建时间 + experimentRequestRelation.setUpdateTime(experimentRequest.getCreationTime()); + + // 将实验请求关系插入数据库 + experimentRequestRelationMapper.insertExperimentRequestRelation(experimentRequestRelation); + + // 返回插入操作影响的行数 + return i; } + + + + + /** * 修改实验申请信息 - * + * * @param experimentRequest 实验申请信息 * @return 结果 */ + @Transactional( rollbackFor = Exception.class ) @Override - public int updateExperimentRequest(ExperimentRequest experimentRequest) - { - experimentRequest.setUpdateTime(DateUtils.getNowDate()); + public int updateExperimentRequest(ExperimentRequest experimentRequest) { + Date nowDate = DateUtils.getNowDate(); + + // 获取当前用户的主体信息 + Subject subject = ShiroUtils.getSubject(); + + // 创建一个新的实验请求关系对象 + ExperimentRequestRelation experimentRequestRelation = new ExperimentRequestRelation(); + + // 设置项目ID为实验请求对象的ID + experimentRequestRelation.setPojectId(experimentRequest.getObjid()); + + // 设置状态为实验请求对象的状态 + experimentRequestRelation.setStatus(experimentRequest.getStatus()); + + // 根据实验请求关系对象查询相关记录列表 + List timeList = experimentRequestRelationMapper + .selectExperimentRequestRelationList(experimentRequestRelation); + + // 如果查询结果不为空,则进行更新操作 + if (!timeList.isEmpty()) { + // 设置更新时间为当前时间 + experimentRequestRelation.setUpdateTime(nowDate); + + // 设置对象ID为查询到的第一条记录的对象ID + experimentRequestRelation.setObjId(timeList.get(0).getObjId()); + + // 更新实验请求关系记录 + experimentRequestRelationMapper.updateExperimentRequestRelation(experimentRequestRelation); + + } else { + // 如果查询结果为空,则进行插入操作 + // 设置更新时间为当前时间 + experimentRequestRelation.setUpdateTime(nowDate); + + // 插入新的实验请求关系记录 + experimentRequestRelationMapper.insertExperimentRequestRelation(experimentRequestRelation); + } + + // 设置实验请求对象的更新时间为当前时间 + experimentRequest.setUpdateTime(nowDate); + + // 更新实验请求记录并返回受影响的行数 return experimentRequestMapper.updateExperimentRequest(experimentRequest); } /** * 删除实验申请信息对象 - * + * * @param ids 需要删除的数据ID * @return 结果 */ + @Transactional @Override public int deleteExperimentRequestByIds(String ids) { + experimentRequestRelationMapper.deleteExperimentRequestRelationByProjectIds(Convert.toStrArray(ids)); return experimentRequestMapper.deleteExperimentRequestByIds(Convert.toStrArray(ids)); } /** * 删除实验申请信息信息 - * + * * @param objid 实验申请信息ID * @return 结果 */ + @Transactional @Override public int deleteExperimentRequestById(Long objid) { + experimentRequestRelationMapper.deleteExperimentRequestRelationByProjectId(objid); return experimentRequestMapper.deleteExperimentRequestById(objid); } } diff --git a/haiwei-activiti/src/main/resources/mapper/activiti/ExperimentRequestMapper.xml b/haiwei-activiti/src/main/resources/mapper/activiti/ExperimentRequestMapper.xml index c6b62c7..004405a 100644 --- a/haiwei-activiti/src/main/resources/mapper/activiti/ExperimentRequestMapper.xml +++ b/haiwei-activiti/src/main/resources/mapper/activiti/ExperimentRequestMapper.xml @@ -11,17 +11,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + + + - select objid, customer_name, project_name, creation_time, execution_time, device_name,device2_name, experiment_desc, create_by, create_time, update_by, update_time, process_id from experiment_request + select objid, customer_name, project_name, creation_time, execution_time, device_name, experiment_desc, create_by, create_time, update_by, update_time, process_id, device2_name, experiment_content, preparation_tools, communication_content, status from experiment_request @@ -42,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where objid = #{objid} - + insert into experiment_request objid, @@ -51,14 +54,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" creation_time, execution_time, device_name, - device2_name, experiment_desc, create_by, create_time, update_by, update_time, process_id, - + device2_name, + experiment_content, + preparation_tools, + communication_content, + status, + #{objid}, #{customerName}, @@ -66,14 +73,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{creationTime}, #{executionTime}, #{deviceName}, - #{device2Name}, #{experimentDesc}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{processId}, - + #{device2Name}, + #{experimentContent}, + #{preparationTools}, + #{communicationContent}, + #{status}, + @@ -84,13 +95,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" creation_time = #{creationTime}, execution_time = #{executionTime}, device_name = #{deviceName}, - device2_name = #{device2Name}, experiment_desc = #{experimentDesc}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, process_id = #{processId}, + device2_name = #{device2Name}, + experiment_content = #{experimentContent}, + preparation_tools = #{preparationTools}, + communication_content = #{communicationContent}, + status = #{status}, where objid = #{objid} diff --git a/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/add.html b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/add.html index c3178a7..5f46dde 100644 --- a/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/add.html +++ b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/add.html @@ -62,12 +62,17 @@ -
+ +
+ +
+ +
@@ -97,4 +102,4 @@ }); - \ No newline at end of file + diff --git a/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editCommunicationContent.html b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editCommunicationContent.html new file mode 100644 index 0000000..56d5997 --- /dev/null +++ b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editCommunicationContent.html @@ -0,0 +1,145 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+ + +
+
+
+ + + +
+ +
+ + +
+ + + +
+ +
+ + + +
+ +
+ +
+
+ + +
+ +
+ + +
+
+ + + +
+ + + + + diff --git a/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editDesc.html b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editDesc.html new file mode 100644 index 0000000..1b624c4 --- /dev/null +++ b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editDesc.html @@ -0,0 +1,147 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+ + +
+
+
+ + + +
+ +
+ + +
+ + + +
+ +
+ +
+ +
+ +
+
+ + + + +
+ +
+ + +
+
+ + + +
+ + + + + diff --git a/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editExperimentContent.html b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editExperimentContent.html new file mode 100644 index 0000000..b2ad1bc --- /dev/null +++ b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editExperimentContent.html @@ -0,0 +1,145 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+ + +
+
+
+ + + +
+ +
+ + +
+ + + +
+ +
+ + + +
+ +
+ +
+
+ + + +
+ +
+ + +
+
+ + + +
+ + + + + diff --git a/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editTools.html b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editTools.html new file mode 100644 index 0000000..2eab097 --- /dev/null +++ b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/editTools.html @@ -0,0 +1,141 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+ + +
+
+
+ + + +
+ +
+ + +
+ + +
+ +
+ + + +
+ +
+ +
+
+ + + +
+ +
+ + +
+
+ + + +
+ + + + + diff --git a/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/experiment_request.html b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/experiment_request.html index 288496d..8020edc 100644 --- a/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/experiment_request.html +++ b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/experiment_request.html @@ -2,6 +2,10 @@ + + + +
@@ -65,6 +69,65 @@ 导出
+ + + + + + + +
@@ -72,15 +135,112 @@
- \ No newline at end of file + diff --git a/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/timeList.html b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/timeList.html new file mode 100644 index 0000000..50301e8 --- /dev/null +++ b/haiwei-activiti/src/main/resources/templates/activiti/experiment_request/timeList.html @@ -0,0 +1,111 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + + - + +
  • +
  • + + +
  • +
  • + 搜索 + 重置 +
  • +
+
+
+
+ + +
+
+
+
+
+ + + +