修改
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user