add:增加二楼分切任务数据导出功能
This commit is contained in:
@@ -8,10 +8,7 @@ import org.nl.modules.logging.annotation.Log;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -250,12 +251,13 @@ public class PdmBiSubpackagerelationController {
|
||||
autoSendVehicleToDjq.getPointCode(task,PackageInfoIvtEnum.TASK_TYPE.code("补空(装箱区->待检区)"));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/ycgzd2")
|
||||
@Log("异常管制点释放")
|
||||
@PostMapping("/downloadData")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> ycgzd2(@RequestBody JSONObject param) {
|
||||
twoOutBoxTask.immediateNotifyAcs(null);
|
||||
return null;
|
||||
public void downloadData(Integer day, HttpServletResponse response) {
|
||||
RedissonUtils.lock(a->{
|
||||
pdmBiSubpackagerelationService.downloadData(3,(HttpServletResponse)a);
|
||||
return null;
|
||||
},"下载任务时间",response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.nl.b_lms.pdm.subpackagerelation.dao.PdmBiSubpackagerelation;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.b_lms.pdm.subpackagerelation.dto.PdmBiSubpackagerelationDto;
|
||||
@@ -36,4 +37,7 @@ public interface PdmBiSubpackagerelationMapper extends BaseMapper<PdmBiSubpackag
|
||||
|
||||
List<JSONObject> recordQuery(List<String> pcns);
|
||||
|
||||
@Select("select resource_name as 下卷设备,sch_base_task.update_time as 下卷结束,sch_base_task.create_time as 下卷开始 from sch_base_task left JOIN pdm_bi_slittingproductionplan on pdm_bi_slittingproductionplan.qzzno = vehicle_code and pdm_bi_slittingproductionplan.container_name is not null where create_time > #{day} and task_status = '07' and vehicle_code != '' and vehicle_code is not NULL and point_code2 IN ('TZZC30','TZZC31','TZZC32','TZZC33','TZZC34','TZZC35','TZZC36','TZZC37','TZZC38')\n")
|
||||
List<Map<String,String>> downloadData(@Param("day") String date);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.nl.b_lms.pdm.subpackagerelation.dto.PdmBiSubpackagerelationDto;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -134,6 +135,12 @@ public interface IpdmBiSubpackagerelationService extends IService<PdmBiSubpackag
|
||||
|
||||
List<JSONObject> recordQuery(List<String> pcsn);
|
||||
|
||||
/**
|
||||
* 导出任务相关数据
|
||||
* @param day
|
||||
*/
|
||||
void downloadData(Integer day, HttpServletResponse response);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package org.nl.b_lms.pdm.subpackagerelation.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.PageResult;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -15,6 +17,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.Data;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.log4j.Log4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@@ -53,6 +56,11 @@ import org.nl.common.enums.SpecEnum;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.logging.service.EsLogService;
|
||||
import org.nl.modules.logging.service.dto.LogQuery;
|
||||
import org.nl.modules.logging.service.dto.LogRepositoryDTO;
|
||||
import org.nl.modules.logging.service.impl.LuceneLogServiceImpl;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
@@ -72,6 +80,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -133,6 +142,9 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
@Qualifier("threadPoolExecutor")
|
||||
private ThreadPoolExecutor pool;
|
||||
|
||||
@Autowired
|
||||
private EsLogService luceneLogService;
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
@@ -847,5 +859,74 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
acsParam.put("product_area","BLK");
|
||||
AcsUtil.notifyAcsObject("api/wms/returnBox", acsParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadData(Integer day, HttpServletResponse response) {
|
||||
if (day>3){
|
||||
throw new BadRequestException("只能导出前三天数据");
|
||||
}
|
||||
Date time = DateUtil.offsetDay(new Date(), -day);
|
||||
LogQuery query = new LogQuery();
|
||||
query.setMessage("forcedFeedShaft_");
|
||||
query.setPage(1);
|
||||
query.setSize(1000);
|
||||
query.setStartTime(time);
|
||||
query.setFilterSql(true);
|
||||
query.setIsRequest(true);
|
||||
JSONObject logPage = luceneLogService.query(query);
|
||||
//forcedFeedShaft
|
||||
int total = logPage.getIntValue("total");
|
||||
List<Map<String,String>> log = new ArrayList<>();
|
||||
if (total>0){
|
||||
PageResult<LogRepositoryDTO> page = (PageResult)logPage.get("page");
|
||||
for (LogRepositoryDTO dto : page) {
|
||||
String message = dto.getMessage();
|
||||
if (!StringUtils.isEmpty(message)){
|
||||
String requestTime = dto.getRequestTime();
|
||||
int start = message.indexOf("{");
|
||||
int end = message.lastIndexOf("}");
|
||||
if (start>0 && end>start){
|
||||
String substring = message.substring(start, end + 1);
|
||||
JSONObject object = JSONObject.parseObject(substring);
|
||||
String deviceCode = object.getString("device_code");
|
||||
log.add(MapOf.of("呼叫时间",requestTime,"设备",deviceCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Map<String,String>> databases = this.baseMapper.downloadData(time.toString());
|
||||
List<Map<String, String>> ioData = new ArrayList<>();
|
||||
int max = Math.max(databases.size(), log.size());
|
||||
for (int i = 0; i < max; i++) {
|
||||
Map<String, String> item = new HashMap<>();
|
||||
if (databases.size()>i){
|
||||
Map<String, String> item1 = databases.get(i);
|
||||
item.putAll(item1);
|
||||
}else {
|
||||
item.put("下卷设备","");
|
||||
item.put("下卷开始","");
|
||||
item.put("下卷结束","");
|
||||
}
|
||||
if (log.size()>i){
|
||||
Map<String, String> item2 = log.get(i);
|
||||
item.putAll(item2);
|
||||
}else {
|
||||
item.put("设备","");
|
||||
item.put("呼叫时间","");
|
||||
}
|
||||
item.put("分割","");
|
||||
if (item.keySet().size()==6){
|
||||
ioData.add(item);
|
||||
}
|
||||
}
|
||||
String[] strings = new String[6];
|
||||
strings[0] = "下卷设备";
|
||||
strings[1] ="下卷开始";
|
||||
strings[2] ="下卷结束";
|
||||
strings[3] = "分割";
|
||||
strings[4] = "设备";
|
||||
strings[5] = "呼叫时间";
|
||||
new FileUtil().downloadExcelIO(ioData,strings,response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,5 +22,12 @@ export function clearLogs(param) {
|
||||
data: param
|
||||
})
|
||||
}
|
||||
export function downloadData(param) {
|
||||
return request({
|
||||
url: '/api/pdmBiSubpackagerelation/downloadData',
|
||||
method: 'post',
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
export default { getLogData, labelsValues, clearLogs }
|
||||
export default { getLogData, labelsValues, clearLogs, downloadData }
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="clearLogs">清空日志</el-button>
|
||||
<el-button @click="downloadData">导出分切数据</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
@@ -195,6 +196,7 @@
|
||||
<script>
|
||||
|
||||
import logOperation from '@/views/loki/api/loki'
|
||||
import { downloadFile } from '@/utils'
|
||||
|
||||
let queryParam = {
|
||||
logLevel: null,
|
||||
@@ -392,6 +394,12 @@ export default {
|
||||
},
|
||||
changetype() {
|
||||
|
||||
},
|
||||
downloadData() {
|
||||
logOperation.downloadData().then(result => {
|
||||
debugger
|
||||
downloadFile(result, '导出数据', 'xlsx')
|
||||
});
|
||||
},
|
||||
clearParam() {
|
||||
queryParam = {
|
||||
|
||||
Reference in New Issue
Block a user