Commit 9679eb3e authored by 竹天卫's avatar 竹天卫

导出功能 完善

parent 78398dbd
......@@ -158,7 +158,7 @@ public class EntrustController {
});
beanParams.put("list", sampleList);
WordUtil.writeWordReport(entrustVo.getEntrustCode() +"-"+ entrustVo.getProjectName() + "-委托单", "entrust2.ftl",
WordUtil.writeWordReportSXB(entrustVo.getEntrustCode() +"-"+ entrustVo.getProjectName() + "-委托单", "entrust2.ftl",
beanParams, response, FileExt.DOC);
}
......@@ -198,12 +198,22 @@ public class EntrustController {
@ApiOperation(value = "样品处理任务分页")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "projectCode", value = "项目编号", paramType = "query", dataType = "String")
@ApiImplicitParam(name = "entrustCode", value = "委托单号", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "status",
value = "状态(0未评审,1已通过,2未通过," +
"3样品处理中,4样品处理完成," +
"5样品检测中,6样品检测完成," +
"7校核中,8校核完成)", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "clientName", value = "委托单位id", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "projectName", value = "项目名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "projectCode", value = "项目编号", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "isUrgent", value = "(1加急,0不加急)", paramType = "query", dataType = "Integer")
})
@GetMapping("/getSampleHandlePage")
public BaseResponse getSampleHandlePage(PageQuery pageQuery, String projectCode) {
public BaseResponse getSampleHandlePage(PageQuery pageQuery, String entrustCode, Integer status,
String clientName, String projectName, String projectCode, Integer isUrgent) {
try {
return entrustService.getSampleHandlePage(pageQuery, projectCode);
return entrustService.getSampleHandlePage(pageQuery, entrustCode, status, clientName, projectName, projectCode, isUrgent);
} catch (Exception e) {
log.debug("样品处理任务分页{}", e);
}
......@@ -289,14 +299,23 @@ public class EntrustController {
@ApiOperation(value = "派发任务分页列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "entrustCode", value = "委托单号", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "status",
value = "状态(0未评审,1已通过,2未通过," +
"3样品处理中,4样品处理完成," +
"5样品检测中,6样品检测完成," +
"7校核中,8校核完成)", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "clientName", value = "委托单位id", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "projectName", value = "项目名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "projectCode", value = "项目编号", paramType = "query", dataType = "String")
@ApiImplicitParam(name = "projectCode", value = "项目编号", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "isUrgent", value = "(1加急,0不加急)", paramType = "query", dataType = "Integer")
})
@GetMapping("/getSampleDistributionPage")
public BaseResponse getSampleDistributionPage(PageQuery pageQuery, String projectName,
String projectCode) {
public BaseResponse getSampleDistributionPage(PageQuery pageQuery, String entrustCode, Integer status,
String clientName, String projectName, String projectCode, Integer isUrgent) {
try {
return entrustService.getSampleDistributionPage(pageQuery, projectName, projectCode);
return entrustService.getSampleDistributionPage(pageQuery, entrustCode, status,
clientName, projectName, projectCode, isUrgent);
} catch (Exception e) {
log.debug("派发任务分页列表{}", e);
}
......
......@@ -47,12 +47,13 @@ public class EquipmentController {
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "brand", value = "设备品牌", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "supplierId", value = "供应商表id", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "name", value = "设备名称", paramType = "query", dataType = "String")
@ApiImplicitParam(name = "name", value = "设备名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "type", value = "设备分类", paramType = "query", dataType = "String")
})
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery, String brand, Integer supplierId, String name) {
public BaseResponse getPage(PageQuery pageQuery, String brand, Integer supplierId, String name, String type) {
try {
return equipmentService.getPage(pageQuery, brand, supplierId, name);
return equipmentService.getPage(pageQuery, brand, supplierId, name, type);
} catch (Exception e) {
log.debug("设备分页列表{}", e);
}
......@@ -100,9 +101,9 @@ public class EquipmentController {
@ApiOperation("设备列表导出")
@PostMapping("/export")
public void export(String brand, Integer supplierId, String name, String fileName, HttpServletResponse response) {
public void export(String brand, Integer supplierId, String name, String type, String fileName, HttpServletResponse response) {
try {
equipmentService.export(brand, supplierId, name, fileName, response);
equipmentService.export(brand, supplierId, name, type, fileName, response);
} catch (Exception e) {
log.debug("设备列表导出{}", e);
}
......
......@@ -159,13 +159,31 @@
left join entrust e on e.id = s.entrust_id
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
where 1=1
where e.is_delete = 1
<if test="params.userId != null">
and t.user_id = #{params.userId}
</if>
<if test="params.entrustCode != null and params.entrustCode != ''">
and e.entrust_code like concat('%', #{params.entrustCode}, '%')
</if>
<if test="params.projectName != null and params.projectName != ''">
and p.name like concat('%', #{params.projectName}, '%')
</if>
<if test="params.projectCode != null and params.projectCode != ''">
and p.code like concat('%', #{params.projectCode}, '%')
</if>
<if test="params.projectType != null and params.projectType != ''">
and e.project_type = #{params.projectType}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
<if test="params.status != null">
and e.status = #{params.status}
</if>
<if test="params.isUrgent != null">
and e.is_urgent = #{params.isUrgent}
</if>
group by e.id
order by e.update_time desc
</select>
......@@ -196,16 +214,31 @@
left join entrust e on e.id = s.entrust_id
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
where 1=1
where e.is_delete = 1
<if test="params.userId != null">
and t.user_id = #{params.userId}
</if>
<if test="params.projectCode != null and params.projectCode != ''">
and p.code like concat('%', #{params.projectCode}, '%')
<if test="params.entrustCode != null and params.entrustCode != ''">
and e.entrust_code like concat('%', #{params.entrustCode}, '%')
</if>
<if test="params.projectName != null and params.projectName != ''">
and p.name like concat('%', #{params.projectName}, '%')
</if>
<if test="params.projectCode != null and params.projectCode != ''">
and p.code like concat('%', #{params.projectCode}, '%')
</if>
<if test="params.projectType != null and params.projectType != ''">
and e.project_type = #{params.projectType}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
<if test="params.status != null">
and e.status = #{params.status}
</if>
<if test="params.isUrgent != null">
and e.is_urgent = #{params.isUrgent}
</if>
GROUP BY e.id
order by e.update_time desc
</select>
......
......@@ -13,6 +13,10 @@
<if test="params.name != null and params.name != ''">
and t.name like concat('%', #{params.name}, '%')
</if>
<if test="params.type != null and params.type != ''">
and t.type like concat('%', #{params.type}, '%')
</if>
</where>
</sql>
......
......@@ -15,11 +15,11 @@
<select id="exportList" resultType="java.util.HashMap">
SELECT
(@i:=@i+1) as 序号,
t.name as 检测依据名,
t.standard as 标准号,
t.number as 检测依据编号,
t.do_date as 实施日期,
t.up_date as 更新日期
IF(ISNULL(t.name),'',t.name) as 检测依据名,
IF(ISNULL(t.standard),'',t.standard) as 标准号,
IF(ISNULL(t.number),'',t.number) as 检测依据编号,
IF(ISNULL(t.do_date),'',t.do_date) as 实施日期,
IF(ISNULL(t.up_date),'',t.up_date) as 更新日期
FROM method t ,(select @i:=0)t
<include refid="where"/>
ORDER BY t.id DESC
......
......@@ -38,10 +38,10 @@
<select id="exportList" resultType="java.util.HashMap">
SELECT
(@i:=@i+1) as 序号,
t.name as 检测项目,
IF(ISNULL(t.name),'',t.name ) as 检测项目,
IF(ISNULL(tg.name ),'',tg.name ) 所在检测组,
t.method_name as 检测依据,
t.charge as 收费标准,
IF(ISNULL(t.method_name),'',t.method_name) as 检测依据,
IF(ISNULL(t.charge),'',t.charge) as 收费标准,
(
CASE t.qualifications
WHEN 0 THEN '资质外'
......
......@@ -47,7 +47,8 @@ public interface IEntrustService extends IService<Entrust> {
// BaseResponse<String> handle(HandleQuery query);
BaseResponse<IPage<EntrustVo>> getSampleHandlePage(PageQuery pageQuery, String projectCode);
BaseResponse<IPage<EntrustVo>> getSampleHandlePage(PageQuery pageQuery, String entrustCode, Integer status,
String clientName, String projectName, String projectCode, Integer isUrgent);
BaseResponse<Map<String, Object>> getSampleHandleList(Integer id);
......@@ -63,8 +64,8 @@ public interface IEntrustService extends IService<Entrust> {
BaseResponse<String> distribution(DistributionQuery query);
BaseResponse<IPage<EntrustVo>> getSampleDistributionPage(PageQuery pageQuery, String projectName,
String projectCode);
BaseResponse<IPage<EntrustVo>> getSampleDistributionPage(PageQuery pageQuery, String entrustCode, Integer status,
String clientName, String projectName, String projectCode, Integer isUrgent);
BaseResponse<Map<String, Object>> getSampleDistributionList(Integer id);
......
......@@ -20,9 +20,9 @@ import javax.servlet.http.HttpServletResponse;
*/
public interface IEquipmentService extends IService<Equipment> {
BaseResponse<IPage<EquipmentVo>> getPage(PageQuery pageQuery, String brand, Integer supplierId, String name);
BaseResponse<IPage<EquipmentVo>> getPage(PageQuery pageQuery, String brand, Integer supplierId, String name, String type);
void export(String brand, Integer supplierId, String name, String fileName, HttpServletResponse response);
void export(String brand, Integer supplierId, String name, String type, String fileName, HttpServletResponse response);
void exportTest(String brand, Integer supplierId, String name, String fileName, HttpServletResponse response);
......
......@@ -1306,13 +1306,19 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
* @return
*/
@Override
public BaseResponse<IPage<EntrustVo>> getSampleHandlePage(PageQuery pageQuery, String projectCode) {
public BaseResponse<IPage<EntrustVo>> getSampleHandlePage(PageQuery pageQuery, String entrustCode, Integer status,
String clientName, String projectName, String projectCode, Integer isUrgent) {
LoginUser loginUser = userService.getLoginUser();
if (loginUser == null) {
return BaseResponse.errorMsg("请登录账号");
}
Map<String, Object> params = new HashMap<>();
params.put("entrustCode", entrustCode);
params.put("status", status);
params.put("clientName", clientName);
params.put("projectName", projectName);
params.put("projectCode", projectCode);
params.put("isUrgent", isUrgent);
params.put("userId", loginUser.getId());
Page<EntrustVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
......@@ -1723,15 +1729,20 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
* @return
*/
@Override
public BaseResponse<IPage<EntrustVo>> getSampleDistributionPage(PageQuery pageQuery, String projectName,
String projectCode) {
public BaseResponse<IPage<EntrustVo>> getSampleDistributionPage(PageQuery pageQuery, String entrustCode, Integer status,
String clientName, String projectName, String projectCode, Integer isUrgent) {
LoginUser loginUser = userService.getLoginUser();
if (loginUser == null) {
return BaseResponse.errorMsg("请登录账号");
}
Map<String, Object> params = new HashMap<>();
params.put("entrustCode", entrustCode);
params.put("status", status);
params.put("clientName", clientName);
params.put("projectName", projectName);
params.put("projectCode", projectCode);
params.put("isUrgent", isUrgent);
params.put("userId", loginUser.getId());
params.put("userId", loginUser.getId());
Page<EntrustVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<EntrustVo> pages = entrustMapper.getSampleDistributionPage(page, params);
......
......@@ -78,11 +78,12 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
* @return
*/
@Override
public BaseResponse<IPage<EquipmentVo>> getPage(PageQuery pageQuery, String brand, Integer supplierId, String name) {
public BaseResponse<IPage<EquipmentVo>> getPage(PageQuery pageQuery, String brand, Integer supplierId, String name, String type) {
Map<String, Object> params = new HashMap<>();
params.put("brand", brand);
params.put("supplierId", supplierId);
params.put("name", name);
params.put("type", type);
Page<EquipmentVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<EquipmentVo> pages = equipmentMapper.getPage(page, params);
return BaseResponse.okData(pages);
......@@ -98,10 +99,12 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
* @param response
*/
@Override
public void export(String brand, Integer supplierId, String name, String fileName, HttpServletResponse response) {
public void export(String brand, Integer supplierId, String name, String type, String fileName, HttpServletResponse response) {
Map<String, Object> params = new HashMap<>();
params.put("brand", brand);
params.put("supplierId", supplierId);
params.put("name", name);
params.put("type", type);
List<Map<String, Object>> list = equipmentMapper.exportList(params);
if (!CollectionUtils.isEmpty(list)) {
Map<String, Object> map = list.get(0);
......
......@@ -263,8 +263,7 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT
headers[2] = "所在检测组";
headers[3] = "检测依据";
headers[4] = "收费标准";
headers[5] = "建议产值";
headers[6] = "资质范围";
headers[5] = "资质范围";
List<Object[]> datas = new ArrayList<>(list.size());
for (Map<String, Object> m : list) {
Object[] objects = new Object[headers.length];
......@@ -275,7 +274,7 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT
}
objects[j] = obj;
}
datas.add(objects);
datas.add(objects);
}
ExcelUtil.excelExport(
fileName == null || fileName.trim().length() <= 0 ? "检测项" : fileName, headers,
......
......@@ -48,6 +48,77 @@ public class WordUtil {
FileExt fileExt) {
Writer out = null;
File file = null;
try {
configuration.setClassForTemplateLoading(WordUtil.class, FTL_FP);
Template template = configuration.getTemplate(templateFileName, "UTF-8");
if (template ==null){
System.out.println("==========================\n 报错-================\n");
}
String filePath;
filePath = "";
file = new File(filePath + templeName);
//输出文件
FileOutputStream fos = new FileOutputStream(file);
out = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
//变量替换
template.process(beanParams, out);
FileInputStream in = new FileInputStream(file);
/*HSSFWorkbook xssfWorkbook = new HSSFWorkbook(in);
ByteArrayOutputStream os = new ByteArrayOutputStream();
xssfWorkbook.write(os);
byte[] bytes = os.toByteArray();*/
byte[] buffer = new byte[in.available()];
int i = in.read(buffer);
if (i == -1) {
return;
}
in.close();
response.reset();
ServletOutputStream outputStream = response.getOutputStream();
response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
response.setContentType("application/octet-stream");
templeName = new String((templeName).getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
response.setHeader("Content-Disposition", "attachment;filename=" + templeName + fileExt.getName());
outputStream.write(buffer);
outputStream.flush();
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
boolean delete = file.delete();
if (!delete) {
log.debug(file.getName() + "文件删除失败!");
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 根据模板导出office文件 带上下标的
*
* @param templeName 导出的文件名
* @param templateFileName 模板名字
* @param beanParams 替换模板中的参数 <${模板占位符},对应值>
* @param response 响应体
*/
public static void writeWordReportSXB(
String templeName,
String templateFileName,
Map<String, Object> beanParams,
HttpServletResponse response,
FileExt fileExt) {
Writer out = null;
File file = null;
try {
configuration.setClassForTemplateLoading(WordUtil.class, FTL_FP);
Template template = configuration.getTemplate(templateFileName, "UTF-8");
......
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