工序出入库

This commit is contained in:
18188916393
2022-07-14 16:34:48 +08:00
parent 36edf3d0d5
commit a20cdd38f9
38 changed files with 4576 additions and 20 deletions

View File

@@ -76,4 +76,12 @@ public class WorkProcedureController {
public ResponseEntity<Object> downSelect() {
return new ResponseEntity<>(workProcedureService.downSelect(), HttpStatus.OK);
}
@GetMapping("/queryWorkprocedure")
@Log("查询生产工序")
@ApiOperation("查询生产工序")
//@PreAuthorize("@el.check('workprocedure:list')")
public ResponseEntity<Object> queryWorkprocedure() {
return new ResponseEntity<>(workProcedureService.queryWorkprocedure(), HttpStatus.OK);
}
}

View File

@@ -3,6 +3,7 @@ package org.nl.wms.basedata.pdm.service;
import com.alibaba.fastjson.JSONArray;
import org.nl.wms.basedata.pdm.service.dto.WorkProcedureDto;
import org.nl.wms.st.out.service.dto.WorkprocedureDto;
import org.springframework.data.domain.Pageable;
import java.util.List;
@@ -77,5 +78,11 @@ public interface WorkProcedureService {
* @return
*/
JSONArray downSelect();
/**
* 查询所有数据不分页
* @param whereJson 条件参数
* @return List<PdmBaseWorkprocedureDto>
*/
List<WorkprocedureDto> queryWorkprocedure();
}

View File

@@ -16,6 +16,7 @@ import org.nl.modules.security.service.dto.JwtUserDto;
import org.nl.utils.SecurityUtils;
import org.nl.wms.basedata.pdm.service.WorkProcedureService;
import org.nl.wms.basedata.pdm.service.dto.WorkProcedureDto;
import org.nl.wms.st.out.service.dto.WorkprocedureDto;
import org.nl.wql.core.bean.ResultBean;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.util.WqlUtil;
@@ -39,7 +40,7 @@ public class WorkProcedureServiceImpl implements WorkProcedureService {
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String where = "";
WQLObject wo = WQLObject.getWQLObject("PDM_BI_WorkProcedure");
WQLObject wo = WQLObject.getWQLObject("pdm_bi_workprocedure");
String search = (String) whereJson.get("search");
if (!StrUtil.isEmpty(search)) {
where = " AND (workprocedure_code like '%" + search + "%' OR workprocedure_name like '%" + search + "%' ) ";
@@ -154,4 +155,12 @@ public class WorkProcedureServiceImpl implements WorkProcedureService {
JSONArray resultJSONArray = workProcedureTab.query("is_delete = '0' and is_used ='1'", "workprocedure_code").getResultJSONArray(0);
return resultJSONArray;
}
@Override
public List<WorkprocedureDto> queryWorkprocedure() {
WQLObject wo = WQLObject.getWQLObject("pdm_bi_workprocedure");
//只查清洗 跟仓储
JSONArray arr = wo.query(" is_delete = '0' and workprocedure_code in ('12','08')").getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(WorkprocedureDto.class);
return null;
}
}

View File

@@ -25,7 +25,7 @@ public class AcsUtil {
}
//ACS地址127.0.0.1:8010
String acsUrl = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("wcs_url").getValue();
String acsUrl = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("ACS_URL").getValue();
String url = acsUrl + api;
try {

View File

@@ -90,4 +90,11 @@ public class PointController {
pointService.syncStruct();
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@GetMapping("/getEndPoint")
@Log("查询点位管理")
@ApiOperation("查询点位管理")
//@PreAuthorize("@el.check('Point:list')")
public ResponseEntity<Object> getEndPoint(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(pointService.getEndPoint(whereJson,page),HttpStatus.OK);
}
}

View File

@@ -74,4 +74,9 @@ public interface PointService {
JSONArray getPoint(Map wherJson);
void syncStruct();
/**
*
* 获取终点点位
*/
Map<String,Object> getEndPoint(Map whereJson, Pageable page);
}

View File

@@ -1,12 +1,14 @@
package org.nl.wms.sch.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mchange.lang.DoubleUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
@@ -60,8 +62,8 @@ public class PointServiceImpl implements PointService {
public PointDto findById(Long point_id) {
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
JSONObject json = wo.query("point_id =" + point_id + "").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){
return json.toJavaObject(PointDto.class);
if (ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(PointDto.class);
}
final PointDto obj = json.toJavaObject(PointDto.class);
return obj;
@@ -72,8 +74,8 @@ public class PointServiceImpl implements PointService {
public PointDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
JSONObject json = wo.query("point_code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){
return json.toJavaObject(PointDto.class);
if (ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(PointDto.class);
}
return null;
}
@@ -151,12 +153,12 @@ public class PointServiceImpl implements PointService {
//如果是仓位点位,更新状态前,先去查询仓位点位所对应的库区是否启用,如果禁用抛出异常
String struct_id = json.getString("point_id");
String point_type = json.getString("point_type");
if (point_type.equals("01")){
if (point_type.equals("01")) {
JSONObject st_ivt_bsRealStorAttr = WQLObject.getWQLObject("ST_IVT_StructAttr").query(" struct_id = '" + struct_id + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(st_ivt_bsRealStorAttr)){
if (ObjectUtil.isNotEmpty(st_ivt_bsRealStorAttr)) {
String sect_id = st_ivt_bsRealStorAttr.getString("sect_id");
JSONObject st_ivt_sectAttr = WQLObject.getWQLObject("ST_IVT_SectAttr").query(" sect_id = '" + sect_id + "' and is_used = '1'").uniqueResult(0);
if (ObjectUtil.isEmpty(st_ivt_sectAttr)){
if (ObjectUtil.isEmpty(st_ivt_sectAttr)) {
throw new BadRequestException("启用失败,请检查仓位点位所属库区是否启用!");
}
}
@@ -223,4 +225,52 @@ public class PointServiceImpl implements PointService {
wo.insert(structMap);
}
}
@Override
public Map<String, Object> getEndPoint(Map whereJson, Pageable page) {
String search = MapUtil.getStr(whereJson, "search");
//String material_id = MapUtil.getStr(whereJson, "material_id");
String area_type = MapUtil.getStr(whereJson, "area_type");
String vehicle_code = MapUtil.getStr(whereJson, "vehicle_code");
String qty = MapUtil.getStr(whereJson, "qty");
String loadSeries = "4";
//根据重量去找最小的级数在哪个范围
if (StrUtil.isNotEmpty(qty) && Double.valueOf(qty) > 0) {
loadSeries = this.getLoadSeriesByqty(Double.valueOf(qty));
}
WQLObject wo_vehicle = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
String vehicle_type = "";
if (StrUtil.isNotEmpty(vehicle_code)) {
JSONObject jsonObject = wo_vehicle.query("is_delete = '0' and storagevehicle_code = '" + vehicle_code + "'").uniqueResult(0);
vehicle_type = jsonObject.getString("storagevehicle_type");
}
JSONObject map = new JSONObject();
map.put("flag", "3");
map.put("area_type", area_type);
map.put("vehicle_type", vehicle_type);
map.put("loadSeries", loadSeries);
//map.put("material_id",material_id);
if (ObjectUtil.isNotEmpty(search)) {
map.put("search", "%" + search + "%");
}
JSONObject json = WQL.getWO("SCH_Point_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "struct_code");
return json;
}
//根据重量返回最大的 级数
public String getLoadSeriesByqty(Double qty) {
JSONArray dictArr = WQLObject.getWQLObject("sys_dict_detail").query("dict_id ='108'", "label").getResultJSONArray(0);
String load_series = "4";
for (int i = 0; i < dictArr.size(); i++) {
JSONObject dictObj = dictArr.getJSONObject(i);
double flag = dictObj.getDouble("label");
if (flag >= qty) {
load_series = dictObj.getString("value");
break;
}
}
return load_series;
}
}

View File

@@ -107,7 +107,7 @@ public class TaskServiceImpl implements TaskService {
@Override
public TaskDto findByDtlId(String taskdtl_id) {
WQLObject wo = WQLObject.getWQLObject("sch_base_task");
JSONObject json = wo.query("taskdtl_id = '" + taskdtl_id + "'").uniqueResult(0);
JSONObject json = wo.query("task_id = '" + taskdtl_id + "'").uniqueResult(0);
final TaskDto obj = json.toJavaObject(TaskDto.class);
return obj;
}
@@ -173,9 +173,9 @@ public class TaskServiceImpl implements TaskService {
@Override
public void operation(Map<String, Object> map) {
String taskdtl_id = MapUtil.getStr(map, "taskdtl_id");
String task_id = MapUtil.getStr(map, "task_id");
String method_name = MapUtil.getStr(map, "method_name");
TaskDto dto = this.findByDtlId(taskdtl_id);
TaskDto dto = this.findByDtlId(task_id);
// 任务处理类
String processing_class = dto.getHandle_class();
String message = "";
@@ -185,7 +185,7 @@ public class TaskServiceImpl implements TaskService {
Object obj = clz.newInstance();
// 调用每个任务类的method_name()强制结束方法
Method m = obj.getClass().getMethod(method_name, String.class);
JSONObject result = (JSONObject) m.invoke(obj, taskdtl_id);
JSONObject result = (JSONObject) m.invoke(obj, task_id);
if (ObjectUtil.isEmpty(result)) return;
JSONArray arr = result.getJSONArray("errArr");
WQLObject wo = WQLObject.getWQLObject("sch_base_task");
@@ -200,7 +200,7 @@ public class TaskServiceImpl implements TaskService {
throw new BadRequestException("任务操作失败!");
} else {
JSONObject param = new JSONObject();
param.put("taskdtl_id", taskdtl_id);
param.put("task_id", task_id);
param.put("remark", "操作成功");
wo.update(param);
}

View File

@@ -84,7 +84,7 @@
task.create_time <= 输入.end_time
ENDOPTION
OPTION 输入.unFinish <> ""
task.task_status <> '99'
task.task_status <> '07'
ENDOPTION
OPTION 输入.task_status <> ""
find_in_set( task.task_status, 输入.task_status)

View File

@@ -0,0 +1,124 @@
[交易说明]
交易名: 点位管理查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.search TYPEAS s_string
输入.point_type TYPEAS s_string
输入.area_type TYPEAS s_string
输入.point_status TYPEAS s_string
输入.lock_type TYPEAS s_string
输入.is_used TYPEAS s_string
输入.material_id TYPEAS s_string
输入.vehicle_type TYPEAS s_string
输入.loadSeries TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT
a.*,b.device_name
FROM
sch_base_point a
left join
pdm_base_device b on a.device_id = b.device_id
WHERE
a.is_delete = '0'
OPTION 输入.search <> ""
(a.point_code like 输入.search or
a.point_name like 输入.search)
ENDOPTION
OPTION 输入.point_type <> ""
a.point_type = 输入.point_type
ENDOPTION
OPTION 输入.area_type <> ""
a.area_type = 输入.area_type
ENDOPTION
OPTION 输入.point_status <> ""
a.point_status = 输入.point_status
ENDOPTION
OPTION 输入.lock_type <> ""
a.lock_type = 输入.lock_type
ENDOPTION
OPTION 输入.is_used <> ""
a.is_used = 输入.is_used
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "2"
PAGEQUERY
SELECT
a.*,b.sect_code
FROM
ST_IVT_StructAttr a
left join
ST_IVT_SectAttr b on a.sect_id = b.sect_id
WHERE
a.is_delete = '0'
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "3"
PAGEQUERY
SELECT DISTINCT
structattr.struct_id,
structattr.struct_code,
structattr.struct_name,
point.area_type,
point.point_type
FROM
st_ivt_structattr structattr
LEFT JOIN sch_base_point point ON point.point_id = structattr.struct_id
LEFT JOIN ST_IVT_StructRelaVehicleType rulevehicle ON rulevehicle.struct_id = structattr.struct_id
LEFT JOIN ST_IVT_StructAttributeRules ruledis ON ruledis.struct_id = structattr.struct_id
WHERE
point.lock_type = '00'
AND (point.vehicle_code = '' or point.vehicle_code is null)
AND point.point_status = '00'
AND point.area_type = 输入.area_type
AND rulevehicle.vehicle_type = 输入.vehicle_type
OPTION 输入.search <> ""
(structattr.struct_code like 输入.search or
structattr.struct_name like 输入.search)
ENDOPTION
OPTION 输入.loadSeries <> ""
ruledis.load_series >= 输入.loadSeries
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -17,6 +17,7 @@ import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.wms.sch.service.impl.PointServiceImpl;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

View File

@@ -12,14 +12,18 @@ import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.utils.SpringContextHolder;
import org.nl.wms.basedata.st.IvtChangeTypeEnum;
import org.nl.wms.basedata.st.StoreIvtServiceImpl;
import org.nl.wms.common.StructFindUtil;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.wms.sch.service.impl.PointServiceImpl;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

View File

@@ -0,0 +1,35 @@
package org.nl.wms.st.in;
/**
* 区域字典表sch_area_type:
* 01困料货架 ,02出窑货架预定03、出窑暂存区04、包装暂存区21:混碾区域22、压制区域 23、液压机料盅架
* 24 窑区域 25 空钢托堆叠区 26 自动柴垛线
*/
public enum AreaEnum {
CPHJ("KQ001", "成品库区"),
BCPHJ("KQ002", "半成品库区"),
BCPSLKKZCQ("KQ003", "半成品上料空框暂存区"),
BCPSXLZCQ("KQ004", "半成品上下料暂存区"),
BCPKKYJQ("KQ005", "半成品空框应急区"),
CPCKZCQ("KQ006", "成品出库暂存区"),
BCPLXQ("KQ007", "半成品料箱区"),
ULQ("RCK001", "原材料区");
private final String name;
private final String code;
AreaEnum(String code, String name) {
this.code = code;
this.name = name;
}
public String getName() {
return name;
}
public String getCode() {
return code;
}
}

View File

@@ -0,0 +1,15 @@
package org.nl.wms.st.in;
/**
* 业务常量配置类
*/
public class BussConstant {
// 混碾入库数量单位
public static final String HN_IN_QTY_UNIT_ID = "1";
// 压制入库数量单位
public static final String YZ_IN_QTY_UNIT_ID = "1";
// 压制出库数量单位
public static final String YZ_OUT_QTY_UNIT_ID = "1";
}

View File

@@ -0,0 +1,66 @@
package org.nl.wms.st.in;
import cn.hutool.core.util.StrUtil;
/**
* 工序类型类型,对应工序表:生产工序表【PDM_BASE_workProcedure】
*/
public enum WorkProcedureEnum {
BZGX(1, "1535144822984282112", "01", "包装工序", ""),
QXGX(2, "1535144552481034240", "02", "清洗工序", ""),
CCGX(2, "1535144934791843840", "02", "仓储工序", "");
//顺序号
private int index;
//工序标识
private String id;
// 工序编码
private String code;
//名字
private String name;
//描述
private String desc;
WorkProcedureEnum(int index, String id, String code, String name, String desc) {
this.index = index;
this.id = id;
this.code = code;
this.name = name;
this.desc = desc;
}
public String getName() {
return name;
}
public String getCode() {
return code;
}
public String getId() {
return id;
}
public String getDesc() {
return desc;
}
public static WorkProcedureEnum get(String workprocedure_id) {
for (WorkProcedureEnum workProcedureEnum : WorkProcedureEnum.values()) {
if (StrUtil.equals(workProcedureEnum.id, workprocedure_id)) {
return workProcedureEnum;
}
}
return null;
}
public static void main(String[] args) {
System.out.println("测试完成1");
for (WorkProcedureEnum workProcedureEnum : WorkProcedureEnum.values()) {
if (StrUtil.equals(workProcedureEnum.id, "1514444198529601536")) {
System.out.println("测试完成2");
}
}
}
}

View File

@@ -0,0 +1,117 @@
package org.nl.wms.st.in.rest;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.st.in.service.WorkprocedureiosService;
import org.nl.wms.st.in.service.dto.WorkprocedureiosDto;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.nl.annotation.Log;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* @author geng by
* @date 2022-04-21
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "工序入库管理")
@RequestMapping("/api/workprocedureiosIn")
@Slf4j
public class WorkprocedureiosController {
private final WorkprocedureiosService workprocedureiosService;
@GetMapping
@Log("查询工序入库")
@ApiOperation("查询工序入库")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(workprocedureiosService.queryAll(whereJson,page),HttpStatus.OK);
}
@PostMapping
@Log("新增工序入库")
@ApiOperation("新增工序入库")
//@PreAuthorize("@el.check('workprocedureios:add')")
public ResponseEntity<Object> create(@Validated @RequestBody WorkprocedureiosDto dto){
workprocedureiosService.create(dto);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping
@Log("修改工序入库")
@ApiOperation("修改工序入库")
//@PreAuthorize("@el.check('workprocedureios:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody WorkprocedureiosDto dto){
workprocedureiosService.update(dto);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除工序入库")
@ApiOperation("删除工序入库")
//@PreAuthorize("@el.check('workprocedureios:del')")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
workprocedureiosService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/getBillTypes")
@Log("查询工序入库单据类型")
@ApiOperation("查询工序入库单据类型")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getBillTypes(){
return new ResponseEntity<>(workprocedureiosService.getBillTypes(),HttpStatus.OK);
}
@PostMapping("/selectStartPoint")
@Log("根据工序查找起始点位")
@ApiOperation("根据工序查找起始点位")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> selectStartPoint(@RequestBody JSONObject json){
return new ResponseEntity<>(workprocedureiosService.selectStartPoint(json.getString("workprocedureid")),HttpStatus.OK);
}
@PostMapping("/getStartArea")
@Log("根据起始点位编码查询点位区域")
@ApiOperation("根据起始点位编码查询点位区域")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getStartArea(@RequestBody JSONObject json){
return new ResponseEntity<>(workprocedureiosService.getStartArea(json.getString("start_point_code")),HttpStatus.OK);
}
@GetMapping("/getMaterial")
@Log("选择物料")
@ApiOperation("选择物料")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getMaterial(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(workprocedureiosService.getMaterial(whereJson,page),HttpStatus.OK);
}
@PostMapping("/genTask")
@Log("生成任务")
@ApiOperation("生成任务")
//@PreAuthorize("@el.check('workprocedureios:add')")
public ResponseEntity<Object> genTask(@RequestBody JSONObject taskJson){
workprocedureiosService.genTask(taskJson);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PostMapping("/getEndAareaByworkprocedureId")
@Log("根据工序查询终点区域")
@ApiOperation("根据工序查询终点区域")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getEndAareaByworkprocedureId(@RequestBody JSONObject param){
return new ResponseEntity<>(workprocedureiosService.getEndAareaByworkprocedureId(param.getString("workprocedure_id")),HttpStatus.OK);
}
}

View File

@@ -0,0 +1,103 @@
package org.nl.wms.st.in.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.st.in.service.dto.WorkprocedureiosDto;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
/**
* @description 服务接口
* @author geng by
* @date 2022-04-21
**/
public interface WorkprocedureiosService {
/**
* 查询数据分页
* @param whereJson 条件
* @param page 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(Map whereJson, Pageable page);
/**
* 查询所有数据不分页
* @param whereJson 条件参数
* @return List<WorkprocedureiosDto>
*/
List<WorkprocedureiosDto> queryAll(Map whereJson);
/**
* 根据ID查询
* @param weight_unit_id ID
* @return Workprocedureios
*/
WorkprocedureiosDto findById(Long weight_unit_id);
/**
* 根据编码查询
* @param code code
* @return Workprocedureios
*/
WorkprocedureiosDto findByCode(String code);
/**
* 创建
* @param dto /
*/
void create(WorkprocedureiosDto dto);
/**
* 编辑
* @param dto /
*/
void update(WorkprocedureiosDto dto);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Long[] ids);
/**
* 查询入库单据类型
* @return
*/
JSONArray getBillTypes();
/**
* 根据工序查询开始点位
* @return
*/
JSONArray selectStartPoint(String workprocedureid);
/**
*根据起始点位编码获取起始区域
* @param start_point_code
* @return
*/
JSONObject getStartArea(String start_point_code);
/**
* 工序入库选择物料查询
* @param whereJson
* @param page
* @return
*/
Map<String,Object> getMaterial(Map whereJson, Pageable page);
/**
* 生成任务
* @param taskJson
*/
void genTask(JSONObject taskJson);
/**
* 根据工序获取终点区域
*/
Map<String,Object> getEndAareaByworkprocedureId(String workprocedure_id);
}

View File

@@ -0,0 +1,116 @@
package org.nl.wms.st.in.service.dto;
import lombok.Data;
import java.math.BigDecimal;
import java.io.Serializable;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
/**
* @description /
* @author geng by
* @date 2022-04-29
**/
@Data
public class WorkprocedureiosDto implements Serializable {
/** 出入单标识 */
/** 防止精度丢失 */
@JsonSerialize(using= ToStringSerializer.class)
private Long iostorinv_id;
/** 单据编号 */
private String bill_code;
/** 出入类型 */
private String io_type;
/** 单据类型 */
private String bill_type;
/** 工序标识 */
private Long workprocedure_id;
/** 物料标识 */
private Long material_id;
/** 载具编码 */
private String vehicle_code;
/** 数量 */
private BigDecimal qty;
/** 数量单位标识 */
/** 防止精度丢失 */
@JsonSerialize(using= ToStringSerializer.class)
private Long qty_unit_id;
/** 单据状态 */
private String bill_status;
/** 起始点位编码 */
private String start_point_code;
/** 终点点位编码 */
private String end_point_code;
/** 起始区域 */
private String start_area;
/** 终点区域 */
private String end_area;
/** 客户标识 */
private Long cust_id;
/** 生成方式 */
private String create_mode;
/** 任务标识 */
private Long task_id;
/** 备注 */
private String remark;
/** 创建人 */
private Long create_id;
/** 创建人 */
private String create_name;
/** 创建时间 */
private String create_time;
/** 修改人 */
private Long update_optid;
/** 修改人 */
private String update_optname;
/** 修改时间 */
private String update_time;
/** 确认人 */
private Long confirm_optid;
/** 确认人 */
private String confirm_optname;
/** 确认时间 */
private String confirm_time;
/** 是否删除 */
private String is_delete;
/** 批次 */
private String pcsn;
/** 物料工序标识 */
private Long ivt_workprocedure_id;
/** 是否满拖 */
private String is_full;
/** 黏次 */
private String mix_seq;
}

View File

@@ -0,0 +1,326 @@
package org.nl.wms.st.in.service.impl;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.wms.sch.tasks.SendMaterialTask;
import org.nl.wms.st.in.AreaEnum;
import org.nl.wms.st.in.BussConstant;
import org.nl.wms.st.in.WorkProcedureEnum;
import org.nl.wms.st.in.service.WorkprocedureiosService;
import org.nl.wms.st.in.service.dto.WorkprocedureiosDto;
import org.nl.wql.WQL;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.utils.SecurityUtils;
import org.nl.wql.core.bean.ResultBean;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.util.WqlUtil;
import lombok.extern.slf4j.Slf4j;
import cn.hutool.core.util.ObjectUtil;
/**
* @author geng by
* @description 服务实现
* @date 2022-04-21
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class WorkprocedureiosServiceImpl implements WorkprocedureiosService {
/*private final String THIS_CLASS = SendMaterialTask.class.getName();*/
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String search = MapUtil.getStr(whereJson, "search");
JSONObject map = new JSONObject();
map.put("flag", "1");
if (ObjectUtil.isNotEmpty(search)) {
map.put("search", "%" + search + "%");
}
JSONObject json = WQL.getWO("ST_Workprocedureios_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "a.create_time desc");
return json;
}
@Override
public List<WorkprocedureiosDto> queryAll(Map whereJson) {
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONArray arr = wo.query().getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(WorkprocedureiosDto.class);
return null;
}
@Override
public WorkprocedureiosDto findById(Long iostorinv_id) {
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject json = wo.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(WorkprocedureiosDto.class);
}
return null;
}
@Override
public WorkprocedureiosDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(WorkprocedureiosDto.class);
}
return null;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(WorkprocedureiosDto dto) {
String bill_code = CodeUtil.getNewCode("IN_STORE_CODE");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
dto.setIostorinv_id(IdUtil.getSnowflake(1, 1).nextId());
dto.setBill_code(bill_code);
dto.setIo_type("0");
dto.setBill_status("10");
Map<String, Object> endMap = this.getEndAareaByworkprocedureId(dto.getWorkprocedure_id().toString());
String end_area = dto.getEnd_area();
if (StrUtil.isEmpty(end_area)) {
String endArea = MapUtil.getStr(endMap, "end_area");
if (StrUtil.isEmpty(endArea)) {
throw new BadRequestException("终点区域为空,枚举中未查到工序对应区域!");
}
dto.setEnd_area(endArea);
}
Long qty_unit_id = dto.getQty_unit_id();
if (ObjectUtil.isNull(qty_unit_id)) {
String unit_id = MapUtil.getStr(endMap, "qty_unit_id");
if (StrUtil.isEmpty(unit_id)) {
throw new BadRequestException("数量单位为空,枚举中未查到工序对应区域!");
}
qty_unit_id = Long.valueOf(unit_id);
dto.setQty_unit_id(qty_unit_id);
}
dto.setCreate_mode("01");
dto.setCreate_id(currentUserId);
dto.setCreate_name(nickName);
dto.setUpdate_optid(currentUserId);
dto.setUpdate_optname(nickName);
dto.setUpdate_time(now);
dto.setCreate_time(now);
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
wo.insert(json);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(WorkprocedureiosDto dto) {
WorkprocedureiosDto entity = this.findById(dto.getIostorinv_id());
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
dto.setBill_status("10");
Map<String, Object> endMap = this.getEndAareaByworkprocedureId(dto.getWorkprocedure_id().toString());
String end_area = dto.getEnd_area();
if (StrUtil.isEmpty(end_area)) {
String endArea = MapUtil.getStr(endMap, "end_area");
if (StrUtil.isEmpty(endArea)) {
throw new BadRequestException("终点区域为空,枚举中未查到工序对应区域!");
}
dto.setEnd_area(endArea);
}
Long qty_unit_id = dto.getQty_unit_id();
if (ObjectUtil.isNull(qty_unit_id)) {
String unit_id = MapUtil.getStr(endMap, "qty_unit_id");
if (StrUtil.isEmpty(unit_id)) {
throw new BadRequestException("数量单位为空,枚举中未查到工序对应区域!");
}
qty_unit_id = Long.valueOf(unit_id);
dto.setQty_unit_id(qty_unit_id);
}
dto.setUpdate_time(now);
dto.setUpdate_optid(currentUserId);
dto.setUpdate_optname(nickName);
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
wo.update(json);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(Long[] ids) {
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
for (Long iostorinv_id : ids) {
JSONObject param = new JSONObject();
param.put("is_delete", "1");
param.put("update_optid", currentUserId);
param.put("update_optname", nickName);
param.put("update_time", now);
wo.update(param, "iostorinv_id = '" + iostorinv_id + "'");
}
}
@Override
public JSONArray getBillTypes() {
WQLObject wo = WQLObject.getWQLObject("sys_dict_detail");
JSONArray arr = wo.query(" name = 'ST_INV_TYPE' and value like '00%'").getResultJSONArray(0);
return arr;
}
@Override
public JSONArray selectStartPoint(String workprocedureid) {
/* WQLObject woDevice = WQLObject.getWQLObject("pdm_base_device");*/
JSONArray arrPoint = new JSONArray();
WQLObject woPoint = WQLObject.getWQLObject("sch_base_point");
//包装工序
if (StrUtil.equals(workprocedureid, WorkProcedureEnum.CCGX.getId())) {
arrPoint = woPoint.query("is_used='1' and is_delete='0' and point_code like 'CPRKW%'").getResultJSONArray(0);
return arrPoint;
}
//包装工序
if (StrUtil.equals(workprocedureid, WorkProcedureEnum.BZGX.getId())) {
arrPoint = woPoint.query("is_used='1' and is_delete='0' and point_code like 'CPRKW%'").getResultJSONArray(0);
return arrPoint;
}
//清洗工序
if (StrUtil.equals(workprocedureid, WorkProcedureEnum.QXGX.getId())) {
}
/*
JSONArray arrDevice = woDevice.query("is_delete = '0' and workprocedure_id = '" + workprocedureid + "'", "device_code").getResultJSONArray(0);
JSONArray arrPoint = new JSONArray();
for (int i = 0; i < arrDevice.size(); i++) {
JSONObject jsonDevice = arrDevice.getJSONObject(i);
JSONArray arrPoints = woPoint.query("is_delete = '0' and device_point_type = '02' and device_id = '" + jsonDevice.getString("device_id") + "'", "point_code").getResultJSONArray(0);
for (int j = 0; j < arrPoints.size(); j++) {
JSONObject jsonPoint = arrPoints.getJSONObject(j);
arrPoint.add(jsonPoint);
}
}*/
return arrPoint;
}
@Override
public JSONObject getStartArea(String start_point_code) {
WQLObject woPoint = WQLObject.getWQLObject("sch_base_point");
JSONObject arrDevice = woPoint.query("is_delete = '0' and point_code = '" + start_point_code + "'").uniqueResult(0);
return arrDevice;
}
@Override
public Map<String, Object> getMaterial(Map whereJson, Pageable page) {
String where = "";
WQLObject wo = WQLObject.getWQLObject("md_me_materialbase");
String search = MapUtil.getStr(whereJson, "search");
if (!StrUtil.isEmpty(search)) {
where = " AND (material_code like '%" + search + "%' OR material_name like '%" + search + "%' ) ";
}
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "is_delete= '0'" + where, "update_time desc");
final JSONObject json = rb.pageResult();
return json;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void genTask(JSONObject taskJson) {
String iostorinv_id = taskJson.getString("iostorinv_id");
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject jsonObject = wo.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
//请求参数 载具、起点 物料,数量,客户,批次,创建方式不能为空! 终点可以不为空时,入库单据编号不能为空
JSONObject form = new JSONObject();
String next_point_code = jsonObject.getString("end_point_code");
String start_point_code = jsonObject.getString("start_point_code");
String vehicle_code = jsonObject.getString("vehicle_code");
String material_id = jsonObject.getString("material_id");
String cust_id = jsonObject.getString("cust_id");
String qty = jsonObject.getString("qty");
String pcsn = jsonObject.getString("pcsn");
String create_mode = jsonObject.getString("create_mode");
String is_full = jsonObject.getString("is_full");
String ivt_workprocedure_id = jsonObject.getString("ivt_workprocedure_id");
form.put("vehicle_code", vehicle_code);
form.put("start_point_code", start_point_code);
form.put("next_point_code", next_point_code);
form.put("material_id", material_id);
form.put("qty", qty);
form.put("cust_id", cust_id);
form.put("create_mode", create_mode);
form.put("pcsn", pcsn);
form.put("is_full", is_full);
form.put("ivt_workprocedure_id", ivt_workprocedure_id);
form.put("iostorinv_id", iostorinv_id);
SendMaterialTask sendMaterialTask = new SendMaterialTask();
String task_id = sendMaterialTask.createTask(form);
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("update_optid", SecurityUtils.getCurrentUserId());
json.put("update_optname", SecurityUtils.getNickName());
json.put("update_time", DateUtil.now());
json.put("bill_status", "20");
wo.update(json, "iostorinv_id = '" + iostorinv_id + "'");
}
@Override
public Map<String, Object> getEndAareaByworkprocedureId(String workprocedure_id) {
String endArea = "";
String qty_unit_id = "";
WorkProcedureEnum workProcedureEnum = WorkProcedureEnum.get(workprocedure_id);
// TODO
switch (workProcedureEnum) {
//包装工序
case CCGX:
endArea = AreaEnum.CPHJ.getCode();
qty_unit_id = BussConstant.HN_IN_QTY_UNIT_ID;
break;
//包装工序
case BZGX:
endArea = AreaEnum.CPHJ.getCode();
qty_unit_id = BussConstant.HN_IN_QTY_UNIT_ID;
break;
// 清洗工序
case QXGX:
endArea = AreaEnum.BCPHJ.getCode();
qty_unit_id = BussConstant.YZ_IN_QTY_UNIT_ID;
break;
default:
endArea = null;
qty_unit_id = null;
break;
}
JSONObject map = new JSONObject();
map.put("end_area", endArea);
map.put("qty_unit_id", qty_unit_id);
return map;
}
}

View File

@@ -0,0 +1,67 @@
[交易说明]
交易名: 工序入库单分页查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.search TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT
a.*,
b.workprocedure_name,
c.material_name,
p1.point_name AS start_point_name,
p2.point_name AS end_point_name,
unit.unit_name,
cust.cust_name
FROM
ST_IVT_workProcedureIOS a
LEFT JOIN pdm_bi_workprocedure b ON a.workprocedure_id = b.workprocedure_id
LEFT JOIN md_me_materialbase c ON c.material_id = a.material_id
LEFT JOIN sch_base_point p1 ON a.start_point_code = p1.point_code
LEFT JOIN sch_base_point p2 ON a.end_point_code = p2.point_code
LEFT JOIN md_pb_measureunit unit ON a.qty_unit_id = unit.measure_unit_id
LEFT JOIN md_cs_customerbase cust ON a.cust_id = cust.cust_id
WHERE
a.is_delete = '0'
AND a.io_type = '0'
OPTION 输入.search <> ""
a.bill_code like 输入.search
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -0,0 +1,145 @@
package org.nl.wms.st.out.rest;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.annotation.Log;
import org.nl.wms.st.in.service.dto.WorkprocedureiosDto;
import org.nl.wms.st.out.service.WorkprocedureiosOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @author geng by
* @date 2022-04-21
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "工序出库管理")
@RequestMapping("/api/workprocedureiosOut")
@Slf4j
public class WorkprocedureiosOutController {
@Autowired
private final WorkprocedureiosOutService workprocedureiosOutService;
@GetMapping
@Log("查询工序出库")
@ApiOperation("查询工序出库")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(workprocedureiosOutService.queryAll(whereJson,page),HttpStatus.OK);
}
@PostMapping
@Log("新增工序出库")
@ApiOperation("新增工序出库")
//@PreAuthorize("@el.check('workprocedureios:add')")
public ResponseEntity<Object> create(@Validated @RequestBody WorkprocedureiosDto dto){
workprocedureiosOutService.create(dto);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping
@Log("修改工序出库")
@ApiOperation("修改工序出库")
//@PreAuthorize("@el.check('workprocedureios:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody WorkprocedureiosDto dto){
workprocedureiosOutService.update(dto);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除工序出库")
@ApiOperation("删除工序出库")
//@PreAuthorize("@el.check('workprocedureios:del')")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
workprocedureiosOutService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/getBillTypes")
@Log("查询工序出库单据类型")
@ApiOperation("查询工序出库单据类型")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getBillTypes(){
return new ResponseEntity<>(workprocedureiosOutService.getBillTypes(),HttpStatus.OK);
}
@PostMapping("/selectEndPoint")
@Log("根据工序查找终点点位")
@ApiOperation("根据工序查找终点点位")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> selectEndPoint(@RequestBody JSONObject json){
return new ResponseEntity<>(workprocedureiosOutService.selectEndPoint(json.getString("workprocedureid")),HttpStatus.OK);
}
@PostMapping("/getEndArea")
@Log("根据终点点位编码查询点位区域")
@ApiOperation("根据起始点位编码查询点位区域")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getStartArea(@RequestBody JSONObject json){
return new ResponseEntity<>(workprocedureiosOutService.getStartArea(json.getString("start_point_code")),HttpStatus.OK);
}
@GetMapping("/getMaterial")
@Log("选择物料")
@ApiOperation("选择物料")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getMaterial(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(workprocedureiosOutService.getMaterial(whereJson,page),HttpStatus.OK);
}
@PostMapping("/genTask")
@Log("生成任务")
@ApiOperation("生成任务")
//@PreAuthorize("@el.check('workprocedureios:add')")
public ResponseEntity<Object> genTask(@RequestBody JSONObject taskJson){
workprocedureiosOutService.genTask(taskJson);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@GetMapping("/getStartPoint")
@Log("查询起点点位")
@ApiOperation("查询起点点位")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getStartPoint(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(workprocedureiosOutService.getStartPoint(whereJson,page),HttpStatus.OK);
}
@PostMapping("/getEndAareaByworkprocedureId")
@Log("根据工序查询起点区域")
@ApiOperation("根据工序查询起点区域")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getEndAareaByworkprocedureId(@RequestBody JSONObject param){
return new ResponseEntity<>(workprocedureiosOutService.getEndAareaByworkprocedureId(param.getString("workprocedure_id")),HttpStatus.OK);
}
@GetMapping("/queryWorkprocedure")
@Log("出库工序下拉")
@ApiOperation("出库工序下拉")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> queryWorkprocedure(){
return new ResponseEntity<>(workprocedureiosOutService.queryWorkprocedure(),HttpStatus.OK);
}
@PostMapping("/getIvtWorkprocedureId")
@Log("根据选择工序查询上一工序")
@ApiOperation("根据选择工序查询上一工序")
//@PreAuthorize("@el.check('workprocedureios:list')")
public ResponseEntity<Object> getIvtWorkprocedureId(@RequestBody JSONObject param){
return new ResponseEntity<>(workprocedureiosOutService.getIvtWorkprocedureId(param),HttpStatus.OK);
}
}

View File

@@ -0,0 +1,126 @@
package org.nl.wms.st.out.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.st.in.service.dto.WorkprocedureiosDto;
import org.nl.wms.st.out.service.dto.WorkprocedureDto;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
/**
* @description 服务接口
* @author geng by
* @date 2022-04-21
**/
public interface WorkprocedureiosOutService {
/**
* 查询数据分页
* @param whereJson 条件
* @param page 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(Map whereJson, Pageable page);
/**
* 查询所有数据不分页
* @param whereJson 条件参数
* @return List<WorkprocedureiosDto>
*/
List<WorkprocedureiosDto> queryAll(Map whereJson);
/**
* 根据ID查询
* @param weight_unit_id ID
* @return Workprocedureios
*/
WorkprocedureiosDto findById(Long weight_unit_id);
/**
* 根据编码查询
* @param code code
* @return Workprocedureios
*/
WorkprocedureiosDto findByCode(String code);
/**
* 创建
* @param dto /
*/
void create(WorkprocedureiosDto dto);
/**
* 编辑
* @param dto /
*/
void update(WorkprocedureiosDto dto);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Long[] ids);
/**
* 查询入库单据类型
* @return
*/
JSONArray getBillTypes();
/**
* 根据工序查找终点点位
* @return
*/
JSONArray selectEndPoint(String workprocedureid);
/**
*根据起始点位编码获取起始区域
* @param start_point_code
* @return
*/
JSONObject getStartArea(String start_point_code);
/**
* 工序入库选择物料查询
* @param whereJson
* @param page
* @return
*/
Map<String,Object> getMaterial(Map whereJson, Pageable page);
/**
* 生产任务
* @param taskJson
*/
void genTask(JSONObject taskJson);
/**
* 获得起始点位
* @param whereJson
* @param page
* @return
*/
Map<String,Object> getStartPoint(Map whereJson, Pageable page);
/**
* 根据工序获取终点区域
*/
Map<String,Object> getEndAareaByworkprocedureId(String workprocedure_id);
/**
* 出库工序下拉
* @return
*/
List<WorkprocedureDto> queryWorkprocedure();
/**
* 根据选择工序查询上一工序
* @param param
* @return
*/
Map<String, Object> getIvtWorkprocedureId(JSONObject param);
}

View File

@@ -0,0 +1,55 @@
package org.nl.wms.st.out.service.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @description /
* @author geng by
* @date 2022-04-12
**/
@Data
public class WorkprocedureDto implements Serializable {
/** 工序标识 */
/** 防止精度丢失 */
@JsonSerialize(using= ToStringSerializer.class)
private Long workprocedure_id;
/** 工序编码 */
private String workprocedure_code;
/** 工序名称 */
private String workprocedure_name;
/** 工序顺序 */
private BigDecimal seq_no;
/** 是否启用 */
private String is_used;
/** 创建人 */
private Long create_id;
/** 创建人姓名 */
private String create_name;
/** 创建时间 */
private String create_time;
/** 修改人 */
private Long update_optid;
/** 修改人姓名 */
private String update_optname;
/** 修改时间 */
private String update_time;
/** 是否删除 */
private String is_delete;
}

View File

@@ -0,0 +1,362 @@
package org.nl.wms.st.out.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.wms.sch.tasks.CallMaterialTask;
import org.nl.wms.st.in.AreaEnum;
import org.nl.wms.st.in.BussConstant;
import org.nl.wms.st.in.WorkProcedureEnum;
import org.nl.wms.st.in.service.dto.WorkprocedureiosDto;
import org.nl.wms.st.out.service.WorkprocedureiosOutService;
import org.nl.wms.st.out.service.dto.WorkprocedureDto;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.ResultBean;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.util.WqlUtil;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
* @author geng by
* @description 服务实现
* @date 2022-04-21
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class WorkprocedureiosServiceOutImpl implements WorkprocedureiosOutService {
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String search = MapUtil.getStr(whereJson, "search");
JSONObject map = new JSONObject();
map.put("flag", "1");
if (ObjectUtil.isNotEmpty(search)) {
map.put("search", "%" + search + "%");
}
JSONObject json = WQL.getWO("ST_WorkprocedureiosOut_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "a.create_time desc");
return json;
}
@Override
public List<WorkprocedureiosDto> queryAll(Map whereJson) {
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONArray arr = wo.query().getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(WorkprocedureiosDto.class);
return null;
}
@Override
public WorkprocedureiosDto findById(Long iostorinv_id) {
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject json = wo.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(WorkprocedureiosDto.class);
}
return null;
}
@Override
public WorkprocedureiosDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(WorkprocedureiosDto.class);
}
return null;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(WorkprocedureiosDto dto) {
String bill_code = CodeUtil.getNewCode("OUT_STORE_CODE");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
dto.setIostorinv_id(IdUtil.getSnowflake(1, 1).nextId());
dto.setBill_code(bill_code);
dto.setIo_type("1");
dto.setBill_status("10");
Map<String, Object> endMap = this.getEndAareaByworkprocedureId(dto.getWorkprocedure_id().toString());
String start_area = dto.getEnd_point_code();
if (StrUtil.isEmpty(start_area)) {
String startArea = MapUtil.getStr(endMap, "start_area");
if (StrUtil.isEmpty(startArea)) {
throw new BadRequestException("起始区域为空,枚举中未查到工序对应区域!");
}
dto.setStart_area(startArea);
}
Long qty_unit_id = dto.getQty_unit_id();
if (ObjectUtil.isNull(qty_unit_id)) {
String unit_id = MapUtil.getStr(endMap, "qty_unit_id");
if (StrUtil.isEmpty(unit_id)) {
throw new BadRequestException("数量单位为空,枚举中未查到工序对应区域!");
}
qty_unit_id = Long.valueOf(unit_id);
dto.setQty_unit_id(qty_unit_id);
}
dto.setCreate_mode("01");
dto.setCreate_id(currentUserId);
dto.setCreate_name(nickName);
dto.setUpdate_optid(currentUserId);
dto.setUpdate_optname(nickName);
dto.setUpdate_time(now);
dto.setCreate_time(now);
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
wo.insert(json);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(WorkprocedureiosDto dto) {
WorkprocedureiosDto entity = this.findById(dto.getIostorinv_id());
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
dto.setBill_status("10");
Map<String, Object> endMap = this.getEndAareaByworkprocedureId(dto.getWorkprocedure_id().toString());
String start_area = dto.getEnd_point_code();
if (StrUtil.isEmpty(start_area)) {
String startArea = MapUtil.getStr(endMap, "start_area");
if (StrUtil.isEmpty(startArea)) {
throw new BadRequestException("起始区域为空,枚举中未查到工序对应区域!");
}
dto.setStart_area(startArea);
}
Long qty_unit_id = dto.getQty_unit_id();
if (ObjectUtil.isNull(qty_unit_id)) {
String unit_id = MapUtil.getStr(endMap, "qty_unit_id");
if (StrUtil.isEmpty(unit_id)) {
throw new BadRequestException("数量单位为空,枚举中未查到工序对应区域!");
}
qty_unit_id = Long.valueOf(unit_id);
dto.setQty_unit_id(qty_unit_id);
}
dto.setUpdate_time(now);
dto.setUpdate_optid(currentUserId);
dto.setUpdate_optname(nickName);
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
wo.update(json);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(Long[] ids) {
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
for (Long iostorinv_id : ids) {
JSONObject param = new JSONObject();
param.put("is_delete", "1");
param.put("update_optid", currentUserId);
param.put("update_optname", nickName);
param.put("update_time", now);
wo.update(param, "iostorinv_id = '" + iostorinv_id + "'");
}
}
@Override
public JSONArray getBillTypes() {
WQLObject wo = WQLObject.getWQLObject("sys_dict_detail");
JSONArray arr = wo.query(" name = 'ST_INV_TYPE' and value like '01%'").getResultJSONArray(0);
return arr;
}
@Override
public JSONArray selectEndPoint(String workprocedureid) {
/*WQLObject woDevice = WQLObject.getWQLObject("pdm_base_device");*/
JSONArray arrPoint = new JSONArray();
WQLObject woPoint = WQLObject.getWQLObject("sch_base_point");
if (StrUtil.equals(workprocedureid, WorkProcedureEnum.CCGX.getId())) {
arrPoint = woPoint.query("is_used='1' and is_delete='0' and area_type ='KQ006'").getResultJSONArray(0);
return arrPoint;
}
//包装工序
if (StrUtil.equals(workprocedureid, WorkProcedureEnum.BZGX.getId())) {
arrPoint = woPoint.query("is_used='1' and is_delete='0' and area_type ='KQ006'").getResultJSONArray(0);
return arrPoint;
}
//清洗工序
if (StrUtil.equals(workprocedureid, WorkProcedureEnum.QXGX.getId())) {
}
/* for (int i = 0; i < arrDevice.size(); i++) {
JSONObject jsonDevice = arrDevice.getJSONObject(i);
JSONArray arrPoints = woPoint.query("is_delete = '0' and device_point_type = '01' and device_id = '" + jsonDevice.getString("device_id") + "'").getResultJSONArray(0);
for (int j = 0; j < arrPoints.size(); j++) {
JSONObject jsonPoint = arrPoints.getJSONObject(j);
arrPoint.add(jsonPoint);
}
}*/
return arrPoint;
}
@Override
public JSONObject getStartArea(String start_point_code) {
WQLObject woPoint = WQLObject.getWQLObject("sch_base_point");
JSONObject arrDevice = woPoint.query("is_delete = '0' and point_code = '" + start_point_code + "'").uniqueResult(0);
return arrDevice;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> getMaterial(Map whereJson, Pageable page) {
String where = "";
WQLObject wo = WQLObject.getWQLObject("MD_ME_Material");
String search = MapUtil.getStr(whereJson, "search");
if (!StrUtil.isEmpty(search)) {
where = " AND (material_code like '%" + search + "%' OR material_name like '%" + search + "%' ) ";
}
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "is_delete= '0'" + where, "update_time desc");
final JSONObject json = rb.pageResult();
return json;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void genTask(JSONObject taskJson) {
String iostorinv_id = taskJson.getString("iostorinv_id");
WQLObject wo = WQLObject.getWQLObject("st_ivt_workprocedureios");
JSONObject jsonObject = wo.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
//请求参数 载具、起点 物料,数量,客户,批次,创建方式不能为空! 终点可以不为空时,入库单据编号不能为空
JSONObject form = new JSONObject();
String next_point_code = jsonObject.getString("end_point_code");
String start_point_code = jsonObject.getString("start_point_code");
String vehicle_code = jsonObject.getString("vehicle_code");
String material_id = jsonObject.getString("material_id");
String cust_id = jsonObject.getString("cust_id");
String pcsn = jsonObject.getString("pcsn");
String is_full = jsonObject.getString("is_full");
String ivt_workprocedure_id = jsonObject.getString("ivt_workprocedure_id");
String create_mode = jsonObject.getString("create_mode");
form.put("start_point_code", start_point_code);
form.put("next_point_code", next_point_code);
form.put("vehicle_code", vehicle_code);
form.put("material_id", material_id);
form.put("cust_id", cust_id);
form.put("create_mode", create_mode);
form.put("pcsn", pcsn);
form.put("is_full", is_full);
form.put("ivt_workprocedure_id", ivt_workprocedure_id);
form.put("iostorinv_id", iostorinv_id);
CallMaterialTask callMaterialTask = new CallMaterialTask();
String task_id = callMaterialTask.createTask(form);
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("update_optid", SecurityUtils.getCurrentUserId());
json.put("update_optname", SecurityUtils.getNickName());
json.put("update_time", DateUtil.now());
json.put("bill_status", "20");
wo.update(json, "iostorinv_id = '" + iostorinv_id + "'");
}
@Override
public Map<String, Object> getStartPoint(Map whereJson, Pageable page) {
String material_id = MapUtil.getStr(whereJson, "material_id");
// String is_full = MapUtil.getStr(whereJson, "is_full");
String ivt_workprocedure_id = MapUtil.getStr(whereJson, "ivt_workprocedure_id");
JSONObject map = new JSONObject();
map.put("flag", "2");
map.put("material_id", material_id);
// map.put("is_full",is_full);
map.put("ivt_workprocedure_id", ivt_workprocedure_id);
JSONObject json = WQL.getWO("ST_WorkprocedureiosOut_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "structivt.pcsn desc");
return json;
}
@Override
public Map<String, Object> getEndAareaByworkprocedureId(String workprocedure_id) {
String startArea = "";
String qty_unit_id = "";
WorkProcedureEnum workProcedureEnum = WorkProcedureEnum.get(workprocedure_id);
// TODO
switch (workProcedureEnum) {
//包装工序
case CCGX:
startArea = AreaEnum.CPHJ.getCode();
qty_unit_id = BussConstant.YZ_OUT_QTY_UNIT_ID;
break;
//包装工序
case BZGX:
startArea = AreaEnum.CPHJ.getCode();
qty_unit_id = null;
break;
// 清洗工序
case QXGX:
startArea = AreaEnum.BCPHJ.getCode();
qty_unit_id = BussConstant.YZ_OUT_QTY_UNIT_ID;
break;
default:
startArea = null;
qty_unit_id = null;
break;
}
JSONObject map = new JSONObject();
map.put("start_area", startArea);
map.put("qty_unit_id", qty_unit_id);
return map;
}
@Override
public List<WorkprocedureDto> queryWorkprocedure() {
WQLObject wo = WQLObject.getWQLObject("pdm_base_workprocedure");
JSONArray arr = wo.query(" is_delete = '0' and workprocedure_id != '1514444198529601536'").getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(WorkprocedureDto.class);
return null;
}
@Override
public Map<String, Object> getIvtWorkprocedureId(JSONObject param) {
String ivt_workprocedure_id = "";
WorkProcedureEnum workProcedureEnum = WorkProcedureEnum.get(param.getString("workprocedureid"));
// TODO
switch (workProcedureEnum) {
case BZGX:
ivt_workprocedure_id = WorkProcedureEnum.BZGX.getId();
break;
case QXGX:
ivt_workprocedure_id = WorkProcedureEnum.QXGX.getId();
break;
}
JSONObject map = new JSONObject();
map.put("ivt_workprocedure_id", ivt_workprocedure_id);
return map;
}
}

View File

@@ -0,0 +1,101 @@
[交易说明]
交易名: 工序出库单分页查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.search TYPEAS s_string
输入.material_id TYPEAS s_string
输入.is_full TYPEAS s_string
输入.ivt_workprocedure_id TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT
a.*,
b.workprocedure_name,
c.material_name,
p1.point_name AS start_point_name,
p2.point_name AS end_point_name,
unit.unit_name
FROM
ST_IVT_workProcedureIOS a
LEFT JOIN pdm_bi_workprocedure b ON a.workprocedure_id = b.workprocedure_id
LEFT JOIN md_me_materialbase c ON c.material_id = a.material_id
LEFT JOIN sch_base_point p1 ON a.start_point_code = p1.point_code
LEFT JOIN sch_base_point p2 ON a.end_point_code = p2.point_code
LEFT JOIN md_pb_measureunit unit ON a.qty_unit_id = unit.measure_unit_id
WHERE
a.is_delete = '0'
AND a.io_type = '1'
OPTION 输入.search <> ""
a.bill_code like 输入.search
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "2"
PAGEQUERY
SELECT
point.*,
material.material_id,
material.material_name,
point.vehicle_code AS vehicle_code111,
structivt.pcsn,
structivt.canuse_qty,
structivt.frozen_qty,
structivt.ivt_qty,
structivt.warehousing_qty,
structivt.qty_unit_id,
structivt.instorage_time,
unit.unit_name
FROM
st_ivt_structivt structivt
LEFT JOIN sch_base_point point ON point.point_id = structivt.struct_id
LEFT JOIN md_me_materialbase material ON structivt.material_id = material.material_id
LEFT JOIN md_pb_measureunit unit ON structivt.qty_unit_id = unit.measure_unit_id
WHERE
point.is_delete = '0'
AND point.lock_type = '00'
AND structivt.canuse_qty > 0
AND point.is_used = '1'
and structivt.workprocedure_id = 输入.ivt_workprocedure_id
and structivt.material_id = 输入.material_id
ENDSELECT
ENDPAGEQUERY
ENDIF