Commit 07963575 by lijingjing

修改样品制备搜索条件;

添加检测项目字段 - 仪器中项目名称(instrument_item_name varchar(120));
parent 571122e9
......@@ -214,6 +214,11 @@ public class EntrustSampleController extends ServiceController {
return success(entrustSampleService.obtainMakeInfo(ids, getAccount()));
}
@ApiOperation("获取制备时的列表信息")
@PostMapping("/get_make_info")
public RestResult<List<EntrustSampleVO>> getMakeInfoList(EntrustSampleVO entrustSampleVO) {
return success(entrustSampleService.getMakeInfoList(entrustSampleVO, getAccount()));
}
@ApiOperation("样品接收分页列表")
@ApiImplicitParams({
......
......@@ -487,6 +487,12 @@ public class EntrustSampleItemController extends ServiceController {
return success(entrustSampleItemService.getListBySampleId(sampleId));
}
@ApiOperation("样品下检测项目列表")
@PostMapping("/list_by_sample_ids")
public RestResult<List<EntrustSampleItemVO>> getListBySampleIds(@RequestParam("sampleIds") Long[] sampleIds) {
return success(entrustSampleItemService.listBySampleIds(sampleIds));
}
@ApiOperation("数据录入提交")
@PostMapping("/submit_test")
......
......@@ -58,4 +58,6 @@ public interface EntrustSampleItemMapper extends BatchMapper<EntrustSampleItem>
List<LmsUserRelGroupVO> selectAllPersonWorkload(RowBounds rowBounds, @Param("rel") LmsUserRelGroup lmsUserRelGroup);
List<EntrustSampleCalcResultVO> selectSampleCalcResult(@Param("vo") QueryDTO queryDTO);
boolean updateItemJudgeByEntrustId(@Param("entrustId") Long entrustId);
}
......@@ -88,4 +88,6 @@ public interface IEntrustSampleItemService extends IBaseService<EntrustSampleIte
List<EntrustSampleCalcResultVO> getSampleCalcResult(QueryDTO queryDTO);
Boolean notWriteToReport(List<Long> ids);
boolean updateItemComposeJudgeByEntrustId(Long entrustId);
}
......@@ -85,4 +85,6 @@ public interface IEntrustSampleService extends IBaseService<EntrustSample> {
boolean scanReceive(String sampleCode, Account account);
boolean makeSingleReport(Long sampleId, Long[] itemIds, Long templateId, Account account);
List<EntrustSampleVO> getMakeInfoList(EntrustSampleVO entrustSampleVO, Account account);
}
......@@ -851,7 +851,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
@Override
public Page<LmsUserRelGroupVO> selectAllPersonWorkload(Page<LmsUserRelGroupVO> page,LmsUserRelGroup rel) {
public Page<LmsUserRelGroupVO> selectAllPersonWorkload(Page<LmsUserRelGroupVO> page, LmsUserRelGroup rel) {
return page.setRecords(baseMapper.selectAllPersonWorkload(page, rel));
}
......@@ -880,4 +880,12 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return entrustSampleItemIndexService.list(Condition.create()
.eq("entrust_sample_item_id", item.getId())).size() == 0;
}
@Override
public boolean updateItemComposeJudgeByEntrustId(Long entrustId) {
if (null == entrustId || 0 == entrustId.longValue()) {
return false;
}
return baseMapper.updateItemJudgeByEntrustId(entrustId);
}
}
......@@ -623,6 +623,87 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
return list;
}
public List<EntrustSampleVO> getMakeInfoList(EntrustSampleVO entrustSampleVO, Account account) {
String makeType = entrustSampleVO.getMakeType();
// 默认全部
boolean bySample = true, sySample = true;
if (StringUtils.isNotBlank(makeType)) {
if ("备样".equals(makeType)) {
bySample = true;
sySample = false;
} else {
bySample = false;
sySample = true;
}
}
List<Long> sampleIdList = entrustSampleVO.getIds();
RestAssert.fail(CollectionUtils.isEmpty(sampleIdList), "请选择要制备的样品");
List<EntrustSample> sampleList = getBatchIds(sampleIdList);
RestAssert.fail(CollectionUtils.isEmpty(sampleList), "请选择要制备的样品");
List<EntrustSampleItem> itemList = entrustSampleItemService.list(Condition.create().in("entrust_sample_id", sampleIdList));
RestAssert.fail(CollectionUtils.isEmpty(itemList), "所选择的样品不含检测项目,无法制备");
//
Set<Long> setSampleIds = itemList.stream().map(EntrustSampleItem::getEntrustSampleId).collect(Collectors.toSet());
if (sampleIdList.size() != setSampleIds.size()) {
RestAssert.fail(CollectionUtils.isEmpty(itemList), "所选择的样品有不含检测项目的,请确认");
}
Map<Long, Map<Long, String>> sampleGroupMap = new HashMap<>();
for (EntrustSampleItem item : itemList) {
if (sampleGroupMap.containsKey(item.getEntrustSampleId())) {
Map<Long, String> groupMap = sampleGroupMap.get(item.getEntrustSampleId());
groupMap.put(item.getGroupId(), item.getGroupName());
sampleGroupMap.put(item.getEntrustSampleId(), groupMap);
} else {
Map<Long, String> groupMap = new HashMap<>();
groupMap.put(item.getGroupId(), item.getGroupName());
sampleGroupMap.put(item.getEntrustSampleId(), groupMap);
}
}
List<EntrustSampleVO> list = new ArrayList<>();
for (EntrustSample sample : sampleList) {
Map<Long, String> groupMap = sampleGroupMap.get(sample.getId());
if (null == groupMap) {
continue;
}
if (sySample) {
for (Map.Entry<Long, String> g : groupMap.entrySet()) {
EntrustSampleVO sampleVO = sample.convert(EntrustSampleVO.class);
sampleVO.setId(null);
sampleVO.setGroupId(g.getKey());
sampleVO.setGroupName(g.getValue());
sampleVO.setMakeType("送检样");
Set<String> itemNameSet = new HashSet<>();
for (EntrustSampleItem item : itemList) {
if (item.getEntrustSampleId().equals(sample.getId()) && item.getGroupId().equals(g.getKey())) {
itemNameSet.add(item.getName());
}
}
sampleVO.setItemNames(StringHandleUtils.join(itemNameSet));
sampleVO.setEntrustSampleId(sample.getId());
list.add(sampleVO);
}
}
//备样
if (bySample) {
EntrustSampleVO sampleVO = sample.convert(EntrustSampleVO.class);
sampleVO.setMakeType("备样");
list.add(sampleVO);
}
}
return list;
}
@Override
public Page<EntrustSampleVO> pageSampleReceive(Page<EntrustSampleVO> page, EntrustSampleVO entrustSample) {
return page.setRecords(baseMapper.selectSampleReceiveList(page, entrustSample));
......@@ -1560,13 +1641,14 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
RestAssert.fail(StringUtils.isBlank(sampleCode), "请扫描二维码");
String[] codeArray = sampleCode.split("~");
RestAssert.fail(codeArray.length != 3, "样品编号有误!");
Long groupId = Long.parseLong(codeArray[1]);
Long sampleId = Long.parseLong(codeArray[2]);
// 样品编号ID,根据当前提供的样品编号和组号获取
EntrustSample sample = getOne(Condition.create().setSqlSelect("id").eq("code", codeArray[0]).last("LIMIT 1"));
List<EntrustSamplePrepare> prepareList = entrustSamplePrepareService.list(Condition.create().eq("entrust_sample_id", sample.getId()).eq("group_id", Long.parseLong(codeArray[1])));
// EntrustSample sample = getOne(Condition.create().setSqlSelect("id").eq("id", codeArray[0]).last("LIMIT 1"));
List<EntrustSamplePrepare> prepareList = entrustSamplePrepareService.list(Condition.create().eq("entrust_sample_id", sampleId).eq("group_id", groupId));
RestAssert.fail(CollectionUtils.isEmpty(prepareList), "暂未查询到样品下的接收信息!");
Long[] sampleIds = prepareList.stream().map(EntrustSamplePrepare::getEntrustSampleId).toArray(size -> new Long[size]);
return entrustSamplePrepareService.submitSampleReceive(sampleIds, "扫码接收", account);
Long[] prepareIds = prepareList.stream().map(EntrustSamplePrepare::getId).toArray(size -> new Long[size]);
return entrustSamplePrepareService.submitSampleReceive(prepareIds, "扫码接收", account);
}
}
\ No newline at end of file
......@@ -455,6 +455,9 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
entrustSampleItemService.saveBatch(saveItemList);
}
}
entrustSampleItemService.updateItemComposeJudgeByEntrustId(entrust.getId());
executor1.execute(new Runnable() {
@Override
public void run() {
......@@ -1079,6 +1082,10 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
if (entrustSampleItemList.size() > 0) {
entrustSampleItemService.saveBatch(entrustSampleItemList);
}
// 更新检测项目判定字段
for (Long entrustId : ids) {
entrustSampleItemService.updateItemComposeJudgeByEntrustId(entrustId);
}
// 操作记录
entrustRecordService.record(ids, EntrustStatusEnum.DRAFT.getDisplay(), EntrustStatusEnum.DRAFT.getDisplay(), 0, account, "复制初始化委托");
......@@ -1218,7 +1225,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
/* 导出检测委托书 */
@Override
public Boolean exportEntrust(List<Long> ids, HttpServletResponse response) {
RestAssert.fail(CollectionUtils.isEmpty(ids),"请选择至少一个委托");
RestAssert.fail(CollectionUtils.isEmpty(ids), "请选择至少一个委托");
ByteArrayOutputStream baos = getEntrustBaos();
List<File> files = null;
try {
......@@ -1263,16 +1270,16 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
private ByteArrayOutputStream getEntrustBaos() {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("\\templates.\\word.\\entrust.\\EntrustExportTemplate.docx");
RestAssert.fail(null == inputStream,"委托检测书模板获取失败");
RestAssert.fail(null == inputStream, "委托检测书模板获取失败");
byte[] buffer = new byte[1024];
int len;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
while ((len = inputStream.read(buffer)) != -1) {
baos.write(buffer,0,len);
baos.write(buffer, 0, len);
}
} catch (IOException e) {
logger.error("读取inputStream异常:{}",e);
logger.error("读取inputStream异常:{}", e);
} finally {
IoUtils.close(inputStream);
}
......@@ -1309,14 +1316,14 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
currItems = items.stream()
.filter(i -> currIds.contains(i.getEntrustSampleId()))
.collect(Collectors.toList());
dataMap.put("sample",samples.get(0));
dataMap.put("sample", samples.get(0));
} else {
dataMap.put("sample",new EntrustSample());
dataMap.put("sample", new EntrustSample());
}
/* 委托 */
entrustVO.setSampleQuantityTotal(Long.parseLong(String.valueOf(samples.size())));
entrustVO.setCodes(ListToStringUtils.listToString(codes,"、",gangCode));
dataMap.put("entrust",entrustVO);
entrustVO.setCodes(ListToStringUtils.listToString(codes, "、", gangCode));
dataMap.put("entrust", entrustVO);
/* 项目名 */
Set<String> itemNames = currItems.stream().filter(i -> StringUtils.isNotEmpty(i.getName()))
.map(i -> i.getName()).collect(Collectors.toSet());
......@@ -1325,17 +1332,17 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
.filter(i -> StringUtils.isNotEmpty(i.getStandard()))
.map(i -> i.getStandard()).collect(Collectors.toSet());
dataMap.put("itemNames", ListToStringUtils.listToString(itemNames,"、",gangCode));
dataMap.put("standards",ListToStringUtils.listToString(standards,"、",gangCode));
dataMap.put("itemNames", ListToStringUtils.listToString(itemNames, "、", gangCode));
dataMap.put("standards", ListToStringUtils.listToString(standards, "、", gangCode));
/* 委托时间和样品接收时间 */
dataMap.put("entrustTimeStr", StringHandleUtils.parse(DateUtils.toYearMonthDay(entrust.getEntrustTime()),gangCode));
dataMap.put("entrustTimeStrCn", StringHandleUtils.parse(DateUtils.toYearMonthDayChinese(entrust.getEntrustTime()),gangCode));
dataMap.put("entrustTimeStrPoint", StringHandleUtils.parse(DateUtils.toYearMonthDayPoint(entrust.getEntrustTime()),gangCode));
dataMap.put("entrustTimeStr", StringHandleUtils.parse(DateUtils.toYearMonthDay(entrust.getEntrustTime()), gangCode));
dataMap.put("entrustTimeStrCn", StringHandleUtils.parse(DateUtils.toYearMonthDayChinese(entrust.getEntrustTime()), gangCode));
dataMap.put("entrustTimeStrPoint", StringHandleUtils.parse(DateUtils.toYearMonthDayPoint(entrust.getEntrustTime()), gangCode));
dataMap.put("receiveTimeStr",StringHandleUtils.parse(DateUtils.toYearMonthDay(entrust.getReceiveTime()),gangCode));
dataMap.put("receiveTimeStrCn",StringHandleUtils.parse(DateUtils.toYearMonthDayChinese(entrust.getReceiveTime()),gangCode));
dataMap.put("receiveTimeStrPoint",StringHandleUtils.parse(DateUtils.toYearMonthDayPoint(entrust.getReceiveTime()),gangCode));
dataMap.put("receiveTimeStr", StringHandleUtils.parse(DateUtils.toYearMonthDay(entrust.getReceiveTime()), gangCode));
dataMap.put("receiveTimeStrCn", StringHandleUtils.parse(DateUtils.toYearMonthDayChinese(entrust.getReceiveTime()), gangCode));
dataMap.put("receiveTimeStrPoint", StringHandleUtils.parse(DateUtils.toYearMonthDayPoint(entrust.getReceiveTime()), gangCode));
XWPFTemplate template = XWPFTemplate.compile(new ByteArrayInputStream(baos.toByteArray())).setDefaultValue("/").render(dataMap);
String filePath = filePathPrefix + entrust.getCode() + "检测委托书.docx";
......@@ -1357,7 +1364,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
entrustAnnexService.save(annex);
files.add(file);
IoUtils.close(fos,template.getXWPFDocument());
IoUtils.close(fos, template.getXWPFDocument());
}
return files;
}
......
......@@ -176,7 +176,9 @@
<select id="selectVOListBySampleIds" resultType="com.patzn.cloud.service.hmhj.vo.EntrustSampleItemVO">
SELECT i.id,i.name,i.agreed_value,i.test_value,i.entrust_sample_id,i.standard,s.code AS "sampleCode"
SELECT
i.*,s.code AS "sampleCode",s.sample_shape ,s.sample_quantity, s.standard,
s.sample_from, s.product_code,s.name_code
FROM
entrust_sample_item i
JOIN entrust_sample s ON i.entrust_sample_id = s.ID
......@@ -491,4 +493,35 @@
</if>
GROUP BY ug.user_id,ug.group_id,ug.realname
</select>
<!--更新委托下检测项目的组合判定状态-->
<update id="updateItemJudgeByEntrustId">
update entrust_sample_item i
set compose_judge = spi.compose_judge
from (
SELECT
distinct
s.entrust_id,
s.id "sample_id",
gp.grading_standard_id,
gi.grading_product_id,
gi.NAME "item_name",
gi.compose_judge
FROM
entrust_sample s
JOIN grading_standard gs ON gs.ID = s.product_standard_id
JOIN grading_product gp ON gp.grading_standard_id = gs.ID
join grading_item gi on gi.grading_product_id = gp.id
WHERE
s.deleted = 0
AND gs.deleted = 0
AND gp.deleted = 0
AND gi.deleted = 0
AND gs.compose_judge = 1
) as spi
where i.deleted = 0
and spi.item_name = i.name
and spi.sample_id = i.entrust_sample_id
and spi.entrust_id = #{entrustId}
</update>
</mapper>
ALTER TABLE "public"."qualification"
ALTER TABLE "public"."qualification"
ADD COLUMN "instrument_item_name" varchar(120) COLLATE "pg_catalog"."default";
COMMENT ON COLUMN "public"."qualification"."instrument_item_name" IS '仪器中项目名称';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment