parent
c17b36f4df
commit
dc152414c2
18 changed files with 816 additions and 50 deletions
@ -0,0 +1,100 @@ |
||||
package org.springblade.lims.entry; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Data; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
@SuppressWarnings("all") |
||||
@TableName("f_handle_sample") |
||||
public class HandleSample extends BaseEntity implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
private Long entrustId; |
||||
|
||||
/** |
||||
* 处理意见 |
||||
*/ |
||||
private String handleOpinion; |
||||
|
||||
/** |
||||
* 申请人id |
||||
*/ |
||||
private Long applicantId; |
||||
|
||||
/** |
||||
* 申请人 |
||||
*/ |
||||
private String applicant; |
||||
|
||||
/** |
||||
* 申请时间 |
||||
*/ |
||||
private Date applicantTime; |
||||
|
||||
/** |
||||
* 审批意见 |
||||
*/ |
||||
private String approveOpinion; |
||||
|
||||
/** |
||||
* 审批人id |
||||
*/ |
||||
private Long opinionId; |
||||
|
||||
/** |
||||
* 审批人 |
||||
*/ |
||||
private String opinionBy; |
||||
|
||||
/** |
||||
* 审批时间 |
||||
*/ |
||||
private Date opinionTime; |
||||
|
||||
/** |
||||
* 当前30天之前的时间 |
||||
*/ |
||||
@TableField(exist = false) |
||||
private Date starTime; |
||||
|
||||
@TableField(exist = false) |
||||
private List<Simple> simpleList; |
||||
|
||||
// 10.样品名称
|
||||
@TableField(exist = false) |
||||
private String simpleName; |
||||
|
||||
// 11.样品数量
|
||||
@TableField(exist = false) |
||||
private Integer simpleCount; |
||||
|
||||
// 18.接样日期
|
||||
@TableField(exist = false) |
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date samplingDate; |
||||
|
||||
// 过期时间
|
||||
@TableField(exist = false) |
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date beyondTime; |
||||
|
||||
// 检测编号
|
||||
@TableField(exist = false) |
||||
private String experieNum; |
||||
|
||||
// 留样处理状态(0待申请 1待处理 2已处理)
|
||||
@TableField(exist = false) |
||||
private Integer handleState; |
||||
|
||||
} |
||||
@ -0,0 +1,88 @@ |
||||
|
||||
package org.springblade.lims.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.lims.entry.Entrust; |
||||
import org.springblade.lims.entry.HandleSample; |
||||
import org.springblade.lims.service.IHandleSampleService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.util.Date; |
||||
|
||||
|
||||
/** |
||||
* @author litao |
||||
* @since 2023年7月17日 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/handleSample") |
||||
public class HandleSampleController extends BladeController { |
||||
|
||||
private IHandleSampleService handleSampleService; |
||||
|
||||
/** |
||||
* 留样处理申请列表 |
||||
*/ |
||||
@GetMapping("/entrustList") |
||||
public R<IPage<HandleSample>> entrustList(Query query, HandleSample handleSample) { |
||||
return R.data(handleSampleService.entrustList(handleSample, Condition.getPage(query))); |
||||
} |
||||
|
||||
/** |
||||
* 留样处理申请列表 |
||||
*/ |
||||
@GetMapping("/queryList") |
||||
public R<IPage<Entrust>> queryList(Query query, Entrust entrust) { |
||||
return R.data(handleSampleService.queryList(entrust, Condition.getPage(query))); |
||||
} |
||||
|
||||
/** |
||||
* 留样处理申请详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
public R detail(String id) { |
||||
return R.data(handleSampleService.getById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 留样处理申请提交 |
||||
*/ |
||||
@PostMapping("/save") |
||||
public R save(@RequestBody HandleSample handleSample) { |
||||
return R.status(handleSampleService.insert(handleSample)); |
||||
} |
||||
|
||||
/** |
||||
* 留样处理申请审批 |
||||
*/ |
||||
@PostMapping("/update") |
||||
public R update(@RequestBody HandleSample handleSample) { |
||||
return R.status(handleSampleService.updateBy(handleSample)); |
||||
} |
||||
|
||||
/** |
||||
* 留样处理(销毁)申请表打印 |
||||
*/ |
||||
@GetMapping("/simpleHandlePrint") |
||||
public void simpleHandlePrint(String id, HttpServletResponse response) { |
||||
handleSampleService.simpleHandlePrint(id, response); |
||||
} |
||||
|
||||
/** |
||||
* 样品处理登记表下载 |
||||
*/ |
||||
@GetMapping("/simpleRegisterPrint") |
||||
public void simpleRegisterPrint(String id, HttpServletResponse response) { |
||||
handleSampleService.simpleRegisterPrint(id, response); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,13 @@ |
||||
|
||||
package org.springblade.lims.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.lims.entry.HandleSample; |
||||
|
||||
/** |
||||
* @author litao |
||||
* @since 2023年7月17日 |
||||
*/ |
||||
public interface HandleSampleMapper extends BaseMapper<HandleSample> { |
||||
|
||||
} |
||||
@ -0,0 +1,29 @@ |
||||
|
||||
package org.springblade.lims.service; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.lims.entry.Entrust; |
||||
import org.springblade.lims.entry.HandleSample; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
/** |
||||
* @author litao |
||||
* @since 2023年7月17日 |
||||
*/ |
||||
public interface IHandleSampleService extends BaseService<HandleSample> { |
||||
IPage<HandleSample> entrustList(HandleSample handleSample, IPage<HandleSample> page); |
||||
|
||||
boolean insert(HandleSample handleSample); |
||||
|
||||
boolean updateBy(HandleSample handleSample); |
||||
|
||||
IPage<Entrust> queryList(Entrust entrust, IPage<Entrust> page); |
||||
|
||||
void simpleHandlePrint(String id, HttpServletResponse response); |
||||
|
||||
void simpleRegisterPrint(String id, HttpServletResponse response); |
||||
|
||||
} |
||||
@ -0,0 +1,432 @@ |
||||
|
||||
package org.springblade.lims.service.impl; |
||||
|
||||
import cn.afterturn.easypoi.entity.ImageEntity; |
||||
import cn.afterturn.easypoi.word.WordExportUtil; |
||||
import com.alibaba.nacos.common.utils.CollectionUtils; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import lombok.AllArgsConstructor; |
||||
import org.apache.commons.lang3.time.DateUtils; |
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument; |
||||
import org.springblade.core.cache.utils.CacheUtil; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.lims.entry.Entrust; |
||||
import org.springblade.lims.entry.HandleSample; |
||||
import org.springblade.lims.entry.Simple; |
||||
import org.springblade.lims.mapper.EntrustMapper; |
||||
import org.springblade.lims.mapper.HandleSampleMapper; |
||||
import org.springblade.lims.service.IEntrtrustService; |
||||
import org.springblade.lims.service.IHandleSampleService; |
||||
import org.springblade.lims.service.ISimpleService; |
||||
import org.springblade.system.cache.DictBizCache; |
||||
import org.springblade.system.entity.Param; |
||||
import org.springblade.system.enums.DictBizEnum; |
||||
import org.springblade.system.feign.ISysClient; |
||||
import org.springblade.system.user.entity.User; |
||||
import org.springblade.system.user.feign.IUserClient; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.*; |
||||
import java.text.SimpleDateFormat; |
||||
import java.time.LocalDateTime; |
||||
import java.util.*; |
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.PARAM_CACHE; |
||||
|
||||
/** |
||||
* @author litao |
||||
* @since 2023年7月17日 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
public class HandleSampleServiceImpl extends BaseServiceImpl<HandleSampleMapper, HandleSample> implements IHandleSampleService { |
||||
|
||||
private EntrustMapper entrustMapper; |
||||
|
||||
private IUserClient userClient; |
||||
|
||||
private ISimpleService simpleService; |
||||
|
||||
private ISysClient sysClient; |
||||
|
||||
@Override |
||||
public IPage<HandleSample> entrustList(HandleSample handleSample, IPage<HandleSample> page) { |
||||
// 获取当前30天之前的时间
|
||||
handleSample.setStarTime(DateUtils.addDays(new Date(), -30)); |
||||
|
||||
List<HandleSample> entrusts = entrustMapper.entrustList(page, handleSample); |
||||
if (CollectionUtils.isNotEmpty(entrusts)) { |
||||
for (HandleSample entrust : entrusts) { |
||||
String experieNum = entrust.getExperieNum(); |
||||
String[] split = experieNum.split(","); |
||||
entrust.setExperieNum(split[0] + "-" + split[split.length - 1]); |
||||
entrust.setBeyondTime(DateUtils.addDays(entrust.getSamplingDate(), 30)); |
||||
} |
||||
} |
||||
return page.setRecords(entrusts); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public boolean insert(HandleSample handleSample) { |
||||
Entrust entrust = new Entrust(); |
||||
entrust.setId(handleSample.getEntrustId()); |
||||
entrust.setHandleState(1); |
||||
entrustMapper.updateById(entrust); |
||||
|
||||
handleSample.setApplicantId(AuthUtil.getUserId()); |
||||
handleSample.setApplicant(userClient.userInfoById(AuthUtil.getUserId()).getData().getName()); |
||||
handleSample.setApplicantTime(new Date()); |
||||
return this.save(handleSample); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public boolean updateBy(HandleSample handleSample) { |
||||
Entrust entrust = new Entrust(); |
||||
entrust.setId(handleSample.getEntrustId()); |
||||
entrust.setHandleState(2); |
||||
entrust.setSampleHandle("交济南滕笙环保公司处理"); |
||||
entrustMapper.updateById(entrust); |
||||
|
||||
handleSample.setOpinionId(AuthUtil.getUserId()); |
||||
handleSample.setOpinionBy(userClient.userInfoById(AuthUtil.getUserId()).getData().getName()); |
||||
handleSample.setOpinionTime(new Date()); |
||||
return this.updateById(handleSample); |
||||
} |
||||
|
||||
@Override |
||||
public IPage<Entrust> queryList(Entrust entrust, IPage<Entrust> page) { |
||||
// List<Entrust> entrusts = entrustMapper.queryList(page, entrust);
|
||||
List<Integer> ins = new ArrayList<>(); |
||||
ins.add(2); |
||||
ins.add(3); |
||||
LambdaQueryWrapper<Entrust> wrapper = Wrappers.lambdaQuery(); |
||||
if (entrust.getStartTime() != null && entrust.getEndTime() != null) { |
||||
wrapper.between(Entrust::getSamplingDate, entrust.getStartTime(), entrust.getEndTime()); |
||||
} |
||||
if (entrust.getHandleState() != null) { |
||||
wrapper.eq(Entrust::getHandleState, entrust.getHandleState()); |
||||
} else { |
||||
wrapper.in(Entrust::getHandleState, ins); |
||||
} |
||||
wrapper.orderByAsc(Entrust::getSamplingDate); |
||||
IPage<Entrust> iPage = entrustMapper.selectPage(page, wrapper); |
||||
List<Entrust> entrusts = iPage.getRecords(); |
||||
if (CollectionUtils.isNotEmpty(entrusts)) { |
||||
entrusts.forEach(entry -> { |
||||
entry.setBeyondTime(DateUtils.addDays(entry.getSamplingDate(), 30)); |
||||
}); |
||||
} |
||||
return iPage; |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void simpleHandlePrint(String id, HttpServletResponse response) { |
||||
Map<String, Object> result = new HashMap<>(); |
||||
String path = sysClient.getParamValue("electronic_signature_real_path").getData(); |
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日"); |
||||
|
||||
HandleSample handleSample = this.getById(id); |
||||
|
||||
String count = sysClient.getParamValue("interface_count1").getData(); |
||||
String[] split1 = count.split("-"); |
||||
int newCount = Integer.parseInt(split1[1]); |
||||
int year = LocalDateTime.now().getYear(); |
||||
if (!String.valueOf(year).equals(split1[0])) { |
||||
newCount = 0; |
||||
} |
||||
newCount++; |
||||
Param param = new Param(); |
||||
param.setParamKey("interface_count1"); |
||||
param.setParamValue(split1[0] + "-" + newCount); |
||||
CacheUtil.clear(PARAM_CACHE); |
||||
sysClient.updateParam(param); |
||||
|
||||
if (newCount >= 0 && newCount < 9) { |
||||
result.put("1", year + "000" + newCount); |
||||
} else if (newCount >= 9 && newCount < 99) { |
||||
result.put("1", year + "00" + newCount); |
||||
} else if (newCount >= 99 && newCount < 999) { |
||||
result.put("1", year + "0" + newCount); |
||||
} else{ |
||||
result.put("1", year + "" + newCount); |
||||
} |
||||
|
||||
result.put("2", handleSample.getHandleOpinion()); |
||||
|
||||
User user = userClient.userInfoById(handleSample.getApplicantId()).getData(); |
||||
if (user != null) { |
||||
ImageEntity farView = new ImageEntity(); |
||||
farView.setHeight(50);//设置高度
|
||||
farView.setWidth(90);//设置宽度
|
||||
farView.setType(ImageEntity.Data);//类型
|
||||
String s1 = path + user.getElectronicSignature(); |
||||
FileInputStream fis = null; |
||||
try { |
||||
fis = new FileInputStream(new File(s1)); |
||||
byte[] bytes = readInputStream(fis); |
||||
farView.setData(bytes); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
result.put("3", farView); |
||||
} |
||||
|
||||
result.put("4", format.format(handleSample.getApplicantTime())); |
||||
result.put("5", handleSample.getApproveOpinion()); |
||||
|
||||
User user1 = userClient.userInfoById(handleSample.getOpinionId()).getData(); |
||||
if (user1 != null) { |
||||
ImageEntity farView = new ImageEntity(); |
||||
farView.setHeight(50);//设置高度
|
||||
farView.setWidth(90);//设置宽度
|
||||
farView.setType(ImageEntity.Data);//类型
|
||||
String s1 = path + user1.getElectronicSignature(); |
||||
FileInputStream fis = null; |
||||
try { |
||||
fis = new FileInputStream(new File(s1)); |
||||
byte[] bytes = readInputStream(fis); |
||||
farView.setData(bytes); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
result.put("6", farView); |
||||
} |
||||
|
||||
result.put("7", format.format(handleSample.getOpinionTime())); |
||||
|
||||
// 对应委托单
|
||||
Entrust entrust = entrustMapper.selectById(handleSample.getEntrustId()); |
||||
entrust.setIsHandle("1"); |
||||
entrustMapper.updateById(entrust); |
||||
result.put("9", entrust.getSimpleCount()); |
||||
result.put("10", entrust.getSimpleName()); |
||||
|
||||
LambdaQueryWrapper<Simple> wrapper = new LambdaQueryWrapper<>(); |
||||
wrapper.eq(Simple::getEntrustId, entrust.getId()).eq(Simple::getIsReagent, "0").eq(Simple::getSort, 1); |
||||
List<Simple> simpleList = simpleService.list(wrapper); |
||||
System.out.println("simpleList===" + simpleList); |
||||
String num = ""; |
||||
if (CollectionUtils.isNotEmpty(simpleList)) { |
||||
String experieNum = simpleList.get(0).getExperieNum(); |
||||
num += experieNum + "-"; |
||||
String[] split = experieNum.split("-"); |
||||
for (int i = 0; i < split.length - 1; i++) { |
||||
num += split[i] + "-"; |
||||
} |
||||
num += entrust.getSimpleCount(); |
||||
System.out.println("num===" + num); |
||||
result.put("8", num); |
||||
} |
||||
|
||||
System.out.println("result===" + result); |
||||
String url = DictBizCache.getKey(DictBizEnum.PRINT_URL.getName(), "simpleHandlePrint"); |
||||
XWPFDocument doc = null; |
||||
// FileOutputStream fos = null;
|
||||
try { |
||||
doc = WordExportUtil.exportWord07(url, result); |
||||
// fos = new FileOutputStream("C://Users//AAA//Desktop//烁今//打印模板//留样处理(销毁)申请表.docx");
|
||||
String filename = "测试.docx"; |
||||
|
||||
response.setContentType("application/octet-stream"); |
||||
response.setHeader("content-disposition", "attachment;filename=12344.docx"); |
||||
|
||||
doc.write(response.getOutputStream()); |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} finally { |
||||
// if (null != doc) {
|
||||
//// doc.close();
|
||||
// try {
|
||||
// doc.write(fos);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// if (null != fos) {
|
||||
// try {
|
||||
// fos.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
if (null != doc) { |
||||
try { |
||||
doc.close(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void simpleRegisterPrint(String id, HttpServletResponse response) { |
||||
Map<String, Object> result = new HashMap<>(); |
||||
List<Map<String, Object>> resultList = new ArrayList<>(); |
||||
|
||||
String count = sysClient.getParamValue("interface_count2").getData(); |
||||
String[] split1 = count.split("-"); |
||||
int newCount = Integer.parseInt(split1[1]); |
||||
int year = LocalDateTime.now().getYear(); |
||||
if (!String.valueOf(year).equals(split1[0])) { |
||||
newCount = 0; |
||||
} |
||||
newCount++; |
||||
Param param = new Param(); |
||||
param.setParamKey("interface_count2"); |
||||
param.setParamValue(split1[0] + "-" + newCount); |
||||
CacheUtil.clear(PARAM_CACHE); |
||||
sysClient.updateParam(param); |
||||
|
||||
if (newCount >= 0 && newCount < 9) { |
||||
result.put("1", year + "000" + newCount); |
||||
} else if (newCount >= 9 && newCount < 99) { |
||||
result.put("1", year + "00" + newCount); |
||||
} else if (newCount >= 99 && newCount < 999) { |
||||
result.put("1", year + "0" + newCount); |
||||
} else{ |
||||
result.put("1", year + "" + newCount); |
||||
} |
||||
|
||||
List<Long> list = Func.toLongList(id); |
||||
|
||||
for (Long aLong : list) { |
||||
// 修改为已导出
|
||||
Entrust entrust = entrustMapper.selectById(aLong); |
||||
entrust.setHandleState(3); |
||||
entrustMapper.updateById(entrust); |
||||
|
||||
// 该委托单样品信息
|
||||
List<Simple> simples = simpleService.list(Wrappers.<Simple>lambdaQuery().eq(Simple::getEntrustId, aLong).eq(Simple::getIsReagent, "0").orderByAsc(Simple::getSort)); |
||||
|
||||
System.out.println("simples===" + simples.size()); |
||||
if (CollectionUtils.isNotEmpty(simples)) { |
||||
String num = ""; |
||||
String experieNum = simples.get(0).getExperieNum(); |
||||
String[] split = experieNum.split("-"); |
||||
for (int i = 0; i < split.length - 1; i++) { |
||||
num += split[i] + "-"; |
||||
} |
||||
|
||||
int start = 1; |
||||
int size = 0; |
||||
for (int i = 0; i < simples.size(); i++) { |
||||
Simple simple = simples.get(i); |
||||
if (simple.getOriginalNum().equals(String.valueOf(i + 1))) { |
||||
size++; |
||||
if (size == simples.size()) { |
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("originalNum", start + "-" + (start + size)); |
||||
map.put("experieNum", num + start + "-" + num + (start + size)); |
||||
map.put("simpleName", simple.getSimpleName()); |
||||
map.put("sampleHandle", entrust.getSampleHandle()); |
||||
map.put("a", "~"); |
||||
map.put("b", "接样室"); |
||||
map.put("c", "李玉杰"); |
||||
resultList.add(map); |
||||
} |
||||
continue; |
||||
} |
||||
if (size > 0) { |
||||
Map<String, Object> map = new HashMap<>(); |
||||
if (size == 1) { |
||||
map.put("originalNum", start); |
||||
map.put("experieNum", num + start); |
||||
} else { |
||||
map.put("originalNum", start + "-" + (start + size)); |
||||
map.put("experieNum", num + start + "-" + num + (start + size)); |
||||
} |
||||
map.put("simpleName", simple.getSimpleName()); |
||||
map.put("sampleHandle", entrust.getSampleHandle()); |
||||
map.put("a", "~"); |
||||
map.put("b", "接样室"); |
||||
map.put("c", "李玉杰"); |
||||
resultList.add(map); |
||||
} |
||||
start = i + 2; |
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("originalNum", simple.getOriginalNum()); |
||||
map.put("experieNum", simple.getExperieNum()); |
||||
map.put("simpleName", simple.getSimpleName()); |
||||
map.put("sampleHandle", entrust.getSampleHandle()); |
||||
map.put("a", "~"); |
||||
map.put("b", "接样室"); |
||||
map.put("c", "李玉杰"); |
||||
resultList.add(map); |
||||
} |
||||
} |
||||
} |
||||
|
||||
result.put("resultList", resultList); |
||||
System.out.println("result===" + result); |
||||
|
||||
//模板地址
|
||||
// String handleUrl = "C://Users//AAA//Desktop//烁今//打印模板//留样登记表(模板).docx";
|
||||
String url = DictBizCache.getKey(DictBizEnum.PRINT_URL.getName(), "simpleRegisterPrint"); |
||||
XWPFDocument doc = null; |
||||
// FileOutputStream fos = null;
|
||||
try { |
||||
doc = WordExportUtil.exportWord07(url, result); |
||||
// fos = new FileOutputStream("C://Users//AAA//Desktop//烁今//打印模板//留样登记表.docx");
|
||||
String filename = "测试.docx"; |
||||
|
||||
response.setContentType("application/octet-stream"); |
||||
response.setHeader("content-disposition", "attachment;filename=12344.docx"); |
||||
|
||||
doc.write(response.getOutputStream()); |
||||
|
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} finally { |
||||
// if (null != doc) {
|
||||
//// doc.close();
|
||||
// try {
|
||||
// doc.write(fos);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// if (null != fos) {
|
||||
// try {
|
||||
// fos.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
if (null != doc) { |
||||
try { |
||||
doc.close(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 读输入流 |
||||
*/ |
||||
private static byte[] readInputStream(InputStream inStream) throws Exception { |
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream(); |
||||
byte[] buffer = new byte[1024]; |
||||
int len = 0; |
||||
while ((len = inStream.read(buffer)) != -1) { |
||||
outStream.write(buffer, 0, len); |
||||
} |
||||
inStream.close(); |
||||
return outStream.toByteArray(); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue