add:粉料计划添加3个导出功能
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
package org.nl.modules.system.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MapOf implements Serializable {
|
||||||
|
|
||||||
|
public static <K> LinkedHashMap of(K... key){
|
||||||
|
LinkedHashMap map = new LinkedHashMap();
|
||||||
|
for (int i = 0; i < (key.length & ~1); i=i+2) {
|
||||||
|
map.put(key[i],key[i+1]);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
public static JSONObject ofJ(String... key){
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
for (int i = 0; i < (key.length & ~1); i=i+2) {
|
||||||
|
map.put((String)key[i],key[i+1]);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,6 +123,12 @@ public class StatisticalReportController {
|
|||||||
statisticalReportService.download(response, whereJson);
|
statisticalReportService.download(response, whereJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出数据2")
|
||||||
|
@GetMapping(value = "/download2/{type}")
|
||||||
|
public void download2(HttpServletResponse response, @RequestParam Map whereJson,@PathVariable("type") String type){
|
||||||
|
statisticalReportService.download2(response, whereJson,type);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/bucketQuery")
|
@GetMapping("/bucketQuery")
|
||||||
@Log("线下桶记录查询")
|
@Log("线下桶记录查询")
|
||||||
@ApiOperation("线下桶记录查询")
|
@ApiOperation("线下桶记录查询")
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public interface StatisticalReportService {
|
|||||||
* @param whereJson
|
* @param whereJson
|
||||||
*/
|
*/
|
||||||
void download(HttpServletResponse response,Map whereJson);
|
void download(HttpServletResponse response,Map whereJson);
|
||||||
|
void download2(HttpServletResponse response,Map whereJson,String type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.nl.modules.system.repository.DeptRepository;
|
|||||||
import org.nl.modules.system.service.DeptService;
|
import org.nl.modules.system.service.DeptService;
|
||||||
import org.nl.modules.system.service.UserService;
|
import org.nl.modules.system.service.UserService;
|
||||||
import org.nl.modules.system.service.dto.UserDto;
|
import org.nl.modules.system.service.dto.UserDto;
|
||||||
|
import org.nl.modules.system.util.MapOf;
|
||||||
import org.nl.pda.exception.PdaRequestException;
|
import org.nl.pda.exception.PdaRequestException;
|
||||||
import org.nl.utils.FileUtil;
|
import org.nl.utils.FileUtil;
|
||||||
import org.nl.utils.SecurityUtils;
|
import org.nl.utils.SecurityUtils;
|
||||||
@@ -29,11 +30,20 @@ import org.springframework.data.domain.PageRequest;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.ToDoubleFunction;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -340,7 +350,7 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
|
|||||||
// JSONObject num_jo = null;
|
// JSONObject num_jo = null;
|
||||||
|
|
||||||
|
|
||||||
JSONObject num_jo = WQL.getWO("QL_ERP").addParamMap(map).setDbname("dataSource1").process().uniqueResult(0);
|
JSONObject num_jo = null;
|
||||||
|
|
||||||
|
|
||||||
//合同在途
|
//合同在途
|
||||||
@@ -654,6 +664,91 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
|
public void download2(HttpServletResponse response, Map whereJson,String type) {
|
||||||
|
if (type ==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, String> headers = new LinkedHashMap<>();
|
||||||
|
List<Map<String, Object>> excelData = new ArrayList<>();
|
||||||
|
JSONArray list = handleData(headers,type,whereJson);
|
||||||
|
if (!CollectionUtils.isEmpty(list)){
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
Map<String, Object> dtl_map = new LinkedHashMap<>();
|
||||||
|
dtl_map.put("序号",i+1==list.size()?"合计":i+1);
|
||||||
|
JSONObject row = list.getJSONObject(i);
|
||||||
|
for (String item : headers.keySet()) {
|
||||||
|
String header = headers.get(item);
|
||||||
|
dtl_map.put(header, row.getString(item));
|
||||||
|
}
|
||||||
|
excelData.add(dtl_map);
|
||||||
|
}
|
||||||
|
FileUtil.downloadExcel(excelData, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
private JSONArray handleData(Map<String, String> headers, String type, Map whereJson){
|
||||||
|
JSONArray list = null;
|
||||||
|
switch (type){
|
||||||
|
case "1":
|
||||||
|
list = query1(whereJson);
|
||||||
|
list.forEach(o -> {
|
||||||
|
JSONObject item = (JSONObject) o;
|
||||||
|
String halfUp = new BigDecimal(item.getDoubleValue("qty")).setScale(3, RoundingMode.HALF_UP).toString();
|
||||||
|
item.put("qty",halfUp);
|
||||||
|
});
|
||||||
|
headers.putAll(MapOf.of("material_code", "物料编码","material_name","物料名称","pcsn","批次","qty","可用重量"));
|
||||||
|
double qty = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("qty")).sum();
|
||||||
|
String halfUp = new BigDecimal(qty).setScale(3, RoundingMode.HALF_UP).toString();
|
||||||
|
list.add(MapOf.ofJ("material_code", " ","material_name"," ","pcsn"," ","qty",halfUp));
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
list = query2(whereJson);
|
||||||
|
list.forEach(o -> {
|
||||||
|
JSONObject item = (JSONObject) o;
|
||||||
|
String rHalfUp = new BigDecimal(item.getDoubleValue("receive_qty")).setScale(2, RoundingMode.HALF_UP).toString();
|
||||||
|
String nHalfUp = new BigDecimal(item.getDoubleValue("noin_qty")).setScale(2, RoundingMode.HALF_UP).toString();
|
||||||
|
item.put("receive_qty",rHalfUp);
|
||||||
|
item.put("noin_qty",nHalfUp);
|
||||||
|
});
|
||||||
|
headers.putAll(MapOf.of("receive_code", "到货单号","material_code","物料编码", "material_name","物料名称","pcsn","批次","receive_qty","订单重量","noin_qty","剩余重量","source_name","供应商"));
|
||||||
|
double receiveQty = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("receive_qty")).sum();
|
||||||
|
double noinQty = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("noin_qty")).sum();
|
||||||
|
String rHalfUp = new BigDecimal(receiveQty).setScale(3, RoundingMode.HALF_UP).toString();
|
||||||
|
String nHalfUp = new BigDecimal(noinQty).setScale(3, RoundingMode.HALF_UP).toString();
|
||||||
|
list.add(MapOf.ofJ("receive_code", " ","material_code"," ", "material_name"," ","pcsn"," ","receive_qty",rHalfUp,"noin_qty",nHalfUp ,"source_name"," "));
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
headers.putAll(MapOf.of("receive_code", "合同号","material_code","物料编码","material_name","物料名称","sumqty","合同重量","notqty","在途重量","norigtaxprice","含税单价","norigtaxmny","金额","name","供应商"));
|
||||||
|
list = query3(whereJson);
|
||||||
|
// byte[] bytes = Files.readAllBytes(Paths.get("/Users/mima0000/Desktop/data.txt"));
|
||||||
|
// String s = new String(bytes);
|
||||||
|
// list = JSONArray.parseArray(s);
|
||||||
|
list.forEach(o -> {
|
||||||
|
JSONObject item = (JSONObject) o;
|
||||||
|
String sumqty = new BigDecimal(item.getDoubleValue("sumqty")).setScale(2, RoundingMode.HALF_UP).toString();
|
||||||
|
String notqty = new BigDecimal(item.getDoubleValue("notqty")).setScale(2, RoundingMode.HALF_UP).toString();
|
||||||
|
String norigtaxprice = new BigDecimal(item.getDoubleValue("norigtaxprice")).setScale(2, RoundingMode.HALF_UP).toString();
|
||||||
|
String norigtaxmny = new BigDecimal(item.getDoubleValue("norigtaxmny")).setScale(2, RoundingMode.HALF_UP).toString();
|
||||||
|
item.put("sumqty",sumqty);
|
||||||
|
item.put("notqty",notqty);
|
||||||
|
item.put("norigtaxprice",norigtaxprice);
|
||||||
|
item.put("norigtaxmny",norigtaxmny);
|
||||||
|
});
|
||||||
|
double sumqtyD = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("sumqty")).sum();
|
||||||
|
double notqtyD = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("notqty")).sum();
|
||||||
|
double norigtaxmnyD = list.stream().mapToDouble(o -> ((JSONObject) o).getDouble("norigtaxmny")).sum();
|
||||||
|
String sumqtySum = new BigDecimal(sumqtyD).setScale(2, RoundingMode.HALF_UP).toString();
|
||||||
|
String notqtySum = new BigDecimal(notqtyD).setScale(2, RoundingMode.HALF_UP).toString();
|
||||||
|
String norigtaxmnySum = new BigDecimal(norigtaxmnyD).setScale(2, RoundingMode.HALF_UP).toString();
|
||||||
|
list.add(MapOf.ofJ("receive_code", " ","material_code"," ","material_name"," ","sumqty",sumqtySum,"notqty",notqtySum,"norigtaxprice"," ","norigtaxmny",norigtaxmnySum,"name"," "));
|
||||||
|
break;
|
||||||
|
default: ;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> bucketQuery(Map whereJson, Pageable page) {
|
public Map<String, Object> bucketQuery(Map whereJson, Pageable page) {
|
||||||
// 仓位属性表【ST_IVT_StructAttr】
|
// 仓位属性表【ST_IVT_StructAttr】
|
||||||
|
|||||||
@@ -35,6 +35,15 @@
|
|||||||
<slot name="left" />
|
<slot name="left" />
|
||||||
<el-button slot="left" type="success" @click="MyQuery2">查询</el-button>
|
<el-button slot="left" type="success" @click="MyQuery2">查询</el-button>
|
||||||
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
|
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
|
||||||
|
<el-button
|
||||||
|
slot="right"
|
||||||
|
class="filter-item"
|
||||||
|
type="success"
|
||||||
|
size="mini"
|
||||||
|
@click="downExcel"
|
||||||
|
>
|
||||||
|
导出Excel
|
||||||
|
</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -64,12 +73,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { header } from '@crud/crud'
|
|
||||||
import report from '@/api/wms/statistics/report'
|
import report from '@/api/wms/statistics/report'
|
||||||
|
import { presenter, header, crud } from '@crud/crud'
|
||||||
|
import { download } from '@/api/data'
|
||||||
|
import { downloadFile } from '@/utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'StructIvt4',
|
name: 'StructIvt4',
|
||||||
mixins: [header()],
|
mixins: [presenter(), header(), crud()],
|
||||||
props: {
|
props: {
|
||||||
dialogShow: {
|
dialogShow: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -81,6 +92,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
currentRow: {},
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
tableDtl: [],
|
tableDtl: [],
|
||||||
cxjList: [],
|
cxjList: [],
|
||||||
@@ -104,6 +116,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
downExcel() {
|
||||||
|
if (this.currentRow !== null) {
|
||||||
|
crud.downloadLoading = true
|
||||||
|
download('/api/statistical/download2/2', this.queryrow).then(result => {
|
||||||
|
downloadFile(result, '待检入库量', 'xlsx')
|
||||||
|
crud.downloadLoading = false
|
||||||
|
}).catch(() => {
|
||||||
|
crud.downloadLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
open() {
|
open() {
|
||||||
report.query4().then(res => {
|
report.query4().then(res => {
|
||||||
this.XLList = res
|
this.XLList = res
|
||||||
|
|||||||
@@ -35,6 +35,15 @@
|
|||||||
<slot name="left" />
|
<slot name="left" />
|
||||||
<el-button slot="left" type="success" @click="MyQuery2">查询</el-button>
|
<el-button slot="left" type="success" @click="MyQuery2">查询</el-button>
|
||||||
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
|
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
|
||||||
|
<el-button
|
||||||
|
slot="right"
|
||||||
|
class="filter-item"
|
||||||
|
type="success"
|
||||||
|
size="mini"
|
||||||
|
@click="downExcel"
|
||||||
|
>
|
||||||
|
导出Excel
|
||||||
|
</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -65,12 +74,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { header } from '@crud/crud'
|
|
||||||
import report from '@/api/wms/statistics/report'
|
import report from '@/api/wms/statistics/report'
|
||||||
|
import { presenter, header, crud } from '@crud/crud'
|
||||||
|
import { download } from '@/api/data'
|
||||||
|
import { downloadFile } from '@/utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'StructIvt3',
|
name: 'StructIvt3',
|
||||||
mixins: [header()],
|
mixins: [presenter(), header(), crud()],
|
||||||
props: {
|
props: {
|
||||||
dialogShow: {
|
dialogShow: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -82,6 +93,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
currentRow: {},
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
tableDtl: [],
|
tableDtl: [],
|
||||||
cxjList: [],
|
cxjList: [],
|
||||||
@@ -105,6 +117,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
downExcel() {
|
||||||
|
if (this.currentRow !== null) {
|
||||||
|
crud.downloadLoading = true
|
||||||
|
download('/api/statistical/download2/3', this.queryrow).then(result => {
|
||||||
|
downloadFile(result, '合同在途', 'xlsx')
|
||||||
|
crud.downloadLoading = false
|
||||||
|
}).catch(() => {
|
||||||
|
crud.downloadLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
open() {
|
open() {
|
||||||
report.query4().then(res => {
|
report.query4().then(res => {
|
||||||
this.XLList = res
|
this.XLList = res
|
||||||
|
|||||||
@@ -35,6 +35,15 @@
|
|||||||
<slot name="left" />
|
<slot name="left" />
|
||||||
<el-button slot="left" type="success" @click="MyQuery2">查询</el-button>
|
<el-button slot="left" type="success" @click="MyQuery2">查询</el-button>
|
||||||
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
|
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
|
||||||
|
<el-button
|
||||||
|
slot="right"
|
||||||
|
class="filter-item"
|
||||||
|
type="success"
|
||||||
|
size="mini"
|
||||||
|
@click="downExcel"
|
||||||
|
>
|
||||||
|
导出Excel
|
||||||
|
</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -61,12 +70,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { header } from '@crud/crud'
|
|
||||||
import report from '@/api/wms/statistics/report'
|
import report from '@/api/wms/statistics/report'
|
||||||
|
import { presenter, header, crud } from '@crud/crud'
|
||||||
|
import { download } from '@/api/data'
|
||||||
|
import { downloadFile } from '@/utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'StructIvt4',
|
name: 'StructIvt4',
|
||||||
mixins: [header()],
|
mixins: [presenter(), header(), crud()],
|
||||||
props: {
|
props: {
|
||||||
dialogShow: {
|
dialogShow: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -78,6 +89,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
currentRow: {},
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
tableDtl: [],
|
tableDtl: [],
|
||||||
XLList: [],
|
XLList: [],
|
||||||
@@ -99,6 +111,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
downExcel() {
|
||||||
|
if (this.currentRow !== null) {
|
||||||
|
crud.downloadLoading = true
|
||||||
|
download('/api/statistical/download2/1', this.queryrow).then(result => {
|
||||||
|
downloadFile(result, '库存现存量', 'xlsx')
|
||||||
|
crud.downloadLoading = false
|
||||||
|
}).catch(() => {
|
||||||
|
crud.downloadLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
open() {
|
open() {
|
||||||
report.query4().then(res => {
|
report.query4().then(res => {
|
||||||
this.XLList = res
|
this.XLList = res
|
||||||
|
|||||||
Reference in New Issue
Block a user