|
@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSONObject; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.nl.modules.common.exception.BadRequestException; |
|
|
import org.nl.modules.common.exception.BadRequestException; |
|
|
|
|
|
import org.nl.modules.common.utils.FileUtil; |
|
|
import org.nl.modules.common.utils.SecurityUtils; |
|
|
import org.nl.modules.common.utils.SecurityUtils; |
|
|
import org.nl.modules.system.util.CodeUtil; |
|
|
import org.nl.modules.system.util.CodeUtil; |
|
|
import org.nl.modules.wql.WQL; |
|
|
import org.nl.modules.wql.WQL; |
|
@ -31,8 +32,13 @@ import org.springframework.http.HttpStatus; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
import static cn.hutool.db.sql.SqlExecutor.query; |
|
|
import static cn.hutool.db.sql.SqlExecutor.query; |
|
|
|
|
|
|
|
@ -57,8 +63,12 @@ public class WorkorderServiceImpl implements WorkordeService { |
|
|
String order_status = MapUtil.getStr(whereJson, "order_status"); |
|
|
String order_status = MapUtil.getStr(whereJson, "order_status"); |
|
|
JSONObject map = new JSONObject(); |
|
|
JSONObject map = new JSONObject(); |
|
|
map.put("flag", "1"); |
|
|
map.put("flag", "1"); |
|
|
map.put("begin_time", begin_time); |
|
|
if (StrUtil.isNotBlank(begin_time)) { |
|
|
map.put("end_time", end_time); |
|
|
map.put("begin_time", begin_time + " 00:00:00"); |
|
|
|
|
|
} |
|
|
|
|
|
if (StrUtil.isNotBlank(end_time)) { |
|
|
|
|
|
map.put("end_time", end_time + " 23:59:59"); |
|
|
|
|
|
} |
|
|
map.put("region_code", MapUtil.getStr(whereJson, "region_code")); |
|
|
map.put("region_code", MapUtil.getStr(whereJson, "region_code")); |
|
|
if (StrUtil.isNotEmpty(order_status)) { |
|
|
if (StrUtil.isNotEmpty(order_status)) { |
|
|
order_status = order_status.replace("[\"", "").replace("\"]", "").replace("\"", ""); |
|
|
order_status = order_status.replace("[\"", "").replace("\"]", "").replace("\"", ""); |
|
@ -448,8 +458,6 @@ public class WorkorderServiceImpl implements WorkordeService { |
|
|
String qualified_qty = row.getString("qualified_qty"); |
|
|
String qualified_qty = row.getString("qualified_qty"); |
|
|
if (StrUtil.isNotBlank(qualified_qty) && !"0".equals(qualified_qty)) { |
|
|
if (StrUtil.isNotBlank(qualified_qty) && !"0".equals(qualified_qty)) { |
|
|
workorder.put("qualified_qty", qualified_qty); |
|
|
workorder.put("qualified_qty", qualified_qty); |
|
|
} else { |
|
|
|
|
|
workorder.put("qualified_qty", workorder.getIntValue("real_qty") - workorder.getIntValue("unqualified_qty")); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
workorder.put("realproduceend_date", DateUtil.now()); |
|
|
workorder.put("realproduceend_date", DateUtil.now()); |
|
@ -493,4 +501,61 @@ public class WorkorderServiceImpl implements WorkordeService { |
|
|
public JSONArray getMaterial() { |
|
|
public JSONArray getMaterial() { |
|
|
return WQLObject.getWQLObject("md_me_materialbase").query().getResultJSONArray(0); |
|
|
return WQLObject.getWQLObject("md_me_materialbase").query().getResultJSONArray(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void downloadExcel(Map<String, Object> params, HttpServletResponse response) { |
|
|
|
|
|
String produceorder_code = MapUtil.getStr(params, "produceorder_code"); |
|
|
|
|
|
String material = MapUtil.getStr(params, "material"); |
|
|
|
|
|
String begin_time = MapUtil.getStr(params, "begin_time"); |
|
|
|
|
|
String end_time = MapUtil.getStr(params, "end_time"); |
|
|
|
|
|
String order_status = MapUtil.getStr(params, "order_status"); |
|
|
|
|
|
JSONObject map = new JSONObject(); |
|
|
|
|
|
map.put("flag", "7"); |
|
|
|
|
|
if (StrUtil.isNotBlank(begin_time)) { |
|
|
|
|
|
map.put("begin_time", begin_time + " 00:00:00"); |
|
|
|
|
|
} |
|
|
|
|
|
if (StrUtil.isNotBlank(end_time)) { |
|
|
|
|
|
map.put("end_time", end_time + " 23:59:59"); |
|
|
|
|
|
} |
|
|
|
|
|
map.put("region_code", MapUtil.getStr(params, "region_code")); |
|
|
|
|
|
if (StrUtil.isNotEmpty(order_status)) { |
|
|
|
|
|
order_status = order_status.replace("[\"", "").replace("\"]", "").replace("\"", ""); |
|
|
|
|
|
} |
|
|
|
|
|
map.put("order_status", order_status); |
|
|
|
|
|
//处理状态为未完成
|
|
|
|
|
|
if (StrUtil.isNotEmpty(order_status) && order_status.contains("-1")) { |
|
|
|
|
|
map.put("unFinish", "-1"); |
|
|
|
|
|
map.put("order_status", order_status.replace("-1", "")); |
|
|
|
|
|
} |
|
|
|
|
|
if (StrUtil.isNotEmpty(produceorder_code)) { |
|
|
|
|
|
map.put("produceorder_code", "%" + produceorder_code + "%"); |
|
|
|
|
|
} |
|
|
|
|
|
if (StrUtil.isNotEmpty(material)) { |
|
|
|
|
|
map.put("material", "%" + material + "%"); |
|
|
|
|
|
} |
|
|
|
|
|
JSONArray workorders = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map).process().getResultJSONArray(0); |
|
|
|
|
|
List<Map<String, Object>> list = workorders.stream().map(o -> { |
|
|
|
|
|
JSONObject workorder = (JSONObject) o; |
|
|
|
|
|
Map<String, Object> workorder_map = new LinkedHashMap<>(); |
|
|
|
|
|
workorder_map.put("工单编码", workorder.getString("workorder_code")); |
|
|
|
|
|
workorder_map.put("工单状态", workorder.getString("order_status")); |
|
|
|
|
|
workorder_map.put("设备", workorder.getString("device_name")); |
|
|
|
|
|
workorder_map.put("物料编码", workorder.getString("material_code")); |
|
|
|
|
|
workorder_map.put("载具类型", workorder.getString("vehicle_type")); |
|
|
|
|
|
workorder_map.put("计划数量", workorder.getString("plan_qty")); |
|
|
|
|
|
workorder_map.put("计划生产日期", workorder.getString("plan_date")); |
|
|
|
|
|
workorder_map.put("实际开始时间", workorder.getString("realproducestart_date")); |
|
|
|
|
|
workorder_map.put("实际结束时间", workorder.getString("realproduceend_date")); |
|
|
|
|
|
workorder_map.put("实际生产数量", workorder.getString("real_qty")); |
|
|
|
|
|
workorder_map.put("合格数量", workorder.getString("qualified_qty")); |
|
|
|
|
|
workorder_map.put("不合格数量", workorder.getString("unqualified_qty")); |
|
|
|
|
|
return workorder_map; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
FileUtil.downloadExcel(list, response); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|