|
|
|
|
@ -1,6 +1,9 @@ |
|
|
|
|
|
|
|
|
|
package org.springblade.lims.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
|
@ -9,7 +12,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.apache.http.client.utils.DateUtils; |
|
|
|
|
import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
|
import org.springblade.core.excel.util.ExcelUtil; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
@ -17,6 +22,8 @@ import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springblade.lims.ao.CommonAo; |
|
|
|
|
import org.springblade.lims.entry.*; |
|
|
|
|
import org.springblade.lims.excel.ExamineExcel; |
|
|
|
|
import org.springblade.lims.excel.ExamineExportExcel; |
|
|
|
|
import org.springblade.lims.service.*; |
|
|
|
|
import org.springblade.system.cache.DictBizCache; |
|
|
|
|
import org.springblade.system.enums.DictBizEnum; |
|
|
|
|
@ -25,6 +32,7 @@ import org.springblade.system.user.entity.User; |
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
@ -281,8 +289,22 @@ public class ExamineController extends BladeController { |
|
|
|
|
public R<IPage<Examine>> list(Examine examine, Query query) { |
|
|
|
|
LambdaQueryWrapper<Examine> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
String dept = sysClient.getParamValue("is_limit_by_dept").getData(); |
|
|
|
|
|
|
|
|
|
//修改前
|
|
|
|
|
// if ("1".equals(dept) || dept == null) {
|
|
|
|
|
// wrapper.eq(Examine::getDeptId, examine.getDeptId());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//修改后
|
|
|
|
|
if ("1".equals(dept) || dept == null) { |
|
|
|
|
wrapper.eq(Examine::getDeptId, examine.getDeptId()); |
|
|
|
|
//判断部门是否为空
|
|
|
|
|
if(examine.getDeptId() != null){ |
|
|
|
|
wrapper.eq(Examine::getDeptId, examine.getDeptId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//验收编号
|
|
|
|
|
if(StringUtil.isNotBlank(examine.getAcceptanceNum())){ |
|
|
|
|
wrapper.eq(Examine::getAcceptanceNum, examine.getAcceptanceNum()); |
|
|
|
|
} |
|
|
|
|
//待领取
|
|
|
|
|
if ("000".equals(examine.getEntrustStatus())) { |
|
|
|
|
@ -325,6 +347,10 @@ public class ExamineController extends BladeController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//添加时间范围查询
|
|
|
|
|
if(StringUtil.isNotBlank(examine.getStartTime()) && StringUtil.isNotBlank(examine.getEndTime())){ |
|
|
|
|
wrapper.between(Examine::getCreateTime, examine.getStartTime(), examine.getEndTime()); |
|
|
|
|
} |
|
|
|
|
wrapper.orderByDesc(Examine::getCreateTime); |
|
|
|
|
// 1. 手动构建分页对象,关闭自动count
|
|
|
|
|
@ -345,11 +371,16 @@ public class ExamineController extends BladeController { |
|
|
|
|
ExamineItem byId = examineItemService.getById(examineItemId); |
|
|
|
|
ExamineWay byId1 = examineWayService.getById(examineWayId); |
|
|
|
|
ExamineBasis byId2 = examineBasisService.getById(examineBasisId); |
|
|
|
|
QueryWrapper<ExamineResult> resultQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
resultQueryWrapper.eq("examine_id", record.getId()); |
|
|
|
|
ExamineResult examineResult = examineResultService.getOne(resultQueryWrapper, false); |
|
|
|
|
record.setExamineResult(examineResult); |
|
|
|
|
if (byId != null) { |
|
|
|
|
record.setExamineItemName(byId.getName()); |
|
|
|
|
} |
|
|
|
|
if (byId1 != null) { |
|
|
|
|
record.setExamineWayName(byId1.getName()); |
|
|
|
|
record.setInputMode(byId1.getInputMode()); |
|
|
|
|
} |
|
|
|
|
if (byId2 != null) { |
|
|
|
|
record.setExamineBasisName(byId2.getName()); |
|
|
|
|
@ -447,4 +478,182 @@ public class ExamineController extends BladeController { |
|
|
|
|
public R batchUpdate(@RequestBody Simple simple) { |
|
|
|
|
return R.status(examineService.batchUpdate(simple)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @MethodName: receiveRevoke |
|
|
|
|
* @Annotation: 撤回领取 |
|
|
|
|
* @author: YangMaoFu |
|
|
|
|
* @date: 2026/3/26 15:51 |
|
|
|
|
* @Version: 1.0 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/receiveRevoke") |
|
|
|
|
@ApiOperation(value = "撤回领取", notes = "撤回已领取的检验任务") |
|
|
|
|
public R receiveRevoke(@RequestParam String id) { |
|
|
|
|
try { |
|
|
|
|
examineService.receiveRevoke(id); |
|
|
|
|
return R.success("撤回成功"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return R.fail(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 单个任务取消 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/cancelExamine") |
|
|
|
|
public R cancelExamine(@RequestBody Examine examine) { |
|
|
|
|
try { |
|
|
|
|
//先更新检测表中状态
|
|
|
|
|
examineService.updateById(examine); |
|
|
|
|
// 获取委托单对应所有检测数据
|
|
|
|
|
Examine examineInfo = examineService.getById(examine.getId()); |
|
|
|
|
Long entrustId = examineInfo.getEntrustId(); |
|
|
|
|
QueryWrapper<Examine> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("entrust_id", entrustId); |
|
|
|
|
List<Examine> list = examineService.list(queryWrapper); |
|
|
|
|
// 通过数量
|
|
|
|
|
int tgNum = 0; |
|
|
|
|
//计数器计算校核通过的检测
|
|
|
|
|
for (Examine examine1 : list) { |
|
|
|
|
if (examine1.getStatus() == 1 || examine1.getStatus() == 2) { |
|
|
|
|
tgNum += 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//判断是否为最后一条检测,如果全部通过修改委托单为审核通过状态
|
|
|
|
|
if (tgNum == list.size()) { |
|
|
|
|
Entrust entrust = service.getById(entrustId); |
|
|
|
|
entrust.setEntrustStatus("8"); |
|
|
|
|
service.updateById(entrust); |
|
|
|
|
} |
|
|
|
|
return R.success("操作成功"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return R.fail("操作失败:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/exportExamineList") |
|
|
|
|
public void exportExamineList(Examine examine, Query query, HttpServletResponse response |
|
|
|
|
) { |
|
|
|
|
LambdaQueryWrapper<Examine> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
String dept = sysClient.getParamValue("is_limit_by_dept").getData(); |
|
|
|
|
|
|
|
|
|
if ("1".equals(dept) || dept == null) { |
|
|
|
|
//判断部门是否为空
|
|
|
|
|
if(examine.getDeptId() != null){ |
|
|
|
|
wrapper.eq(Examine::getDeptId, examine.getDeptId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//验收编号
|
|
|
|
|
if(StringUtil.isNotBlank(examine.getAcceptanceNum())){ |
|
|
|
|
wrapper.eq(Examine::getAcceptanceNum, examine.getAcceptanceNum()); |
|
|
|
|
} |
|
|
|
|
//待领取
|
|
|
|
|
if ("000".equals(examine.getEntrustStatus())) { |
|
|
|
|
wrapper.eq(Examine::getIsDistribute, 0) |
|
|
|
|
.eq(Examine::getStatus, 0); |
|
|
|
|
} |
|
|
|
|
//待检测
|
|
|
|
|
if ("111".equals(examine.getEntrustStatus())) { |
|
|
|
|
wrapper.eq(Examine::getIsFinished, "-1") |
|
|
|
|
.eq(Examine::getStatus, 0) |
|
|
|
|
.eq(Examine::getIsDistribute, 1); |
|
|
|
|
} |
|
|
|
|
//待审核
|
|
|
|
|
if ("3".equals(examine.getEntrustStatus())) { |
|
|
|
|
wrapper.eq(Examine::getIsFinished, "1") |
|
|
|
|
.eq(Examine::getStatus, 0); |
|
|
|
|
} |
|
|
|
|
//审核通过
|
|
|
|
|
if ("4".equals(examine.getEntrustStatus())) { |
|
|
|
|
wrapper.eq(Examine::getStatus, 1); |
|
|
|
|
} |
|
|
|
|
//审核作废
|
|
|
|
|
if ("-1".equals(examine.getEntrustStatus())) { |
|
|
|
|
wrapper.eq(Examine::getStatus, -1); |
|
|
|
|
} |
|
|
|
|
// 模糊查询
|
|
|
|
|
|
|
|
|
|
if (examine.getSimpleName() != null && !examine.getSimpleName().trim().isEmpty()) { |
|
|
|
|
String[] keywords = examine.getSimpleName().trim().split("\\s+"); |
|
|
|
|
|
|
|
|
|
// 遍历每个关键词,每个关键词都要满足「匹配simpleName 或 匹配t_examine_item.name」
|
|
|
|
|
for (String keyword : keywords) { |
|
|
|
|
if (keyword.isEmpty()) { |
|
|
|
|
continue; // 跳过空的关键词(比如连续空格导致的空字符串)
|
|
|
|
|
} |
|
|
|
|
wrapper.and(w -> w.like(Examine::getSimpleName, keyword) // 匹配主表simpleName
|
|
|
|
|
.or() // 匹配关联的t_examine_item.name
|
|
|
|
|
.exists("SELECT 1 FROM t_examine_item t WHERE t.id = examine_item_id AND t.name LIKE '%" + keyword + "%'")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//添加时间范围查询
|
|
|
|
|
if(StringUtil.isNotBlank(examine.getStartTime()) && StringUtil.isNotBlank(examine.getEndTime())){ |
|
|
|
|
wrapper.between(Examine::getCreateTime, examine.getStartTime(), examine.getEndTime()); |
|
|
|
|
} |
|
|
|
|
wrapper.orderByDesc(Examine::getCreateTime); |
|
|
|
|
List<Examine> records = examineService.list(wrapper); |
|
|
|
|
if (records.size() > 0 && records != null) { |
|
|
|
|
for (Examine record : records) { |
|
|
|
|
Long examineItemId = record.getExamineItemId(); |
|
|
|
|
Long examineWayId = record.getExamineWayId(); |
|
|
|
|
Long examineBasisId = record.getExamineBasisId(); |
|
|
|
|
ExamineItem byId = examineItemService.getById(examineItemId); |
|
|
|
|
ExamineWay byId1 = examineWayService.getById(examineWayId); |
|
|
|
|
ExamineBasis byId2 = examineBasisService.getById(examineBasisId); |
|
|
|
|
QueryWrapper<ExamineResult> resultQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
resultQueryWrapper.eq("examine_id", record.getId()); |
|
|
|
|
ExamineResult examineResult = examineResultService.getOne(resultQueryWrapper); |
|
|
|
|
record.setExamineResult(examineResult); |
|
|
|
|
if (byId != null) { |
|
|
|
|
record.setExamineItemName(byId.getName()); |
|
|
|
|
} |
|
|
|
|
if (byId1 != null) { |
|
|
|
|
record.setExamineWayName(byId1.getName()); |
|
|
|
|
record.setInputMode(byId1.getInputMode()); |
|
|
|
|
} |
|
|
|
|
if (byId2 != null) { |
|
|
|
|
record.setExamineBasisName(byId2.getName()); |
|
|
|
|
} |
|
|
|
|
if (record.getExamineBy() != null && !"".equals(record.getExamineBy())) { |
|
|
|
|
R<User> userR = userClient.userInfoById(Long.valueOf(record.getExamineBy())); |
|
|
|
|
record.setExamineByName(userR.getData().getName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<ExamineExportExcel> list = records.stream().map(m -> { |
|
|
|
|
ExamineExportExcel examineExportExcel = new ExamineExportExcel(); |
|
|
|
|
examineExportExcel.setExamineItemName(m.getExamineItemName()); |
|
|
|
|
examineExportExcel.setSimpleName(m.getSimpleName()); |
|
|
|
|
examineExportExcel.setExperieNum(m.getExperieNum()); |
|
|
|
|
examineExportExcel.setSimpleCount(String.valueOf(m.getSimpleCount())); |
|
|
|
|
|
|
|
|
|
examineExportExcel.setExamineWayName(m.getExamineWayName()); |
|
|
|
|
examineExportExcel.setExamineBasisName(m.getExamineBasisName()); |
|
|
|
|
examineExportExcel.setDemandCompletionTime(DateUtils.formatDate(m.getDemandCompletionTime(), "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
examineExportExcel.setCreateTime(DateUtils.formatDate(m.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
examineExportExcel.setExamineByName(m.getExamineByName()); |
|
|
|
|
examineExportExcel.setSimpleCurrPlace(m.getSimpleCurrPlace()); |
|
|
|
|
|
|
|
|
|
if(m.getIsDistribute() == 0 && m.getStatus() != -1){ |
|
|
|
|
examineExportExcel.setStatus("待领取"); |
|
|
|
|
} else if(m.getStatus() == 2 && m.getStatus() != -1){ |
|
|
|
|
examineExportExcel.setStatus("已取消"); |
|
|
|
|
} else if(m.getIsDistribute() == 1 && m.getIsFinished().equals("-1") && m.getStatus() != -1){ |
|
|
|
|
examineExportExcel.setStatus("待检测"); |
|
|
|
|
} else if(m.getIsFinished().equals("1") && m.getStatus() == 0 && m.getStatus() != -1){ |
|
|
|
|
examineExportExcel.setStatus("待校核"); |
|
|
|
|
} else if(m.getIsFinished().equals("1") && m.getStatus() == 1 && m.getStatus() != -1){ |
|
|
|
|
examineExportExcel.setStatus("校核通过"); |
|
|
|
|
} else if(m.getStatus() == -1){ |
|
|
|
|
examineExportExcel.setStatus("已驳回"); |
|
|
|
|
} |
|
|
|
|
return examineExportExcel; |
|
|
|
|
}).collect(Collectors.toList());; |
|
|
|
|
ExcelUtil.export(response, "检测清单统计", "检测清单", list, ExamineExportExcel.class); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|