Commit 6139c9bc authored by tangwei's avatar tangwei

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents 938f976c 631fbc57
......@@ -30,9 +30,15 @@ public class KeySiteDto extends BaseDto implements Serializable{
@ApiModelProperty(value = "所属单位/部门id")
private Long belongId;
@ApiModelProperty(value = "所属单位/部门名称")
private String belongName;
@ApiModelProperty(value = "所属建筑id")
private Long buildingId;
@ApiModelProperty(value = "所属建筑名称")
private String buildingName;
@ApiModelProperty(value = "位置描述")
private String addressDesc;
......@@ -62,7 +68,7 @@ public class KeySiteDto extends BaseDto implements Serializable{
private String fireFacilitiesInfo;
@ApiModelProperty(value = "防火标志设立情况")
private String firePreventionFlag;
private Boolean firePreventionFlag;
@ApiModelProperty(value = "危险源")
private String hazard;
......@@ -79,9 +85,10 @@ public class KeySiteDto extends BaseDto implements Serializable{
@ApiModelProperty(value = "使用性质名称")
private String useNatureName;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "附件")
private Map<String, List<AttachmentDto>> attachments;
}
......@@ -5,6 +5,7 @@ import java.io.Serializable;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -28,6 +29,7 @@ public class KeySiteExcleDto implements Serializable {
private String name;
@ExcelProperty(value = "所属单位/部门id", index = 1)
@ExplicitConstraint(indexNum = 1, sourceClass = RoleNameExplicitConstraint.class, method = "getCompanyList") //固定下拉内容
@ApiModelProperty(value = "所属单位/部门id")
private String belongName;
......@@ -35,6 +37,7 @@ public class KeySiteExcleDto implements Serializable {
private Long belongId;
@ExcelProperty(value = "所属建筑id", index = 2)
@ExplicitConstraint(indexNum = 2, sourceClass = RoleNameExplicitConstraint.class, method = "getBuildTree") //固定下拉内容
@ApiModelProperty(value = "所属建筑id")
private String buildingName;
......@@ -80,7 +83,7 @@ public class KeySiteExcleDto implements Serializable {
@ExcelProperty(value = "防火标志设立情况", index = 12)
@ApiModelProperty(value = "防火标志设立情况")
private String firePreventionFlag;
private String firePreventionFlagName;
@ExcelProperty(value = "危险源", index = 13)
@ApiModelProperty(value = "危险源")
......
......@@ -26,6 +26,7 @@ public class OrgMenuDto {
private List<OrgMenuDto> children;
private String bizOrgType;
private String bizOrgCode;
private int num;//统计值
public Boolean getLeaf() {
return ObjectUtils.isEmpty(children);
......@@ -52,7 +53,16 @@ public class OrgMenuDto {
this.leaf = leaf;
this.bizOrgCode = bizOrgCode;
}
public OrgMenuDto(Long key, String title, Long parentId, String bizOrgType, boolean leaf, String bizOrgCode,int num) {
super();
this.key = key;
this.title = title;
this.parentId = parentId;
this.bizOrgType = bizOrgType;
this.leaf = leaf;
this.bizOrgCode = bizOrgCode;
this.num=num;
}
public OrgMenuDto(Long key, String title, Long parentId, String bizOrgType, boolean leaf) {
super();
this.key = key;
......
......@@ -34,5 +34,5 @@ public class OrgUsrTreeDto extends BaseDto implements Serializable{
@ApiModelProperty(value = "归属机构")
private String parentId;
@ApiModelProperty(value = "部门数量")
private String num;
private int num;
}
......@@ -3,10 +3,10 @@ package com.yeejoin.amos.boot.module.common.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 重点部位
......@@ -39,6 +39,9 @@ public class KeySite extends BaseEntity {
*/
@TableField("building_id")
private Long buildingId;
@TableField("building_name")
private String buildingName;
/**
* 位置描述
......@@ -98,7 +101,7 @@ public class KeySite extends BaseEntity {
* 防火标志设立情况
*/
@TableField("fire_prevention_flag")
private String firePreventionFlag;
private Boolean firePreventionFlag;
/**
* 危险源
......
......@@ -4,8 +4,7 @@ import java.util.List;
import com.yeejoin.amos.boot.module.common.api.dto.KeySiteDto;
import com.yeejoin.amos.boot.module.common.api.dto.KeySiteExcleDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrTreeDto;
import com.yeejoin.amos.boot.module.common.api.entity.KeySite;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
/**
* 重点部位接口类
......@@ -19,7 +18,7 @@ public interface IKeySiteService {
* @param id
* @return
*/
public boolean deletebyId(Long id);
public boolean deleteById(Long id);
/**
* 保存
* @param model
......@@ -31,12 +30,12 @@ public KeySiteDto save(KeySiteDto model);
* @param keySite
* @return
*/
public boolean update (KeySite keySite);
public boolean update (KeySiteDto keySite);
/**
* 获取机场单位组织结构树,包含单位下部门数量的统计
* @return
*/
public List<OrgUsrTreeDto> getOrguserTree();
public List<OrgMenuDto> getOrguserTree();
/**
*
* @return
......@@ -51,5 +50,10 @@ public KeySiteDto getSequenceNbr(Long sequenceNbr);
public List<KeySiteExcleDto> exportToExcel();
public boolean saveExcle(List<KeySiteExcleDto> excelDtoList);
/**获取所在建筑的树结构信息
*
* @return
*/
public List<Object> getBuildTree() ;
public boolean saveExcel(List<KeySiteExcleDto> excelDtoList);
}
......@@ -9,7 +9,9 @@
SELECT
c.`name` as name,
c.belong_id as belongId,
cou.biz_org_name as belongName,
c.building_id as buildingId,
c.building_name as buildingName,
c.address_desc as addressDesc,
c.building_area as buildingArea,
c.building_height as buildingHeight,
......@@ -49,6 +51,7 @@ LEFT JOIN (
cb_key_site c
LEFT JOIN cb_data_dictionary b ON c.use_nature = b.`code`
) un ON c.use_nature = un.use_nature
left join cb_org_usr cou on c.building_id =cou.sequence_nbr
where c.is_delete=FALSE
<if test="name != null and name != ''">
AND c.`name`=#{name}
......@@ -73,7 +76,9 @@ where c.is_delete=FALSE
SELECT
c.`name` as name,
c.belong_id as belongId,
cou.biz_org_name as belongName,
c.building_id as buildingId,
c.building_name as buildingName,
c.address_desc as addressDesc,
c.building_area as buildingArea,
c.building_height as buildingHeight,
......@@ -113,6 +118,7 @@ LEFT JOIN (
cb_key_site c
LEFT JOIN cb_data_dictionary b ON c.use_nature = b.`code`
) un ON c.use_nature = un.use_nature
left join cb_org_usr cou on c.building_id =cou.sequence_nbr
where c.sequence_nbr=#{sequenceNbr} and c.is_delete=FALSE;
</select>
......@@ -121,7 +127,9 @@ where c.sequence_nbr=#{sequenceNbr} and c.is_delete=FALSE;
SELECT
c.`name` as name,
c.belong_id as belongId,
cou.biz_org_name as belongName,
c.building_id as buildingId,
c.building_name as buildingName,
c.address_desc as addressDesc,
c.building_area as buildingArea,
c.building_height as buildingHeight,
......@@ -161,6 +169,7 @@ LEFT JOIN (
cb_key_site c
LEFT JOIN cb_data_dictionary b ON c.use_nature = b.`code`
) un ON c.use_nature = un.use_nature
left join cb_org_usr cou on c.building_id =cou.sequence_nbr
where c.is_delete=FALSE;
</select>
......
......@@ -261,5 +261,40 @@ FROM
WHERE
a.biz_org_name = #{bizOrgName}
</select>
<select id="getCompanyAndCountDepartment" resultType="com.yeejoin.amos.boot.module.common.api.dto.OrgUsrTreeDto">
SELECT
company_sur.sequence_nbr as sequenceNbr,
company_sur.biz_org_name as bizOrgName ,
company_sur.parent_id as parentId,
CASE
WHEN keysite_sur.num IS NULL THEN
0
ELSE
keysite_sur.num
END AS num
FROM
(
SELECT
company.sequence_nbr,
company.parent_id,
company.biz_org_name
FROM
cb_org_usr company
WHERE
company.biz_org_type = 'COMPANY'
AND company.is_delete = FALSE
) company_sur
LEFT JOIN (
SELECT
keysite.belong_id,
COUNT(keysite.belong_id) as num
FROM
cb_key_site keysite
WHERE
keysite.is_delete = FALSE
GROUP BY
keysite.belong_id
) keysite_sur ON company_sur.sequence_nbr = keysite_sur.belong_id
</select>
</mapper>
......@@ -15,5 +15,10 @@
<artifactId>amos-boot-module-common-api</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-jcs-api</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
</dependencies>
</project>
......@@ -26,7 +26,6 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.api.dto.KeySiteDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrTreeDto;
import com.yeejoin.amos.boot.module.common.api.entity.KeySite;
import com.yeejoin.amos.boot.module.common.api.service.IKeySiteService;
import com.yeejoin.amos.boot.module.common.api.service.IMaintenanceCompanyService;
......@@ -80,7 +79,7 @@ public class KeySiteController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "update/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新重点部位", notes = "根据sequenceNbr更新重点部位")
public ResponseModel<Boolean> updateBySequenceNbrKeySite(@RequestBody KeySite model) {
public ResponseModel<Boolean> updateBySequenceNbrKeySite(@RequestBody KeySiteDto model) {
return ResponseHelper.buildResponse(keySiteService.update(model));
}
......@@ -94,7 +93,7 @@ public class KeySiteController extends BaseController {
@DeleteMapping(value = "delete/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除重点部位", notes = "根据sequenceNbr删除重点部位")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
return ResponseHelper.buildResponse(keySiteService.deletebyId(sequenceNbr));
return ResponseHelper.buildResponse(keySiteService.deleteById(sequenceNbr));
}
/**
......@@ -150,13 +149,7 @@ public class KeySiteController extends BaseController {
@ApiOperation(httpMethod = "GET",value = "机场单位组织结构树", notes = "机场单位组织结构树")
@GetMapping(value = "/getOrguserTree")
public ResponseModel<List<OrgMenuDto>> getOrguserTree() throws Exception{
List<OrgMenuDto> menus = iOrgUsrService.getTree(null,
keySiteService.getOrguserTree(), OrgUsrTreeDto.class.getName(),
"getSequenceNbr", 2, "getBizOrgName", "getParentId", "getNum");
return ResponseHelper.buildResponse(menus);
return ResponseHelper.buildResponse(keySiteService.getOrguserTree());
}
}
......@@ -49,8 +49,6 @@ public class MaintenanceCompanyController extends BaseController {
@Autowired
MaintenanceCompanyServiceImpl maintenanceCompanyServiceImpl;
SourceFileServiceImpl sourceFileService;
@Autowired
IMaintenanceCompanyService maintenanceCompanyService;
......
package com.yeejoin.amos.boot.module.common.biz.service.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -12,7 +15,9 @@ import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -20,12 +25,14 @@ import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.api.dto.KeySiteDto;
import com.yeejoin.amos.boot.module.common.api.dto.KeySiteExcleDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrTreeDto;
import com.yeejoin.amos.boot.module.common.api.entity.KeySite;
import com.yeejoin.amos.boot.module.common.api.entity.SourceFile;
import com.yeejoin.amos.boot.module.common.api.mapper.KeySiteMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper;
import com.yeejoin.amos.boot.module.common.api.service.IKeySiteService;
import com.yeejoin.amos.boot.module.jcs.api.feign.EquipFeignClient;
/**
* 重点部位服务实现类
......@@ -45,6 +52,9 @@ public class KeySiteServiceImpl extends BaseService<KeySiteDto, KeySite, KeySite
@Autowired
OrgUsrMapper orgUsrMapper;
@Autowired
EquipFeignClient equipFeignClient;
/**
* 分页查询
*/
......@@ -53,20 +63,44 @@ public class KeySiteServiceImpl extends BaseService<KeySiteDto, KeySite, KeySite
keySite.getFireEnduranceRate(), keySite.getUseNature(), keySite.getFireFacilitiesInfo());
}
public List<Object> getBuildTree() {
ResponseModel<Object> response = equipFeignClient.getBuildingTree();
if (200 == response.getStatus() && ObjectUtils.isNotEmpty(response.getResult())) {
return JSONArray.parseArray(JSON.toJSONString(response.getResult()));
}
return null;
}
/**
* 列表查询 示例
*/
@Override
public List<KeySiteDto> queryForKeySiteList() {
return keySiteMapper.getKeySiteList();
}
@Override
public List<KeySiteExcleDto> exportToExcel() {
List<KeySiteDto> list = this.queryForKeySiteList();
return JSONArray.parseArray(JSONArray.toJSONString(list), KeySiteExcleDto.class);
List<KeySiteExcleDto> excleList = new ArrayList<>();
list.stream().forEach(i->{
KeySiteExcleDto keySiteExcleDto =new KeySiteExcleDto();
Bean.copyExistPropertis(i, keySiteExcleDto);
if(i.getFirePreventionFlag()) {
keySiteExcleDto.setFirePreventionFlagName("有");
}else {
keySiteExcleDto.setFirePreventionFlagName("无");
}
keySiteExcleDto.setUseNature(i.getUseNatureName());
keySiteExcleDto.setBelongName(i.getBelongName());
keySiteExcleDto.setFireEnduranceRate(i.getFireEnduranceRateName());
excleList.add(keySiteExcleDto);
});
return excleList;
}
@Override
public boolean deletebyId(Long id) {
public boolean deleteById(Long id) {
KeySite keySite = keySiteMapper.selectById(id);
if (keySite == null) {
return false;
......@@ -85,7 +119,7 @@ public class KeySiteServiceImpl extends BaseService<KeySiteDto, KeySite, KeySite
KeySite keySite = new KeySite();
Bean.copyExistPropertis(model, keySite);
this.save(keySite);
this.saveAttachments(model);
sourceFileService.saveAttachments(model.getSequenceNbr(), model.getAttachments());
// TODO Auto-generated method stub
return model;
}
......@@ -116,32 +150,77 @@ public class KeySiteServiceImpl extends BaseService<KeySiteDto, KeySite, KeySite
return sourceFiles;
}
public boolean update(KeySite keySite) {
keySite.setIsDelete(false);
int num = keySiteMapper.updateById(keySite);
@Transactional(rollbackFor = Exception.class)
public boolean update(KeySiteDto keySite) {
KeySite entity = new KeySite();
Bean.copyExistPropertis(keySite, entity);
entity.setIsDelete(false);
int num = keySiteMapper.updateById(entity);
Map<String, List<AttachmentDto>> map = keySite.getAttachments();
if (ObjectUtils.isNotEmpty(map)) {
this.saveAttachments(keySite);
}
if (num > 0) {
return true;
}
return false;
}
@Override
public List<OrgUsrTreeDto> getOrguserTree() {
return orgUsrMapper.getCompanyAndCountDepartment();
public List<OrgMenuDto> getOrguserTree() {
return buildTreeParallel(orgUsrMapper.getCompanyAndCountDepartment());
}
public static List<OrgMenuDto> buildTreeParallel(List<OrgUsrTreeDto> list) {
List<OrgMenuDto> menuList = list.stream().map(o -> {
OrgMenuDto menu = new OrgMenuDto(o.getSequenceNbr(), o.getBizOrgName(),
ObjectUtils.isEmpty(o.getParentId()) ? 0L : Long.valueOf(o.getParentId()), o.getBizOrgType(), false,
o.getBizOrgCode(),o.getNum());
return menu;
}).collect(Collectors.toList());
List<OrgMenuDto> result = new ArrayList<>();
Map<Long, OrgMenuDto> map = new HashMap<>(menuList.size());
menuList.forEach(e -> map.put(e.getKey(), e));
Set<? extends Map.Entry<Long, ? extends OrgMenuDto>> entries = map.entrySet();
entries.parallelStream().forEach(entry -> {
OrgMenuDto value = entry.getValue();
if (value != null) {
OrgMenuDto treeDto = map.get(value.getParentId());
if (treeDto != null) {
List<OrgMenuDto> children = treeDto.getChildren();
if (children == null) {
children = new ArrayList<>();
treeDto.setChildren(children);
}
children.add(value);
} else {
result.add(value);
}
}
});
return result;
}
@Override
public KeySiteDto getSequenceNbr(Long sequenceNbr) {
return keySiteMapper.getSequenceNbr(sequenceNbr);
}
@Override
public boolean saveExcle(List<KeySiteExcleDto> excelDtoList) {
public boolean saveExcel(List<KeySiteExcleDto> excelDtoList) {
List<KeySite> excelList = new ArrayList<KeySite>();
for (KeySiteExcleDto keySiteExcleDto : excelDtoList) {
KeySite keySiteDto = new KeySite();
Bean.copyExistPropertis(keySiteExcleDto, keySiteDto);
keySiteDto.setIsDelete(false);
if (StringUtils.isNotBlank(keySiteExcleDto.getBelongName())
&& keySiteExcleDto.getBelongName().contains("@")){
keySiteDto.setBelongId(Long.parseLong(keySiteExcleDto.getBelongName().split("@")[1]));
}
if (StringUtils.isNotBlank(keySiteExcleDto.getBuildingName()) && keySiteExcleDto.getBuildingName().contains("@")){
String[] fireEnduranceRateArray = keySiteExcleDto.getBuildingName().split("@");
keySiteDto.setBuildingId(Long.parseLong(fireEnduranceRateArray[1]));
keySiteDto.setBuildingName(fireEnduranceRateArray[0]);
}
if (StringUtils.isNotBlank(keySiteExcleDto.getFireEnduranceRate())
&& keySiteExcleDto.getFireEnduranceRate().contains("@")) {
String[] fireEnduranceRateArray = keySiteExcleDto.getFireEnduranceRate().split("@");
......@@ -153,11 +232,16 @@ public class KeySiteServiceImpl extends BaseService<KeySiteDto, KeySite, KeySite
&& keySiteExcleDto.getUseNature().contains("@")) {
String[] useNatureArray = keySiteExcleDto.getUseNature().split("@");
if (useNatureArray.length > 1) {
keySiteDto.setFireEnduranceRate(useNatureArray[1]);
keySiteDto.setUseNature(useNatureArray[1]);
}
}
if(keySiteExcleDto.getFirePreventionFlagName().equals("有")) {
keySiteDto.setFirePreventionFlag(true);
}else {
keySiteDto.setFirePreventionFlag(false);
}
excelList.add(keySiteDto);
}
return this.saveBatch(excelList);
return this.saveBatch(excelList);
}
}
\ No newline at end of file
}
......@@ -116,7 +116,7 @@ public class MaintenanceCompanyServiceImpl
try {
this.save(maintenanceCompany);
saveAttachments(maintenanceCompany);
sourceFileService.saveAttachments(maintenanceCompany.getSequenceNbr(), maintenanceCompany.getAttachments());
} catch (Exception e) {
e.printStackTrace();
return false;
......@@ -144,7 +144,7 @@ public class MaintenanceCompanyServiceImpl
try {
this.save(maintenanceCompany);
saveAttachments(maintenanceCompany);
sourceFileService.saveAttachments(maintenanceCompany.getSequenceNbr(), maintenanceCompany.getAttachments());
} catch (Exception e) {
return false;
}
......@@ -152,35 +152,6 @@ public class MaintenanceCompanyServiceImpl
}
/**
* 保存附件
*/
public void saveAttachments(MaintenanceCompany maintenanceCompany) {
if (!ValidationUtil.isEmpty(maintenanceCompany.getAttachments())) {
List<SourceFile> sourceFiles = Lists.newArrayList();
Map<String, List<AttachmentDto>> attachmentMap = maintenanceCompany.getAttachments();
attachmentMap.entrySet().forEach(entry -> {
List<AttachmentDto> atts = entry.getValue();
sourceFiles.addAll(attachment2SourceFile(entry.getKey(), atts));
});
sourceFileService.saveSourceFile(maintenanceCompany.getSequenceNbr(), sourceFiles);
}
}
private List<SourceFile> attachment2SourceFile(String type, List<AttachmentDto> attachmentDtoList) {
List<SourceFile> sourceFiles = Lists.newArrayList();
if (!ValidationUtil.isEmpty(attachmentDtoList)) {
attachmentDtoList.forEach(a -> {
SourceFile s = new SourceFile();
s.setFilePath(a.getUrl());
s.setFileName(a.getName());
s.setFileCategory(type);
sourceFiles.add(s);
});
}
return sourceFiles;
}
/**
* 添加动态表单信息
*
* @param maintenanceCompany
......@@ -212,7 +183,7 @@ public class MaintenanceCompanyServiceImpl
try {
this.save(maintenanceCompany);
saveAttachments(maintenanceCompany);
sourceFileService.saveAttachments(maintenanceCompany.getSequenceNbr(), maintenanceCompany.getAttachments());
} catch (Exception e) {
return false;
}
......@@ -488,7 +459,7 @@ public class MaintenanceCompanyServiceImpl
this.updateById(model);
// 更新附件
saveAttachments(model);
sourceFileService.saveAttachments(model.getSequenceNbr(), model.getAttachments());
} catch (Exception e) {
e.printStackTrace();
return false;
......
......@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.api.dto.SourceFileDto;
import com.yeejoin.amos.boot.module.common.api.entity.SourceFile;
import com.yeejoin.amos.boot.module.common.api.mapper.SourceFileMapper;
......@@ -11,12 +13,14 @@ import com.yeejoin.amos.boot.module.common.api.service.ISourceFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
......@@ -76,4 +80,32 @@ public class SourceFileServiceImpl extends BaseService<SourceFileDto, SourceFile
boolean flag = this.saveOrUpdateBatch(sourceFiles);
return flag ? sourceFiles : Collections.EMPTY_LIST;
}
/**
* 保存附件
*/
public void saveAttachments(Long sequenceNbr, Map<String, List<AttachmentDto>> attachmentMap) {
if (!ValidationUtil.isEmpty(attachmentMap)) {
List<SourceFile> sourceFiles = Lists.newArrayList();
attachmentMap.entrySet().forEach(entry -> {
List<AttachmentDto> attachments = entry.getValue();
sourceFiles.addAll(attachment2SourceFile(entry.getKey(), attachments));
});
saveSourceFile(sequenceNbr, sourceFiles);
}
}
private List<SourceFile> attachment2SourceFile(String type, List<AttachmentDto> attachmentDtoList) {
List<SourceFile> sourceFiles = Lists.newArrayList();
if (!ValidationUtil.isEmpty(attachmentDtoList)) {
attachmentDtoList.forEach(a -> {
SourceFile s = new SourceFile();
s.setFilePath(a.getUrl());
s.setFileName(a.getName());
s.setFileCategory(type);
sourceFiles.add(s);
});
}
return sourceFiles;
}
}
\ No newline at end of file
......@@ -285,7 +285,7 @@ public class ExcelController extends BaseController {
private void excelImportkeySite(MultipartFile multipartFile, String wbry) throws Exception {
List<KeySiteExcleDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
KeySiteExcleDto.class, 1);
keySiteService.saveExcle(excelDtoList);
keySiteService.saveExcel(excelDtoList);
}
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -11,29 +32,16 @@ import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersZhDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
import com.yeejoin.amos.boot.module.common.api.entity.DataDictionary;
import com.yeejoin.amos.boot.module.common.api.entity.Firefighters;
import com.yeejoin.amos.boot.module.common.api.entity.MaintenanceCompany;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.enums.ExcelSelectData;
import com.yeejoin.amos.boot.module.common.api.excel.DataSources;
import com.yeejoin.amos.boot.module.common.api.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.module.common.api.service.IKeySiteService;
import com.yeejoin.amos.boot.module.common.api.service.IMaintenanceCompanyService;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.feign.EquipFeignClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class DataSourcesImpl implements DataSources {
......@@ -55,6 +63,8 @@ public class DataSourcesImpl implements DataSources {
IMaintenanceCompanyService maintenanceCompanyService;
@Autowired
IKeySiteService keySiteService;
@Autowired
private RestTemplate restTemplate;
@Value("${security.systemctl.name}")
......@@ -111,6 +121,10 @@ public class DataSourcesImpl implements DataSources {
break;
case "getCompanyAndDeparementTree":
str= getCompanyAndDeparementTree();
break;
case "getBuildTree":
str=getBuildTree();
break;
}
}
return str;
......@@ -226,4 +240,23 @@ public class DataSourcesImpl implements DataSources {
return str;
}
private String[] getBuildTree() throws Exception {
List<Object> menus = keySiteService.getBuildTree();
List<String> stringList = new ArrayList<String>();
initBuildTreeList(menus, stringList);
String[] str = stringList.toArray(new String[stringList.size()]);
return str;
}
private void initBuildTreeList(List<Object> menus, List<String> stringList) {
for (Object orgMenuDto : menus) {
JSONObject detailObject= JSONObject.parseObject(orgMenuDto.toString());
stringList.add(detailObject.getString("id") + "@" + detailObject.getString("name"));
JSONArray children = detailObject.getJSONArray("children");
if (children != null && children.size() > 0) {
initBuildTreeList(children, stringList);
}
}
}
}
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