Browse Source

add 导出生产统计

master
张江玮 2 years ago
parent
commit
ea0ecd5e69
  1. 6
      lms/nladmin-system/pom.xml
  2. 2
      lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java
  3. 4
      lms/nladmin-system/src/main/java/org/nl/wms/pda/rest/PdaController.java
  4. 8
      lms/nladmin-system/src/main/java/org/nl/wms/pdm/rest/WorkorderController.java
  5. 3
      lms/nladmin-system/src/main/java/org/nl/wms/pdm/service/WorkordeService.java
  6. 73
      lms/nladmin-system/src/main/java/org/nl/wms/pdm/service/impl/WorkorderServiceImpl.java
  7. 55
      lms/nladmin-system/src/main/java/org/nl/wms/pdm/wql/MPS_PRODUCEDURE001.wql
  8. 4
      lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/RegionInType.java
  9. 8
      lms/nladmin-system/src/main/resources/config/application-dev.yml
  10. 2
      lms/nladmin-ui/src/views/wms/pdm/workerorder/fj/index.vue
  11. 2
      lms/nladmin-ui/src/views/wms/pdm/workerorder/hl/index.vue
  12. 20
      lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue

6
lms/nladmin-system/pom.xml

@ -215,17 +215,17 @@
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId> <artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version> <version>4.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
<version>3.17</version> <version>4.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
<version>3.17</version> <version>4.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>xerces</groupId> <groupId>xerces</groupId>

2
lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java

@ -721,6 +721,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
workorder.put("order_status", WorkOrderEnum.ORDER_STATUS_FINISH.value()); workorder.put("order_status", WorkOrderEnum.ORDER_STATUS_FINISH.value());
if (!"0".equals(qty)) { if (!"0".equals(qty)) {
workorder.put("real_qty", qty); workorder.put("real_qty", qty);
} else {
workorder.put("real_qty", workorder.getIntValue("unqualified_qty") + workorder.getIntValue("qualified_qty"));
} }
String unqualified_qty = jsonObject.getString("unqualified_qty"); String unqualified_qty = jsonObject.getString("unqualified_qty");
if (StrUtil.isNotBlank(unqualified_qty) && !"0".equals(unqualified_qty)) { if (StrUtil.isNotBlank(unqualified_qty) && !"0".equals(unqualified_qty)) {

4
lms/nladmin-system/src/main/java/org/nl/wms/pda/rest/PdaController.java

@ -92,10 +92,6 @@ public class PdaController {
@ApiOperation("不合格品上报") @ApiOperation("不合格品上报")
@PdaAnnotation @PdaAnnotation
public JSONObject report(@RequestBody JSONObject param) { public JSONObject report(@RequestBody JSONObject param) {
String func = param.getString("func");
if (StrUtil.isBlank(func)) {
throw new BadRequestException("未知功能!");
}
String device_code = param.getString("device_code"); String device_code = param.getString("device_code");
if (StrUtil.isBlank(device_code)) { if (StrUtil.isBlank(device_code)) {
throw new BadRequestException("区域不能为空!"); throw new BadRequestException("区域不能为空!");

8
lms/nladmin-system/src/main/java/org/nl/wms/pdm/rest/WorkorderController.java

@ -15,6 +15,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.Map; import java.util.Map;
/** /**
@ -150,4 +151,11 @@ public class WorkorderController {
return new ResponseEntity<>(workordeService.getMaterial(),HttpStatus.OK); return new ResponseEntity<>(workordeService.getMaterial(),HttpStatus.OK);
} }
@GetMapping("/downloadExcel")
@Log("导出Excel")
@ApiOperation("导出Excel")
public void downloadExcel(@RequestParam Map<String, Object> params, HttpServletResponse response) {
workordeService.downloadExcel(params, response);
}
} }

3
lms/nladmin-system/src/main/java/org/nl/wms/pdm/service/WorkordeService.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import org.nl.wms.pdm.service.dto.WorkorderDto; import org.nl.wms.pdm.service.dto.WorkorderDto;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -123,4 +124,6 @@ public interface WorkordeService {
JSONArray getDtl(JSONObject param); JSONArray getDtl(JSONObject param);
JSONArray getMaterial(); JSONArray getMaterial();
void downloadExcel(Map<String, Object> params, HttpServletResponse response);
} }

73
lms/nladmin-system/src/main/java/org/nl/wms/pdm/service/impl/WorkorderServiceImpl.java

@ -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);
}
}
} }

55
lms/nladmin-system/src/main/java/org/nl/wms/pdm/wql/MPS_PRODUCEDURE001.wql

@ -191,3 +191,58 @@
ENDQUERY ENDQUERY
ENDIF ENDIF
IF 输入.flag = "7"
QUERY
SELECT
ShiftOrder.workorder_code,
d1.label AS order_status,
device.device_name,
material.material_code,
d2.label AS vehicle_type,
ShiftOrder.plan_qty,
ShiftOrder.plan_date,
ShiftOrder.realproducestart_date,
ShiftOrder.realproduceend_date,
ShiftOrder.real_qty,
ShiftOrder.qualified_qty,
ShiftOrder.unqualified_qty
FROM
PDM_BD_WORKORDER ShiftOrder
LEFT JOIN md_me_materialbase material ON material.material_id = ShiftOrder.material_id
LEFT JOIN pdm_bi_device device ON ShiftOrder.device_id = device.device_id
LEFT JOIN sys_dict_detail d1 ON ShiftOrder.order_status = d1.value AND d1.name = 'pdm_workorder_status'
LEFT JOIN sys_dict_detail d2 ON ShiftOrder.vehicle_type = d2.value AND d2.name = 'vehicle_type'
WHERE
ShiftOrder.is_delete = '0'
OPTION 输入.unFinish <> ""
ShiftOrder.order_status <> '5'
ENDOPTION
OPTION 输入.order_status <> ""
find_in_set( ShiftOrder.order_status, 输入.order_status)
ENDOPTION
OPTION 输入.begin_time <> ""
ShiftOrder.realproducestart_date IS NOT NULL
AND ShiftOrder.realproducestart_date <> ''
AND ShiftOrder.realproducestart_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
ShiftOrder.realproduceend_date IS NOT NULL
AND ShiftOrder.realproducestart_date <> ''
AND ShiftOrder.realproduceend_date <= 输入.end_time
ENDOPTION
OPTION 输入.produceorder_code <> ""
ShiftOrder.workorder_code like 输入.produceorder_code
ENDOPTION
OPTION 输入.material <> ""
(
material.material_code like 输入.material
)
ENDOPTION
OPTION 输入.region_code <> ""
device.region_code = 输入.region_code
ENDOPTION
ORDER BY
ShiftOrder.order_status ASC, ShiftOrder.create_time DESC
ENDSELECT
ENDQUERY
ENDIF

4
lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/RegionInType.java

@ -16,8 +16,8 @@ public enum RegionInType {
WGRK("完工入库", "F"), WGRK("完工入库", "F"),
BCPRK("半成品入库", "W"), BCPRK("半成品入库", "W"),
BCPFPRK("半成品废品入库", "W"), BCPFPRK("废品入库", "W"),
CCPFPRK("产成品废品入库", "F"); CCPFPRK("废品入库", "F");
private final String label; private final String label;
private final String value; private final String value;

8
lms/nladmin-system/src/main/resources/config/application-dev.yml

@ -162,3 +162,11 @@ sa-token:
loki: loki:
url: http://localhost:3100/loki/api/v1 url: http://localhost:3100/loki/api/v1
systemName: acs systemName: acs
#erp
erp:
sqlserver:
enabled: false
jdbcurl: jdbc:sqlserver://192.168.0.251:1433;DatabaseName=UFDATA_001_2023;
username: rl
password: SH123

2
lms/nladmin-ui/src/views/wms/pdm/workerorder/fj/index.vue

@ -247,7 +247,7 @@
label="实际结束时间" label="实际结束时间"
:min-width="flexWidth('realproduceend_date',crud.data,'实际结束时间')" :min-width="flexWidth('realproduceend_date',crud.data,'实际结束时间')"
/> />
<el-table-column prop="real_qty" label="实际数量" :min-width="flexWidth('real_qty',crud.data,'实际数量')" /> <el-table-column prop="real_qty" label="实际生产数量" :min-width="flexWidth('real_qty',crud.data,'实际生产数量')" />
<el-table-column <el-table-column
prop="qualified_qty" prop="qualified_qty"
label="合格数量" label="合格数量"

2
lms/nladmin-ui/src/views/wms/pdm/workerorder/hl/index.vue

@ -205,7 +205,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="realproducestart_date" label="实际开始时间" :min-width="flexWidth('realproducestart_date',crud.data,'实际开始时间')" /> <el-table-column prop="realproducestart_date" label="实际开始时间" :min-width="flexWidth('realproducestart_date',crud.data,'实际开始时间')" />
<el-table-column prop="realproduceend_date" label="实际结束时间" :min-width="flexWidth('realproduceend_date',crud.data,'实际结束时间')" /> <el-table-column prop="realproduceend_date" label="实际结束时间" :min-width="flexWidth('realproduceend_date',crud.data,'实际结束时间')" />
<el-table-column prop="real_qty" label="实际重量" :min-width="flexWidth('real_qty',crud.data,'实际量')" /> <el-table-column prop="real_qty" label="实际生产重量" :min-width="flexWidth('real_qty',crud.data,'实际生产重量')" />
<el-table-column prop="create_name" label="创建人" :min-width="flexWidth('create_name',crud.data,'创建人')" /> <el-table-column prop="create_name" label="创建人" :min-width="flexWidth('create_name',crud.data,'创建人')" />
<el-table-column prop="create_time" label="创建时间" :min-width="flexWidth('create_time',crud.data,'创建时间')" /> <el-table-column prop="create_time" label="创建时间" :min-width="flexWidth('create_time',crud.data,'创建时间')" />
<el-table-column prop="update_optname" label="修改人" :min-width="flexWidth('update_optname',crud.data,'修改人')" /> <el-table-column prop="update_optname" label="修改人" :min-width="flexWidth('update_optname',crud.data,'修改人')" />

20
lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue

@ -88,6 +88,16 @@
> >
强制完成 强制完成
</el-button> </el-button>
<el-button
slot="right"
class="filter-item"
type="danger"
icon="el-icon-download"
size="mini"
@click="downloadExcel()"
>
导出Excel
</el-button>
</crudOperation> </crudOperation>
<!--表单组件--> <!--表单组件-->
<el-dialog <el-dialog
@ -237,7 +247,7 @@
label="实际结束时间" label="实际结束时间"
:min-width="flexWidth('realproduceend_date',crud.data,'实际结束时间')" :min-width="flexWidth('realproduceend_date',crud.data,'实际结束时间')"
/> />
<el-table-column prop="real_qty" label="实际数量" :min-width="flexWidth('real_qty',crud.data,'实际数量')" /> <el-table-column prop="real_qty" label="实际生产数量" :min-width="flexWidth('real_qty',crud.data,'实际生产数量')" />
<el-table-column <el-table-column
prop="qualified_qty" prop="qualified_qty"
label="合格数量" label="合格数量"
@ -344,6 +354,8 @@ import pagination from '@crud/Pagination'
import MaterDtl from '@/views/wms/pub/MaterDialog' import MaterDtl from '@/views/wms/pub/MaterDialog'
import ViewDialog from '@/views/wms/pdm/workerorder/ViewDialog' import ViewDialog from '@/views/wms/pdm/workerorder/ViewDialog'
import DeviceDialog from '@/views/wms/pub/DeviceDialog' import DeviceDialog from '@/views/wms/pub/DeviceDialog'
import { download } from '@/api/data'
import { downloadFile } from '@/utils'
const defaultForm = { const defaultForm = {
workorder_id: null, workorder_id: null,
@ -523,6 +535,12 @@ export default {
this.crud.notify('下发成功', CRUD.NOTIFICATION_TYPE.SUCCESS) this.crud.notify('下发成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.crud.toQuery() this.crud.toQuery()
}) })
},
downloadExcel() {
download('/api/workorder/downloadExcel', this.crud.query).then(res => {
downloadFile(res, '生产统计', 'xlsx')
crud.downloadLoading = false
})
} }
} }
} }

Loading…
Cancel
Save