Commit e22b53ae authored by 耿迪迪's avatar 耿迪迪

居民工商业安检单导出修改

parent 266c4fbb
......@@ -146,11 +146,11 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
List<TTaskInspect> businessInspectList = userInspectExportList.stream().filter(item -> 2 == item.getType()).collect(Collectors.toList());
businessExport(businessInspectList);
//工业季度安检单
List<TTaskInspect> industryQuarterInspectList = userInspectExportList.stream().filter(item -> 3 == item.getType() && 2 == item.getCheckType()).collect(Collectors.toList());
List<TTaskInspect> industryQuarterInspectList = userInspectExportList.stream().filter(item -> 3 == item.getType()).collect(Collectors.toList());
industryQuarterExport(industryQuarterInspectList);
//工业月度安检单
List<TTaskInspect> industryMonthInspectList = userInspectExportList.stream().filter(item -> 3 == item.getType() && 1 == item.getCheckType()).collect(Collectors.toList());
industryMonthExport(industryMonthInspectList);
/*List<TTaskInspect> industryMonthInspectList = userInspectExportList.stream().filter(item -> 3 == item.getType() && 1 == item.getCheckType()).collect(Collectors.toList());
industryMonthExport(industryMonthInspectList);*/
}
/**
......@@ -179,12 +179,21 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
JSONObject obj = contentJson.getJSONObject("obj");
for(String key : obj.keySet()){
JSONArray valueArr = obj.getJSONObject(key).getJSONArray("valueArr2");
if(null != valueArr){
for(int i = 0; i < valueArr.size(); i++){
map.put(key+i,valueArr.get(i));
}
}
map.put("dangerNumber",contentJson.getString("dangerNumber"));
map.put("zgDay",contentJson.getString("zgDay"));
}
if(map.containsKey("qitawenti0")){
map.put("qitawentiText",obj.getJSONObject("qitawenti").getString("textarea"));
}else{
map.put("qitawenti0",false);
map.put("qitawentiText","");
}
String dangerNumber = contentJson.getString("dangerNumber");
map.put("dangerNumber","0".equals(dangerNumber) ? true : false);
//map.put("zgDay",contentJson.getString("zgDay"));
map.put("qmUrl",contentJson.getString("qmUrl"));
JSONObject userInfo = contentJson.getJSONObject("userInfo");
if(null != userInfo){
......@@ -198,22 +207,10 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
map.put("username",user.getUsername());
map.put("usernum",user.getUsernum());
map.put("phone",user.getPhone());
map.put("address",user.getAddress());
map.put("zaoNum",null != user.getDevice() && user.getDevice().contains("0100")? "1" : "0");
map.put("guaNum",null != user.getDevice() && user.getDevice().contains("0300")? "1" : "0");
map.put("reNum",null != user.getDevice() && user.getDevice().contains("0200")? "1" : "0");
map.put("meterType1",null != user.getMeterType() && 1 == user.getMeterType());
map.put("meterType2",null != user.getMeterType() && 2 == user.getMeterType());
map.put("meterCompany1",null != user.getMeterCompany() && 1 == user.getMeterCompany());
map.put("meterCompany2",null != user.getMeterCompany() && 2 == user.getMeterCompany());
map.put("meterModel1",null != user.getMeterModel() && 1 == user.getMeterModel());
map.put("meterModel2",null != user.getMeterModel() && 2 == user.getMeterModel());
map.put("meterModel3",null != user.getMeterModel() && 3 == user.getMeterModel());
map.put("direction1",null != user.getDirection() && 1 == user.getDirection());
map.put("direction2",null != user.getDirection() && 2 == user.getDirection());
map.put("villageName",user.getVillageName());
}
//安检单中获取
map.put("rectificationRequirements",inspectExport.getRemark());
//map.put("rectificationRequirements",inspectExport.getRemark());
map.put("inspector",inspectExport.getMemberName());
map.put("currentDate", new SimpleDateFormat("yyyy-MM-dd").format(inspectExport.getCreateTime()));
map.put("createTime", new SimpleDateFormat("yyyyMMddHHmmss").format(inspectExport.getCreateTime()));
......@@ -231,7 +228,7 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
list.add(map);
}
InspectExportUtil excelUtil = new InspectExportUtil();
excelUtil.exportExcel("resident.xlsx",list);
excelUtil.exportExcel("resident_new.xlsx",list);
List<TTaskInspectExport> logList = list.stream().filter(item -> item.containsKey("exportLog"))
.flatMap(map -> map.entrySet().stream())
.filter(entry -> "exportLog".equals(entry.getKey()))
......@@ -263,65 +260,38 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
JSONObject obj = contentJson.getJSONObject("obj");
for(String key : obj.keySet()){
JSONArray valueArr = obj.getJSONObject(key).getJSONArray("valueArr2");
if(null != valueArr){
for(int i = 0; i < valueArr.size(); i++){
map.put(key+i,(boolean)valueArr.get(i)?"\u2611":"\u2610");
}
}
}
if(map.containsKey("qitawenti0")){
map.put("qitawentiText",obj.getJSONObject("qitawenti").getString("textarea"));
}else{
map.put("qitawenti0","\u2610");
map.put("qitawentiText","");
}
if(StringUtils.isNotEmpty(contentJson.getString("qmUrl"))){
//Image image = ImgUtil.rotate(ImageIO.read(new URL(contentJson.getString("qmUrl"))), -90);
byte[] bytes = ImgUtil.toBytes(InspectExportUtil.rotateImage(contentJson.getString("qmUrl"),-90),"png");
ImageEntity imageEntity = new ImageEntity(bytes,100,40);
map.put("qmUrl",imageEntity);
}
map.put("dangerNumber",contentJson.getString("dangerNumber"));
map.put("zgDay",contentJson.getString("zgDay"));
JSONObject userInfo = contentJson.getJSONObject("userInfo");
if(null != userInfo){
for(String userKey : userInfo.keySet()){
map.put(userKey,userInfo.getString(userKey));
}
}
//user中获取
TBusiness businessInfo = tBusinessMapper.selectTBusinessById(businessInspectList.get(finalIndex).getReceiveId());
if(null != businessInfo){
map.put("company",businessInfo.getCompany());
map.put("contract",businessInfo.getContract());
map.put("address",businessInfo.getAddress());
map.put("usernum",businessInfo.getUsernum());
map.put("username",businessInfo.getUsername());
map.put("phone",businessInfo.getPhone());
map.put("meterType1",null != businessInfo.getMeterType() && 1 == businessInfo.getMeterType()?"\u2611":"\u2610");
map.put("meterType2",null != businessInfo.getMeterType() && 2 == businessInfo.getMeterType()?"\u2611":"\u2610");
map.put("meterModel1",null != businessInfo.getMeterModel() && 1==businessInfo.getMeterModel()?"\u2611":"\u2610");
map.put("meterModel2",null != businessInfo.getMeterModel() && 2==businessInfo.getMeterModel()?"\u2611":"\u2610");
map.put("meterModel3",null != businessInfo.getMeterModel() && 3==businessInfo.getMeterModel()?"\u2611":"\u2610");
map.put("meterCompany1",null != businessInfo.getMeterCompany() && 1==businessInfo.getMeterCompany()?"\u2611":"\u2610");
map.put("meterCompany2",null != businessInfo.getMeterCompany() && 2==businessInfo.getMeterCompany()?"\u2611":"\u2610");
map.put("direction1",null != businessInfo.getDirection() && 1==businessInfo.getDirection()?"\u2611":"\u2610");
map.put("direction2",null != businessInfo.getDirection() && 1==businessInfo.getDirection()?"\u2611":"\u2610");
String device = businessInfo.getDevice();
if(StringUtils.isNotEmpty(device)){
JSONObject deviceObj = JSON.parseObject(device);
map.put("bothEyes",deviceObj.getString("bothEyes"));
map.put("singleEyes",deviceObj.getString("singleEyes"));
map.put("manyEyes",deviceObj.getString("manyEyes"));
map.put("cauldron",deviceObj.getString("cauldron"));
map.put("civil",deviceObj.getString("civil"));
map.put("barbecue",deviceObj.getString("barbecue"));
map.put("lowSoup",deviceObj.getString("lowSoup"));
map.put("clayPot",deviceObj.getString("clayPot"));
map.put("dwarf",deviceObj.getString("dwarf"));
map.put("oven",deviceObj.getString("oven"));
map.put("steamer",deviceObj.getString("steamer"));
map.put("barrel",deviceObj.getString("barrel"));
map.put("wall",deviceObj.getString("wall"));
}
}
//安检单中取
map.put("qitawentiText",obj.getJSONObject("qitawenti").getString("textarea"));
map.put("yijian",contentJson.getString("yijian"));
map.put("inspector",businessInspectList.get(finalIndex).getMemberName());
map.put("currentDate", new SimpleDateFormat("yyyy-MM-dd").format(businessInspectList.get(finalIndex).getCreateTime()));
map.put("currentDate", new SimpleDateFormat("yyyy年MM月dd日").format(businessInspectList.get(finalIndex).getCreateTime()));
map.put("createTime", new SimpleDateFormat("yyyyMMddHHmmss").format(businessInspectList.get(finalIndex).getCreateTime()));
//日志类组装
TTaskInspectExport exportLog = new TTaskInspectExport();
......@@ -349,7 +319,7 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
}
InspectExportUtil excelUtil = new InspectExportUtil();
excelUtil.exportEasyWord("business-easy.docx",mapList);
excelUtil.exportEasyWord("business_new.docx",mapList);
List<TTaskInspectExport> logList = mapList.stream().filter(item -> item.containsKey("exportLog"))
.flatMap(map -> map.entrySet().stream())
.filter(entry -> "exportLog".equals(entry.getKey()))
......@@ -373,50 +343,78 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
*/
private void industryQuarterExport(List<TTaskInspect> industryQuarterInspectList){
if (CollectionUtils.isEmpty(industryQuarterInspectList)) return;
try{
List<Map<String,Object>> list = new ArrayList<>();
for(TTaskInspect inspectExport : industryQuarterInspectList){
List<Map<String,Object>> mapList = new Vector<>();
Future<?>[] futures = new Future[industryQuarterInspectList.size()];
for(int index = 0; index < industryQuarterInspectList.size(); index++){
int finalIndex = index;
futures[index] = threadPoolTaskExecutor.submit(()->{
try {
Map<String,Object> map = new HashMap<>();
JSONObject contentJson = (JSONObject) JSON.parse(inspectExport.getContent());
JSONObject contentJson = (JSONObject) JSON.parse(industryQuarterInspectList.get(finalIndex).getContent());
JSONObject obj = contentJson.getJSONObject("obj");
for(String key : obj.keySet()){
JSONArray valueArr = obj.getJSONObject(key).getJSONArray("valueArr2");
if(null != valueArr){
for(int i = 0; i < valueArr.size(); i++){
map.put(key+i,valueArr.get(i));
map.put(key+i,(boolean)valueArr.get(i)?"\u2611":"\u2610");
}
}
map.put("dangerNumber",contentJson.getString("dangerNumber"));
map.put("qmUrl",contentJson.getString("qmUrl"));
if(!map.containsKey("famanz0")){
map.put("famenz0",true);
map.put("famenz1",false);
}
if(map.containsKey("qitawenti0")){
map.put("qitawentiText",obj.getJSONObject("qitawenti").getString("textarea"));
}else{
map.put("qitawenti0","\u2610");
map.put("qitawentiText","");
}
if(StringUtils.isNotEmpty(contentJson.getString("qmUrl"))){
//Image image = ImgUtil.rotate(ImageIO.read(new URL(contentJson.getString("qmUrl"))), -90);
byte[] bytes = ImgUtil.toBytes(InspectExportUtil.rotateImage(contentJson.getString("qmUrl"),-90),"png");
ImageEntity imageEntity = new ImageEntity(bytes,100,40);
map.put("qmUrl",imageEntity);
}
//user中获取
TIndustry user = tIndustryMapper.selectTIndustryById(inspectExport.getReceiveId());
TIndustry user = tIndustryMapper.selectTIndustryById(industryQuarterInspectList.get(finalIndex).getReceiveId());
if(null != user){
map.put("username",user.getCompany());
map.put("company",user.getCompany());
}
//安检单中获取
map.put("remarks",inspectExport.getRemark());
map.put("inspector",inspectExport.getMemberName());
map.put("currentDate", new SimpleDateFormat("yyyy-MM-dd").format(inspectExport.getCreateTime()));
map.put("createTime", new SimpleDateFormat("yyyyMMddHHmmss").format(inspectExport.getCreateTime()));
//安检单中取
map.put("qitawentiText",obj.getJSONObject("qitawenti").getString("textarea"));
map.put("yijian",contentJson.getString("yijian"));
map.put("inspector",industryQuarterInspectList.get(finalIndex).getMemberName());
map.put("currentDate", new SimpleDateFormat("yyyy年MM月dd日").format(industryQuarterInspectList.get(finalIndex).getCreateTime()));
map.put("createTime", new SimpleDateFormat("yyyyMMddHHmmss").format(industryQuarterInspectList.get(finalIndex).getCreateTime()));
//日志类组装
TTaskInspectExport exportLog = new TTaskInspectExport();
exportLog.setTaskId(inspectExport.getTaskId());
exportLog.setInspectId(inspectExport.getId());
exportLog.setInspectTime(inspectExport.getCreateTime());
exportLog.setReceiveId(inspectExport.getReceiveId());
exportLog.setMemberId(inspectExport.getMemberId());
exportLog.setType(inspectExport.getType());
exportLog.setTaskId(industryQuarterInspectList.get(finalIndex).getTaskId());
exportLog.setInspectId(industryQuarterInspectList.get(finalIndex).getId());
exportLog.setInspectTime(industryQuarterInspectList.get(finalIndex).getCreateTime());
exportLog.setReceiveId(industryQuarterInspectList.get(finalIndex).getReceiveId());
exportLog.setMemberId(industryQuarterInspectList.get(finalIndex).getMemberId());
exportLog.setType(industryQuarterInspectList.get(finalIndex).getType());
exportLog.setCreateTime(new Date());
exportLog.setFileName((String) map.get("username") + map.get("createTime") + "安检单.xlsx");
exportLog.setFileName((String) map.get("company") + map.get("createTime") + "安检单.docx");
map.put("exportLog",exportLog);
list.add(map);
mapList.add(map);
} catch (Exception e) {
logger.error("工业参数组装失败:" + e);
}
});
}
// 等待所有任务完成
for (Future<?> future : futures) {
// 这将阻塞直到每个Future表示的任务完成。
future.get();
}
InspectExportUtil excelUtil = new InspectExportUtil();
excelUtil.exportExcel("quarter.xlsx",list);
List<TTaskInspectExport> logList = list.stream().filter(item -> item.containsKey("exportLog"))
excelUtil.exportEasyWord("quarter_new.docx",mapList);
List<TTaskInspectExport> logList = mapList.stream().filter(item -> item.containsKey("exportLog"))
.flatMap(map -> map.entrySet().stream())
.filter(entry -> "exportLog".equals(entry.getKey()))
.map(map ->{
......@@ -424,8 +422,9 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
})
.collect(Collectors.toList());
if(!CollectionUtils.isEmpty(logList)) tTaskInspectExportMapper.batchInsertInspectExport(logList);
}catch (Exception e){
logger.error("工业季度安检导出错误:" + e.getMessage());
logger.error("工业安检导出错误:" + e.getMessage());
}
}
......
......@@ -220,14 +220,14 @@
:loading="exportLoading"
@click="handlejmInspectExport"
>导出</el-button>
<!--<el-button
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
:loading="batchExportLoading"
@click="handleBatchInspectExport"
>安检单导出</el-button>-->
>安检单导出</el-button>
</el-col>
</el-row>
......
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