app试验管理、审查管理、检测报告管理、合格证管理

This commit is contained in:
hayu 2024-08-15 20:15:04 +08:00
parent 66652b9915
commit 3220ec32c7
33 changed files with 1394 additions and 155 deletions

View File

@ -0,0 +1,177 @@
package com.bonus.aqgqj.app.controller;
import com.bonus.aqgqj.annotation.DecryptAndVerify;
import com.bonus.aqgqj.annotation.LogAnnotation;
import com.bonus.aqgqj.app.entity.SamplesManageAppVo;
import com.bonus.aqgqj.app.service.CertificateAppService;
import com.bonus.aqgqj.app.service.SamplesManageAppService;
import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.utils.ServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 合格证管理--app
* @author hay
*/
@Api(tags = "合格证管理")
@RestController
@RequestMapping("/app/certificate/")
public class CertificateAppController {
private static final Logger log = LoggerFactory.getLogger("adminLogger");
@Autowired
private CertificateAppService service;
@PostMapping(value = "getList")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "app合格证管理", operation = "查询列表", operDesc = "业务级事件",operType="查询")
// @PreAuthorize("@pms.hasPermission('sys:samples:query')" )
public ServerResponse getList(EncryptedReq<SamplesManageAppVo> data) {
PageHelper.startPage(data.getData().getPage(), data.getData().getLimit());
try {
List<SamplesManageAppVo> list = service.list(data.getData());
PageInfo<SamplesManageAppVo> pageInfo = new PageInfo<>(list);
return ServerResponse.createSuccessPage(pageInfo,data.getData().getPage(),data.getData().getLimit());
} catch (Exception e) {
log.error(e.toString(),e);
}
return ServerResponse.createErrorPage(data.getData().getPage(),data.getData().getLimit());
}
/**
* @description 删除收样列表数据
*/
@PostMapping("delSamplesList")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "收样管理", operation = "删除收样列表数据", operDesc = "业务级事件", operType = "删除")
// @PreAuthorize("@pms.hasPermission('sys:samples:add')")
public ServerResponse delSamplesList(EncryptedReq<SamplesManageAppVo> vo) {
try {
return service.delSamplesList(vo.getData());
}catch (Exception e){
log.error(e.toString(),e);
return ServerResponse.createErroe("操作失败");
}
}
/**
* @description 删除收样详情数据
*/
@PostMapping("delSamplesDetails")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "收样管理", operation = "删除收样详情数据", operDesc = "业务级事件", operType = "删除")
// @PreAuthorize("@pms.hasPermission('sys:samples:add')")
public ServerResponse delSamplesDetails(EncryptedReq<SamplesManageAppVo> vo) {
try {
return service.delSamplesDetails(vo.getData());
}catch (Exception e){
log.error(e.toString(),e);
return ServerResponse.createErroe("操作失败");
}
}
/**
* @description 修改收样信息
*/
@PostMapping("updateSamplesList")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "收样管理", operation = "修改收样信息", operDesc = "业务级事件", operType = "删除")
// @PreAuthorize("@pms.hasPermission('sys:samples:add')")
public ServerResponse updateSamplesList(EncryptedReq<SamplesManageAppVo> vo) {
try {
return service.updateSamplesList(vo.getData());
}catch (Exception e){
log.error(e.toString(),e);
return ServerResponse.createErroe("操作失败");
}
}
@PostMapping(value = "getDetailsList")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "app合格证管理", operation = "详情", operDesc = "业务级事件",operType="查询")
// @PreAuthorize("@pms.hasPermission('sys:samples:query')" )
public ServerResponse getDetailsList(EncryptedReq<SamplesManageAppVo> data) {
PageHelper.startPage(data.getData().getPage(), data.getData().getLimit());
try {
List<SamplesManageAppVo> list = service.getDetailsList(data.getData());
PageInfo<SamplesManageAppVo> pageInfo = new PageInfo<>(list);
return ServerResponse.createSuccessPage(pageInfo,data.getData().getPage(),data.getData().getLimit());
} catch (Exception e) {
log.error(e.toString(),e);
}
return ServerResponse.createErrorPage(data.getData().getPage(),data.getData().getLimit());
}
@PostMapping(value = "getSampleLabelData")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "app收样管理", operation = "收样标签", operDesc = "业务级事件",operType="查询")
// @PreAuthorize("@pms.hasPermission('sys:samples:query')" )
public ServerResponse getSampleLabelData(EncryptedReq<SamplesManageAppVo> data) {
try {
SamplesManageAppVo list = service.getSampleLabelData(data.getData());
return ServerResponse.createSuccess(list);
} catch (Exception e) {
log.error(e.toString(),e);
}
return ServerResponse.createErroe("操作失败");
}
/**
* @description 新增收样数据
*/
@PostMapping("addSamples")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "收样管理", operation = "新增收样数据", operDesc = "业务级事件", operType = "新增")
// @PreAuthorize("@pms.hasPermission('sys:samples:add')")
public ServerResponse addSamples(EncryptedReq<SamplesManageAppVo> vo) {
try {
return service.addSamples(vo.getData());
}catch (Exception e){
log.error(e.toString(),e);
return ServerResponse.createErroe(e.getMessage().toString());
}
}
/**
* @description 派工
*/
@PostMapping("dispatchWork")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "收样管理", operation = "派工", operDesc = "业务级事件", operType = "新增")
// @PreAuthorize("@pms.hasPermission('sys:samples:dispatch')")
public ServerResponse dispatchWork(EncryptedReq<SamplesManageAppVo> vo) {
try {
return service.dispatchWork(vo.getData());
} catch (Exception e) {
log.error(e.toString(), e);
return ServerResponse.createErroe("操作失败");
}
}
@PostMapping(value = "getAuthority")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "收样管理", operation = "查询是否具有派工/收样权限", operDesc = "业务级事件",operType="查询")
// @PreAuthorize("@pms.hasPermission('sys:samples:query')" )
public ServerResponse getAuthority(EncryptedReq<SamplesManageAppVo> data) {
try {
Boolean res = service.getAuthority(data.getData());
return ServerResponse.createSuccess(res);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("操作失败");
}
}

View File

@ -149,12 +149,6 @@ public class PrimaryDataAppController {
sheet = handleNineRow(vo, sheet, commonStyle2, rowNum++, hbNum);
sheet = handleTenRow(vo, sheet, commonStyle, rowNum++, hbNum);
// OutputStream outputStream = new FileOutputStream(uploadPath + "\\" + "原始记录" + ".xlsx");
// wb.write(outputStream);
// outputStream.close();
// byte[] excelBytes = Files.readAllBytes(Paths.get(uploadPath + "\\" + "原始记录" + ".xlsx"));
// String base64Excel = Base64.getEncoder().encodeToString(excelBytes);
// Excel 文档写入字节数组
ByteArrayOutputStream baos = new ByteArrayOutputStream();
wb.write(baos);

View File

@ -140,7 +140,7 @@ public class SamplesManageAppController {
return samplesManageAppService.addSamples(vo.getData());
}catch (Exception e){
log.error(e.toString(),e);
return ServerResponse.createErroe("操作失败");
return ServerResponse.createErroe(e.getMessage().toString());
}
}

View File

@ -11,12 +11,15 @@ import com.bonus.aqgqj.basis.entity.vo.TestVo;
import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.utils.DateTimeHelper;
import com.bonus.aqgqj.utils.ExcelStyleUtil;
import com.bonus.aqgqj.utils.FileUtil;
import com.bonus.aqgqj.utils.ServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import freemarker.template.Configuration;
import freemarker.template.Template;
import io.swagger.annotations.Api;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -36,10 +39,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
@ -251,6 +251,33 @@ public class TestReportManageAppController {
}
}
/**
* 批量下载原始记录压缩文件
*
* @param request
* @param response
* @param dto
* @return void
* @author cwchen
* @date 2024/7/28 17:30
*/
@PostMapping(value = "downLoadExcelZip")
@DecryptAndVerify(decryptedClass = TestReportManageAppVo.class)
public void downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq<TestReportManageAppVo> dto) {
List<String> fileNameList = new ArrayList();
try {
service.downLoadExcelZip(response, dto.getData(),fileNameList);
} catch (Exception e) {
log.error("zip导出错误-异常信息", e);
} finally {
if (CollectionUtils.isNotEmpty(fileNameList)) {
for (String fileName : fileNameList) {
FileUtil.deleteFile(fileName);
}
}
}
}
/**

View File

@ -0,0 +1,128 @@
package com.bonus.aqgqj.app.dao;
import com.bonus.aqgqj.app.entity.SamplesManageAppVo;
import com.bonus.aqgqj.basis.entity.vo.ConfigItemsVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 收样管理
* @author: hay
*/
@Mapper
public interface CertificateAppDao {
/**
* 查询列表
* @param bean
* @return
*/
List<SamplesManageAppVo> list(SamplesManageAppVo bean);
/**
* 获取详情列表
* @param data
* @return
*/
List<SamplesManageAppVo> getDetailsList(SamplesManageAppVo data);
/**
* 新增收样数据 tb_samples
* @param SamplesManageAppVo
* @return
*/
int addSamples(SamplesManageAppVo SamplesManageAppVo);
/**
* 新增设备数据 tb_samples_device
* @param dto
* @return
*/
int addSamplesDevice(SamplesManageAppVo dto);
/**
* 设备类型编码
* @param sampleToolsId
* @return
*/
String getDevTypeCodeById(Integer sampleToolsId);
/**
* 获取设备编码
* @param nowDate
* @return
*/
String selectCustomerCode(String nowDate);
/**
* 修改班组
* @param dto
* @return
*/
int updateTeamId(SamplesManageAppVo dto);
/**
* 获取标签数据
* @param data
* @return
*/
SamplesManageAppVo getSampleLabelData(SamplesManageAppVo data);
/**
* 获取实验项
* @param dto
* @return
*/
List<ConfigItemsVo> getTestItemList(SamplesManageAppVo dto);
/**
* 获取收样批次编号
* @param nowDate
* @return
*/
String selectBatchCode(String nowDate);
/**
* 根据批次编号获取id
* @param batchCode
* @return
*/
Integer getIdByBatchCode(String batchCode);
/**
* 删除收样数据 tb_samples_device
* @param data
* @return
*/
int delSamplesDetails(SamplesManageAppVo data);
/**
* 删除收样数据 tb_samples
* @param data
* @return
*/
int delSamplesList(SamplesManageAppVo data);
/**
* 修改收样数据 tb_samples
* @param data
* @return
*/
int updateSamplesList(SamplesManageAppVo data);
/**
* 删除收样数据 tb_samples_device
* 根据详情id
* @param data
* @return
*/
int delSamplesDetailsList(SamplesManageAppVo data);
/**
* 根据设备编码查询设备数量
* @param devCode
* @return
*/
int getCountByDevCode(String devCode,String sampleTools);
}

View File

@ -90,7 +90,8 @@ public interface ExamineAppMapper {
/**
* 更新收样信息审核的状态
*
* @param userId
* @param isEr
* @param vo
* @param audtiStatus
* @param processStatus
@ -98,7 +99,7 @@ public interface ExamineAppMapper {
* @author cwchen
* @date 2024/7/25 9:41
*/
void updateSampleStatus(@Param("params") AuditHistoryVo vo, @Param("audtiStatus") Integer audtiStatus, @Param("processStatus") Integer processStatus,@Param("isEr")String isEr);
void updateSampleStatus(@Param("params") AuditHistoryVo vo, @Param("audtiStatus") Integer audtiStatus, @Param("processStatus") Integer processStatus,@Param("isEr")String isEr,@Param("userId")Integer userId);
/**
* 获取设备试验项/收样的是否二次审阅的值

View File

@ -393,15 +393,25 @@ public interface ExperimentalAppMapper {
*/
int isNotEditData(List<Long> list);
// /**
// * 更新收样表中的状态为待审阅
// *
// * @param id
// * @return void
// * @author cwchen
// * @date 2024/7/22 15:33
// */
// void updateSampleStatus(Long id);
/**
* 更新收样表中的状态为待审阅
*
* @param id
* @param list
* @return void
* @author cwchen
* @date 2024/7/22 15:33
*/
void updateSampleStatus(Long id);
void updateSampleStatus(List<Long> list);
/**
* 更新试验表中数据为待审阅

View File

@ -31,4 +31,10 @@ public interface QrCodeDao {
*/
List<ConfigItemsVo> getTestItemList(SamplesManageAppVo dto);
/**
* 获取合格证数据
* @param data
* @return
*/
SamplesManageAppVo getCertificateData(SamplesManageAppVo data);
}

View File

@ -125,4 +125,11 @@ public interface SamplesManageAppDao {
* @return
*/
int delSamplesDetailsList(SamplesManageAppVo data);
/**
* 根据设备编码查询设备数量
* @param devCode
* @return
*/
int getCountByDevCode(String devCode,String sampleTools);
}

View File

@ -64,6 +64,27 @@ public class ExperimentalAppVo {
private String audtiStatus;
/**
* 状态 默认0 (实验完成)待提交 1 待审阅 2 待审核 3 待审批 4 审批通过
*/
private Integer status;
/**
* 审核状态 0 待审核 1审核通过 2 审阅不通过 3审核不同过 4审批未通过
*/
private Integer auditStatus;
/**
* 是否二次审阅 null:不是 1.
*/
private Integer isEr;
/**
* 状态结果 待提交待审阅待重新审阅
*/
private String statusResult;
/**
* 备注
*/
@ -80,11 +101,6 @@ public class ExperimentalAppVo {
*/
private String experTime;
/**
* 状态
*/
private Integer status;
/**
* 角色编码
*/

View File

@ -19,6 +19,11 @@ public class SamplesManageAppVo extends PageEntity {
private String ids;
/**
* 收样id
*/
private Integer sampleId;
/**
* 名称
*/
@ -192,4 +197,24 @@ public class SamplesManageAppVo extends PageEntity {
*/
private List<ConfigItemsVo> configItemsVos;
/**
* 送样数量
*/
private Integer customNum;
/**
* 生成时间
*/
private String createTime;
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
}

View File

@ -231,5 +231,4 @@ public class TestReportManageAppVo extends PageEntity {
*/
private String createTime;
}

View File

@ -0,0 +1,75 @@
package com.bonus.aqgqj.app.service;
import com.bonus.aqgqj.app.entity.SamplesManageAppVo;
import com.bonus.aqgqj.utils.ServerResponse;
import java.util.List;
/**
* 收样管理
* @author hay
*/
public interface CertificateAppService {
/**
* 查询列表
* @param bean
* @return
*/
List<SamplesManageAppVo> list(SamplesManageAppVo bean);
/**
* 详情列表
* @param data
* @return
*/
List<SamplesManageAppVo> getDetailsList(SamplesManageAppVo data);
/**
* 新增
* @param data
* @return
*/
ServerResponse addSamples(SamplesManageAppVo data);
/**
* 派工
* @param data
* @return
*/
ServerResponse dispatchWork(SamplesManageAppVo data);
/**
* 查询权限
* @param data
* @return
*/
Boolean getAuthority(SamplesManageAppVo data);
/**
* 收样标签 信息获取
* @param data
* @return
*/
SamplesManageAppVo getSampleLabelData(SamplesManageAppVo data);
/**
* 删除收样列表数据
* @param data
* @return
*/
ServerResponse delSamplesList(SamplesManageAppVo data);
/**
* 修改收样列表数据
* @param data
* @return
*/
ServerResponse updateSamplesList(SamplesManageAppVo data);
/**
* 删除收样详情数据
* @param data
* @return
*/
ServerResponse delSamplesDetails(SamplesManageAppVo data);
}

View File

@ -6,6 +6,7 @@ import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
@ -61,13 +62,6 @@ public interface TestReportManageAppService {
*/
TestReportManageAppVo downloadCertificateList(TestReportManageAppVo data);
/**
* 检测报告下载
* @param data
* @return
*/
ServerResponse download(TestReportManageAppVo data);
/**
* 检测报告下载
* @param request
@ -83,4 +77,12 @@ public interface TestReportManageAppService {
* @return
*/
ServerResponse testReportExcelBase64(TestReportManageAppVo data);
/**
* 检测报告下载
* @param data
* @param response
* @return
*/
void downLoadExcelZip(HttpServletResponse response, TestReportManageAppVo data, List<String> fileNameList);
}

View File

@ -0,0 +1,305 @@
package com.bonus.aqgqj.app.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bonus.aqgqj.app.dao.CertificateAppDao;
import com.bonus.aqgqj.app.entity.SamplesManageAppVo;
import com.bonus.aqgqj.app.service.CertificateAppService;
import com.bonus.aqgqj.app.service.SamplesManageAppService;
import com.bonus.aqgqj.basis.entity.vo.ConfigItemsVo;
import com.bonus.aqgqj.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
* @description 收样管理
* @author hay
* @date 2024/7/20 16:10
*/
@Slf4j
@Service
public class CertificateAppServiceImpl implements CertificateAppService {
@Resource
private CertificateAppDao dao;
/**
* 查询列表
* @param bean
* @return
*/
@Override
public List<SamplesManageAppVo> list(SamplesManageAppVo bean) {
return dao.list(bean);
}
/**
* 查询详情列表
* @param data
* @return
*/
@Override
public List<SamplesManageAppVo> getDetailsList(SamplesManageAppVo data) {
return dao.getDetailsList(data);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse addSamples(SamplesManageAppVo data) {
JSONArray jsonArray = JSONObject.parseArray(data.getParamsList());
List<SamplesManageAppVo> SamplesManageAppVos = jsonArray.toJavaList(SamplesManageAppVo.class);
if (SamplesManageAppVos.size() > 0){
//获取登录人id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
//先查看收样批次编号是否为空
String batchCode = SamplesManageAppVos.get(0).getBatchCode();
if (StringHelper.isEmpty(batchCode)){
//为空则该批次首次上传数据需要新增tb_sample表并且需要生成批次编号
//生成编号
String batchCode2 =batchCodeRule();
SamplesManageAppVos.get(0).setBatchCode(batchCode2);
SamplesManageAppVos.get(0).setCreateBy(userId);
int re= dao.addSamples(SamplesManageAppVos.get(0));
if (re>0){
//添加tb_sample_device数据
Boolean state = addSamplesDevice(SamplesManageAppVos);
if (state){
return ServerResponse.createBySuccessMsg(batchCode2);
}
}else {
throw new RuntimeException("收样单位信息表添加失败");
}
}else {
//不为空则该批次已上传过数据在该批次下新增tb_sample_device表数据
//查询该编号的id
Integer sampleId = dao.getIdByBatchCode(batchCode);
if (sampleId!=null){
//添加tb_sample_device数据
SamplesManageAppVos.get(0).setId(sampleId);
SamplesManageAppVos.get(0).setCreateBy(userId);
Boolean state = addSamplesDevice(SamplesManageAppVos);
if (state){
return ServerResponse.createBySuccessMsg(batchCode);
}
}else {
throw new RuntimeException("收样批次编号不存在");
}
}
}else {
throw new RuntimeException("未获取到数据");
}
return ServerResponse.createErroe("收样数据添加失败");
}
/**
* 添加tb_sample_device数据
* @param data
*/
public Boolean addSamplesDevice(List<SamplesManageAppVo> data) {
for (SamplesManageAppVo dto : data){
//查询设备编号是否重复
if (StringHelper.isNotEmpty(dto.getDevCode())){
if (dao.getCountByDevCode(dto.getDevCode(),dto.getSampleTools())>0){
throw new RuntimeException(dto.getSampleTools() +"设备编号:"+ dto.getDevCode() +"已存在");
}
}
//查询设备类型编码
if (dto.getSampleToolsId()!=null){
String devTypeCode = dao.getDevTypeCodeById(dto.getSampleToolsId());
dto.setDevTypeCode(devTypeCode);
}
//生成设备编码
String customerCode = customerCodeRule();
dto.setCustomerCode(customerCode);
dto.setId(data.get(0).getId());
dto.setCreateBy(data.get(0).getCreateBy());
int res= dao.addSamplesDevice(dto);
if (res<=0){
throw new RuntimeException("收样设备信息表添加失败");
}
}
return true;
}
@Override
public Boolean getAuthority(SamplesManageAppVo data) {
if (StringHelper.isNotEmpty(data.getName())){
if ("派工".equals(data.getName())){
return SystemUtils.isComprehensiveTeamLeader();
}else if ("收样".equals(data.getName())){
return (SystemUtils.isComprehensiveTeam() || SystemUtils.isComprehensiveTeamLeader());
}
}
return false;
}
/**
* 收样标签
*/
@Override
public SamplesManageAppVo getSampleLabelData(SamplesManageAppVo data) {
//查询详情数据
SamplesManageAppVo dto = dao.getSampleLabelData(data);
if (dto!=null){
//查询试验项目
List<ConfigItemsVo> itemList = dao.getTestItemList(data);
if (itemList.size()>0){
dto.setConfigItemsVos(itemList);
}
}
return dto;
}
/**
* 删除收样数据
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse delSamplesList(SamplesManageAppVo data) {
//先判断id是否为空
if (data.getId() != null){
//获取登录人id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
data.setUpdateBy(userId);
//先删除详情
int res = dao.delSamplesDetails(data);
if (res>0){
//再删除列表
int res2 = dao.delSamplesList(data);
if (res2>0){
return ServerResponse.createBySuccessMsg("删除成功");
}else {
throw new RuntimeException("收样单位信息表删除失败");
}
}else {
throw new RuntimeException("收样设备信息表删除失败");
}
}else {
throw new RuntimeException("未获取到数据");
}
}
/**
* 修改收样单位等信息
*/
@Override
public ServerResponse updateSamplesList(SamplesManageAppVo data) {
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
data.setUpdateBy(userId);
int res = dao.updateSamplesList(data);
if (res>0){
return ServerResponse.createBySuccessMsg("修改成功");
}else {
throw new RuntimeException("修改失败");
}
}
/**
* 删除收样设备信息 tb_sample_device
*/
@Override
public ServerResponse delSamplesDetails(SamplesManageAppVo data) {
//先判断id是否为空
if (data.getId() != null) {
//获取登录人id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
data.setUpdateBy(userId);
//删除详情
int res = dao.delSamplesDetailsList(data);
if (res > 0) {
return ServerResponse.createBySuccessMsg("删除成功");
} else {
throw new RuntimeException("收样设备信息表删除失败");
}
} else {
throw new RuntimeException("未获取到数据");
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse dispatchWork(SamplesManageAppVo data) {
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
if (StringHelper.isNotEmpty(data.getIds())){
//拆分用逗号分隔的数据
String[] ids = data.getIds().split(",");
for (String id : ids){
SamplesManageAppVo dto = new SamplesManageAppVo();
dto.setId(Integer.parseInt(id));
dto.setTeamId(data.getTeamId());
dto.setUpdateBy(userId);
//更新班组数据
int res = dao.updateTeamId(dto);
if (res<=0){
throw new RuntimeException("派工失败");
}
}
}
return ServerResponse.createBySuccessMsg("派工成功");
}
/**
* 收样批次编号--自动生成
* 格式PYYYYMMDD-NN
* P表示批次编号的前缀
* YYYY年份4位数字
* MM月份2位数字
* DD日期2位数字
* NN当天的批次序号2位数字按当天批次顺序递增
* 每天的批次编号从 01 开始按批次顺序递增
*/
private String batchCodeRule() {
String nowDate = DateTimeHelper.getNowYMD();
//查询本日收样批次流水号
String batchCode = dao.selectBatchCode(nowDate);
if (StringHelper.isNotEmpty(batchCode)) {
// 将字符串转换为整数
int num = Integer.parseInt(batchCode);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是四位数不足四位则在前面补0
batchCode = String.format("%02d", num);
} else {
batchCode = "01";
}
String code = "P" + nowDate + "-" + batchCode;
return code;
}
/**
* 设备编号--自动生成
* 格式SYYYYMMDD-XXX
* S表示收样编号的前缀
* YYYY年份4位数字
* MM月份2位数字
* DD日期2位数字
* XXX当天的收样序号3位数字按当天收样顺序递增
* 每天的设备收样编号从 001 开始按收样顺序递增
*/
private String customerCodeRule() {
String nowDate = DateTimeHelper.getNowYMD();
//查询本日收样流水号
String customerCode = dao.selectCustomerCode(nowDate);
if (StringHelper.isNotEmpty(customerCode)) {
// 将字符串转换为整数
int num = Integer.parseInt(customerCode);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是四位数不足四位则在前面补0
customerCode = String.format("%03d", num);
} else {
customerCode = "001";
}
String code = "S" + nowDate + "-" + customerCode;
return code;
}
}

View File

@ -15,6 +15,7 @@ import com.bonus.aqgqj.basis.entity.vo.ExperimentalVo;
import com.bonus.aqgqj.basis.service.ExamineService;
import com.bonus.aqgqj.utils.ServerResponse;
import com.bonus.aqgqj.utils.SystemUtils;
import com.bonus.aqgqj.utils.UserUtil;
import com.bonus.aqgqj.webResult.Constants;
import com.bonus.aqgqj.webResult.HttpStatus;
import lombok.extern.slf4j.Slf4j;
@ -52,17 +53,17 @@ public class ExamineAppServiceImpl implements ExamineAppService {
List<ExperimentalAppVo> list = new ArrayList<>();
try {
list = mapper.getList(dto);
if (list.size() > 0) {
//查询详情里需要审核的id
for (int i = 0; i < list.size(); i++) {
ExperimentalAppVo experimentalAppVo = list.get(i);
if ("待重新审阅".equals(experimentalAppVo.getAudtiStatus())) {
experimentalAppVo.setAudtiStatus("待审阅");
}
List<ExperimentalAppVo> list1 = mapper.getDetailIdBySampleId(experimentalAppVo.getId(),experimentalAppVo.getAudtiStatus());
list.get(i).setIds(list1.get(0).getIds());
}
}
// if (list.size() > 0) {
// //查询详情里需要审核的id
// for (int i = 0; i < list.size(); i++) {
// ExperimentalAppVo experimentalAppVo = list.get(i);
// if ("待重新审阅".equals(experimentalAppVo.getAudtiStatus())) {
// experimentalAppVo.setAudtiStatus("待审阅");
// }
// List<ExperimentalAppVo> list1 = mapper.getDetailIdBySampleId(experimentalAppVo.getId(),experimentalAppVo.getAudtiStatus());
// list.get(i).setIds(list1.get(0).getIds());
// }
// }
} catch (Exception e) {
log.error(e.toString(), e);
}
@ -151,7 +152,9 @@ public class ExamineAppServiceImpl implements ExamineAppService {
}
// 审核状态流程状态不为0时修改收样信息审核状态
if(!Objects.equals(audtiStatus, Constants.ALL_EXPER_INDEX) || !Objects.equals(processStatus, Constants.ALL_EXPER_INDEX)){
mapper.updateSampleStatus(vo, audtiStatus, processStatus,isEr);
//获取登录人id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
mapper.updateSampleStatus(vo, audtiStatus, processStatus,isEr,userId);
}
} catch (Exception e) {
log.error(e.toString(), e);

View File

@ -348,42 +348,54 @@ public class ExperimentalAppServiceImpl implements ExperimentalAppService {
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse commitCheckTestData(ParamsAppDto dto) {
try {
if (dto.getId() == null || dto.getIds() == null || dto.getIds().length == 0) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "未提交审查数据");
}
if (!SystemUtils.isExperimentalTeam()) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法提交审查数据");
}
List<Long> list = Arrays.asList(dto.getIds());
//先更新tb_exper表中数据为待审阅
mapper.updateExperStatus(list);
//在查询tb_exper中是否全部为待审阅
int res = mapper.isAllSubmit(dto.getId());
if (res<=0){
//如果全部为待审阅更新收样表中的状态为待审阅
mapper.updateSampleStatus(dto.getId());
}
// // 判断是否提交空数据
// if (dto.getIds() == null || dto.getIds().length == 0) {
// @Override
// @Transactional(rollbackFor = Exception.class)
// public ServerResponse commitCheckTestData(ParamsAppDto dto) {
// try {
// if (dto.getId() == null || dto.getIds() == null || dto.getIds().length == 0) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "未提交审查数据");
// }
// if (!SystemUtils.isExperimentalTeam()) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法提交审查数据");
// }
// // 判断提交数据中是否存在流程数据或者存在待试验项
// List<Long> list = Arrays.asList(dto.getIds());
// int result = mapper.isNotEditData(list);
// if (result > 0) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "提交数据中存在待试验项或处于审核流程或已试验结束");
// }
// // 更新收样表中的状态为待审阅
// mapper.updateSampleStatus(list);
// // 更新试验表中数据为待审阅
// //先更新tb_exper表中数据为待审阅
// mapper.updateExperStatus(list);
// //在查询tb_exper中是否全部为待审阅
// int res = mapper.isAllSubmit(dto.getId());
// if (res<=0){
// //如果全部为待审阅更新收样表中的状态为待审阅
// mapper.updateSampleStatus(dto.getId());
// }
// } catch (Exception e) {
// log.error(e.toString(), e);
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "操作失败");
// }
// return ServerResponse.createBySuccessMsg("操作成功");
// }
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse commitCheckTestData(ParamsAppDto dto) {
try {
// 判断是否提交空数据
if (dto.getIds() == null || dto.getIds().length == 0) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "未提交审查数据");
}
if (!SystemUtils.isExperimentalTeam()) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法提交审查数据");
}
// 判断提交数据中是否存在流程数据或者存在待试验项
List<Long> list = Arrays.asList(dto.getIds());
int result = mapper.isNotEditData(list);
if (result > 0) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "提交数据中存在待试验项或处于审核流程或已试验结束");
}
// 更新收样表中的状态为待审阅
mapper.updateSampleStatus(list);
// 更新试验表中数据为待审阅
mapper.updateExperStatus(list);
} catch (Exception e) {
log.error(e.toString(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

View File

@ -44,6 +44,9 @@ public class QrCodeImpl implements QrCodeService {
//收样标签
data.setCustomerCode(customerCode[1]);
dto = getSampleLabelData(data);
}else if ("hgz".equals(customerCode[0])){
data.setCustomerCode(customerCode[1]);
dto = getCertificateData(data);
}
}else {
throw new RuntimeException("customerCode不能为空");
@ -51,6 +54,13 @@ public class QrCodeImpl implements QrCodeService {
return dto;
}
/**
* 获取合格证数据
*/
private SamplesManageAppVo getCertificateData(SamplesManageAppVo data) {
return dao.getCertificateData(data);
}
/**
* 获取收样标签数据
*/

View File

@ -106,6 +106,13 @@ public class SamplesManageAppServiceImpl implements SamplesManageAppService {
*/
public Boolean addSamplesDevice(List<SamplesManageAppVo> data) {
for (SamplesManageAppVo dto : data){
//查询设备编号是否重复
if (StringHelper.isNotEmpty(dto.getDevCode())){
if (samplesManageAppDao.getCountByDevCode(dto.getDevCode(),dto.getSampleTools())>0){
throw new RuntimeException(dto.getSampleTools() +"设备编号:"+ dto.getDevCode() +"已存在");
}
}
//查询设备类型编码
if (dto.getSampleToolsId()!=null){
String devTypeCode = samplesManageAppDao.getDevTypeCodeById(dto.getSampleToolsId());

View File

@ -2,7 +2,9 @@ package com.bonus.aqgqj.app.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bonus.aqgqj.app.dao.TestReportManageAppDao;
import com.bonus.aqgqj.app.entity.SamplesManageAppVo;
import com.bonus.aqgqj.app.entity.TestReportManageAppVo;
import com.bonus.aqgqj.app.service.TestReportManageAppService;
import com.bonus.aqgqj.basis.entity.vo.*;
@ -12,10 +14,12 @@ import com.bonus.aqgqj.utils.ListHelper;
import com.bonus.aqgqj.utils.ServerResponse;
import com.bonus.aqgqj.utils.StringHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -24,10 +28,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
@ -44,6 +46,8 @@ import java.util.zip.ZipOutputStream;
@Service
public class TestReportManageAppServiceImpl implements TestReportManageAppService {
@Value("${file.windwos.upload_path}")
private String uploadPath;
@Resource
private TestReportManageAppDao testReportManageAppDao;
@ -168,35 +172,6 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
return testReportManageAppDao.downloadCertificateList(data);
}
@Override
public ServerResponse download(TestReportManageAppVo data) {
//根据选择的id获取详情数据
TestReportManageAppVo bean = new TestReportManageAppVo();
bean.setId(data.getId());
List<TestReportManageAppVo> list = getDetailsList(bean);
//查询详情里所有数据的检测报告
for (TestReportManageAppVo dto : list){
//根据试验id设备类型是否合格部门id来查询每个检测报告
ServerResponse serverResponse = viewTestData(dto);
if (serverResponse.isSuccess()){
File zipFile = new File("检测报告_"+DateTimeHelper.getNowDMS()+".zip");
try (FileOutputStream fos = new FileOutputStream(zipFile);
ZipOutputStream zos = new ZipOutputStream(fos)) {
TestReportManageAppVo testVo = (TestReportManageAppVo) serverResponse.getData();
//将数据传给检测报告生成的方法
try {
generateReport(testVo,zos);
} catch (Exception e){
e.printStackTrace();
}
}catch (IOException e){
e.printStackTrace();
}
}
}
return null;
}
@Override
public ResponseEntity<FileSystemResource> downloadFile(HttpServletRequest request, File tempZipFile) throws IOException {
String ids = request.getParameter("ids");
@ -221,7 +196,7 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
TestReportManageAppVo testVo = (TestReportManageAppVo) serverResponse.getData();
log.info("sj--->{}", testVo);
//生成检测报告
generateReport(testVo, zos);
generateReport(testVo, 2);
}
}
@ -245,7 +220,7 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
TestReportManageAppVo testVo = (TestReportManageAppVo) serverResponse.getData();
//将数据传给检测报告生成的方法
try {
String base64Excel = generateReport(testVo,null);
String base64Excel = generateReport(testVo,2);
// 返回 Base64 字符串
return ServerResponse.createSuccess(base64Excel);
} catch (Exception e) {
@ -255,10 +230,39 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
return ServerResponse.createErroe("查看失败");
}
@Override
public void downLoadExcelZip(HttpServletResponse response, TestReportManageAppVo data,List<String> fileNameList) {
List<File> fileList = new ArrayList();
JSONArray jsonArray = JSONObject.parseArray(data.getParamsList());
List<TestReportManageAppVo> list = jsonArray.toJavaList(TestReportManageAppVo.class);
if (list != null && list.size() > 0) {
try {
for (TestReportManageAppVo testReportManageAppVo : list) {
//根据试验id设备类型是否合格部门id来查询每个检测报告
ServerResponse serverResponse = viewTestData(testReportManageAppVo);
if (serverResponse.isSuccess()) {
TestReportManageAppVo testVo = (TestReportManageAppVo) serverResponse.getData();
log.info("sj--->{}", testVo);
//生成检测报告
String excelModelPath =generateReport(testVo, 1);
if (StringUtils.isNotBlank(excelModelPath)) {
fileList.add(new File(excelModelPath));
fileNameList.add(excelModelPath);
}
}
}
downloadZip(response, fileList);
}catch (Exception e){
log.error("zip导出错误-异常信息", e);
}
}
}
/**
* 生成检测报告
* type 1生成zip压缩包2生成base64
*/
public String generateReport(TestReportManageAppVo bean,ZipOutputStream zos) throws IOException {
public String generateReport(TestReportManageAppVo bean,Integer type) throws IOException {
//先计算出总共有多少列和动态生成的有多少列
//总列数
int totalNum = 0;
@ -565,20 +569,31 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
applyBordersToMergedRegion(sheet, new CellRangeAddress(row.get(),row.get(),num112+2,totalNum-1), style);
if (zos!=null){
// 保存到 ZIP 文件
ByteArrayOutputStream baos = new ByteArrayOutputStream();
workbook.write(baos);
if (StringHelper.isNotEmpty(bean.getReportCode())){
//将字符串中ML/BG-去除
bean.setReportCode(bean.getReportCode().replace("ML/BG-",""));
if (type==1){
String fileName = uploadPath + "检测报告_" + bean.getReportCode() + "_"+DateTimeHelper.getNowDMS()+".xlsx";
File file = new File(fileName);
//生成文件夹
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
ZipEntry entry = new ZipEntry("检测报告_" + bean.getReportCode() + "_"+DateTimeHelper.getNowDMS()+".xlsx");
zos.putNextEntry(entry);
zos.write(baos.toByteArray());
zos.closeEntry();
workbook.close();
return null;
FileOutputStream fos = new FileOutputStream(file);
workbook.write(fos);
return fileName;
// // 保存到 ZIP 文件
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// workbook.write(baos);
// if (StringHelper.isNotEmpty(bean.getReportCode())){
// //将字符串中ML/BG-去除
// bean.setReportCode(bean.getReportCode().replace("ML/BG-",""));
// }
// ZipEntry entry = new ZipEntry("检测报告_" + bean.getReportCode() + "_"+DateTimeHelper.getNowDMS()+".xlsx");
// zos.putNextEntry(entry);
// zos.write(baos.toByteArray());
// zos.closeEntry();
// workbook.close();
// return null;
}else {
// Excel 文档写入字节数组
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -679,4 +694,25 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
}
public void downloadZip(HttpServletResponse response, List<File> filesToZip) throws IOException {
// 设置响应头信息‌指定下载的文件名为"files.zip"
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment; filename=files.zip");
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
for (File file : filesToZip) {
try (FileInputStream fis = new FileInputStream(file)) {
ZipEntry zipEntry = new ZipEntry(file.getName());
zos.putNextEntry(zipEntry);
byte[] buffer = new byte[1024];
int len;
while ((len = fis.read(buffer)) > 0) {
zos.write(buffer, 0, len);
}
}
}
} catch (IOException e) {
log.error("文件压缩异常");
}
}
}

View File

@ -93,4 +93,11 @@ public interface SamplesManageDao {
* @return
*/
List<SamplesManageDto> getDeptSelectedById(SamplesManageDto data);
/**
* 获取收样批次编号
* @param nowDate
* @return
*/
String selectBatchCode(String nowDate);
}

View File

@ -61,6 +61,11 @@ public class SamplesManageDto extends PageEntity {
*/
private String sampleTools;
/**
* 批次编号
*/
private String batchCode;
/**
* 收样人
*/

View File

@ -74,7 +74,10 @@ public class SamplesManageServiceImpl implements SamplesManageService {
if (samplesManageDtos.size() > 0){
//先增加基础数据表并返回Id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
//生成编号
String batchCode2 =batchCodeRule();
samplesManageDtos.get(0).setCreateBy(userId);
samplesManageDtos.get(0).setBatchCode(batchCode2);
int re= samplesManageDao.addSamples(samplesManageDtos.get(0));
if (re>0){
//添加详情数据
@ -155,6 +158,34 @@ public class SamplesManageServiceImpl implements SamplesManageService {
return ServerResponse.createBySuccessMsg("派工成功");
}
/**
* 收样批次编号--自动生成
* 格式PYYYYMMDD-NN
* P表示批次编号的前缀
* YYYY年份4位数字
* MM月份2位数字
* DD日期2位数字
* NN当天的批次序号2位数字按当天批次顺序递增
* 每天的批次编号从 01 开始按批次顺序递增
*/
private String batchCodeRule() {
String nowDate = DateTimeHelper.getNowYMD();
//查询本日收样批次流水号
String batchCode = samplesManageDao.selectBatchCode(nowDate);
if (StringHelper.isNotEmpty(batchCode)) {
// 将字符串转换为整数
int num = Integer.parseInt(batchCode);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是四位数不足四位则在前面补0
batchCode = String.format("%02d", num);
} else {
batchCode = "01";
}
String code = "P" + nowDate + "-" + batchCode;
return code;
}
/**
* 设备编号--自动生成
* 格式SYYYYMMDD-XXX

View File

@ -189,6 +189,19 @@ public class UserController {
return ServerResponse.createErroe("获取登录用户失败");
}
@PostMapping(value = "getUserData")
@LogAnnotation(operModul = "系统管理-用户管理", operation = "当前登录用户信息", operDesc = "业务级事件",operType="查询")
public ServerResponse getUserData() {
try {
String loginName = UserUtil.getLoginUser().getLoginName();
SysUser u = userService.getUser(loginName);
return ServerResponse.createSuccess(u);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("获取用户信息失败");
}
@PostMapping(value = "getById")
@DecryptAndVerify(decryptedClass = UserDto.class)
@LogAnnotation(operModul = "系统管理-用户管理", operation = "查询用户信息", operDesc = "系统级事件",operType="查询")

View File

@ -0,0 +1,239 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.aqgqj.app.dao.CertificateAppDao">
<insert id="addSamples" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
INSERT INTO tb_sample(custom_id,
custom_name,
sample_user,
sample_time,
create_time,
create_user,
sample_date,
batch_code)
VALUES (#{customId},
#{customName},
#{sampleUser},
#{sampleTime},
NOW(),
#{createBy},
#{sampleTime},
#{batchCode})
</insert>
<insert id="addSamplesDevice">
INSERT INTO tb_sample_device(sample_id,
dev_type_name,
dev_type_code,
dev_module,
dev_code,
customer_code,
department_id,
sample_time,
create_time,
create_user)
VALUES (#{id},
#{sampleTools},
#{devTypeCode},
#{devModule},
#{devCode},
#{customerCode},
#{departmentId},
#{sampleTime},
NOW(),
#{createBy})
</insert>
<update id="updateTeamId">
UPDATE tb_sample
SET team_id = #{teamId},
dispatch_time=NOW(),
dispatch_user= #{updateBy},
update_time=NOW(),
update_user=#{updateBy}
WHERE id = #{id}
</update>
<update id="delSamplesDetails">
UPDATE tb_sample_device
SET del_falg = '1',
update_time = NOW(),
update_user = #{updateBy}
WHERE sample_id = #{id}
</update>
<update id="delSamplesList">
UPDATE tb_sample
SET del_flag = '1',
update_time = NOW(),
update_user = #{updateBy}
WHERE id = #{id}
</update>
<update id="updateSamplesList">
UPDATE tb_sample
SET custom_id = #{customId},
custom_name = #{customName},
sample_user = #{sampleUser},
sample_time = #{sampleTime},
update_time = NOW(),
update_user = #{updateBy}
WHERE id = #{id}
</update>
<delete id="delSamplesDetailsList">
UPDATE tb_sample_device
SET del_falg = '1',
update_time = NOW(),
update_user = #{updateBy}
WHERE id = #{id}
</delete>
<select id="list" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo">
SELECT
ts.id,
tc.custom_name as customName,
DATE_FORMAT(ts.update_time, '%Y-%m-%d') AS createTime,
tsd.sampleTools,
tsd.customNum,
tt.team_name as teamName
FROM
tb_sample ts
LEFT JOIN(
SELECT
sample_id,
COUNT(id) as customNum,
GROUP_CONCAT(DISTINCT dev_type_name) as sampleTools
FROM
tb_sample_device tsd
WHERE
del_falg=0
GROUP BY tsd.sample_id
) tsd on tsd.sample_id=ts.id
LEFT JOIN tb_custom tc ON tc.id = ts.custom_id and tc.del_flag=0
LEFT JOIN tb_team tt on tt.id=ts.team_id and tt.del_flag=0
WHERE
ts.del_flag = '0'
AND ts.team_id IS NOT NULL
and ts.process_status=4
<if test="sampleTools != null and sampleTools != ''">
and tsd.sampleTools like concat('%',#{sampleTools}, '%')
</if>
<if test="startTime != null and endTime!=''">
AND DATE_FORMAT(ts.update_time, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
</if>
<if test="keyWord != null and keyWord != ''">
AND (
tc.custom_name like concat('%', #{keyWord}, '%') OR
tt.team_name like concat('%', #{keyWord}, '%')
)
</if>
GROUP BY ts.id
</select>
<select id="getDetailsList" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo">
SELECT
ted.id,
tsd.sample_id as sampleId,
tsd.dev_type_name as sampleTools,
tsd.dev_module as devModule,
tsd.dev_code as devCode,
tsd.customer_code as customerCode,
tc.custom_name as sampleDepartment,
CASE
ted.is_hg
WHEN 0 THEN
'合格'
WHEN 1 THEN
'不合格'
END AS experConclu,
te.exper_time as experTime
FROM
tb_exper_dev ted
LEFT JOIN tb_sample_device tsd ON tsd.id = ted.dev_id
AND tsd.del_falg = 0
LEFT JOIN tb_custom tc ON tc.id = tsd.department_id
AND tc.del_flag = 0
LEFT JOIN tb_exper te ON te.id = ted.exper_id
AND te.del_flag = 0
WHERE
tsd.sample_id = #{sampleId}
<if test="sampleTools != null and sampleTools != ''">
and tsd.dev_type_name like concat('%',#{sampleTools}, '%')
</if>
<if test="startTime != null and endTime!=''">
AND DATE_FORMAT(te.exper_time, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
</if>
<if test="keyWord != null and keyWord != ''">
AND (
tsd.dev_code like concat('%', #{keyWord}, '%') OR
tsd.dev_module like concat('%', #{keyWord}, '%') OR
tc.custom_name like concat('%', #{keyWord}, '%')
)
</if>
</select>
<select id="getDevTypeCodeById" resultType="java.lang.String">
select sd.dict_code
from sys_distinct sd
where sd.p_id = 92
and sd.id = #{sampleToolsId}
and del_flag = 0
</select>
<select id="selectCustomerCode" resultType="java.lang.String">
SELECT
SUBSTRING( customer_code, - 3 ) AS CODE
FROM
tb_sample_device
WHERE
SUBSTRING( customer_code, 2, 8 )= #{nowDate}
ORDER BY
customer_code DESC
LIMIT 1
</select>
<select id="getSampleLabelData" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo">
SELECT
te.submit_location as submitLocation,
tsd.dev_type_name as sampleTools,
tsd.dev_module as devModule,
tsd.dev_code as devCode,
ts.process_status as processStatus,
tc.custom_name as customName
FROM
tb_sample_device tsd
LEFT JOIN tb_sample ts on ts.id=tsd.sample_id and ts.del_flag=0
LEFT JOIN tb_custom tc on tc.id=ts.custom_id and tc.del_flag=0
LEFT JOIN tb_exper te on te.sample_id=ts.id and te.del_flag=0
WHERE
tsd.id=#{id}
</select>
<select id="getTestItemList" resultType="com.bonus.aqgqj.basis.entity.vo.ConfigItemsVo">
SELECT
tei.id,
tei.exper_type_name AS experTypeName,
tei.amount
FROM
tb_exper_items tei
LEFT JOIN tb_exper te on te.id=tei.exper_id and te.del_flag=0
LEFT JOIN tb_sample ts on ts.id=te.sample_id and ts.del_flag=0
LEFT JOIN tb_sample_device tsd on tsd.sample_id=ts.id and tsd.del_falg=0
WHERE
tsd.id=#{id}
</select>
<select id="selectBatchCode" resultType="java.lang.String">
SELECT
SUBSTRING( batch_code, - 2 ) AS CODE
FROM
tb_sample
WHERE
SUBSTRING( batch_code, 2, 8 )= #{nowDate}
and del_flag = 0
ORDER BY
batch_code DESC
LIMIT 1
</select>
<select id="getIdByBatchCode" resultType="java.lang.Integer">
SELECT id
FROM tb_sample
WHERE batch_code = #{batchCode}
and del_flag = 0
</select>
<select id="getCountByDevCode" resultType="java.lang.Integer">
SELECT count(1)
FROM tb_sample_device
WHERE dev_code = #{devCode}
and dev_type_name = #{sampleTools}
and del_falg = 0
</select>
</mapper>

View File

@ -14,7 +14,7 @@
</update>
<!--更新收样信息审核的状态-->
<update id="updateSampleStatus">
UPDATE tb_sample SET audti_status = #{audtiStatus},process_status = #{processStatus},is_er = #{isEr},remarks = #{params.auditRemark} WHERE id = #{params.sampleId}
UPDATE tb_sample SET audti_status = #{audtiStatus},process_status = #{processStatus},is_er = #{isEr},remarks = #{params.auditRemark},update_user=#{userId},update_time=NOW() WHERE id = #{params.sampleId}
</update>
<!--试验审查列表-->
@ -145,18 +145,43 @@
WHERE exper_id = #{experId}
</select>
<!--查询试验项是否都是通过-->
<!-- <select id="getExperIsPass" resultType="java.lang.Integer">-->
<!-- SELECT COUNT(*) FROM tb_exper WHERE sample_id = #{sampleId} AND del_flag = 0-->
<!-- UNION ALL-->
<!-- SELECT COUNT(*) FROM tb_exper WHERE sample_id = #{sampleId} AND del_flag = 0-->
<!-- <if test="auditType == 1">-->
<!-- AND status >1-->
<!-- </if>-->
<!-- <if test="auditType == 2">-->
<!-- AND status > 2-->
<!-- </if>-->
<!-- <if test="auditType == 3">-->
<!-- AND status >3-->
<!-- </if>-->
<!-- UNION ALL-->
<!-- SELECT COUNT(*) FROM tb_exper WHERE sample_id = #{sampleId} AND del_flag = 0-->
<!-- <if test="auditType == 1">-->
<!-- AND status = 1 AND audit_status = 2-->
<!-- </if>-->
<!-- <if test="auditType == 2">-->
<!-- AND status = 2 AND audit_status = 3-->
<!-- </if>-->
<!-- <if test="auditType == 3">-->
<!-- AND status = 3 AND audit_status = 4-->
<!-- </if>-->
<!-- </select>-->
<select id="getExperIsPass" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tb_exper WHERE sample_id = #{sampleId} AND del_flag = 0
UNION ALL
SELECT COUNT(*) FROM tb_exper WHERE sample_id = #{sampleId} AND del_flag = 0
<if test="auditType == 1">
AND status >1
AND status = 2 AND audit_status = 0
</if>
<if test="auditType == 2">
AND status > 2
AND status = 3 AND audit_status = 0
</if>
<if test="auditType == 3">
AND status >3
AND status = 4 AND audit_status = 1
</if>
UNION ALL
SELECT COUNT(*) FROM tb_exper WHERE sample_id = #{sampleId} AND del_flag = 0

View File

@ -188,14 +188,21 @@
exper_conclu = #{experConclu},remarsk = #{remarsk} WHERE id = #{id}
</update>
<!--更新收样表中的状态为待审阅-->
<!-- <update id="updateSampleStatus">-->
<!-- UPDATE tb_sample SET audti_status = 0,process_status = 1,remarks = null-->
<!-- WHERE id =#{id}-->
<!-- </update>-->
<update id="updateSampleStatus">
UPDATE tb_sample SET audti_status = 0,process_status = 1,remarks = null
WHERE id =#{id}
WHERE id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<!--更新试验表中数据为待审阅-->
<update id="updateExperStatus">
UPDATE tb_exper SET status = 1,audit_status = 0,audit_user_name = null,audit_time = null,audit_remakr = null
WHERE id IN
WHERE sample_id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
@ -260,7 +267,21 @@
ts.batch_code as batchCode,
tsd.sampleDev,
IFNULL(tsd.num,0) AS customNum,
tt.team_name AS teamName
tt.team_name AS teamName,
ts.process_status as status,
ts.audti_status as auditStatus,
CASE WHEN ts.process_status IS NULL THEN '待试验'
WHEN ts.process_status = 0 AND ts.audti_status = 0 THEN '待提交'
WHEN ts.process_status = 1 AND ts.audti_status = 0 AND ts.is_er IS NULL THEN '待审阅'
WHEN ts.process_status = 1 AND ts.audti_status = 0 AND ts.is_er = '1' THEN '待重新审阅'
WHEN ts.process_status = 1 AND ts.audti_status = 2 THEN '审阅不通过'
WHEN ts.process_status = 2 AND ts.audti_status = 0 THEN '待审核'
WHEN ts.process_status = 2 AND ts.audti_status = 2 THEN '审核不通过'
WHEN ts.process_status = 3 AND ts.audti_status = 0 THEN '待审批'
WHEN ts.process_status = 3 AND ts.audti_status = 2 THEN '审批不通过'
WHEN ts.process_status = 4 AND ts.audti_status = 1 THEN '试验完成'
ELSE '待试验'
END AS statusResult
FROM
tb_sample ts
LEFT JOIN tb_custom tc on tc.id=ts.custom_id and tc.del_flag=0

View File

@ -63,7 +63,7 @@
LEFT JOIN sys_user su2 ON te.update_user = su2.id AND su2.del_flag = 0
WHERE tsd.sample_id = #{id} AND tsd.del_falg = 0 and te.`status` = 4 and te.audit_status = 1
<if test="devTypeCode != null and devTypeCode!=''">
AND INSTR(tsd.dev_type_code,#{devTypeCode})
AND INSTR(ANY_VALUE(tsd.dev_type_name),#{devTypeCode})
</if>
GROUP BY tsd.dev_type_code
)a

View File

@ -42,6 +42,35 @@
WHERE
tsd.customer_code=#{customerCode}
and tsd.del_falg=0
LIMIT 1
</select>
<select id="getCertificateData" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo">
SELECT
ted.id,
te.submit_location as submitLocation,
tsd.dev_type_name as sampleTools,
tsd.dev_module as devModule,
ted.dev_code as devCode,
te.exper_time as experTime,
te.next_exper_time as nextExperTime,
su.user_name as experUser,
case ted.is_hg when 0 then '合格'
when 1 then '不合格'
end as experConclu,
tc.custom_name as customName,
tsd.customer_code as customerCode
FROM
tb_exper_dev ted
LEFT JOIN tb_sample_device tsd on ted.dev_id=tsd.id and tsd.del_falg=0
LEFT JOIN tb_sample ts on ts.id=tsd.sample_id and ts.del_flag=0
LEFT JOIN tb_custom tc on tc.id=ts.custom_id and tc.del_flag=0
LEFT JOIN tb_exper te on te.id=ted.exper_id
LEFT JOIN sys_user su on su.id=te.create_user and su.del_flag=0
WHERE
tsd.dev_type_name is not null
and te.`status`=4
and tsd.customer_code=#{customerCode}
LIMIT 1
</select>
</mapper>

View File

@ -133,11 +133,13 @@
tc.custom_name as sampleDepartment,
tsd.dev_code as devCode,
tsd.customer_code as customerCode,
tt.team_name as teamName,
tsd.is_print as isPrint
from
tb_sample_device tsd
LEFT JOIN tb_sample ts on tsd.sample_id=ts.id
LEFT JOIN tb_custom tc on tsd.department_id=tc.id and tc.del_flag=0
LEFT JOIN tb_team tt on tt.id=ts.team_id and tt.del_flag=0
where tsd.del_falg = 0
and tsd.sample_id = #{id}
<if test="keyWord != null and keyWord != ''">
@ -215,4 +217,11 @@
WHERE batch_code = #{batchCode}
and del_flag = 0
</select>
<select id="getCountByDevCode" resultType="java.lang.Integer">
SELECT count(1)
FROM tb_sample_device
WHERE dev_code = #{devCode}
and dev_type_name = #{sampleTools}
and del_falg = 0
</select>
</mapper>

View File

@ -8,14 +8,16 @@
sample_time,
create_time,
create_user,
sample_date)
sample_date,
batch_code)
VALUES (#{customId},
#{customName},
#{sampleUser},
#{sampleTime},
NOW(),
#{createBy},
#{sampleTime})
#{sampleTime},
#{batchCode})
</insert>
<insert id="addSamplesDevice">
INSERT INTO tb_sample_device(sample_id,
@ -169,4 +171,16 @@
and custom_status = 0
and dept_id = 1
</select>
<select id="selectBatchCode" resultType="java.lang.String">
SELECT
SUBSTRING( batch_code, - 2 ) AS CODE
FROM
tb_sample
WHERE
SUBSTRING( batch_code, 2, 8 )= #{nowDate}
and del_flag = 0
ORDER BY
batch_code DESC
LIMIT 1
</select>
</mapper>

View File

@ -66,7 +66,7 @@
</insert>
<!--登录查询用户-->
<select id="getUser" parameterType="String" resultType="com.bonus.aqgqj.model.SysUser">
select t.id,t.user_name as username,t.login_name as loginName,
select t.id,t.user_name as username,t.login_name as loginName,t.phone,
t.password,t.state,t.role_id as roleId,t.login_type loginType,t.new_user newUser,
sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId
from sys_user t

View File

@ -196,7 +196,7 @@ function initTable(dataList, limit, page) {
unresize: true,
align: "center",
templet: function (d) {
return `<a href="#" style="color: blue;" onclick="handleClick2('${d.submitLocation}','${d.sampleTools}','${d.devModule}','${d.devCode}','${d.experTime}','${d.nextExperTime}','${d.experUser}','${d.experConclu}','${d.customName}')">打印</a>`;
return `<a href="#" style="color: blue;" onclick="handleClick2('${d.customerCode}','${d.submitLocation}','${d.sampleTools}','${d.devModule}','${d.devCode}','${d.experTime}','${d.nextExperTime}','${d.experUser}','${d.experConclu}','${d.customName}')">打印</a>`;
}
},
],
@ -229,24 +229,26 @@ function handleClick1(submitLocation,sampleTools,devModule,devCode,experTime,nex
/**
* 打印二维码
*/
function handleClick2(submitLocation,sampleTools,devModule,devCode,experTime,nextExperTime,experUser,experConclu,customName) {
function handleClick2(customerCode,submitLocation,sampleTools,devModule,devCode,experTime,nextExperTime,experUser,experConclu,customName) {
// 准备二维码内容
const qrCodeData = {
"样品名称": sampleTools,
"规格型号": devModule,
"样品编号": devCode,
"检验日期": experTime,
"下次检验日期": nextExperTime,
"试验人员": experUser,
"试验结果": experConclu,
"送检单位": customName
};
// 将对象转换为字符串
const qrCodeString = JSON.stringify(qrCodeData, null, 2);
const qrCodeData = "hgz/"+customerCode;
// const qrCodeData = {
// "样品名称": sampleTools,
// "规格型号": devModule,
// "样品编号": devCode,
// "检验日期": experTime,
// "下次检验日期": nextExperTime,
// "试验人员": experUser,
// "试验结果": experConclu,
// "送检单位": customName
// };
// // 将对象转换为字符串
// const qrCodeString = JSON.stringify(qrCodeData, null, 2);
// 清空二维码容器
$('#Qrcode').empty();
// 生成二维码
$('#Qrcode').qrcode(utf16to8(qrCodeString));
$('#Qrcode').qrcode(utf16to8(qrCodeData));
// 显示模态对话框
modal.show();
// // 打印二维码
@ -280,20 +282,24 @@ function batchDownload() {
selectedRows.forEach(function (row, index) {
// 准备二维码内容
const qrCodeData = {
"样品名称": row.sampleTools,
"规格型号": row.devModule,
"样品编号": row.devCode,
"检验日期": row.experTime,
"下次检验日期": row.nextExperTime,
"试验人员": row.experUser,
"试验结果": row.experConclu,
"送检单位": row.customName
};
const qrCodeData="hgz/"+row.customerCode;
// const qrCodeData = {
// "样品名称": row.sampleTools,
// "规格型号": row.devModule,
// "样品编号": row.devCode,
// "检验日期": row.experTime,
// "下次检验日期": row.nextExperTime,
// "试验人员": row.experUser,
// "试验结果": row.experConclu,
// "送检单位": row.customName
// };
// 创建二维码并填充白色背景
$('#qr-canvas').empty();
$('#qr-canvas').qrcode(utf16to8(JSON.stringify(qrCodeData, null, 2)));
// $('#qr-canvas').qrcode(utf16to8(JSON.stringify(qrCodeData, null, 2)));
$('#qr-canvas').qrcode(utf16to8(qrCodeData));
// 获取 qr-canvas 中的二维码元素
var qrCanvas = document.querySelector('#qr-canvas canvas');