Commit 5366470d authored by mengbali153's avatar mengbali153

Merge remote-tracking branch 'origin/master' into master

parents f666a56f a6943c59
......@@ -23,6 +23,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......
package cn.wise.sc.cement.business.config;
import org.apache.catalina.session.StandardSessionFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
@Configuration
public class WebSocketConfig extends ServerEndpointConfig.Configurator {
private static final Logger log = LoggerFactory.getLogger(WebSocketConfig.class);
/**
* 修改握手信息
*/
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
StandardSessionFacade ssf = (StandardSessionFacade) request.getHttpSession();
if (ssf != null) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
//关键操作
sec.getUserProperties().put("sessionId", httpSession.getId());
log.info("获取到的SessionID:" + httpSession.getId());
}
super.modifyHandshake(sec, request, response);
}
/**
* WebSocket的支持
* @return
*/
@Bean
public ServerEndpointExporter serverEndpointExporter() {
//这个对象说一下,貌似只有服务器是tomcat的时候才需要配置,具体我没有研究
return new ServerEndpointExporter();
}
}
......@@ -8,6 +8,7 @@ import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.*;
import cn.wise.sc.cement.business.model.vo.TeamVo;
import cn.wise.sc.cement.business.service.IEquipmentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
......@@ -59,6 +60,31 @@ public class EquipmentController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "检定设备")
@PostMapping("/test")
public BaseResponse test(@RequestBody EquipmentTestQuery query) {
try {
return equipmentService.test(query);
}catch (Exception e) {
log.debug("检定设备{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "设备检定历史")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "equipmentId", value = "设备表id", paramType = "query", dataType = "Integer")
})
@GetMapping("/getTestPage")
public BaseResponse getTestPage(PageQuery pageQuery, Integer equipmentId) {
try {
return equipmentService.getTestPage(pageQuery, equipmentId);
} catch (Exception e) {
log.debug("设备检定历史{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation("设备列表导出")
@PostMapping("/export")
public void export(String brand, Integer supplierId, String name, String fileName, HttpServletResponse response) {
......@@ -79,8 +105,6 @@ public class EquipmentController {
}
}
@ApiOperation(value = "新增设备")
@PostMapping("/create")
public BaseResponse create(@RequestBody EquipmentQuery query) {
......@@ -118,7 +142,9 @@ public class EquipmentController {
@GetMapping("/getList")
public BaseResponse getList(){
try {
List<Equipment> list = equipmentService.list();
QueryWrapper<Equipment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("status", 1);
List<Equipment> list = equipmentService.list(queryWrapper);
return BaseResponse.okData(list);
}catch (Exception e){
log.debug("设备列表{}",e);
......@@ -138,30 +164,8 @@ public class EquipmentController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "检定设备")
@PostMapping("/test")
public BaseResponse test(@RequestBody EquipmentTestQuery query) {
try {
return equipmentService.test(query);
}catch (Exception e) {
log.debug("检定设备{}",e);
}
return BaseResponse.errorMsg("失败!");
}
/* @ApiOperation(value = "设备检定分页列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "equipmentId", value = "设备表id", paramType = "query", dataType = "Integer")
})
@GetMapping("/getTestPage")
public BaseResponse getTestPage(PageQuery pageQuery, Integer equipmentId) {
try {
return equipmentService.getTestPage(pageQuery, equipmentId);
} catch (Exception e) {
log.debug("设备检定分页列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}*/
/*
@ApiOperation(value = "设备检定详情")
......@@ -190,12 +194,12 @@ public class EquipmentController {
@ApiOperation(value = "设备故障维修登记分页列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "equipmentId", value = "设备表id", paramType = "query", dataType = "Integer")
@ApiImplicitParam(name = "name", value = "设备名称", paramType = "query", dataType = "String")
})
@GetMapping("/getTroubleshootingPage")
public BaseResponse getTroubleshootingPage(PageQuery pageQuery, Integer equipmentId) {
public BaseResponse getTroubleshootingPage(PageQuery pageQuery, String name) {
try {
return equipmentService.getTroubleshootingPage(pageQuery, equipmentId);
return equipmentService.getTroubleshootingPage(pageQuery, name);
} catch (Exception e) {
log.debug("设备故障维修登记分页列表{}", e);
}
......@@ -204,9 +208,9 @@ public class EquipmentController {
@ApiOperation("设备维修列表导出")
@PostMapping("/exportTroubleshooting")
public void exportTroubleshooting(Integer equipmentIde, String fileName, HttpServletResponse response) {
public void exportTroubleshooting( String name, String fileName, HttpServletResponse response) {
try {
equipmentService.exportTroubleshooting(equipmentIde, fileName, response);
equipmentService.exportTroubleshooting(name, fileName, response);
} catch (Exception e) {
log.debug("设备维修列表导出{}", e);
}
......
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.FileExt;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.ReportDetailVo;
import cn.wise.sc.cement.business.model.SixElementKey;
import cn.wise.sc.cement.business.model.SixElementReport;
import cn.wise.sc.cement.business.model.vo.EntrustVo;
import cn.wise.sc.cement.business.service.IEntrustService;
import cn.wise.sc.cement.business.util.WordUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -21,8 +25,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @description: 报告管理
......@@ -80,8 +86,8 @@ public class ReportController {
public void getReportDetail(@PathVariable("entrustId") Integer entrustId,
HttpServletResponse response) {
//首页及封面导出
ReportDetailVo rts = iEntrustService.getReportDetail(entrustId);
Map<String, Object> beanParams = new HashMap<>(10);
beanParams.put("sendName", rts.getSendName());
beanParams.put("sender", rts.getSender());
......@@ -94,9 +100,52 @@ public class ReportController {
beanParams.put("projectName", rts.getProjectName());
beanParams.put("printDate", rts.getPrintDate());
WordUtil.writeWordReport(rts.getProjectName() + "(报告).xls", "report.ftl",
beanParams, response);
//六元素导出
List<SixElementReport> list = iEntrustService.getSampleSixElementCheck(entrustId);
list.forEach(this::initMapStr2AlongPro);
List<SixElementReport> al2o3AndTio2List = list.stream()
.filter(arg -> !"-".equals(arg.getAl2o3AndTio2()))
.collect(Collectors.toList());
List<SixElementReport> al2o3SplitTio2List = list.stream()
.filter(arg -> "-".equals(arg.getAl2o3AndTio2()))
.collect(Collectors.toList());
beanParams.put("list1", al2o3AndTio2List);
beanParams.put("list2", al2o3SplitTio2List);
WordUtil.writeWordReport(rts.getProjectName() + "(报告)", "report.ftl",
beanParams, response, FileExt.EXCL);
}
/**
* 将样品六元素检测Map转换成单独属性
*
* @param sixElement 带转换的六元素检测结果
* @return 已转换结果
*/
private void initMapStr2AlongPro(SixElementReport sixElement) {
String countResult = sixElement.getCountResult();
HashMap<String, String> countResultMap = JSON.parseObject(countResult, HashMap.class);
sixElement.setAl2o3("-");
sixElement.setTio2("-");
sixElement.setAl2o3AndTio2("-");
//判断检测结果中六元素Al2O3是否包含TiO2
if (countResultMap.containsKey(SixElementKey.Al2O3AndTiO2.getKey())) {
sixElement.setAl2o3AndTio2(countResultMap.get(SixElementKey.Al2O3AndTiO2.getKey()));
} else {
sixElement.setAl2o3(countResultMap.getOrDefault(SixElementKey.Al2O3.getKey(), "0"));
sixElement.setTio2(countResultMap.getOrDefault(SixElementKey.TiO2.getKey(), "0"));
}
sixElement.setCao(countResultMap.getOrDefault(SixElementKey.CaO.getKey(), "0"));
sixElement.setCl(countResultMap.getOrDefault(SixElementKey.Cl.getKey(), "0"));
sixElement.setFe2o3(countResultMap.getOrDefault(SixElementKey.Fe2O3.getKey(), "0"));
sixElement.setLoi(countResultMap.getOrDefault(SixElementKey.LOI.getKey(), "0"));
sixElement.setMgo(countResultMap.getOrDefault(SixElementKey.MgO.getKey(), "0"));
sixElement.setSio2(countResultMap.getOrDefault(SixElementKey.SiO2.getKey(), "0"));
sixElement.setSo3(countResultMap.getOrDefault(SixElementKey.SO3.getKey(), "0"));
}
private String set2String(Set<String> source) {
......@@ -119,6 +168,6 @@ public class ReportController {
strBuilder.append("&#10;").append(target);
}
return strBuilder.replace(0,5,"").toString();
return strBuilder.replace(0, 5, "").toString();
}
}
package cn.wise.sc.cement.business.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-10-13
*/
@RestController
@RequestMapping("/business/sys-user-message")
public class SysUserMessageController {
}
......@@ -50,6 +50,15 @@ public class EquipmentTest implements Serializable {
@ApiModelProperty("实施结果")
private String tryResult;
@ApiModelProperty("附件地址")
private String enclosureUrl;
@ApiModelProperty("文件名")
private String alias;
@ApiModelProperty("扩展名")
private String extName;
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDate;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
......@@ -29,13 +30,11 @@ import lombok.experimental.Accessors;
public class QualityApply implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 项目名
*/
@ApiModelProperty("项目名字")
private String projectName;
/**
* 项目id
*/
......@@ -44,43 +43,42 @@ public class QualityApply implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 来样编号
*/
@ApiModelProperty("来样编号")
private String sampleCode;
/**
* 本所编号
*/
@ApiModelProperty("本所编号")
private String cementCode;
/**
* 部门名
*/
@ApiModelProperty("部门名")
@TableField(exist = false)
private String groupName;
/**
* 样品状态
*/
@ApiModelProperty("样品状态")
private String sampleForm;
/**
* 计算结果
*/
@ApiModelProperty("输入结果")
private String inputResult;
/**
* 检测项id
*/
@ApiModelProperty("检测项id")
private Integer teamGroupId;
/**
* 时间
*/
@ApiModelProperty("项目时间")
private LocalDate createTime;
/**
* 1:人工检测 2:标准 3:误差
*/
......@@ -99,4 +97,9 @@ public class QualityApply implements Serializable {
private String teams;
@ApiModelProperty("检测人")
private String userName;
@ApiModelProperty("userId")
private Integer userId;
@ApiModelProperty("部门")
@TableField(exist = false)
private String positionName;
}
package cn.wise.sc.cement.business.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author ztw
* @since 2020-10-13
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SysUserMessage implements Serializable {
private static final long serialVersionUID=1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 接收人id
*/
private Integer userId;
/**
* 接收信息
*/
private String message;
/**
* 相关内容(委托表id)
*/
private Integer appId;
/**
* 是否查看(0:否,1:是)
*/
private Integer isCheck;
/**
* 消息类型(1委托管理)
*/
private Integer messageType;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 是否处理(0:未处理,1:已处理)
*/
private Integer isDeal;
public interface MessageType {
int ENTRUST = 1;
}
}
package cn.wise.sc.cement.business.mapper;
import cn.wise.sc.cement.business.entity.SampleCheck;
import cn.wise.sc.cement.business.model.SixElementReport;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* <p>
* Mapper 接口
......@@ -13,4 +16,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface SampleCheckMapper extends BaseMapper<SampleCheck> {
/**
* 获取样品六元素检测结果
* @param entrustId 项目id
* @return SixElementReport
*/
List<SixElementReport> getSampleSixElementCheck(Integer entrustId);
}
package cn.wise.sc.cement.business.mapper;
import cn.wise.sc.cement.business.entity.SysUserMessage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ztw
* @since 2020-10-13
*/
public interface SysUserMessageMapper extends BaseMapper<SysUserMessage> {
List<SysUserMessage> getNoCheck(@Param(value = "userId") Integer userId,
@Param(value = "appId") Integer appId,
@Param(value = "messageType") Integer messageType);
List<SysUserMessage> getNoDeal(@Param(value = "userId") Integer userId,
@Param(value = "appId") Integer appId,
@Param(value = "messageType") Integer messageType);
}
......@@ -3,7 +3,9 @@
<mapper namespace="cn.wise.sc.cement.business.mapper.EquipmentTroubleshootingMapper">
<sql id="where">
<where>
and et.equipment_id = #{params.equipmentId}
<if test="params.name != null and params.name != ''">
and e.name like concat('%', #{params.name}, '%')
</if>
</where>
</sql>
......
......@@ -2,4 +2,18 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wise.sc.cement.business.mapper.SampleCheckMapper">
<select id="getSampleSixElementCheck" resultType="cn.wise.sc.cement.business.model.SixElementReport">
SELECT * FROM (SELECT count_result,entrust_id,team_group_name,sct.sample_id FROM sample_check sc
LEFT JOIN
(SELECT check_id,sample_id FROM sample_check_team) sct
ON sct.check_id = sc.id
AND sc. is_parallel = 0
WHERE sct.sample_id IS NOT NULL AND sc.team_group_name = '六元素' ) sscct
RIGHT JOIN
(SELECT cement_code,sample_code,sample_form,`name` as sample_name,weight,id
FROM sample) s
ON s.id = sscct.sample_id AND entrust_id =1
WHERE count_result IS NOT NULL;
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wise.sc.cement.business.mapper.SysUserMessageMapper">
<!-- 未查看消息 -->
<select id="getNoCheck" resultType="cn.wise.sc.cement.business.entity.SysUserMessage" >
select *
FROM sys_user_message rum
where rum.is_check=0
<if test="userId != null and userId !=''">
and rum.user_id = #{userId}
</if>
<if test="appId != null and appId !=''">
and rum.app_id = #{appId}
</if>
<if test="messageType != null and messageType !=''">
and rum.message_type = #{messageType}
</if>
</select>
<!-- 未处理消息记录 -->
<select id="getNoDeal" resultType="cn.wise.sc.cement.business.entity.SysUserMessage" >
select *
FROM sys_user_message rum
where rum.is_deal=0
<if test="userId != null and userId !=''">
and rum.user_id = #{userId}
</if>
<if test="appId != null and appId !=''">
and rum.app_id = #{appId}
</if>
<if test="messageType != null and messageType !=''">
and rum.message_type = #{messageType}
</if>
</select>
</mapper>
......@@ -29,7 +29,7 @@
left join team_group tg on tg.id = t.group_id
left join method m on m.id = t.method_id
<include refid="where" />
ORDER BY t.id DESC
ORDER BY t.id ASC
</select>
<select id="exportList" resultType="java.util.HashMap">
......
package cn.wise.sc.cement.business.model;
/**
* @description: 文件扩展名
* @author: qh
* @create: 2020-10-16 13:40
**/
public enum FileExt {
//office后缀名
DOC(".doc"),
EXCL(".xls");
private String name;
FileExt(String name){
this.name = name;
}
public String getName() {
return name;
}
}
package cn.wise.sc.cement.business.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Message implements Serializable {
private static final long serialVersionUID = 8508882582940066562L;
@ApiModelProperty("接收人id")
private String userId;
@ApiModelProperty("接收信息")
private String message;
@ApiModelProperty("消息类型: 1个人报销,2对公收付款")
private Integer messageType;
@ApiModelProperty("相关对象表id(个人报销表或对公收付款表)")
private Integer appId;
@ApiModelProperty("发送时间")
private LocalDateTime createTime;
}
package cn.wise.sc.cement.business.model;
/**
* @description: 六元素检测结果中的key
* @author: qh
* @create: 2020-10-15 14:03
**/
public enum SixElementKey {
//六元素key
LOI("L.O.I"),
SiO2("SiO2"),
Al2O3("Al2O3"),
TiO2("TiO2"),
CaO("CaO"),
MgO("MgO"),
SO3("So3"),
Cl("Cl"),
Fe2O3("Fe2O3"),
Al2O3AndTiO2("Al2O3+TiO2");
private String key;
SixElementKey(String key) {
this.key = key;
}
public String getKey(){
return this.key;
}
}
package cn.wise.sc.cement.business.model;
import lombok.Data;
import java.io.Serializable;
/**
* @description: 六元素检测报告
* @author: qh
* @create: 2020-10-15 12:24
**/
@Data
public class SixElementReport implements Serializable {
private static final long serialVersionUID = 42L;
/**
* 样品名称
*/
private String sampleName;
/**
* 来样状态
*/
private String sampleForm;
/**
* 来样编号
*/
private String sampleCode;
/**
* 样品重量
*/
private String weight;
/**
* 本所编号
*/
private String cementCode;
/**
* 校核数据
*/
private String countResult;
//下面为六元素
private String loi ="";
private String sio2 ="";
private String fe2o3 ="";
private String cao ="";
private String mgo ="";
private String so3 ="";
private String cl="";
//情况一:Al2O3(含TiO3)
private String al2o3AndTio2 ="";
//情况二:Al2O3和TiO3单独分开
private String al2o3 ="";
private String tio2 ="";
}
......@@ -52,8 +52,13 @@ public class EquipmentTestVo {
@ApiModelProperty("校核附件")
private String enclosure;
@ApiModelProperty("校核附件信息")
private List<EnclosureQuery> enclosureQueryList;
@ApiModelProperty("文件名")
private String alias;
@ApiModelProperty("扩展名")
private String extName;
@ApiModelProperty("路径")
private String enclosureUrl;
}
......@@ -46,6 +46,7 @@ public class QualityDetailVo implements Serializable {
public static class SampleOriginal {
private String cementCode;
private String userName;
private Integer userId;
private String teamValues;
}
......
......@@ -3,7 +3,6 @@ package cn.wise.sc.cement.business.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description:
* @author: ztw
......@@ -49,13 +48,4 @@ public class SampleDistributionTeamVo {
@ApiModelProperty("扩展名")
private String extName;
}
......@@ -7,6 +7,7 @@ import cn.wise.sc.cement.business.entity.SampleHandleEnclosure;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.ReportDetailVo;
import cn.wise.sc.cement.business.model.SixElementReport;
import cn.wise.sc.cement.business.model.query.*;
import cn.wise.sc.cement.business.model.vo.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -34,6 +35,7 @@ public interface IEntrustService extends IService<Entrust> {
BaseResponse<Entrust> create(EntrustQuery query);
BaseResponse<EntrustVo> getDtail(Integer id);
BaseResponse<EntrustVo> getDetailCapacity(Integer id);
BaseResponse<String> getMaxCementCode();
......@@ -106,10 +108,10 @@ public interface IEntrustService extends IService<Entrust> {
BaseResponse<List<SampleVo>> getSampleCheckDtail(Integer id);
/**
* 查询六元素的检测结果
* @param entrustId 委托id
* @return 六元素校核
*/
List<SixElementReport> getSampleSixElementCheck(Integer entrustId);
}
......@@ -40,9 +40,9 @@ public interface IEquipmentService extends IService<Equipment> {
BaseResponse<String> troubleshooting(EquipmentTroubleshootingQuery query);
BaseResponse<IPage<EquipmentTroubleshootingVo>> getTroubleshootingPage(PageQuery pageQuery, Integer equipmentId);
BaseResponse<IPage<EquipmentTroubleshootingVo>> getTroubleshootingPage(PageQuery pageQuery, String name);
void exportTroubleshooting(Integer equipmentId, String fileName, HttpServletResponse response);
void exportTroubleshooting(String name, String fileName, HttpServletResponse response);
BaseResponse<EquipmentTroubleshootingVo> getTroubleshootingDetail(Integer id);
......
package cn.wise.sc.cement.business.service;
import cn.wise.sc.cement.business.entity.SysUserMessage;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.util.WebSocketServer;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* <p>
* 服务类
* </p>
*
* @author ztw
* @since 2020-10-13
*/
public interface ISysUserMessageService extends IService<SysUserMessage> {
BaseResponse<String> sendMessage(Integer userId, String message, Integer appId, Integer messageType);
BaseResponse<String> checkMessage(Integer userId, Integer appId, Integer messageType);
BaseResponse<String> dealMessage(Integer userId, Integer appId, Integer messageType);
}
......@@ -9,6 +9,7 @@ import cn.wise.sc.cement.business.model.vo.*;
import cn.wise.sc.cement.business.service.IEquipmentService;
import cn.wise.sc.cement.business.service.ISysUserService;
import cn.wise.sc.cement.business.util.ExcelUtil;
import cn.wise.sc.cement.business.wrapper.page.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
......@@ -224,8 +225,6 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
}
/**
* 设备检定 保存设备检定表信息和附件表信息,附件表的entity_type为3
* @param query (不传id为添加记录,传id为修改记录)
......@@ -246,6 +245,9 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
EquipmentTest equipmentTest = new EquipmentTest();
BeanUtils.copyProperties(query, equipmentTest);
equipmentTest.setUserId(userService.getLoginUser().getId())
.setEnclosureUrl(enclosureQuery.getEnclosureUrl())
.setAlias(enclosureQuery.getAlias())
.setExtName(enclosureQuery.getExtName())
.setCreateTime(LocalDateTime.now());
testMapper.insert(equipmentTest);
equipment.setTestDate(equipmentTest.getTestDate());
......@@ -256,13 +258,6 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
equipment.setAlias(enclosureQuery.getAlias());
equipment.setExtName(enclosureQuery.getExtName());
equipmentMapper.updateById(equipment);
//保存校核附件信息
List<EnclosureQuery> enclosureQueryList = new ArrayList<>();
enclosureQueryList.add(enclosureQuery);
Boolean ref = commonService.saveEntityEnclosure(EntityEnclosure.EntityType.EQUIPMENT_TEST, equipmentTest.getId(), enclosureQueryList);
if(!ref){
return BaseResponse.errorMsg("保存保存校核附件失败!");
}
return BaseResponse.okData("检定完成");
}
......@@ -278,21 +273,6 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
params.put("equipmentId", equipmentId);
Page<EquipmentTestVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<EquipmentTestVo> pages = testMapper.getPage(page,params);
List<EquipmentTestVo> list = page.getRecords();
if(list != null && list.size()>0){
for(EquipmentTestVo equipmentTestVo : list){
List<EntityEnclosure> entityEnclosureList = commonService.getEnclosureList
(EntityEnclosure.EntityType.EQUIPMENT_TEST, equipmentTestVo.getId());
String enclosure = "";
if(entityEnclosureList != null && entityEnclosureList.size()>0){
for(EntityEnclosure entityEnclosure : entityEnclosureList){
String fileName = entityEnclosure.getAlias()+entityEnclosure.getExtName();
enclosure = enclosure.equals("")?fileName:enclosure+"、"+fileName;
}
}
equipmentTestVo.setEnclosure(enclosure);
}
}
return BaseResponse.okData(pages);
}
......@@ -318,7 +298,7 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
.setExtName(entityEnclosure.getExtName());
enclosureQueryList.add(enclosureQuery);
}
equipmentTestVo.setEnclosureQueryList(enclosureQueryList);
return BaseResponse.okData(equipmentTestVo);
}
......@@ -356,13 +336,14 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
/**
* 设备故障维修登记分页查询
* @param pageQuery
* @param equipmentId
* @param name
* @return
*/
@Override
public BaseResponse<IPage<EquipmentTroubleshootingVo>> getTroubleshootingPage(PageQuery pageQuery, Integer equipmentId) {
public BaseResponse<IPage<EquipmentTroubleshootingVo>> getTroubleshootingPage(PageQuery pageQuery,
String name) {
Map<String, Object> params = new HashMap<>();
params.put("equipmentId", equipmentId);
params.put("equipmentId", name);
Page<EquipmentTroubleshootingVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<EquipmentTroubleshootingVo> pages = troubleshootingMapper.getPage(page,params);
return BaseResponse.okData(pages);
......@@ -370,14 +351,14 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
/**
* 设备维修列表导出
* @param equipmentId
* @param name
* @param fileName
* @param response
*/
@Override
public void exportTroubleshooting(Integer equipmentId, String fileName, HttpServletResponse response) {
public void exportTroubleshooting(String name, String fileName, HttpServletResponse response) {
Map<String, Object> params = new HashMap<>();
params.put("equipmentId", equipmentId);
params.put("name", name);
List<Map<String, Object>> list= troubleshootingMapper.exportList(params);
if (!CollectionUtils.isEmpty(list)) {
Map<String, Object> map = list.get(0);
......@@ -437,7 +418,12 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
if(equipmentVo == null){
return BaseResponse.errorMsg("信息错误!");
}
QueryWrapper<EquipmentScrap> esWrapper = new QueryWrapper<>();
esWrapper.eq("equipment_id",equipmentVo.getId());
EquipmentScrap es = scrapMapper.selectOne(esWrapper);
if(es != null){
return BaseResponse.errorMsg("此设备已经申请报废!");
}
EquipmentScrap equipmentScrap = new EquipmentScrap();
BeanUtils.copyProperties(query, equipmentScrap);
if(query.getId() == null){
......
package cn.wise.sc.cement.business.service.impl;
import cn.wise.sc.cement.business.entity.QualityApply;
import cn.wise.sc.cement.business.entity.SysGroup;
import cn.wise.sc.cement.business.entity.SysUser;
import cn.wise.sc.cement.business.mapper.QualityApplyMapper;
import cn.wise.sc.cement.business.service.IQualityApplyService;
import cn.wise.sc.cement.business.service.ISysGroupService;
import cn.wise.sc.cement.business.service.ISysUserService;
import cn.wise.sc.cement.business.util.ExcelUtil;
import cn.wise.sc.cement.business.util.RedisUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.Data;
import org.apache.poi.ss.usermodel.Header;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -32,6 +40,21 @@ import java.util.stream.Collectors;
public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, QualityApply>
implements IQualityApplyService {
final
RedisUtil redisUtil;
final
ISysUserService iSysUserService;
final
ISysGroupService iSysGroupService;
public QualityApplyServiceImpl(RedisUtil redisUtil,
ISysUserService iSysUserService,
ISysGroupService iSysGroupService) {
this.redisUtil = redisUtil;
this.iSysUserService = iSysUserService;
this.iSysGroupService = iSysGroupService;
}
@Override
public Set<Integer> selectQualityApplyStatusByProIds(List<Integer> projectIds) {
if (projectIds.size() == 0) {
......@@ -59,8 +82,42 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua
List<QualityApply> list = this.list(qw);
//找到所有项目id归类
Set<Integer> projectIds = list.stream().map(QualityApply::getProjectId).collect(Collectors.toSet());
String[] headers = new String[30];
String[] headers = null;
List<Object[]> datas = new ArrayList<>();
//关联部门名字
Set<Integer> userIds = list.stream()
.filter(arg -> !"误差".equals(arg.getUserName()) &&
!"标准样".equals(arg.getUserName()))
.map(QualityApply::getUserId)
.collect(Collectors.toSet());
//获取所以用户
final String userCache = "SYS_USER:CACHE";
final String groupCache = "SYS_GROUP:CACHE";
if (!redisUtil.existsKey(userCache)) {
List<SysUser> sysUsers = iSysUserService.list();
redisUtil.setString(userCache, JSON.toJSONString(sysUsers), 600);
}
if (!redisUtil.existsKey(groupCache)) {
List<SysGroup> sysGroups = iSysGroupService.list();
redisUtil.setString(groupCache, JSON.toJSONString(sysGroups), 600);
}
//会有临界值问题
List<SysUser> sysUsers = JSON.parseArray(redisUtil.getString(userCache) + "", SysUser.class);
List<SysGroup> sysGroups = JSON.parseArray(redisUtil.getString(groupCache) + "", SysGroup.class);
Map<Integer, String> userGroupMap = new HashMap<>(userIds.size());
sysUsers.stream()
.filter(arg -> userIds.contains(arg.getId()))
.forEach(arg -> sysGroups.forEach(opt -> {
if (opt.getId().intValue() == arg.getGroupId()) {
userGroupMap.put(arg.getId(), opt.getName());
}
}));
if (userGroupMap.size() == 0) {
return;
}
for (Integer projectId : projectIds) {
//找到每个项目的检测组 以检测组归类
Set<Integer> teamIds = list.stream()
......@@ -78,26 +135,31 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua
//写每个样品的表头
list.stream()
.filter(arg -> arg.getTeamGroupId().intValue() == teamId )
.filter(arg -> arg.getTeamGroupId().intValue() == teamId)
.findFirst().ifPresent(arg -> {
List<String> teams = JSON.parseArray(arg.getTeams(), String.class);
Object[] objs = new Object[teams.size() + 7];
Object[] objs = new Object[teams.size() + 8];
objs[0] = "项目名称";
objs[1] = "项目编号";
objs[2] = "样品名称";
objs[3] = "样品状态";
objs[4] = "来样编号";
objs[5] = "本所编号";
objs[6] = "分析";
objs[6] = "部门";
objs[7] = "分析";
for (int i = 0; i < teams.size(); i++) {
objs[7 + i] = teams.get(i);
String teamName = teams.get(i);
if (teamName.contains("\"")) {
teamName = teamName.replace("\"", "");
}
objs[8 + i] = teamName;
}
datas.add(objs);
});
//为每个样品写值
samples.forEach(arg -> {
List<String> inputValus = JSON.parseArray(arg.getInputResult(), String.class);
Object[] objs = new Object[inputValus.size() + 7];
Object[] objs = new Object[inputValus.size() + 8];
if (!"误差".equals(arg.getUserName())) {
objs[0] = arg.getProjectName();
objs[1] = arg.getProjectId();
......@@ -105,15 +167,21 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua
objs[3] = arg.getSampleForm();
objs[4] = arg.getSampleCode();
objs[5] = arg.getCementCode();
objs[6] = userGroupMap.get(arg.getUserId());
}
//添加名字
objs[6] = arg.getUserName();
objs[7] = arg.getUserName();
for (int i = 0; i < inputValus.size(); i++) {
objs[7 + i] = inputValus.get(i);
}
for (int i = 0; i < inputValus.size(); i++) {
objs[7 + i] = inputValus.get(i);
String value = inputValus.get(i);
if (value == null){
value = "0";
}
if ( value.contains("\"")) {
value = value.replace("\"", "");
}
objs[8 + i] = value;
}
datas.add(objs);
});
......
......@@ -77,7 +77,7 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i
if (StringUtils.isNotEmpty(supplierName)) {
qw.like("supplier_name", supplierName);
}
qw.orderByDesc("create_time");
qw.orderByDesc("name");
IPage<Standard> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
page = standardMapper.selectPage(page, qw);
return BaseResponse.okData(page);
......
package cn.wise.sc.cement.business.service.impl;
import cn.wise.sc.cement.business.entity.SysUser;
import cn.wise.sc.cement.business.entity.SysUserMessage;
import cn.wise.sc.cement.business.mapper.SysUserMessageMapper;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.Message;
import cn.wise.sc.cement.business.service.ISysUserMessageService;
import cn.wise.sc.cement.business.service.ISysUserService;
import cn.wise.sc.cement.business.util.WebSocketServer;
import cn.wise.sc.cement.business.wrapper.WrapMapper;
import cn.wise.sc.cement.business.wrapper.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author ztw
* @since 2020-10-13
*/
@Service
public class SysUserMessageServiceImpl extends ServiceImpl<SysUserMessageMapper, SysUserMessage> implements ISysUserMessageService {
@Resource
private SysUserMessageMapper userMessageMapper;
@Resource
protected HttpServletResponse response;
@Autowired
protected HttpServletRequest request;
@Autowired
WebSocketServer webSocketServer;
/**
* 发送消息
* @param userId
* @param message
* @param appId
* @param messageType
* @return
*/
@Override
public BaseResponse<String> sendMessage(Integer userId, String message, Integer appId, Integer messageType) {
int ret = 0;
SysUserMessage userMessage = new SysUserMessage();
userMessage.setUserId(userId);
userMessage.setMessage(message);
userMessage.setAppId(appId);
userMessage.setIsCheck(0);
userMessage.setMessageType(messageType);
userMessage.setCreateTime(LocalDateTime.now());
userMessage.setUpdateTime(userMessage.getCreateTime());
userMessage.setIsDeal(0);
ret = this.userMessageMapper.insert(userMessage);
if(ret == 0 ){
return BaseResponse.errorMsg("消息推送失败");
}
String dealer = String.valueOf(userId);
Message m =Message.builder().userId(dealer).message(message).messageType(messageType).appId(appId)
.createTime(userMessage.getCreateTime()).build();
webSocketServer.sendTo(m);
/*SysUser sysUser = userService.getById(userId);
if(sysUser != null && StringUtils.isNotBlank(sysUser.getPhone())){
SMSUtil.sendCode(sysUser.getPhone(), message);
}*/
return BaseResponse.okData("成功");
}
/**
* 查看消息
* @param userId
* @param appId
* @param messageType
* @return
*/
@Override
public BaseResponse<String> checkMessage(Integer userId, Integer appId, Integer messageType) {
int ret = 0;
List<SysUserMessage> list = this.userMessageMapper.getNoCheck(userId, appId, messageType);
if(list != null && list.size()>0){
for(SysUserMessage um : list){
um.setIsCheck(1);
ret = this.userMessageMapper.updateById(um);
if (ret == 0) {
return BaseResponse.errorMsg("查看消息记录更新失败");
}
}
}
return BaseResponse.okData("成功");
}
/**
* 处理消息
* @param userId
* @param appId
* @param messageType
* @return
*/
@Override
public BaseResponse<String> dealMessage(Integer userId, Integer appId, Integer messageType) {
int ret = 0;
List<SysUserMessage> list = this.userMessageMapper.getNoDeal(userId, appId, messageType);
if(list != null && list.size()>0){
for(SysUserMessage um : list){
um.setIsCheck(1);
um.setIsDeal(1);
ret = this.userMessageMapper.updateById(um);
if (ret == 0) {
return BaseResponse.errorMsg("处理消息记录更新失败");
}
}
}
return BaseResponse.okData("成功");
}
}
......@@ -49,7 +49,7 @@ public class TeamGroupServiceImpl extends ServiceImpl<TeamGroupMapper, TeamGroup
if(StringUtils.isNotEmpty(name)){
qw.like("name", name);
}
qw.orderByDesc("create_time");
qw.orderByAsc("id");
IPage<TeamGroup> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
page = teamGroupMapper.selectPage(page, qw);
return BaseResponse.okData(page);
......
......@@ -2,6 +2,7 @@ package cn.wise.sc.cement.business.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.entity.Team;
import cn.wise.sc.cement.business.entity.TeamGroup;
import cn.wise.sc.cement.business.exception.BusinessExceptionEnum;
import cn.wise.sc.cement.business.mapper.TeamMapper;
import cn.wise.sc.cement.business.model.BaseResponse;
......@@ -87,6 +88,12 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT
if(query.getIsDisplay() != 1 && query.getIsDisplay() !=0){
return BaseResponse.errorMsg("委托是否可见参数错误");
}
QueryWrapper<Team> qw = new QueryWrapper<>();
qw.eq("name", query.getName());
int count = teamMapper.selectCount(qw);
if (count > 0) {
return BaseResponse.errorMsg(query.getName() + "已存在");
}
BeanUtils.copyProperties(query, create);
create.setStatus(1).setCreateTime(LocalDateTime.now());
teamMapper.insert(create);
......@@ -111,9 +118,18 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT
if(query.getMethodId() == null){
return BaseResponse.errorMsg("请选择检依据");
}
QueryWrapper<Team> qw = new QueryWrapper<>();
qw.eq("name", query.getName());
qw.ne("id", query.getId());
int count = teamMapper.selectCount(qw);
if (count > 0) {
return BaseResponse.errorMsg(query.getName() + "已存在");
}
update.setGroupId(query.getGroupId())
.setMethodId(query.getMethodId())
.setName(query.getName());
.setName(query.getName())
.setIsDisplay(query.getIsDisplay())
.setQualifications(query.getQualifications());
teamMapper.updateById(update);
return BaseResponse.okData(update);
}
......
package cn.wise.sc.cement.business.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* 序列化对象工具类,用于保存和读取redis数据使用
* Function:
* Date: 2018年9月12日10:18:56
*/
public class SerializeUtil {
private static Logger log = LoggerFactory.getLogger(SerializeUtil.class);
/**
* 序列化对象
* @param object
* @return
*/
public static byte[] serialize(Object object) {
ObjectOutputStream oos = null;
ByteArrayOutputStream baos = null;
byte[] bytes = null;
try {
// 序列化
baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(object);
bytes = baos.toByteArray();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (oos != null) {
oos.close();
}
if (baos != null) {
baos.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return bytes;
}
/**
* 反序列化对象
* @param bytes
* @return
*/
public static Object unserialize(byte[] bytes) {
Object obj = null;
ByteArrayInputStream bais = null;
try {
// 反序列化
bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
obj = ois.readObject();
ois.close();
bais.close();
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}
/**
* 关闭的数据源或目标。调用 close()方法可释放对象保存的资源(如打开文件)
* 关闭此流并释放与此流关联的所有系统资源。如果已经关闭该流,则调用此方法无效。
* @param closeable
*/
public static void close(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception e) {
log.info("Unable to close %s", closeable, e);
}
}
}
/**
* 列表序列化(用于Redis整存整取)
* @param value
* @return
*/
public static <T> byte[] serialize(List<T> value) {
if (value == null) {
throw new NullPointerException("Can't serialize null");
}
byte[] rv=null;
ByteArrayOutputStream bos = null;
ObjectOutputStream os = null;
try {
bos = new ByteArrayOutputStream();
os = new ObjectOutputStream(bos);
for(T obj : value){
os.writeObject(obj);
}
os.writeObject(null);
os.close();
bos.close();
rv = bos.toByteArray();
} catch (IOException e) {
throw new IllegalArgumentException("Non-serializable object", e);
} finally {
close(os);
close(bos);
}
return rv;
}
/**
* 反序列化列表(用于Redis整存整取)
* @param in
* @return
*/
public static <T> List<T> unserializeForList(byte[] in) {
List<T> list = new ArrayList<T>();
ByteArrayInputStream bis = null;
ObjectInputStream is = null;
try {
if(in != null) {
bis=new ByteArrayInputStream(in);
is=new ObjectInputStream(bis);
while (true) {
T obj = (T) is.readObject();
if(obj == null){
break;
}else{
list.add(obj);
}
}
is.close();
bis.close();
}
} catch (IOException e) {
log.warn("Caught IOException decoding %d bytes of data",
in == null ? 0 : in.length, e);
} catch (ClassNotFoundException e) {
log.warn("Caught CNFE decoding %d bytes of data",
in == null ? 0 : in.length, e);
} finally {
close(is);
close(bis);
}
return list;
}
}
package cn.wise.sc.cement.business.util;
import cn.wise.sc.cement.business.model.Message;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ServerEndpoint("/test-websocket/{sid}")
@Component
@Slf4j
public class WebSocketServer {
/**
* 用于存放所有在线客户端
*/
private static Map<String, Session> clients = new ConcurrentHashMap<>();
// private static Map<String, List<Message>> messages = new ConcurrentHashMap<>();
/*@Value("${websocket.socketKey}")
private String SOCKET_KEY;
@Value("${websocket.host}")
private String host;
@Value("${websocket.port}")
private int port;
@Value("${websocket.timeout}")
private int timeout;
@Value("${websocket.clientDB}")
private long clientDB;
@Value("${websocket.selectDB}")
private int selectDB;
@Value("${websocket.password}")
private String password;*/
private static final String SOCKET_KEY = "socketkey";
private static final String host = "localhost";
private static final int port = 6379;
private static final int timeout = 100000;
private static final long clientDB = 2;
private static final int selectDB = 2;
private static final String password = "Wise_@123456";
@OnOpen
public void onOpen(Session session,@PathParam("sid") String sid) {
log.info("有新的客户端上线: {}", session.getId());
clients.put(sid, session);
Jedis jedis = new Jedis(host, port, timeout);
// jedis.auth(password);
jedis.select(selectDB);
// jedis.getClient().setDb(clientDB);
List<Message> messageList = SerializeUtil.unserializeForList(jedis.get((SOCKET_KEY+sid).getBytes()));
if (session != null) {
for(int i=0; i<messageList.size(); i++){
Message message = messageList.get(i);
try {
JSONObject json = (JSONObject)JSONObject.toJSON(message);
String msg = json.toJSONString();
session.getBasicRemote().sendText(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
jedis.del((SOCKET_KEY+sid).getBytes());
}
}
@OnClose
public void onClose(Session session,@PathParam("sid") String sid) {
String sessionId = session.getId();
log.info("有客户端离线: {}", sessionId);
clients.remove(sid);
}
@OnError
public void onError(Session session, Throwable throwable,@PathParam("sid") String sid) {
throwable.printStackTrace();
if (clients.get(sid) != null) {
clients.remove(sid);
}
}
@OnMessage
public void onMessage(String message) {
log.info("收到客户端发来的消息: {}", message);
this.sendTo(JSON.parseObject(message, Message.class));
}
/**
* 发送消息
*
* @param message 消息对象
*/
public void sendTo(Message message) {
if (clients.get(message.getUserId()) == null) {
Jedis jedis = new Jedis(host, port, timeout);
// jedis.auth(password);
jedis.select(selectDB);
// jedis.getClient().setDb(clientDB);
List<Message> messageList = SerializeUtil.unserializeForList(jedis.get((SOCKET_KEY+message.getUserId()).getBytes()));
messageList.add(message);
jedis.set((SOCKET_KEY+message.getUserId()).getBytes(), SerializeUtil.serialize(messageList));
}else{
Session s = clients.get(message.getUserId());
if (s != null) {
try {
JSONObject json = (JSONObject)JSONObject.toJSON(message);
String msg = json.toJSONString();
s.getBasicRemote().sendText(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
package cn.wise.sc.cement.business.util;
import cn.wise.sc.cement.business.model.FileExt;
import freemarker.template.Configuration;
import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j;
......@@ -45,7 +46,8 @@ public class WordUtil {
String templeName,
String templateFileName,
Map<String, Object> beanParams,
HttpServletResponse response) {
HttpServletResponse response,
FileExt fileExt) {
Writer out = null;
File file = null;
try {
......@@ -74,7 +76,7 @@ public class WordUtil {
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 + ".xls");
response.setHeader("Content-Disposition", "attachment;filename=" + templeName + fileExt.getName());
outputStream.write(buffer);
outputStream.flush();
outputStream.close();
......
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Version>16.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>12650</WindowHeight>
<WindowWidth>22260</WindowWidth>
<WindowTopX>32767</WindowTopX>
<WindowTopY>32767</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="等线" x:CharSet="134" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s63">
<Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
<Font ss:FontName="等线" x:CharSet="134" ss:Size="11" ss:Color="#000000"
ss:Bold="1"/>
</Style>
<Style ss:ID="s64">
<Font ss:FontName="等线" x:CharSet="134" ss:Size="11" ss:Color="#000000"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="8" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="52" ss:DefaultRowHeight="14">
<Column ss:AutoFitWidth="0" ss:Width="116.5"/>
<Column ss:AutoFitWidth="0" ss:Width="117"/>
<Row>
<Cell ss:MergeAcross="1" ss:StyleID="s63"><Data ss:Type="String">中国水泥发展中心物化检测所检测委托单</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">委托单位</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${clientName}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">委托编号</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${entrustCode}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">委托人</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${userName}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">电话</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${userPhone}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">传真</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${userFax}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">项目名称</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${projectName}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">样品数量</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${sampleNum}</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>9</ActiveRow>
<ActiveCol>4</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
This diff is collapsed.
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