Commit c252f347 authored by chenzhao's avatar chenzhao

巡检项导入导出模板下载

parent 3d23b517
...@@ -1152,7 +1152,7 @@ LEFT JOIN ( ...@@ -1152,7 +1152,7 @@ LEFT JOIN (
cf.certificate_number certificatesNumber, cf.certificate_number certificatesNumber,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'personNumber' AND dfi.instance_id = u.sequence_nbr ) AS employee_number, ( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'personNumber' AND dfi.instance_id = u.sequence_nbr ) AS employee_number,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'telephone' AND dfi.instance_id = u.sequence_nbr ) AS telephone, ( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'telephone' AND dfi.instance_id = u.sequence_nbr ) AS telephone,
( CASE WHEN cfp.post_qualification IS NULL or cfp.post_qualification == '' THEN 0 ELSE 1 END ) AS is_certificate, ( CASE WHEN cfp.post_qualification IS NULL or cfp.post_qualification = '' THEN 0 ELSE 1 END ) AS is_certificate,
IF IF
( (
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'peopleType' AND dfi.instance_id = u.sequence_nbr ) = 1601, ( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'peopleType' AND dfi.instance_id = u.sequence_nbr ) = 1601,
......
...@@ -43,4 +43,10 @@ public class VideoImportantEquipmentVo { ...@@ -43,4 +43,10 @@ public class VideoImportantEquipmentVo {
@ApiModelProperty(value = "详细地址") @ApiModelProperty(value = "详细地址")
private String address; private String address;
@ApiModelProperty(value = "token")
private String token;
@ApiModelProperty(value = "视频格式")
private String videoType;
} }
\ No newline at end of file
package com.yeejoin.amos.patrol.common.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum PointCheckTypeEnum {
WGJC("外观检查", "WGJC"),
GNCS("功能测试", "GNCS"),
HJJC("环境检查", "HJJC"),
QT("其他", "QT");
private String name;
private String value;
private PointCheckTypeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getName(String value) {
for (PointCheckTypeEnum c : PointCheckTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public static String getValue(String name) {
for (PointCheckTypeEnum c : PointCheckTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static PointCheckTypeEnum getEnum(String name) {
for (PointCheckTypeEnum c : PointCheckTypeEnum.values()) {
if (c.getName().equals(name)) {
return c;
}
}
return null;
}
public static List<String> getEnumNameList() {
List<String> nameList = new ArrayList<String>();
for (PointCheckTypeEnum c: PointCheckTypeEnum.values()) {
nameList.add(c.getName());
}
return nameList;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.yeejoin.amos.patrol.business.controller; package com.yeejoin.amos.patrol.business.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.patrol.business.dao.mapper.InputItemMapper; import com.yeejoin.amos.patrol.business.dao.mapper.InputItemMapper;
import com.yeejoin.amos.patrol.business.dao.repository.IInputItemDao; import com.yeejoin.amos.patrol.business.dao.repository.IInputItemDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPointInputItemDao; import com.yeejoin.amos.patrol.business.dao.repository.IPointInputItemDao;
import com.yeejoin.amos.patrol.business.dto.InputItemDataDto;
import com.yeejoin.amos.patrol.business.dto.InputItemDataJsonlDto;
import com.yeejoin.amos.patrol.business.dto.InputItemExcelDto;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient; import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import com.yeejoin.amos.patrol.business.param.InputItemPageParam; import com.yeejoin.amos.patrol.business.param.InputItemPageParam;
import com.yeejoin.amos.patrol.business.param.InputItemParam; import com.yeejoin.amos.patrol.business.param.InputItemParam;
...@@ -26,6 +31,7 @@ import com.yeejoin.amos.patrol.dao.entity.InputItem; ...@@ -26,6 +31,7 @@ import com.yeejoin.amos.patrol.dao.entity.InputItem;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import liquibase.pro.packaged.S;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -36,14 +42,13 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -36,14 +42,13 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.ArrayList; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
/** /**
* 检查项 * 检查项
...@@ -317,6 +322,92 @@ public class InputItemController extends AbstractBaseController { ...@@ -317,6 +322,92 @@ public class InputItemController extends AbstractBaseController {
} }
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导入检查项", notes = "导入检查项")
@PostMapping(value = "/importData", produces = "application/json;charset=UTF-8")
public void importData(@RequestPart("file") MultipartFile multipartFile) {
try {
List<InputItemExcelDto> inputItemExcelDtos = ExcelUtil.readFirstSheetExcel(multipartFile, InputItemExcelDto.class, 1);
for (InputItemExcelDto inputItemExcelDto : inputItemExcelDtos) {
if (StringUtils.isEmpty(inputItemExcelDto.getItemNo()) || StringUtils.isEmpty(inputItemExcelDto.getName()) || StringUtils.isEmpty(inputItemExcelDto.getInputClassify())){
throw new BadRequest("编号、名称、检查类型不能为空");
}
//组装参数 因部分字段数据数据库中用json统一保存 按类型组装为所需数据结构
if (inputItemExcelDto.getItemType().equals("选择") && StringUtil.isNotEmpty(inputItemExcelDto.getDataJson())){
List<InputItemDataDto> itemDataDtos = new ArrayList<>();
if (inputItemExcelDto.getDataJson().contains("|")) {
String[] datas = inputItemExcelDto.getDataJson().split("\\|");
List<String> list = Arrays.asList(datas);
list.forEach(e->{
String[] data = e.split(",");
InputItemDataDto inputItemDataDto = new InputItemDataDto(data[0],data[1],data[2],data[3]);
itemDataDtos.add(inputItemDataDto);
});
}else {
String[] data = inputItemExcelDto.getDataJson().split(",");
InputItemDataDto inputItemDataDto = new InputItemDataDto(data[0],data[1],data[2],data[3]);
itemDataDtos.add(inputItemDataDto);
}
inputItemExcelDto.setDataJson(JSON.toJSONString(itemDataDtos));
}else if(inputItemExcelDto.getItemType().equals("数字") && StringUtil.isNotEmpty(inputItemExcelDto.getDataJson())){
InputItemDataJsonlDto inputItemDataJsonlDto = new InputItemDataJsonlDto();
BeanUtils.copyProperties(inputItemExcelDto,inputItemDataJsonlDto);
inputItemExcelDto.setDataJson(JSON.toJSONString(inputItemExcelDto));
}
//转化为新增接口所需参数
InputItemParam inputItemParam = new InputItemParam();
BeanUtils.copyProperties(inputItemExcelDto,inputItemParam);
//新增接口
this.addNewItemNew(inputItemParam);
}
} catch (Exception e) {
throw new BadRequest(e.getMessage());
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出检查项", notes = "导出检查项")
@RequestMapping(value = "/exportData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public void exportData(HttpServletResponse response) {
InputItemPageParam criterias = new InputItemPageParam();
List<InputItemExcelDto> content = inputItemMapper.getInputItemInfoExcelNew(criterias);
//此处对数据做统一处理 拼接为易读内容
for (InputItemExcelDto inputItemExcelDto : content) {
String text = "";
if (inputItemExcelDto.getItemType().equals("选择")&& !inputItemExcelDto.getDataJson().equals("[]")) {
List<Map> maps = JSONObject.parseArray(inputItemExcelDto.getDataJson(), Map.class);
for (int i = 0; i< maps.size(); i++) {
Map jsonObject = maps.get(i);
text = text + jsonObject.get("name")+","+jsonObject.get("score")+","+jsonObject.get("isOk")+","+jsonObject.get("isChecked");
if(i < (maps.size()-1) ){
text = text+"|";
inputItemExcelDto.setDataJson(text);
}else {
inputItemExcelDto.setDataJson(text);
}
}
}
if (inputItemExcelDto.getItemType().equals("数字") || inputItemExcelDto.getItemType().equals("文本")) {
//此处为避免大量set方法 将data_json字段中的数据转为对象组装
InputItemDataJsonlDto inputItemDataJsonlDto = JSONObject.parseObject(inputItemExcelDto.getDataJson(), InputItemDataJsonlDto.class);
BeanUtils.copyProperties(inputItemDataJsonlDto,inputItemExcelDto);
inputItemExcelDto.setDataJson(null);
}
}
ExcelUtil.createTemplate(response,"检查项","检查项",content,InputItemExcelDto.class,null,true);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "模板下载", notes = "模板下载")
@RequestMapping(value = "/downTemplate", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public void downTemplate(HttpServletResponse response) {
ExcelUtil.createTemplate(response,"检查项模板","检查项",null,InputItemExcelDto.class,null,true);
}
/** /**
* 删除检查项 * 删除检查项
* *
...@@ -557,7 +648,6 @@ public class InputItemController extends AbstractBaseController { ...@@ -557,7 +648,6 @@ public class InputItemController extends AbstractBaseController {
} }
} }
if (CollectionUtils.isNotEmpty(inputItemDao.findByItemNo(param.getItemNo(), param.getId() != 0 ? String.valueOf(param.getId()) : null))) { if (CollectionUtils.isNotEmpty(inputItemDao.findByItemNo(param.getItemNo(), param.getId() != 0 ? String.valueOf(param.getId()) : null))) {
throw new BadRequest("该编号已存在,请重新输入"); throw new BadRequest("该编号已存在,请重新输入");
} }
......
package com.yeejoin.amos.patrol.business.dao.mapper; package com.yeejoin.amos.patrol.business.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.patrol.business.dto.InputItemExcelDto;
import com.yeejoin.amos.patrol.business.param.InputItemPageParam; import com.yeejoin.amos.patrol.business.param.InputItemPageParam;
import com.yeejoin.amos.patrol.business.vo.InputItemVo; import com.yeejoin.amos.patrol.business.vo.InputItemVo;
import com.yeejoin.amos.patrol.business.vo.PointInputItemVo; import com.yeejoin.amos.patrol.business.vo.PointInputItemVo;
...@@ -30,6 +31,8 @@ public interface InputItemMapper extends BaseMapper<InputItem> { ...@@ -30,6 +31,8 @@ public interface InputItemMapper extends BaseMapper<InputItem> {
public List<InputItemVo> getInputItemInfoNew(InputItemPageParam param); public List<InputItemVo> getInputItemInfoNew(InputItemPageParam param);
public List<InputItemExcelDto> getInputItemInfoExcelNew(InputItemPageParam param);
Map<Long, Long> getAllCountInfo(); Map<Long, Long> getAllCountInfo();
Map<String,String> getEquipParentCode(String code); Map<String,String> getEquipParentCode(String code);
......
package com.yeejoin.amos.patrol.business.dto;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.util.Date;
@Data
public class ExcelDto {
@ApiModelProperty(value = "文件名称")
private String fileName;
@ApiModelProperty(value = "sheet页名称")
private String sheetName;
@ApiModelProperty(value = "类包全路径")
private String classUrl;
@ApiModelProperty(value = "导出类型 来源于ExcelEnums常量")
private String type;
public ExcelDto(String fileName, String sheetName, String classUrl, String type) {
super();
this.fileName = fileName;
this.sheetName = sheetName;
this.classUrl = classUrl;
this.type = type;
}
public ExcelDto(String fileName, String sheetName, String type) {
this.fileName = fileName;
this.sheetName = sheetName;
this.type = type;
}
public ExcelDto() {
}
public String getFileName() {
return StringUtils.isEmpty(fileName) ? DateUtils.convertDateToString(new Date(), "yyyyMMddHHmmss") : fileName;
}
public String getSheetName() {
return StringUtils.isEmpty(sheetName) ? "Sheet1" : sheetName;
}
}
package com.yeejoin.amos.patrol.business.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "InputItemDataDto", description = "检查项文本JSON数据")
@Data
public class InputItemDataDto extends BaseDto {
private String name;
private String score;
private String isOk;
private String isChecked;
public InputItemDataDto(String name, String score, String isOk, String isChecked) {
this.name = name;
this.score = score;
this.isOk = isOk;
this.isChecked = isChecked;
}
}
package com.yeejoin.amos.patrol.business.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "InputItemDataJsonlDto", description = "检查项JSON数据")
@Data
public class InputItemDataJsonlDto extends BaseDto {
@ApiModelProperty(value = "合格评分数")
private Integer okScore;
@ApiModelProperty(value = "不合格评分数")
private Integer noScore;
@ApiModelProperty(value = "合格判断方法")
private String checkType;
@ApiModelProperty(value = "有效值上限")
private Integer validUp;
@ApiModelProperty(value = "有效值下限")
private Integer validDown;
@ApiModelProperty(value = "合格值上限")
private Integer okUp;
@ApiModelProperty(value = "合格值下限")
private Integer okDown;
@ApiModelProperty(value = "强制校验,输入值不能大于有效值上限")
private String checkValidUp;
@ApiModelProperty(value = "强制校验,输入值不能小于有效值下限")
private String checkValidDown;
@ApiModelProperty(value = "合格判断,输入值大于合格值上限时为不合格")
private String checkOkUp;
@ApiModelProperty(value = "合格判断,输入值小于合格值上限时为不合格")
private String checkOkDown;
@ApiModelProperty(value = "小数点后位数")
private Integer precision;
public String getCheckValidUp() {
if (checkValidUp != null) {
return checkValidUp.equals("true") ? "是":"否";
}
return checkValidUp;
}
public String getCheckValidDown() {
if (checkValidDown != null) {
return checkValidDown.equals("true") ? "是":"否";
}
return checkValidDown;
}
public String getCheckOkUp() {
if (checkOkUp != null) {
return checkOkUp.equals("true") ? "是":"否";
}
return checkOkUp;
}
public String getCheckOkDown() {
if (checkOkDown != null) {
return checkOkDown.equals("true") ? "是":"否";
}
return checkOkDown;
}
}
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
v.type, v.type,
v.url, v.url,
v.img, v.img,
v.address v.address,
v.video_type as videoType,
v.token as token
FROM FROM
wl_video v wl_video v
<where> <where>
......
...@@ -65,6 +65,8 @@ ...@@ -65,6 +65,8 @@
<result property="facilitiesType" column="facilities_type" /> <result property="facilitiesType" column="facilities_type" />
<result property="equipmentType" column="equipment_type" /> <result property="equipmentType" column="equipment_type" />
</resultMap> </resultMap>
<!--统计 --> <!--统计 -->
<select id="countInputItemInfoData" resultType="long"> <select id="countInputItemInfoData" resultType="long">
SELECT SELECT
...@@ -386,6 +388,104 @@ ...@@ -386,6 +388,104 @@
</choose> </choose>
</select> </select>
<select id="getInputItemInfoExcelNew" resultType="com.yeejoin.amos.patrol.business.dto.InputItemExcelDto">
SELECT
a.id,
a.name,
a.item_no,
a.item_type,
a.is_must,
a.default_value,
a.is_score,
b.name as catalog_name,
a.remark,
a.input_classify,
a.check_method,
(CASE a.equipment_type
WHEN a.equipment_type is not null and a.equipment_type = '-1'
THEN '通用消防装备'
ELSE
(select name from wl_equipment_category where code = a.equipment_type AND industry_code = 2)
END) as equipment_type,
(CASE a.facilities_type
WHEN a.facilities_type is not null and a.facilities_type = '-1'
THEN '通用消防设施'
ELSE (select name from wl_equipment_category where code = a.facilities_type AND industry_code = 2)
END) as facilities_type,
(CASE a.level
WHEN 1 THEN
'1级'
WHEN 2 THEN
'2级'
WHEN 3 THEN
'3级'
WHEN 4 THEN
'4级'
ELSE
'5级'
END )AS level,
(CASE a.key_parts_type
WHEN 0 THEN
'是'
WHEN 1 THEN
'否'
END )AS keyPartsType,
(CASE a.custom_type
WHEN 0 THEN
'是'
WHEN 1 THEN
'否'
END )AS customType,
a.risk_desc,
a.data_json
from
p_input_item a left join p_catalog_tree b on a.catalog_id = b.id
where a.is_delete = '0'
and a.input_type!='1'
<if test="name!=null"> and a.name like concat(concat("%",#{name}),"%")</if>
<if test="itemNo!=null"> and a.item_no like concat(concat("%",#{itemNo}),"%")</if>
<if test="isScore!=null"> and a.is_Score = #{isScore}</if>
<if test="itemType!=null"> and a.item_Type = #{itemType} </if>
<if test="orgCode!=null"> and a.org_Code = #{orgCode}</if>
<if test="catalogIds !=null">
and a.catalog_id in <foreach collection="catalogIds" item="catalogId" index="index" open="(" separator="," close=")" >#{catalogId}</foreach>
</if>
<if test="bizOrgCode!=null and bizOrgCode!=''">
and a.biz_org_code LIKE CONCAT (#{bizOrgCode},'%')
</if>
<if test="treeId != null and treeId != '' and treeId == '-1'">
and a.facilities_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId == '-2'">
and a.equipment_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId == '-4'">
and a.key_parts_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId == '-5'">
and a.custom_type is not null
</if>
<if test="subCode!=null and subCode!='' and subCode!=' ' and
treeId != null and treeId != '' and treeId != '-3' and treeId != '-1' and
treeId != '-2' and treeId != '-4' and treeId != '-5' and treeId.contains('@'.toString())">
and LEFT (a.facilities_type, #{inhierarchy}) = #{subCode}
</if>
<if test="subCode!=null and subCode!='' and subCode!=' ' and
treeId != null and treeId != '' and treeId != '-3' and treeId != '-1' and
treeId != '-2' and treeId != '-4' and treeId != '-5' and !treeId.contains('@'.toString())">
and LEFT (a.equipment_type, #{inhierarchy}) = #{subCode}
</if>
<choose>
<when test="level == '-0' ">and a.level is null</when>
<when test="level!=null and level != '-0'">and a.level = #{level}</when>
</choose>
order by a.id desc
<choose>
<when test="pageSize==-1"></when>
<when test="pageSize!=-1">limit #{offset},#{pageSize}</when>
</choose>
</select>
<select id="getEquipParentCode" resultType="map"> <select id="getEquipParentCode" resultType="map">
select * from wl_equipment_category where code = #{code} and industry_code = '2' select * from wl_equipment_category where code = #{code} and industry_code = '2'
</select> </select>
......
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