Commit fa86f636 authored by 李腾威's avatar 李腾威

linux 下生成word文件保存解决

parent 190e7c25
......@@ -342,9 +342,11 @@ AND cft.type_code = (
</select>
<select id='queryByCompanyId' resultType="map">
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone, amosUserId from (
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId
from cb_org_usr orgUsr left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone, amosUserId,companyName from (
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId, cou1.biz_org_name companyName
from (select * from cb_org_usr cou where is_delete = 0 ) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId from (
......@@ -367,9 +369,11 @@ AND cft.type_code = (
<select id='queryByCompanyNew' resultType="map">
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone,amosUserId from (
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId
from cb_org_usr orgUsr left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone, amosUserId,companyName from (
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId, cou1.biz_org_name companyName
from (select * from cb_org_usr cou where is_delete = 0 ) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId from (
......
......@@ -179,7 +179,7 @@
mobile_phone as mobilePhone,
amos_user_id amosUserId
FROM
cb_firefighters firefighters
(select * from cb_firefighters fr where is_delete = 0) firefighters
WHERE
fire_team_id in ( select sequence_nbr from cb_fire_team cft where company in (
select sequence_nbr from cb_org_usr cou where biz_org_name = #{name}) )
......
......@@ -688,16 +688,16 @@ LEFT JOIN (
</select>
<select id="queryCompanyId" resultType="map">
select * from (
select d.*,cbo.biz_org_name companyName from (
select cou.biz_org_name bizOrgName,cou.sequence_nbr sequenceNbr ,cou .parent_id parentId,
a.fireManagementPostCode, b.telephone,cou.amos_org_id amosUserId from cb_org_usr cou
a.fireManagementPostCode, b.telephone,cou.amos_org_id amosUserId from ( select * from cb_org_usr cou where is_delete = 0 ) cou
left join (select i.instance_id id1 ,if(i.field_code = 'fireManagementPostCode',
i.field_value, null) as 'fireManagementPostCode' from cb_dynamic_form_instance i where i.field_code = 'fireManagementPostCode'
and i.field_value_label is not null) a on cou .sequence_nbr = a.id1
left join (select i.instance_id id2,if(i.field_code = 'telephone',
i.field_value, null) as 'telephone' from cb_dynamic_form_instance i where i.field_code = 'telephone'
and i.field_value is not null) b on cou .sequence_nbr = b.id2
) d where d.parentId in (select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})
) d left join cb_org_usr cbo on cbo.sequence_nbr = d.parentId where d.parentId in (select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})
and (d.fireManagementPostCode in
<foreach item="item" index="index" collection="codes" open="(" separator="," close=")">
#{item}
......@@ -706,16 +706,17 @@ LEFT JOIN (
</select>
<select id="queryCompanyIdNew" resultType="map">
select * from (
select d.*,cbo.biz_org_name companyName from (
select cou.biz_org_name bizOrgName,cou.sequence_nbr sequenceNbr ,cou .parent_id parentId,
a.administrativePositionCode, b.telephone, cou.amos_org_id amosUserId from cb_org_usr cou
a.administrativePositionCode, b.telephone, cou.amos_org_id amosUserId from ( select * from cb_org_usr cou where is_delete = 0 ) cou
left join (select i.instance_id id1 ,if(i.field_code = 'administrativePositionCode',
i.field_value_label, null) as 'administrativePositionCode' from cb_dynamic_form_instance i where i.field_code = 'administrativePositionCode'
and i.field_value_label is not null) a on cou .sequence_nbr = a.id1
left join (select i.instance_id id2,if(i.field_code = 'telephone',
inner join (select i.instance_id id2,if(i.field_code = 'telephone',
i.field_value, null) as 'telephone' from cb_dynamic_form_instance i where i.field_code = 'telephone'
and i.field_value is not null) b on cou .sequence_nbr = b.id2
) d where d.parentId in (select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})
) d left join cb_org_usr cbo on cbo.sequence_nbr = d.parentId where d.parentId in (select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})
</select>
</mapper>
......@@ -277,8 +277,6 @@ public class AlertSubmittedController extends BaseController {
alertSubmittedService.generateMob(alertCalledFormDto.getAlertCalled());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
......
......@@ -72,6 +72,7 @@ public class AlertCalledAction {
@RuleMethod(methodLabel = "短信报送", project = "西咸机场119接处警规则")
public void sendcmd(String smsCode, String sendType, List<Map<String,Object>> submittedList, Object object) throws Exception {
System.out.println("接收到规则调用--------------西咸机场119接处警规则/alertCalledRule");
alertSubmittedService.ruleCallbackAction(smsCode, submittedList, object);
}
......
package com.yeejoin.amos.boot.module.jcs.biz.rule.action;
import java.util.ArrayList;
import java.util.List;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.PowerrTransferLogServiceImpl;
......@@ -57,16 +58,18 @@ public class PowerTransferAction {
if (object instanceof AlertCallePowerTransferRo) {
AlertCallePowerTransferRo calledRo = (AlertCallePowerTransferRo) object;
powerrTransferLogServiceImpl.savePowerTransferLog(calledRo);
// 获取力量调派发送人员
List<String> persons = new ArrayList<>();
calledRo.getPowerTransType();
if (FireBrigadeTypeEnum.专职消防队.getKey().equals(calledRo.getPowerTransType())) {
alertSubmittedService.ruleCallbackActionForPowerTransferForCar(smsCode, sendIds, object);//消防车辆
alertSubmittedService.ruleCallbackActionForPowerTransferForCar(smsCode, sendIds, object,persons);//消防车辆
} else if (FireBrigadeTypeEnum.医疗救援队.getKey().equals(calledRo.getPowerTransType())) {
alertSubmittedService.ruleCallbackActionForPowerTransferForAid(smsCode, sendIds, object);//120急救站
alertSubmittedService.ruleCallbackActionForPowerTransferForAid(smsCode, sendIds, object,persons);//120急救站
} else if (FireBrigadeTypeEnum.监控大队.getKey().equals(calledRo.getPowerTransType())) {
alertSubmittedService.ruleCallbackActionForPowerTransferForSurvBrigade(smsCode, sendIds, object);//监控大队
alertSubmittedService.ruleCallbackActionForPowerTransferForSurvBrigade(smsCode, sendIds, object,persons);//监控大队
}
powerrTransferLogServiceImpl.savePowerTransferLog(calledRo,persons);
}
}
}
......@@ -299,6 +299,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
map.put("sequenceNbr",f.getSequenceNbr());
map.put("bizOrgName",f.getName());
map.put("amosUserId",f.getAmosUserId());
map.put("companyName", e.get("name").toString());
orgUsers.add(map);
});
......@@ -424,6 +425,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
alertSubmittedObject.setUserId(Long.valueOf(String.valueOf(orgUser.get("sequenceNbr"))));
alertSubmittedObject.setUserName((String) orgUser.get("bizOrgName"));
alertSubmittedObject.setCompanyName((String) orgUser.get("companyName"));
if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) {
mobiles.add((String) orgUser.get("telephone"));
......@@ -605,8 +607,6 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
AlertCalledFormDto alertCalledFormDto = (AlertCalledFormDto)alertCalledService.selectAlertCalledById(alertSubmittedDto.getAlertCalledId());
AlertCalled alertCalled = alertCalledFormDto.getAlertCalled();
generateMob(alertCalled);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (ParseException e) {
......@@ -660,7 +660,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
return map;
}
public void generateMob(AlertCalled alertCalled) throws UnsupportedEncodingException, FileNotFoundException, ParseException {
public void generateMob(AlertCalled alertCalled) throws ParseException, FileNotFoundException {
AlertCalledMobDto report = new AlertCalledMobDto();
report.setYear(String.valueOf(DateUtils.getYear(new Date())));
......@@ -734,11 +734,26 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
report.setAlertCalledPowerInfoDtoList(list);
if (!ValidationUtil.isEmpty(report)) {
String checkReportTemplatePath = this.getClass().getClassLoader().getResource("templates/check-report-template" +
".docx").getFile();
String filePath = this.getClass().getClassLoader().getResource("templates").getPath();
String fileName = filePath + "/" + System.currentTimeMillis() + ".docx";
String os = System.getProperty("os.name");
InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("templates/check-report-template.docx");
String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
// String checkReportTemplatePath = this.getClass().getClassLoader().getResource("templates/check-report-template" +
// ".docx").getFile();
// String filePath = this.getClass().getClassLoader().getResource("templates").getPath();
String filePath = "";
String fileName = "";
if(os.toLowerCase().startsWith("win")) {
filePath = this.getClass().getClassLoader().getResource("templates").getPath();
fileName = filePath + "/" + System.currentTimeMillis() + ".docx";
} else {
// String [] arr = path.split("amos-boot-system-jcs-1.0.0.jar!");
// System.out.println(arr[0].substring(0,arr[0].lastIndexOf("/")));
// fileName = arr[0].substring(0,arr[0].lastIndexOf("/")) + "/" + System.currentTimeMillis() + ".docx";
fileName = "/opt/file/"+System.currentTimeMillis() + ".docx";
}
String newFileName= "";
AlertCalledPowerInfoTablePolicy calledPowerInfoTablePolicy = new AlertCalledPowerInfoTablePolicy();
......@@ -747,7 +762,22 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
Configure.ConfigureBuilder configureBuilder = Configure.newBuilder();
configureBuilder.setElMode(ELMode.SPEL_MODE).bind("alertCalledPowerInfoDtoList", calledPowerInfoTablePolicy)
.bind("alertCallCommandDtoList", alertCallCommandTablePolicy).build();
XWPFTemplate template = XWPFTemplate.compile(checkReportTemplatePath, configureBuilder.build()).render(report);
XWPFTemplate template = XWPFTemplate.compile(resourceAsStream, configureBuilder.build()).render(report);
File file = new File(fileName);
if (!file .getParentFile().exists()) {
file .getParentFile().mkdirs();
}
if(!file .exists()) {
try {
file .createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
file.setExecutable(true);
file.setReadable(true);
file.setWritable(true);
}
FileOutputStream out = new FileOutputStream(fileName);
BufferedOutputStream bos = null;
......@@ -760,19 +790,20 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
// docx 转 doc
Document document = new Document();
String os = System.getProperty("os.name");
//拼接完整连接
String pa1 = "";
if(os.toLowerCase().startsWith("win")){
String pa = fileName.substring(1);
String pa = fileName.substring(1);
document.loadFromFile(pa);
newFileName = filePath +"/" + System.currentTimeMillis()+".doc";
newFileName = System.currentTimeMillis()+".doc";
//保存结果文件
pa1 = newFileName.substring(1);
document.saveToFile(pa1, FileFormat.Doc);
} else {
document.loadFromFile(fileName);
newFileName = filePath + System.currentTimeMillis()+".doc";
System.out.println(fileName);
newFileName = "/opt/file/" + System.currentTimeMillis()+".doc";
System.out.println(newFileName);
document.saveToFile(newFileName, FileFormat.Doc);
pa1 = newFileName;
}
......@@ -801,9 +832,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
out.close();
template.close();
File file = new File(fileName);
if(file.exists()) {
file.delete();
File file2 = new File(fileName);
if(file2.exists()) {
file2.delete();
}
File file1 = new File(newFileName);
......@@ -1160,7 +1191,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
@SuppressWarnings("unchecked")
public void ruleCallbackActionForPowerTransferForCar(String smsCode, List sendIds, Object object)
public void ruleCallbackActionForPowerTransferForCar(String smsCode, List sendIds, Object object, List<String> pList)
throws IllegalAccessException, MqttPersistenceException, MqttException {
List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList();
......@@ -1262,6 +1293,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
alertSubmittedObject.setUserId(Long.parseLong(orgUser.get("userId").toString()));
alertSubmittedObject.setUserName(orgUser.get("userName").toString());
// 将发送人放入 list
pList.add(orgUser.get("userName").toString());
if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) {
mobiles.add((String) orgUser.get("telephone"));
alertSubmittedObject.setUserPhone((String) orgUser.get("telephone"));
......@@ -1305,6 +1339,8 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
}
alertSubmittedObjectSub.setUserId(Long.parseLong(map.get("userId").toString()));
alertSubmittedObjectSub.setUserName(map.get("userName").toString());
//
pList.add(map.get("userName").toString());
Set<String> mobile =null;
List<String> userList=null;
if (!ValidationUtil.isEmpty(map.get("mobilePhone"))) {
......@@ -1368,7 +1404,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
}
@SuppressWarnings("unchecked")
public void ruleCallbackActionForPowerTransferForSurvBrigade(String smsCode, List sendIds, Object object) throws MqttPersistenceException, MqttException {
public void ruleCallbackActionForPowerTransferForSurvBrigade(String smsCode, List sendIds, Object object, List<String> pList) throws MqttPersistenceException, MqttException {
List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList();
......@@ -1431,6 +1467,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
alertSubmittedObject.setType(false);
alertSubmittedObject.setUserId(Long.parseLong(orgUser.get("userId").toString()));
alertSubmittedObject.setUserName(orgUser.get("userName").toString());
pList.add(orgUser.get("userName").toString());
if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) {
mobiles.add((String) orgUser.get("telephone"));
......@@ -1482,7 +1519,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
public void ruleCallbackActionForPowerTransferForAid(String smsCode, List sendIds, Object object) throws MqttPersistenceException, MqttException {
public void ruleCallbackActionForPowerTransferForAid(String smsCode, List sendIds, Object object, List<String> pList) throws MqttPersistenceException, MqttException {
List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList();
......@@ -1551,6 +1588,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
alertSubmittedObject.setType(false);
alertSubmittedObject.setUserId(Long.parseLong(orgUser.get("userId").toString()));
alertSubmittedObject.setUserName(orgUser.get("userName").toString());
pList.add(orgUser.get("userName").toString());
if (!ValidationUtil.isEmpty(orgUser.get("mobilePhone"))) {
mobiles.add((String) orgUser.get("mobilePhone"));
......
......@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCallePowerTransferRo;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyResourcesDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransferCompany;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransferCompanyResources;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerrTransferLog;
......@@ -15,6 +16,7 @@ import com.yeejoin.amos.boot.module.jcs.api.enums.FireBrigadeTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerrTransferLogMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IPowerrTransferLogService;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerrTransferLogDto;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -42,6 +44,9 @@ public class PowerrTransferLogServiceImpl extends BaseService<PowerrTransferLogD
@Autowired
PowerTransferCompanyResourcesServiceImpl powerTransferCompanyResourcesService;
@Autowired
AlertCalledServiceImpl iAlertCalledService;
/**
* 分页查询
*/
......@@ -98,11 +103,16 @@ public class PowerrTransferLogServiceImpl extends BaseService<PowerrTransferLogD
}
public void savePowerTransferLog( AlertCallePowerTransferRo alertCallePowerTransferRo) {
String powerTransType = alertCallePowerTransferRo.getPowerTransType();
public void savePowerTransferLog( AlertCallePowerTransferRo alertCallePowerTransferRo, List<String> persons) {
String powerTransType = alertCallePowerTransferRo.getPowerTransType();
AlertCalled alertCalled = iAlertCalledService.getById(alertCallePowerTransferRo.getSequenceNbr());
String personName = "";
if (persons.size() > 0) {
personName = StringUtils.join(persons.toArray(),",");
}
final String receiveName = personName;
List<PowerrTransferLog> list = new ArrayList<>();
if (FireBrigadeTypeEnum.专职消防队.getKey().equals(powerTransType)) {
List<Object> companyDetail = JSONArray.parseArray(JSON.toJSON(alertCallePowerTransferRo.getCompany()).toString(),Object.class);
for (Object powerTransferCompanyDto : companyDetail) {
PowerTransferCompanyDto powerDto = JSONObject.parseObject(JSON.toJSON(powerTransferCompanyDto).toString(), PowerTransferCompanyDto.class);
......@@ -110,7 +120,8 @@ public class PowerrTransferLogServiceImpl extends BaseService<PowerrTransferLogD
powerTransferCompanyResourcesDtoList.stream().forEach(f-> {
PowerrTransferLog pw = new PowerrTransferLog();
pw.setResourceId(f.getSequenceNbr());
pw.setReceiveName(f.getRecUserName());
pw.setReceiveName(receiveName);
pw.setRecUserName(alertCalled.getRecUserName());
try {
pw.setSendTime(DateUtils.dateTimeToDateString(new Date(System.currentTimeMillis())));
} catch (ParseException ex) {
......@@ -127,7 +138,8 @@ public class PowerrTransferLogServiceImpl extends BaseService<PowerrTransferLogD
PowerTransferCompanyDto powerDto = JSONObject.parseObject(JSON.toJSON(powerTransferCompanyDto).toString(), PowerTransferCompanyDto.class);
PowerrTransferLog pw = new PowerrTransferLog();
pw.setTeamId(powerDto.getSequenceNbr());
pw.setReceiveName(powerDto.getRecUserName());
pw.setReceiveName(receiveName);
pw.setRecUserName(alertCalled.getRecUserName());
try {
pw.setSendTime(DateUtils.dateTimeToDateString(new Date(System.currentTimeMillis())));
} catch (ParseException ex) {
......
......@@ -71,6 +71,7 @@ public class RuleAlertCalledService {
if(!ValidationUtil.isEmpty(mobiles)) {
alertCalledRo.setIds(mobiles);
}
System.out.println("触发规则调用--------------西咸机场119接处警规则/alertCalledRule");
//触发规则
ruleTrigger.publish(alertCalledRo, "西咸机场119接处警规则/alertCalledRule", new String[0]);
......
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