Commit 0f3c2618 by ghxdhr

修改检测委托书的打印状态

parent 7cac6acc
package com.patzn.cloud.service.lims.hmhj.controller;
import com.baomidou.kisso.annotation.Action;
import com.baomidou.kisso.annotation.Login;
import com.google.common.collect.Lists;
import com.patzn.cloud.service.hmhj.dto.EntrustDTO;
import com.patzn.cloud.service.hmhj.entity.Entrust;
......@@ -846,4 +848,11 @@ public class EntrustController extends ServiceController {
return success(entrustService.exportEntrust(ids,response));
}
/* 打印检测委托书完成后的ajax调用,先使用未登录方式 */
@ApiOperation("修改检测委托书打印状态")
@Login(action = Action.Skip)
@PostMapping("/update_print_status")
public RestResult<Boolean> updatePrintStatus(@RequestParam("ids") List<Long> ids) {
return success(entrustService.updatePrintStatus(ids));
}
}
......@@ -93,4 +93,7 @@ public interface IEntrustService extends IBaseService<Entrust> {
boolean rejectSubmitApply(Long id,String reason, Account account);
Boolean exportEntrust(List<Long> ids, HttpServletResponse response);
/* 修改检测委托书的打印状态 */
Boolean updatePrintStatus(List<Long> ids);
}
......@@ -1267,6 +1267,24 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
return false;
}
/* 修改检测委托书的状态 */
@Override
public Boolean updatePrintStatus(List<Long> ids) {
if (CollectionUtils.isNotEmpty(ids)) {
List<Entrust> entrusts = ids.stream().map(id -> {
Entrust entrust = new Entrust();
entrust.setId(id);
entrust.setPrintStatus(1);
return entrust;
}).collect(Collectors.toList());
/* 删除上传的文件 */
List<EntrustAnnex> entrustAnnex = entrustAnnexService.list(Condition.create().in("entrust_id", ids));
ossClient.deleteObjects(entrustAnnex.stream().map(ea -> ea.getObjectKey()).collect(Collectors.toList()));
return this.updateBatchById(entrusts);
}
return true;
}
private ByteArrayOutputStream getEntrustBaos() {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("\\templates.\\word.\\entrust.\\EntrustExportTemplate.docx");
RestAssert.fail(null == inputStream,"委托检测书模板获取失败");
......@@ -1304,9 +1322,18 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
filter(s -> entrust.getId().equals(s.getEntrustId())).
collect(Collectors.toList());
/* 该样品对应的项目 */
List<EntrustSampleItem> currItems = items.stream()
List<EntrustSampleItem> currItems = new ArrayList<>();
if (CollectionUtils.isNotEmpty(samples)) {
/* 该样品对应的项目 */
currItems = items.stream()
.filter(i -> samples.get(0).getId().equals(i.getEntrustSampleId()))
.collect(Collectors.toList());
dataMap.put("sample",samples.get(0));
} else {
dataMap.put("sample",new EntrustSample());
}
/* 委托*/
dataMap.put("entrust",entrust);
/* 项目名 */
Set<String> itemNames = currItems.stream().filter(i -> StringUtils.isNotEmpty(i.getName()))
.map(i -> i.getName()).collect(Collectors.toSet());
......@@ -1314,7 +1341,10 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
Set<String> standards = currItems.stream()
.filter(i -> StringUtils.isNotEmpty(i.getStandard()))
.map(i -> i.getStandard()).collect(Collectors.toSet());
dataMap.put("entrust",entrust);
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));
......@@ -1324,10 +1354,6 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
dataMap.put("receiveTimeStrCn",StringHandleUtils.parse(DateUtils.toYearMonthDayChinese(entrust.getReceiveTime()),gangCode));
dataMap.put("receiveTimeStrPoint",StringHandleUtils.parse(DateUtils.toYearMonthDayPoint(entrust.getReceiveTime()),gangCode));
dataMap.put("sample",samples.get(0));
dataMap.put("itemNames", ListToStringUtils.listToString(itemNames,"、",gangCode));
dataMap.put("standards",ListToStringUtils.listToString(standards,"、",gangCode));
XWPFTemplate template = XWPFTemplate.compile(new ByteArrayInputStream(baos.toByteArray())).setDefaultValue("/").render(dataMap);
String filePath = filePathPrefix + entrust.getCode() + "检测委托书.docx";
File file = new File(filePath);
......
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