修改
This commit is contained in:
@@ -16,6 +16,8 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -65,6 +67,14 @@ public class PointController {
|
||||
pointService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void download(@RequestParam Map map, HttpServletResponse response) throws IOException {
|
||||
pointService.download(map, response);
|
||||
}
|
||||
|
||||
@PutMapping("/changeActive")
|
||||
@Log("修改点位启用状态")
|
||||
@ApiOperation("修改点位启用状态")
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.sch.service.dto.PointDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -101,4 +103,6 @@ public interface PointService {
|
||||
* 仓位同步
|
||||
*/
|
||||
void sync();
|
||||
|
||||
void download(Map map, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
@@ -23,9 +24,9 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
@@ -65,7 +66,7 @@ public class PointServiceImpl implements PointService {
|
||||
if (!ObjectUtil.isEmpty(point_status)) {
|
||||
JSONObject statusArr = new JSONObject();
|
||||
String[] split = point_status_explain.split(",");
|
||||
for ( int j = 0; j < split.length; j++) {
|
||||
for (int j = 0; j < split.length; j++) {
|
||||
String[] status = split[j].split("-");
|
||||
statusArr.put(status[0], status[1]);
|
||||
}
|
||||
@@ -75,7 +76,7 @@ public class PointServiceImpl implements PointService {
|
||||
if (!ObjectUtil.isEmpty(point_type)) {
|
||||
JSONObject typeArr = new JSONObject();
|
||||
String[] split = point_type_explain.split(",");
|
||||
for ( int j = 0; j < split.length; j++) {
|
||||
for (int j = 0; j < split.length; j++) {
|
||||
String[] types = split[j].split("-");
|
||||
typeArr.put(types[0], types[1]);
|
||||
}
|
||||
@@ -165,7 +166,7 @@ public class PointServiceImpl implements PointService {
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
Long region_id = dto.getRegion_id();
|
||||
JSONObject region = WQLObject.getWQLObject("sch_base_region").query("region_id = '"+region_id+"'").uniqueResult(0);
|
||||
JSONObject region = WQLObject.getWQLObject("sch_base_region").query("region_id = '" + region_id + "'").uniqueResult(0);
|
||||
dto.setRegion_code(region.getString("region_code"));
|
||||
dto.setRegion_name(region.getString("region_name"));
|
||||
|
||||
@@ -280,7 +281,7 @@ public class PointServiceImpl implements PointService {
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_Point");
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
String used = jsonObject.getString("used");
|
||||
for ( int i = 0; i < data.size(); i++ ) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject object = data.getJSONObject(i);
|
||||
if (used.equals("1")) object.put("is_used", 1);
|
||||
else object.put("is_used", 0);
|
||||
@@ -298,7 +299,7 @@ public class PointServiceImpl implements PointService {
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_Point");
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
String lock = jsonObject.getString("lock_type");
|
||||
for ( int i = 0; i < data.size(); i++ ) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject object = data.getJSONObject(i);
|
||||
if (lock.equals("1")) object.put("lock_type", 1);
|
||||
else object.put("lock_type", 2);
|
||||
@@ -326,7 +327,7 @@ public class PointServiceImpl implements PointService {
|
||||
for (int i = 0; i < arrStruct.size(); i++) {
|
||||
JSONObject json = arrStruct.getJSONObject(i);
|
||||
JSONObject structMap = new JSONObject();
|
||||
structMap.put("point_id", IdUtil.getSnowflake(1,1).nextId());
|
||||
structMap.put("point_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
structMap.put("point_code", json.getString("struct_code"));
|
||||
structMap.put("point_name", json.getString("struct_name"));
|
||||
structMap.put("region_id", json.get("sect_id"));
|
||||
@@ -365,4 +366,71 @@ public class PointServiceImpl implements PointService {
|
||||
}
|
||||
return load_series;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(Map whereJson, HttpServletResponse response) throws IOException {
|
||||
HashMap map = new HashMap();
|
||||
map.put("flag", "1");
|
||||
map.put("region_id", whereJson.get("region_id"));
|
||||
map.put("ids", whereJson.get("ids"));
|
||||
map.put("lock_type", whereJson.get("lock_type"));
|
||||
map.put("point_status", whereJson.get("point_status"));
|
||||
map.put("is_used", whereJson.get("is_used"));
|
||||
map.put("point_type", whereJson.get("point_type"));
|
||||
map.put("name", whereJson.get("name"));
|
||||
JSONArray content = WQL.getWO("QSCH_BASE_POINT").addParamMap(map).process().getResultJSONArray(0);
|
||||
JSONArray res = new JSONArray();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (int i = 0; i < content.size(); i++) {
|
||||
JSONObject object = content.getJSONObject(i);
|
||||
Long region_id = object.getLong("region_id");
|
||||
String point_status = object.getString("point_status");
|
||||
String point_type = object.getString("point_type");
|
||||
RegionDto regionDto = regionService.findById(region_id);
|
||||
String point_status_explain = regionDto.getPoint_status_explain();
|
||||
String point_type_explain = regionDto.getPoint_type_explain();
|
||||
// 获取点位状态名称
|
||||
if (!ObjectUtil.isEmpty(point_status)) {
|
||||
JSONObject statusArr = new JSONObject();
|
||||
String[] split = point_status_explain.split(",");
|
||||
for (int j = 0; j < split.length; j++) {
|
||||
String[] status = split[j].split("-");
|
||||
statusArr.put(status[0], status[1]);
|
||||
}
|
||||
object.put("point_status_name", statusArr.getString(point_status));
|
||||
}
|
||||
// 获取点位类型
|
||||
if (!ObjectUtil.isEmpty(point_type)) {
|
||||
JSONObject typeArr = new JSONObject();
|
||||
String[] split = point_type_explain.split(",");
|
||||
for (int j = 0; j < split.length; j++) {
|
||||
String[] types = split[j].split("-");
|
||||
typeArr.put(types[0], types[1]);
|
||||
}
|
||||
object.put("point_type_name", typeArr.getString(point_type));
|
||||
}
|
||||
Map<String, Object> mp = new LinkedHashMap<>();
|
||||
mp.put("点位编码", object.getString("point_code"));
|
||||
mp.put("点位名称", object.getString("point_name"));
|
||||
mp.put("区域名称", object.getString("region_name"));
|
||||
mp.put("点位类型", object.getString("point_type_name"));
|
||||
mp.put("点位状态", object.getString("point_status_name"));
|
||||
mp.put("锁定类型", object.getString("lock_type_name"));
|
||||
mp.put("载具编码", object.getString("vehicle_code"));
|
||||
mp.put("物料批次", object.getString("material_code"));
|
||||
mp.put("载具数量", object.getString("vehicle_qty"));
|
||||
mp.put("生产区域", object.getString("product_area"));
|
||||
mp.put("备注", object.getString("remark"));
|
||||
if (object.getString("is_used").equals("0")) {
|
||||
mp.put("是否启用", "否");
|
||||
}
|
||||
if (object.getString("is_used").equals("1")) {
|
||||
mp.put("是否启用", "是");
|
||||
}
|
||||
mp.put("修改人", object.getString("update_optname"));
|
||||
mp.put("修改时间", object.getString("update_time"));
|
||||
list.add(mp);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +199,16 @@
|
||||
>
|
||||
仓位同步
|
||||
</el-button>-->
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="success"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
@click="downdtl"
|
||||
>
|
||||
导出Excel
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog
|
||||
@@ -353,6 +363,8 @@ import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import { download } from '@/api/data'
|
||||
import { downloadFile } from '@/utils'
|
||||
|
||||
const defaultForm = { point_id: null, point_code: null, point_name: null, point_type: null, point_status: null, lock_type: '1', vehicle_code: null, source_id: null, remark: null, is_used: null, is_delete: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null }
|
||||
export default {
|
||||
@@ -426,6 +438,18 @@ export default {
|
||||
this.getPointStatusAndTypeList(this.form.region_id, 2)
|
||||
}
|
||||
},
|
||||
downdtl() {
|
||||
if (this.currentRow !== null) {
|
||||
crud.downloadLoading = true
|
||||
download('/api/point/download', this.crud.query).then(result => {
|
||||
debugger
|
||||
downloadFile(result, '库存', 'xlsx')
|
||||
crud.downloadLoading = false
|
||||
}).catch(() => {
|
||||
crud.downloadLoading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
hand(value) {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
|
||||
@@ -75,4 +75,11 @@ export function sync() {
|
||||
})
|
||||
}
|
||||
|
||||
export function download() {
|
||||
return request({
|
||||
url: 'api/point/download',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, changeActive, findPoints, getPoint, getRegion, changeUsed, changeLock, sync }
|
||||
|
||||
Reference in New Issue
Block a user