Browse Source

feat:[资源库管理][仪器管理]稽查轨迹

master
HanLong 2 weeks ago
parent
commit
afd0773495
11 changed files with 439 additions and 35 deletions
  1. +2
    -0
      hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/domain/MpBaseEntity.java
  2. +37
    -18
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/YqController.java
  3. +22
    -3
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Yq.java
  4. +16
    -6
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/YqJcgj.java
  5. +155
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqForm.java
  6. +71
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqSearchForm.java
  7. +9
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IYqJcgjService.java
  8. +5
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IYqService.java
  9. +26
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/YqJcgjServiceImpl.java
  10. +63
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/YqServiceImpl.java
  11. +33
    -7
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/ObjectCompareUtil.java

+ 2
- 0
hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/domain/MpBaseEntity.java View File

@ -2,6 +2,7 @@ package com.hxhq.common.core.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hxhq.common.core.annotation.Excel;
import java.io.Serializable;
import java.util.Date;
@ -39,6 +40,7 @@ public class MpBaseEntity implements Serializable
private Date updateTime;
/** 备注 */
@Excel(name = "备注")
private String remark;
@TableField(value = "del_flag", fill = FieldFill.INSERT)

+ 37
- 18
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/YqController.java View File

@ -1,9 +1,16 @@
package com.hxhq.business.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.hxhq.business.domain.YqJcgj;
import com.hxhq.business.form.yq.YqForm;
import com.hxhq.business.service.IYqJcgjService;
import com.hxhq.common.security.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.hxhq.business.domain.Yq;
import com.hxhq.business.service.IYqService;
@ -20,46 +27,58 @@ import com.hxhq.common.core.web.page.TableDataInfo;
*/
@RestController
@RequestMapping("/business/yq")
public class YqController extends BaseController
{
public class YqController extends BaseController {
@Autowired
private IYqService yqService;
@Autowired
private IYqJcgjService yqJcgjService;
/**
* 查询仪器管理列表
*/
@GetMapping("/list")
public TableDataInfo list(Yq yq)
{
public TableDataInfo list(Yq yq) {
startPage();
List<Yq> list = yqService.queryList(yq);
return getDataTable(list);
}
/**
* 查询仪器稽查轨迹列表
*/
@GetMapping("/jcgj/list")
public TableDataInfo list(Long id) {
if(id == null ) {
return getDataTable(new ArrayList<>());
}
startPage();
YqJcgj yqJcgj = new YqJcgj();
yqJcgj.setYqId(id);
List<YqJcgj> list = yqJcgjService.queryList(yqJcgj);
return getDataTable(list);
}
/**
* 获取仪器管理详细信息
*/
@GetMapping(value = "/info")
public AjaxResult getInfo(Long id)
{
public AjaxResult getInfo(Long id) {
return AjaxResult.success(yqService.getById(id));
}
/**
* 新增仪器管理信息
* 新增编辑仪器管理信息
*/
@PostMapping("/save")
public AjaxResult save(@RequestBody Yq yq)
{
return toAjax(yqService.saveOrUpdate(yq));
public AjaxResult save(@RequestBody @Validated YqForm form) {
// TODO 签名密码校验
if(form.getId() != null) {
yqService.updateYq(form);
} else {
yqService.addYq(form);
}
return success();
}
/**
* 删除仪器管理信息
*/
@PostMapping("/delete")
public AjaxResult delete(@RequestBody Long[] ids)
{
return toAjax(yqService.removeByIds(Arrays.asList(ids)));
}
}

+ 22
- 3
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Yq.java View File

@ -4,6 +4,7 @@ import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hxhq.common.core.annotation.Excel;
import com.hxhq.common.core.domain.MpBaseEntity;
import org.hibernate.validator.constraints.Length;
@ -27,6 +28,7 @@ public class Yq extends MpBaseEntity {
*/
@NotEmpty(message = "请输入仪器名称")
@Length(max = 50, message = "仪器名称不能超过50字")
@Excel(name = "仪器名称")
private String mc;
/**
@ -34,6 +36,7 @@ public class Yq extends MpBaseEntity {
*/
@NotEmpty(message = "请输入仪器编号")
@Length(max = 50, message = "仪器编号不能超过50字")
@Excel(name = "仪器编号")
private String bh;
/**
@ -41,6 +44,7 @@ public class Yq extends MpBaseEntity {
*/
@NotEmpty(message = "请输入仪器型号")
@Length(max = 50, message = "仪器型号不能超过50字")
@Excel(name = "仪器型号")
private String xh;
/**
@ -48,6 +52,7 @@ public class Yq extends MpBaseEntity {
*/
@NotEmpty(message = "请输入仪器来源")
@Length(max = 50, message = "仪器来源不能超过50字")
@Excel(name = "仪器来源")
private String ly;
/**
@ -55,6 +60,7 @@ public class Yq extends MpBaseEntity {
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@NotNull(message = "请选择校准日期")
@Excel(name = "下次校准日期")
private Date jzrq;
/**
@ -63,11 +69,17 @@ public class Yq extends MpBaseEntity {
@NotNull(message = "请选择所属部门")
private Long bmId;
/** 部门名称 */
@Excel(name = "所属部门")
private String bmMc;
/**
* 温层
*/
@NotNull(message = "请选择所温层")
private Long wc;
@Excel(name = "温层")
private String wc;
public void setMc(String mc) {
@ -118,12 +130,19 @@ public class Yq extends MpBaseEntity {
return bmId;
}
public void setWc(Long wc) {
public void setWc(String wc) {
this.wc = wc;
}
public Long getWc() {
public String getWc() {
return wc;
}
public String getBmMc() {
return bmMc;
}
public void setBmMc(String bmMc) {
this.bmMc = bmMc;
}
}

+ 16
- 6
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/YqJcgj.java View File

@ -19,13 +19,13 @@ public class YqJcgj extends MpBaseEntity
private Long yqId;
/** 稽查轨迹类型 */
private String jcgjlx;
private Integer jcgjlx;
/** 稽查名称 */
private String jcmc;
/** 稽查名称颜色:1:蓝色;3:红色;5:绿色;7:橙色 */
private Long jcmcys;
private Integer jcmcys;
/** 稽查内容 */
private String jcnr;
@ -36,6 +36,9 @@ public class YqJcgj extends MpBaseEntity
/** 签名人id */
private Long qmrId;
/** 签名人名称 */
private String qmrMc;
public void setYqId(Long yqId)
{
@ -47,12 +50,12 @@ public class YqJcgj extends MpBaseEntity
return yqId;
}
public void setJcgjlx(String jcgjlx)
public void setJcgjlx(Integer jcgjlx)
{
this.jcgjlx = jcgjlx;
}
public String getJcgjlx()
public Integer getJcgjlx()
{
return jcgjlx;
}
@ -67,12 +70,12 @@ public class YqJcgj extends MpBaseEntity
return jcmc;
}
public void setJcmcys(Long jcmcys)
public void setJcmcys(Integer jcmcys)
{
this.jcmcys = jcmcys;
}
public Long getJcmcys()
public Integer getJcmcys()
{
return jcmcys;
}
@ -107,4 +110,11 @@ public class YqJcgj extends MpBaseEntity
return qmrId;
}
public String getQmrMc() {
return qmrMc;
}
public void setQmrMc(String qmrMc) {
this.qmrMc = qmrMc;
}
}

+ 155
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqForm.java View File

@ -0,0 +1,155 @@
package com.hxhq.business.form.yq;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hxhq.common.core.annotation.Excel;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
public class YqForm {
private Long id;
@NotEmpty(message = "请输入仪器名称")
@Length(max = 50, message = "仪器名称不能超过50字")
@Excel(name = "仪器名称")
private String mc;
/**
* 编号
*/
@NotEmpty(message = "请输入仪器编号")
@Length(max = 50, message = "仪器编号不能超过50字")
@Excel(name = "仪器编号")
private String bh;
/**
* 型号
*/
@NotEmpty(message = "请输入仪器型号")
@Length(max = 50, message = "仪器型号不能超过50字")
@Excel(name = "仪器型号")
private String xh;
/**
* 来源
*/
@NotEmpty(message = "请输入仪器来源")
@Length(max = 50, message = "仪器来源不能超过50字")
@Excel(name = "仪器来源")
private String ly;
/**
* 校准日期
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@NotNull(message = "请选择校准日期")
@Excel(name = "下次校准日期")
private Date jzrq;
/** 部门名称 */
@NotEmpty(message = "请选择所属部门")
@Excel(name = "所属部门")
private String bmMc;
/**
* 温层
*/
@NotNull(message = "请选择所温层")
@Excel(name = "温层")
private String wc;
/** 备注 */
@Length(max = 500, message = "备注不能超过500字")
private String remark;
/** 签名人密码 */
@NotNull(message = "请输入签名人密码")
private String qmrmm;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMc() {
return mc;
}
public void setMc(String mc) {
this.mc = mc;
}
public String getBh() {
return bh;
}
public void setBh(String bh) {
this.bh = bh;
}
public String getXh() {
return xh;
}
public void setXh(String xh) {
this.xh = xh;
}
public String getLy() {
return ly;
}
public void setLy(String ly) {
this.ly = ly;
}
public Date getJzrq() {
return jzrq;
}
public void setJzrq(Date jzrq) {
this.jzrq = jzrq;
}
public String getBmMc() {
return bmMc;
}
public void setBmMc(String bmMc) {
this.bmMc = bmMc;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getQmrmm() {
return qmrmm;
}
public void setQmrmm(String qmrmm) {
this.qmrmm = qmrmm;
}
public String getWc() {
return wc;
}
public void setWc(String wc) {
this.wc = wc;
}
}

+ 71
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqSearchForm.java View File

@ -0,0 +1,71 @@
package com.hxhq.business.form.yq;
/** 仪器列表搜索 */
public class YqSearchForm {
/** 名称 */
private String mc;
/** 编号 */
private String bh;
/** 失效日期开始 */
private String startDate;
/** 失效日期结束 */
private String endDate;
/** 制剂状态:1:入库;3:已发放;5:已锁定;7:待归档;9:归档;11:待解档 */
private Integer zjzt;
/** 借阅状态 1:未借阅 3:待借阅 5:借阅中 */
private Integer jyzt;
public String getMc() {
return mc;
}
public void setMc(String mc) {
this.mc = mc;
}
public String getBh() {
return bh;
}
public void setBh(String bh) {
this.bh = bh;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public Integer getZjzt() {
return zjzt;
}
public void setZjzt(Integer zjzt) {
this.zjzt = zjzt;
}
public Integer getJyzt() {
return jyzt;
}
public void setJyzt(Integer jyzt) {
this.jyzt = jyzt;
}
}

+ 9
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IYqJcgjService.java View File

@ -20,4 +20,13 @@ public interface IYqJcgjService extends IService
*/
public List<YqJcgj> queryList(YqJcgj yqJcgj);
/**
* 新增稽查轨迹
* @param yqId 仪器id
* @param jcgjlx 稽查轨迹类型:1:流程3编辑
* @param jcmc 稽查名称
* @param jcmcys 稽查名称颜色1蓝色3红色5绿色7橙色
* @param jcnr 稽查内容
*/
public void saveJcgj(Long yqId, Integer jcgjlx, String jcmc, Integer jcmcys, String jcnr);
}

+ 5
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IYqService.java View File

@ -3,6 +3,7 @@ package com.hxhq.business.service;
import java.util.List;
import com.hxhq.business.domain.Yq;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hxhq.business.form.yq.YqForm;
/**
* 仪器管理Service接口
@ -20,4 +21,8 @@ public interface IYqService extends IService
*/
public List<Yq> queryList(Yq yq);
/** 新增仪器信息 */
void addYq(YqForm yqForm);
void updateYq(YqForm yqForm);
}

+ 26
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/YqJcgjServiceImpl.java View File

@ -1,8 +1,14 @@
package com.hxhq.business.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.business.domain.MjyJcgj;
import com.hxhq.common.core.domain.MpBaseEntity;
import com.hxhq.common.security.utils.SecurityUtils;
import com.hxhq.system.api.domain.SysUser;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.YqJcgjMapper;
import com.hxhq.business.domain.YqJcgj;
@ -18,6 +24,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class YqJcgjServiceImpl extends ServiceImpl<YqJcgjMapper, YqJcgj> implements IYqJcgjService
{
/**
* 查询仪器管理-稽查轨迹列表
*
@ -27,8 +34,26 @@ public class YqJcgjServiceImpl extends ServiceImpl impleme
@Override
public List<YqJcgj> queryList(YqJcgj yqJcgj)
{
QueryWrapper<YqJcgj> queryWrapper = Wrappers.query();
LambdaQueryWrapper<YqJcgj> queryWrapper = new LambdaQueryWrapper<>();
if(yqJcgj.getId() != null) {
queryWrapper.eq(YqJcgj::getYqId, yqJcgj.getId());
}
queryWrapper.orderByDesc(MpBaseEntity::getCreateTime);
return this.list(queryWrapper);
}
@Override
public void saveJcgj(Long yqId, Integer jcgjlx, String jcmc, Integer jcmcys, String jcnr) {
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
YqJcgj yqJcgj = new YqJcgj();
yqJcgj.setYqId(yqId);
yqJcgj.setJcgjlx(jcgjlx);
yqJcgj.setJcmc(jcmc);
yqJcgj.setJcmcys(jcmcys);
yqJcgj.setJcnr(jcnr);
yqJcgj.setQmrId(sysUser.getUserId());
yqJcgj.setQmrMc(sysUser.getNickName());
this.save(yqJcgj);
}
}

+ 63
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/YqServiceImpl.java View File

@ -1,13 +1,30 @@
package com.hxhq.business.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.business.domain.MjyJcgj;
import com.hxhq.business.domain.YqJcgj;
import com.hxhq.business.enums.zykgl.JcgjlxEnum;
import com.hxhq.business.enums.zykgl.JcmcysEnum;
import com.hxhq.business.form.yq.YqForm;
import com.hxhq.business.service.IYqJcgjService;
import com.hxhq.business.utils.ObjectCompareUtil;
import com.hxhq.common.core.exception.ServiceException;
import com.hxhq.common.security.utils.SecurityUtils;
import com.hxhq.system.api.domain.SysUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.YqMapper;
import com.hxhq.business.domain.Yq;
import com.hxhq.business.service.IYqService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
/**
* 仪器管理Service业务层处理
@ -18,6 +35,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class YqServiceImpl extends ServiceImpl<YqMapper, Yq> implements IYqService
{
@Autowired
private IYqJcgjService yqJcgjService;
/**
* 查询仪器管理列表
*
@ -31,4 +51,47 @@ public class YqServiceImpl extends ServiceImpl implements IYqServi
return this.list(queryWrapper);
}
@Override
public void addYq(YqForm yqForm) {
Yq yq = new Yq();
BeanUtils.copyProperties(yqForm, yq);
save(yq);
yqJcgjService.saveJcgj(yq.getId(), JcgjlxEnum.bj.getValue(), "新增仪器", JcmcysEnum.blue.getValue(), null);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateYq(YqForm yqForm) {
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
Yq yq = getById(yqForm.getId());
if(yq == null) {
throw new ServiceException("仪器不存在或已删除");
}
List<ObjectCompareUtil.FieldChange> fieldChanges = ObjectCompareUtil.compareObjects(yq, yqForm);
if (fieldChanges.size() == 0) {
throw new SecurityException("你没有修改任何内容");
}
BeanUtils.copyProperties(yqForm, yq);
updateById(yq);
// 稽查轨迹
List<YqJcgj> yqJcgjList = new ArrayList<>();
for (ObjectCompareUtil.FieldChange fieldChange : fieldChanges) {
YqJcgj yqJcgj = new YqJcgj();
yqJcgj.setYqId(yq.getId());
yqJcgj.setJcgjlx(JcgjlxEnum.bj.getValue());
yqJcgj.setJcmc("编辑仪器");
yqJcgj.setQmyy("编辑");
yqJcgj.setJcmcys(JcmcysEnum.orange.getValue());
yqJcgj.setJcnr(fieldChange.toString());
yqJcgj.setQmrId(sysUser.getUserId());
yqJcgj.setQmrMc(sysUser.getNickName());
yqJcgjList.add(yqJcgj);
}
yqJcgjService.saveBatch(yqJcgjList);
}
}

+ 33
- 7
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/ObjectCompareUtil.java View File

@ -1,6 +1,7 @@
package com.hxhq.business.utils;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.common.core.utils.StringUtils;
import org.slf4j.Logger;
@ -54,18 +55,38 @@ public class ObjectCompareUtil {
Object oldValue = field.get(oldObj);
String oldValueStr = "";
String newValueStr = "";
if (field.getType().getName().equals("java.util.Date")) {
oldValueStr = autoConvert(oldValue, "yyyy-MM-dd HH:mm:ss");
if(oldValue == null) {
oldValueStr = "";
} else {
oldValueStr = oldValue.toString();
if (field.getType().getName().equals("java.util.Date")) {
JsonFormat annotation = field.getAnnotation(JsonFormat.class);
if(annotation != null && StringUtils.isNotEmpty(annotation.pattern())) {
oldValueStr = autoConvert(oldValue, annotation.pattern());
} else {
oldValueStr = autoConvert(oldValue, "yyyy-MM-dd HH:mm:ss");
}
} else {
oldValueStr = oldValue.toString();
}
}
try {
Object newValue = JSONObject.parseObject(JSONObject.toJSONString(newObj)).get(name);
if (field.getType().getName().equals("java.util.Date")) {
newValueStr = autoConvert(newValue, "yyyy-MM-dd HH:mm:ss");
if(newValue == null) {
newValueStr = "";
} else {
newValueStr = newValue.toString();
if (field.getType().getName().equals("java.util.Date")) {
JsonFormat annotation = field.getAnnotation(JsonFormat.class);
if(annotation != null && StringUtils.isNotEmpty(annotation.pattern())) {
newValueStr = autoConvert(newValue, annotation.pattern());
} else {
newValueStr = autoConvert(newValue, "yyyy-MM-dd HH:mm:ss");
}
} else {
newValueStr = newValue.toString();
}
}
if (StringUtils.isNoneBlank(oldValueStr) && StringUtils.isNoneBlank(newValueStr)) {
// 对比字段值
if (!Objects.equals(oldValue, newValue)) {
@ -208,7 +229,12 @@ public class ObjectCompareUtil {
@Override
public String toString() {
return String.format("字段名:%s;原值:%s;新值:%s", fieldLabel, oldValue, newValue);
Map<String, Object> map = new HashMap<>();
map.put("字段名", fieldLabel);
map.put("原值", oldValue);
map.put("新值", newValue);
return JSONObject.toJSONString(map);
//return String.format("字段名:%s;原值:%s;新值:%s", fieldLabel, oldValue, newValue);
}
}

Loading…
Cancel
Save