rev:接口联调
This commit is contained in:
@@ -20,11 +20,11 @@ import java.util.stream.Collectors;
|
||||
public enum AcsTaskEnum {
|
||||
UNDEFINED("0","未定义类型"),
|
||||
//任务类型:3个点,任务编号,无需载具
|
||||
TASK_PRODUCT_MAC("1","专机-专机任务"),
|
||||
TASK_PRODUCT_MAC("1","专机-专机满料任务"),
|
||||
//3个点,任务编号,缓存线空载具列表
|
||||
TASK_PRODUCT_CACHE("2","专机-缓存线任务"),
|
||||
TASK_PRODUCT_CACHE("2","专机-缓存线满料任务"),
|
||||
//3个点,任务编号,缓存线满料载具列表
|
||||
TASK_CACHELINE_OUT("3","缓存线出库任务"),
|
||||
TASK_CACHELINE_OUT("3","缓存线-专机出库任务"),
|
||||
|
||||
//回调状态
|
||||
STATUS_START("1","执行中"),
|
||||
@@ -33,6 +33,10 @@ public enum AcsTaskEnum {
|
||||
//专机请求
|
||||
REQUEST_CALLTYPE_FULL("1","满料请求"),
|
||||
REQUEST_CALLTYPE_EMP("2","缺料请求"),
|
||||
|
||||
//
|
||||
ACSSYSTEM_NB("1","诺宝机器人任务"),
|
||||
ACSSYSTEM_XC("1","叉车任务"),
|
||||
;
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
@@ -46,6 +46,13 @@ public enum StatusEnum {
|
||||
//出入料箱
|
||||
PAUSE_CACHELINE("1","暂停",""),
|
||||
START_CACHELINE("2","启动",""),
|
||||
|
||||
//设备状态枚举1-关机、2-开机、3-生产中、4-待机、5-故障
|
||||
DEVICE_STATUS_OFF("1","启动",""),
|
||||
DEVICE_STATUS_ON("2","启动",""),
|
||||
DEVICE_STATUS_RUNING("3","启动",""),
|
||||
DEVICE_STATUS_WAITING("4","启动",""),
|
||||
DEVICE_STATUS_ERROR("5","启动",""),
|
||||
;
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
@@ -8,8 +8,13 @@ package org.nl.config;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@Data
|
||||
@@ -17,4 +22,15 @@ public class ESConfig {
|
||||
|
||||
@Value(("${es.index}"))
|
||||
private String index;
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
|
||||
@Bean
|
||||
public DataSourceTransactionManager transactionManager()
|
||||
{
|
||||
DataSourceTransactionManager transactionManager=new DataSourceTransactionManager(this.dataSource);
|
||||
|
||||
return transactionManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package org.nl.wms.ext.acs.rest;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -12,6 +13,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.api.ResultCode;
|
||||
import org.nl.modules.common.exception.BizCoreException;
|
||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||
import org.nl.wms.pda.service.CacheLineHandService;
|
||||
import org.nl.wms.sch.tasks.SpeMachineryTask;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -31,12 +34,16 @@ import java.util.Map;
|
||||
@Api(tags = "acs接收wms")
|
||||
@RequestMapping("/api/acsToWms/task")
|
||||
@Slf4j
|
||||
|
||||
public class AcsToWmsController {
|
||||
private final AcsToWmsService acsToWmsService;
|
||||
private final SpeMachineryTask speMachineryTask;
|
||||
private final CacheLineHandService cacheLineHandService;
|
||||
|
||||
@PostMapping("/apply")
|
||||
@Log("ACS给WMS发送任务")
|
||||
@ApiOperation("ACS给WMS发送任务")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> receiveTaskFromAcs(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.apply(whereJson), HttpStatus.OK);
|
||||
}
|
||||
@@ -44,6 +51,7 @@ public class AcsToWmsController {
|
||||
@PostMapping("/receiveTaskIdToCacheLine")
|
||||
@Log("ACS给WMS发送缓存线的实时任务ID")
|
||||
@ApiOperation("ACS给WMS发送缓存线的实时任务ID")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> receiveTaskIdToCacheLine(@RequestBody JSONObject whereJson) {
|
||||
//参数校验
|
||||
if(StringUtils.isEmpty(whereJson.getString("task_id")) || StringUtils.isEmpty(whereJson.getString("position_code"))) {
|
||||
@@ -55,6 +63,7 @@ public class AcsToWmsController {
|
||||
@PostMapping("/status")
|
||||
@Log("ACS给WMS反馈任务状态")
|
||||
@ApiOperation("ACS给WMS反馈任务状态")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> receiveTaskStatusAcs(@RequestBody String string) {
|
||||
return new ResponseEntity<>(acsToWmsService.receiveTaskStatusAcs(string), HttpStatus.OK);
|
||||
}
|
||||
@@ -62,6 +71,7 @@ public class AcsToWmsController {
|
||||
@PostMapping("/orderStatus")
|
||||
@Log("ACS给WMS下发工单完成状态")
|
||||
@ApiOperation("ACS给WMS下发工单完成状态")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> orderFinish(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(acsToWmsService.orderStatus(param), HttpStatus.OK);
|
||||
}
|
||||
@@ -69,8 +79,9 @@ public class AcsToWmsController {
|
||||
@PostMapping("/feedDeviceStatusType")
|
||||
@Log("向wms反馈设备状态")
|
||||
@ApiOperation("向wms反馈设备状态")
|
||||
public ResponseEntity<Object> feedDeviceStatusType(@RequestBody String string) {
|
||||
return new ResponseEntity<>(acsToWmsService.feedDeviceStatusType(string), HttpStatus.OK);
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> feedDeviceStatusType(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(acsToWmsService.feedDeviceStatusType(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +89,8 @@ public class AcsToWmsController {
|
||||
@PostMapping("/feedDeviceQty")
|
||||
@Log("向wms反馈设备实时数量")
|
||||
@ApiOperation("向wms反馈设备实时数量")
|
||||
public ResponseEntity<Object> feedDeviceRealQty(@RequestBody List<JSONObject> param) {
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> feedDeviceRealQty(@RequestBody Map param) {
|
||||
acsToWmsService.feedDevQty(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@@ -86,6 +98,7 @@ public class AcsToWmsController {
|
||||
@PostMapping("/feedcachelineVe")
|
||||
@Log("向wms反馈缓存载具信息")
|
||||
@ApiOperation("向wms反馈缓存载具信息")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> feedcachelineVe(@RequestBody JSONObject param) {
|
||||
acsToWmsService.feedcachelineVe(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
@@ -95,8 +108,21 @@ public class AcsToWmsController {
|
||||
@PostMapping("/feedOrderRealQty")
|
||||
@Log("向wms反实施数量")
|
||||
@ApiOperation("向wms反订单实施数量")
|
||||
public ResponseEntity<Object> feedOrderRealQty(@RequestBody String string) {
|
||||
return new ResponseEntity<>(acsToWmsService.feedOrderRealQty(string), HttpStatus.OK);
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> feedOrderRealQty(@RequestBody JSONObject string) {
|
||||
acsToWmsService.feedOrderRealQty(string);
|
||||
return new ResponseEntity<>( HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/testDemo")
|
||||
@Log("向wms反实施数量")
|
||||
@ApiOperation("向wms反订单实施数量")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> test(@RequestBody JSONObject param) {
|
||||
cacheLineHandService.cacheLineMaterSync(param.getString("cacheline_code"));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.nl.wms.ext.acs.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AcsToWmsService {
|
||||
@@ -59,14 +58,14 @@ public interface AcsToWmsService {
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
void feedDevQty(List<JSONObject> param);
|
||||
void feedDevQty(Map param);
|
||||
|
||||
/**
|
||||
* ACS给WMS反馈设备状态状态
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> feedDeviceStatusType(String string);
|
||||
Map<String, Object> feedDeviceStatusType(JSONObject string);
|
||||
|
||||
/**
|
||||
* acs反馈缓存线载具对应关系
|
||||
@@ -80,5 +79,5 @@ public interface AcsToWmsService {
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> feedOrderRealQty(String string);
|
||||
void feedOrderRealQty(JSONObject string);
|
||||
}
|
||||
|
||||
@@ -1,36 +1,34 @@
|
||||
package org.nl.wms.ext.acs.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
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 org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.anno.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.AcsTaskEnum;
|
||||
import org.nl.common.enums.WorkerOrderEnum;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||
import org.nl.wms.pda.service.CacheLineHandService;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.nl.wms.sch.service.TaskService;
|
||||
import org.nl.wms.sch.service.dto.TaskDto;
|
||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@@ -44,7 +42,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
|
||||
@Autowired
|
||||
private CacheLineHandService cacheLineHandService;
|
||||
private final AgvInstService agvInstService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> apply(JSONObject jsonObject) {
|
||||
Map result = MapOf.of("status", HttpStatus.OK.value(), "message", "ACS向WMS申请任务成功!");
|
||||
@@ -173,31 +170,21 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
|
||||
public Map<String, Object> orderStatus(JSONObject orderJson) {
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
String ext_order_id = orderJson.getString("workorder_id");
|
||||
// JSONArray array = JSONArray.parseArray(string);
|
||||
//TODO: 表未维护
|
||||
String workorder_id = orderJson.getString("workorder_id");
|
||||
String order_status = orderJson.getString("status");
|
||||
String real_qty = orderJson.getString("real_qty");
|
||||
WQLObject wo = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("produceorder_id", ext_order_id);
|
||||
map.put("order_status", "04");
|
||||
map.put("update_optid", 1001001);
|
||||
map.put("device_id", "");
|
||||
map.put("update_optname", "acs");
|
||||
map.put("workorder_id", workorder_id);
|
||||
map.put("order_status", order_status);
|
||||
map.put("update_id", 1001001);
|
||||
map.put("real_qty", real_qty);
|
||||
map.put("current_device_code", "");
|
||||
map.put("update_name", "acs");
|
||||
map.put("update_time", DateUtil.now());
|
||||
map.put("realproduceend_date", DateUtil.now());
|
||||
wo.update(map, "produceorder_id = '" + ext_order_id + "'");
|
||||
JSONObject jsonObject = wo.query("produceorder_id = '" + ext_order_id + "'").uniqueResult(0);
|
||||
String real_qty = jsonObject.getString("real_qty");
|
||||
if (StrUtil.isEmpty(real_qty)){
|
||||
real_qty = "0";
|
||||
}
|
||||
//同时修改工单记录表中的期末数量及完成数量
|
||||
WQLObject wo_record = WQLObject.getWQLObject("MPS_BD_MacOperateRecord");
|
||||
JSONObject result1 = wo_record.query("produceorder_id = '" + ext_order_id + "' and (operatetime_end = '' or operatetime_end is null) ").uniqueResult(0);
|
||||
result1.put("finish_qty",real_qty);
|
||||
result1.put("finishproduct_qty",real_qty);
|
||||
result1.put("operatetime_end",DateUtil.now());
|
||||
wo_record.update(result1);
|
||||
wo.update(map, "workorder_id = '" + workorder_id + "'");
|
||||
|
||||
} catch (Exception e){
|
||||
result.put("status", 400);
|
||||
result.put("message", e.getMessage());
|
||||
@@ -209,57 +196,38 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> feedDeviceStatusType(String string) {
|
||||
@Transactional
|
||||
public Map<String, Object> feedDeviceStatusType(JSONObject param) {
|
||||
Assert.notNull(param, "请求参数不能为空");
|
||||
WQLObject devRecordTab = WQLObject.getWQLObject("PDM_BI_DeviceRunStatusRecord");
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
JSONObject param = JSONObject.parseObject(string);
|
||||
String device_code = param.getString("device_code");
|
||||
String status_type = param.getString("status_type");
|
||||
String start_time = param.getString("start_time");
|
||||
Integer error_code = Integer.parseInt(param.getString("error_code"));
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
JSONObject device_json = wo.query("is_delete = '0' and is_active = '1' and device_code = '" + device_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(device_json)) {
|
||||
String device_id = device_json.getString("device_id");
|
||||
WQLObject wo_status = WQLObject.getWQLObject("PDM_BI_DeviceRunStatusRecord");
|
||||
JSONObject status_json = wo_status.query("device_id = '" + device_id + "' and (end_time is null or end_time = '' )").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(status_json)) {
|
||||
status_json.put("end_time", start_time);
|
||||
wo_status.update(status_json);
|
||||
log.warn("上一次设备状态结束时间修改成功:{}",device_code);
|
||||
}
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("record_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
map.put("device_id", device_id);
|
||||
map.put("status_type", status_type);
|
||||
map.put("start_time", start_time);
|
||||
if (error_code > 0) {
|
||||
map.put("err_status_id", error_code);
|
||||
} else {
|
||||
map.put("err_status_id", null);
|
||||
}
|
||||
wo_status.insert(map);
|
||||
log.warn("设备状态新增成功{}",device_code);
|
||||
}
|
||||
} catch (Exception e){
|
||||
result.put("status", 400);
|
||||
result.put("message", e.getMessage());
|
||||
return result;
|
||||
String device_code = param.getString("device_code");
|
||||
Assert.notEmpty(device_code, "设备编号不能为空");
|
||||
String workorder_code = param.getString("workorder_code");
|
||||
String status_type = param.getString("status_type");
|
||||
String start_time = param.getString("start_time");
|
||||
String err_status_id = param.getString("err_status_id");
|
||||
JSONObject lastRecord = devRecordTab.query("device_code = '" + device_code + "' order by order_num desc limit 1").uniqueResult(0);
|
||||
if (lastRecord!=null){
|
||||
lastRecord.put("end_time",DateUtil.now());
|
||||
devRecordTab.update(lastRecord);
|
||||
}
|
||||
devRecordTab.insert(MapOf.of("record_id", IdUtil.getStringId(),"device_code",device_code,"status_type",status_type,"start_time",start_time,"err_status_id",err_status_id));
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "设备状态反馈成功");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void feedDevQty(List<JSONObject> param) {
|
||||
public void feedDevQty(Map param) {
|
||||
WQLObject deviceTab = WQLObject.getWQLObject("pdm_bi_device");
|
||||
if (CollectionUtils.isEmpty(param)){
|
||||
return;
|
||||
}
|
||||
for (JSONObject item : param) {
|
||||
String deviceCode = item.getString("device_code");
|
||||
String qty = item.getString("qty");
|
||||
Iterator iterator = param.keySet().iterator();
|
||||
while (iterator.hasNext()){
|
||||
String deviceCode = (String)iterator.next();
|
||||
String qty = String.valueOf(param.get(deviceCode));
|
||||
deviceTab.update(MapOf.of("deviceinstor_qty",qty),"device_code = '"+deviceCode+"'");
|
||||
}
|
||||
}
|
||||
@@ -267,45 +235,38 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
|
||||
@Override
|
||||
public void feedcachelineVe(JSONObject param) {
|
||||
WQLObject positionTab = WQLObject.getWQLObject("sch_cacheline_position");
|
||||
//{""cacheline_code":"xxx","param":"01_zj001,02_zj002,...""}
|
||||
if (param == null|| StringUtils.isEmpty(param.getString("cacheline_code")) || StringUtils.isEmpty(param.getString("param"))){
|
||||
if (param == null|| StringUtils.isEmpty(param.getString("device_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))){
|
||||
return;
|
||||
}
|
||||
String cachelineCode = param.getString("cacheline_code");
|
||||
String cacheVehicle = param.getString("param");
|
||||
String cachelineCode = param.getString("device_code");
|
||||
String cacheVehicle = param.getString("vehicle_code");
|
||||
String[] collect = cacheVehicle.split(",");
|
||||
for (String positionVehicle : collect) {
|
||||
String[] s = positionVehicle.split("_");
|
||||
positionTab.update(MapOf.of("position_code",s[0],"Vehicle_code",s[1]),"cacheline_code = '"+cachelineCode+"'");
|
||||
//order by layer_num,order_no ASC
|
||||
JSONArray cachePositions = positionTab.query("cacheLine_code = '" + cachelineCode + "' order by layer_num,order_no ASC").getResultJSONArray(0);
|
||||
if (cachePositions.size() != collect.length){
|
||||
throw new BadRequestException("缓存线位置数量与acs返回数量不一致");
|
||||
}
|
||||
for (int i = 0; i < cachePositions.size(); i++) {
|
||||
JSONObject cachePosition = (JSONObject) cachePositions.get(i);
|
||||
cachePosition.put("vehicle_code",collect[i].equals("0")?"":collect[i]);
|
||||
positionTab.update(cachePosition,"position_code = '"+cachePosition.getString("position_code")+"'");
|
||||
}
|
||||
//更新缓存线及缓存线载具表对应关系
|
||||
cacheLineHandService.cacheLineMaterSync(param.getString("cacheline_code"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> feedOrderRealQty(String string) {
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
try {
|
||||
JSONObject param = JSONObject.parseObject(string);
|
||||
String order_code = param.getString("order");
|
||||
String real_qty = param.getString("real_qty");
|
||||
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
|
||||
JSONObject jsonObject = wo.query("produceorder_code = '" + order_code + "'").uniqueResult(0);
|
||||
String report_qty = jsonObject.getString("report_qty");
|
||||
int i = Integer.parseInt(report_qty);
|
||||
int j = Integer.parseInt(real_qty);
|
||||
int k = i + j;
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("real_qty", k);
|
||||
wo.update(map, "produceorder_code = '" + order_code + "' and order_status != '04'");
|
||||
} catch (Exception e){
|
||||
result.put("status", 400);
|
||||
result.put("message", e.getMessage());
|
||||
public void feedOrderRealQty(JSONObject param) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
|
||||
if (CollectionUtils.isEmpty(param)){
|
||||
return;
|
||||
}
|
||||
Iterator<String> iterator = param.keySet().iterator();
|
||||
while (iterator.hasNext()){
|
||||
String workorder_id = iterator.next();
|
||||
String real_qty = param.getString(workorder_id);
|
||||
wo.update(MapOf.of("real_qty",real_qty),"workorder_id = '"+workorder_id+"'");
|
||||
}
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "设备状态反馈成功");
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.nl.wms.ext.acs.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -13,9 +16,26 @@ import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.utils.PointLockUtils;
|
||||
import org.nl.wms.sch.tasks.SpeMachineryTask;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RReadWriteLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
import org.springframework.transaction.support.DefaultTransactionStatus;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
@@ -31,6 +51,11 @@ public class AgvInstService {
|
||||
|
||||
@Autowired
|
||||
private PointLockUtils pointLockUtils;
|
||||
@Autowired
|
||||
private PlatformTransactionManager transactionManager;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
//满料请求
|
||||
//1.判断当前设备路由表是否配置下一道路由设备,如果不是则说明直接到清洗
|
||||
//2.是否设置人工搬运(人工搬运之后维护设备状态)
|
||||
@@ -45,10 +70,10 @@ public class AgvInstService {
|
||||
WQLObject cacheLineSearch = WQLObject.getWQLObject("SCH_cacheLine_region_relation");
|
||||
try {
|
||||
String workorder = param.getString("workorder_code");//
|
||||
String point_code = param.getString("point_code");
|
||||
String point_code = param.getString("device_code");
|
||||
String quantity = param.getString("quantity");
|
||||
//1.PDM_produce_workOrder
|
||||
JSONObject order = workOrder.query("workorder_code = '" + workorder + "' and is_delete = 0 and status != "+StatusEnum.TASK_FINISH.getCode()).uniqueResult(0);
|
||||
JSONObject order = workOrder.query("workorder_code = '" + workorder + "' and is_delete = 0 and workorder_status != "+StatusEnum.TASK_FINISH.getCode()).uniqueResult(0);
|
||||
if (order==null){
|
||||
throw new BadRequestException("下发工单不存在未完成工单:"+workorder);
|
||||
}
|
||||
@@ -56,16 +81,16 @@ public class AgvInstService {
|
||||
String materialprocessSeries = order.getString("materialprocess_series");
|
||||
|
||||
String taskType = AcsTaskEnum.TASK_PRODUCT_MAC.getCode();
|
||||
if (StatusEnum.STATUS_TRUE.equals(needMove)){
|
||||
if (StatusEnum.STATUS_TRUE.getCode().equals(needMove)){
|
||||
JSONObject devicePoint = basePoint.query("point_code = '" + point_code + "' and is_delete = 0 and is_used = 1").uniqueResult(0);
|
||||
JSONObject empPoint = WQL.getWO("sch_point").addParamMap(MapOf.of("flag", "2", "point_code", point_code, "point_type", StatusEnum.POINT_LOCATION_EMP.getCode())).process().uniqueResult(0);
|
||||
|
||||
String nextPoint = null;
|
||||
//2.进行终点判断
|
||||
JSONArray nextPointList = WQL.getWO("sch_point").addParamMap(MapOf.of("region_code", devicePoint.getString("next_regin_code"),"qty",quantity)).process().getResultJSONArray(0);
|
||||
JSONArray nextPointList = WQL.getWO("sch_point").addParamMap(MapOf.of("flag","3","region_code", devicePoint.getString("next_region_code"),"qty",quantity)).process().getResultJSONArray(0);
|
||||
if (nextPointList.size()>0){
|
||||
//判断缓存线是不是去深坑清洗
|
||||
if (devicePoint.getString("next_regin_code").equals(ConstantParam.SK_REGION)){
|
||||
if (devicePoint.getString("next_region_code").equals(ConstantParam.SK_REGION)){
|
||||
String deviceSql = nextPointList.stream().map(a -> ((JSONObject) a).getString("device_code")).collect(Collectors.joining("','"));
|
||||
JSONArray runDevs = WQL.getWO("sch_point").addParamMap(MapOf.of("flag","4", "device_code","'"+deviceSql+"'")).process().getResultJSONArray(0);
|
||||
if (runDevs.size()>0){
|
||||
@@ -80,8 +105,8 @@ public class AgvInstService {
|
||||
String cacheVehile = "";
|
||||
//根据区域物料对应关系查询缓存线
|
||||
if (StringUtils.isEmpty(nextPoint)){
|
||||
JSONObject cacheLine = cacheLineSearch.query("materialprocess_series = '"+materialprocessSeries+"' and region_code = '"+devicePoint.getString("regin_code")+"'").uniqueResult(0);
|
||||
nextPoint = cacheLine.getString("cacheLine_code");
|
||||
JSONObject cacheLine = cacheLineSearch.query("region_code = '"+devicePoint.getString("region_code")+"'").uniqueResult(0);
|
||||
nextPoint = cacheLine.getString("cacheline_code");
|
||||
//满料请求:查询缓存线空载具列表
|
||||
cacheVehile = getCacheVehile(nextPoint, null);
|
||||
if (StringUtils.isEmpty(cacheVehile)) {
|
||||
@@ -92,8 +117,8 @@ public class AgvInstService {
|
||||
|
||||
//生成任务nextPoint
|
||||
SpeMachineryTask pointTask = new SpeMachineryTask();
|
||||
JSONObject taskForm = new JSONObject(MapOf.of("start_device_code",point_code,
|
||||
"next_device_code",nextPoint,"return_device_code", empPoint.getString("point_code"),"vehicle_code",
|
||||
JSONObject taskForm = new JSONObject(MapOf.of("start_point_code",point_code,
|
||||
"next_point_code",nextPoint,"return_point_code", empPoint.getString("point_code"),"vehicle_code",
|
||||
cacheVehile,"quantity", quantity,"product_area",devicePoint.getString("product_area"),"type",taskType));
|
||||
String taskId = pointTask.createTask(taskForm);
|
||||
log.info(OPT_NAME+"fullMaster taskID:{}",taskId);
|
||||
@@ -109,34 +134,44 @@ public class AgvInstService {
|
||||
//3.agv根据对应载具列表行进扫码匹配:匹配到对应物料则创建点对点任务
|
||||
public void callMatter(JSONObject param){
|
||||
log.info(OPT_NAME+"callMatter param:{}",JSONObject.toJSONString(param));
|
||||
|
||||
WQLObject basePoint = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject workOrder = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
WQLObject cacheLineSearch = WQLObject.getWQLObject("SCH_cacheLine_region_relation");
|
||||
WQLObject basePointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject workOrderTable = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
WQLObject cacheLineTable = WQLObject.getWQLObject("SCH_cacheLine_region_relation");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("SCH_base_task");
|
||||
//参数
|
||||
String point_code = param.getString("point_code");
|
||||
String point_code = param.getString("device_code");
|
||||
String workorder = param.getString("workorder_code");
|
||||
|
||||
JSONObject devicePoint = basePoint.query("point_code = '" + point_code + "' and is_delete = 0 and is_used = 1").uniqueResult(0);
|
||||
JSONObject order = workOrder.query("workorder_code = '" + workorder + "' and is_delete = 0 and status != "+StatusEnum.TASK_FINISH.getCode()).uniqueResult(0);
|
||||
|
||||
JSONObject devicePoint = basePointTable.query("point_code = '" + point_code + "' and is_delete = 0 and is_used = 1").uniqueResult(0);
|
||||
JSONObject order = workOrderTable.query("workorder_code = '" + workorder + "' and is_delete = 0 and workorder_status != "+StatusEnum.TASK_FINISH.getCode()).uniqueResult(0);
|
||||
Assert.notNull(devicePoint, String.format("点位%s对应点位信息不存在", point_code));
|
||||
if (order == null){
|
||||
return;
|
||||
}
|
||||
String material_id = order.getString("material_id");
|
||||
try {
|
||||
JSONObject cacheLine = cacheLineSearch.query("materialprocess_series = '"+order.getString("materialprocess_series")+"' and region_code = '"+devicePoint.getString("regin_code")+"'").uniqueResult(0);
|
||||
|
||||
if (cacheLine != null){
|
||||
//缓存线位置编码 :缺料请求获取缓存线满载具列表
|
||||
String startPoint = cacheLine.getString("cacheLine_code");
|
||||
String cacheVehile = getCacheVehile(startPoint, null);
|
||||
if (StringUtils.isEmpty(cacheVehile)) {
|
||||
throw new BadRequestException("缓存线:"+startPoint+"没有可用空载具");
|
||||
}
|
||||
SpeMachineryTask pointTask = new SpeMachineryTask();
|
||||
JSONObject taskForm = new JSONObject(MapOf.of("start_device_code",startPoint,
|
||||
"next_device_code",point_code,"return_device_code", startPoint,"vehicle_code",
|
||||
cacheVehile,"product_area",devicePoint.getString("product_area"),"type",AcsTaskEnum.TASK_CACHELINE_OUT.getCode()));
|
||||
String taskId = pointTask.createTask(taskForm);
|
||||
log.info(OPT_NAME+"callMatter taskID:{}",taskId);
|
||||
JSONObject cacheLine = cacheLineTable.query("region_code = '"+devicePoint.getString("region_code")+"' and is_active = '"+StatusEnum.STATUS_TRUE.getCode()+"'").uniqueResult(0);
|
||||
Assert.notNull(cacheLine, String.format("区域%s对应缓存线信息不存在", devicePoint.getString("region_code")));
|
||||
//缓存线位置编码 :缺料请求获取缓存线满载具列表
|
||||
String startPoint = cacheLine.getString("cacheline_code");
|
||||
String cacheVehile = getCacheVehile(startPoint, material_id);
|
||||
if (StringUtils.isEmpty(cacheVehile)) {
|
||||
throw new BadRequestException("缓存线:"+startPoint+"没有可用载具");
|
||||
}
|
||||
//判断当前物料载具已经任务分配数量:如果>物料已经分配任务。说明满了,不允许再分配
|
||||
|
||||
JSONArray allocateTask = taskTable.query("point_code1 = '" + startPoint + "' and material_id = '" + material_id + "' and task_status <" + StatusEnum.TASK_FINISH.getCode()).getResultJSONArray(0);
|
||||
if (allocateTask.size()>=cacheVehile.split(",").length){
|
||||
log.error(OPT_NAME+"callMatter 缓存线:{}上含有物料:{}的载具分配完,任务id:{}",startPoint,material_id,allocateTask.stream().map(o-> ((JSONObject)o).getString("task_id")).collect(Collectors.joining(",")));
|
||||
throw new BadRequestException(String.format("缓存线%s上含物料%s的载具已分配完",startPoint,material_id));
|
||||
}
|
||||
SpeMachineryTask pointTask = new SpeMachineryTask();
|
||||
JSONObject taskForm = new JSONObject(MapOf.of("start_point_code",startPoint,
|
||||
"next_point_code",point_code,"return_point_code", startPoint,"vehicle_code",
|
||||
cacheVehile,"product_area",devicePoint.getString("product_area"),"type",AcsTaskEnum.TASK_CACHELINE_OUT.getCode(),"material_id", material_id));
|
||||
String taskId = pointTask.createTask(taskForm);
|
||||
log.info(OPT_NAME+"callMatter taskID:{}",taskId);
|
||||
|
||||
}catch (Exception ex){
|
||||
log.error(OPT_NAME+"callMatter error:{}",ex);
|
||||
throw ex;
|
||||
@@ -144,16 +179,11 @@ public class AgvInstService {
|
||||
}
|
||||
|
||||
public String getCacheVehile(String cacheLine,String materialId){
|
||||
WQLObject cacheLineVehile = WQLObject.getWQLObject("SCH_CacheLine_VehileMaterial");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
StringBuffer sql = new StringBuffer("vehicle_status = '");
|
||||
JSONArray runingTask = taskTable.query("point_code2 = " + cacheLine + "' and task_status < '" + StatusEnum.TASK_FINISH + "'").getResultJSONArray(0);
|
||||
if (StringUtils.isEmpty(materialId)){
|
||||
sql.append(StatusEnum.CACHE_VEL_EMT.getCode()).append("'");
|
||||
}else {
|
||||
sql.append(StatusEnum.CACHE_VEL_FULL.getCode()).append("'").append("material_id = '").append(materialId).append("'");
|
||||
}
|
||||
JSONArray result = cacheLineVehile.query(sql.toString()).getResultJSONArray(0);
|
||||
JSONArray runingTask = taskTable.query("point_code2 = '" + cacheLine + "' and task_status < '" + StatusEnum.TASK_FINISH.getCode() + "'").getResultJSONArray(0);
|
||||
String status = StringUtils.isEmpty(materialId) ? StatusEnum.CACHE_VEL_EMT.getCode() : StatusEnum.CACHE_VEL_FULL.getCode();
|
||||
JSONArray result = WQL.getWO("sch_point").addParamMap(MapOf.of("flag", "6", "vehicle_status", status, "material_id", materialId)).process().getResultJSONArray(0);
|
||||
if (result.size()>0){
|
||||
if (result.size()>runingTask.size()){
|
||||
return result.stream().map(a -> ((JSONObject) a).getString("vehicle_code")).collect(Collectors.joining(","));
|
||||
|
||||
@@ -36,7 +36,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService{
|
||||
form.add(param);
|
||||
}
|
||||
String api = "api/wms/task";
|
||||
return AcsUtil.notifyAcs(api, arr);
|
||||
return AcsUtil.notifyAcs(api, form);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,7 +64,6 @@ public class ProduceshiftorderController {
|
||||
@PostMapping("/saveReport")
|
||||
@Log("看板报工")
|
||||
@ApiOperation("看板报工")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:list')")
|
||||
public ResponseEntity<Object> saveReport(@RequestBody JSONObject param) {
|
||||
produceshiftorderService.saveReport(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
@@ -73,7 +72,6 @@ public class ProduceshiftorderController {
|
||||
@PostMapping("/finish")
|
||||
@Log("看板强制完成")
|
||||
@ApiOperation("看板强制完成")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:list')")
|
||||
public ResponseEntity<Object> finish(@RequestBody JSONObject param) {
|
||||
produceshiftorderService.finish(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.anno.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.WorkerOrderEnum;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
@@ -343,49 +345,18 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveReport(JSONObject param) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
final String report_qty = param.getString("report_qty");
|
||||
final JSONObject row = param.getJSONObject("row");
|
||||
final String produceorder_id = row.getString("produceorder_id");
|
||||
//报工时工单的工单状态为暂停,报工数量为这条工单上次加这次报工数量的和,也就是这条工单每次记录的和
|
||||
WQLObject wo = WQLObject.getWQLObject("MPS_BD_ProduceShiftOrder");
|
||||
JSONObject jsonObject = wo.query("produceorder_id = '" + produceorder_id + "'").uniqueResult(0);
|
||||
JSONObject produceorderMap = new JSONObject();
|
||||
produceorderMap.put("produceorder_id", produceorder_id);
|
||||
if (row.getString("report_qty").equals("0") || StrUtil.isEmpty(row.getString("report_qty"))) {
|
||||
produceorderMap.put("report_qty", report_qty);
|
||||
} else {
|
||||
Integer sum = Integer.parseInt(row.getString("report_qty")) + Integer.parseInt(report_qty);
|
||||
produceorderMap.put("report_qty", sum);
|
||||
}
|
||||
produceorderMap.put("order_status", "03");
|
||||
produceorderMap.put("update_optid", currentUserId);
|
||||
produceorderMap.put("update_optname", nickName);
|
||||
produceorderMap.put("update_time", DateUtil.now());
|
||||
wo.update(produceorderMap);
|
||||
//同时修改这条工单对应的记录表中最新的一条数据的报工数量
|
||||
WQLObject wo_record = WQLObject.getWQLObject("MPS_BD_MacOperateRecord");
|
||||
//获取最新的工单的对应记录信息
|
||||
JSONObject newRecord = wo_record.query("produceorder_id = '" + produceorder_id + "' and (operatetime_end is null or operatetime_end = '')").uniqueResult(0);
|
||||
newRecord.put("report_qty", report_qty);
|
||||
newRecord.put("finish_qty", jsonObject.getString("real_qty"));
|
||||
Integer finishproduct_qty = Integer.parseInt(jsonObject.getString("real_qty")) - Integer.parseInt(newRecord.getString("init_qty"));
|
||||
newRecord.put("finishproduct_qty", finishproduct_qty);
|
||||
newRecord.put("operatetime_end", DateUtil.now());
|
||||
wo_record.update(newRecord);
|
||||
//wms向acs发送请求 工单暂停
|
||||
// 报工的时候同时向acs发送工单暂停状态
|
||||
// TODO
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("ext_order_id", produceorder_id);
|
||||
map.put("type", "1");
|
||||
array.add(map);
|
||||
wmsToAcsService.orderStatusUpdate(array);
|
||||
String report_qty = param.getString("report_qty");
|
||||
String workorder_id = param.getString("workorder_id");
|
||||
wo.update(MapOf.of("workorder_status",WorkerOrderEnum.STOP.getCode(),"real_qty",report_qty,"update_id",currentUserId,"update_name",nickName),"workorder_id = '"+workorder_id+"'");
|
||||
//下发acs暂时
|
||||
JSONArray arr = new JSONArray();
|
||||
arr.add(MapOf.of("workorder_id",workorder_id,"status", WorkerOrderEnum.STOP.getCode()));
|
||||
wmsToAcsService.orderStatusUpdate(arr);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ public class CachelineVehileMaterialDto implements Serializable{
|
||||
/**
|
||||
* 缓存线编码
|
||||
*/
|
||||
private String cacheLine_code;
|
||||
private String cacheline_code;
|
||||
/**
|
||||
* 载具编码
|
||||
*/
|
||||
|
||||
@@ -258,7 +258,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(cacheLineVehilesSub)) {
|
||||
for(String vehileCode : cacheLineVehilesSub) {
|
||||
ivtTab.insert(MapOf.of("vehmaterial_id", IdUtil.getStringId(), "vehicle_code", vehileCode, "vehicle_status", StatusEnum.CACHE_VEL_ERR.getCode(), "cacheline_code", cachelineCode, "err_type", StatusEnum.STATUS_TRUE.getCode()));
|
||||
ivtTab.insert(MapOf.of("create_time",DateUtil.now(),"vehmaterial_id", IdUtil.getStringId(), "vehicle_code", vehileCode, "vehicle_status", StatusEnum.CACHE_VEL_ERR.getCode(), "cacheline_code", cachelineCode, "err_type", StatusEnum.STATUS_TRUE.getCode()));
|
||||
}
|
||||
}
|
||||
}, cachelineCode, 3);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.condition TYPEAS s_string
|
||||
输入.cacheLine_code TYPEAS s_string
|
||||
输入.cacheline_code TYPEAS s_string
|
||||
输入.product_area TYPEAS s_string
|
||||
输入.status TYPEAS s_string
|
||||
输入.inst_num TYPEAS s_string
|
||||
@@ -179,7 +179,7 @@
|
||||
IF 输入.flag = "8"
|
||||
QUERY
|
||||
SELECT
|
||||
sch_cacheline_position.cacheLine_code as wcsdevice_code,
|
||||
sch_cacheline_position.cacheline_code,
|
||||
sch_cacheline_position.position_code,
|
||||
sch_cacheline_position.position_name,
|
||||
sch_cacheline_position.vehicle_code,
|
||||
@@ -203,11 +203,11 @@
|
||||
OPTION 输入.product_area <> ""
|
||||
sch_cacheline_position.product_area = 输入.product_area
|
||||
ENDOPTION
|
||||
OPTION 输入.cacheLine_code <> ""
|
||||
sch_cacheline_position.cacheLine_code = 输入.cacheLine_code
|
||||
OPTION 输入.cacheline_code <> ""
|
||||
sch_cacheline_position.cacheline_code = 输入.cacheline_code
|
||||
ENDOPTION
|
||||
ORDER BY
|
||||
sch_cacheline_position.cacheLine_code
|
||||
sch_cacheline_position.cacheline_code
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
Binary file not shown.
@@ -11,11 +11,12 @@ import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -24,167 +25,175 @@ import java.util.Map;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SpeMachineryTask extends AbstractAcsTask{
|
||||
private final Map<String,SpeStatusHandler> SpeHandles = new HashMap<>();
|
||||
private static String OPT_NAME = "ACS回调# ";
|
||||
public class SpeMachineryTask extends AbstractAcsTask {
|
||||
private final Map<String,SpeStatusHandler > SpeHandles= new HashMap<>();
|
||||
private static String OPT_NAME = "ACS回调# ";
|
||||
|
||||
public SpeMachineryTask() {
|
||||
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_MAC.name(), new Spe2Spe());
|
||||
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_CACHE.name(), new Spe2Cache());
|
||||
SpeHandles.put(AcsTaskEnum.TASK_CACHELINE_OUT.name(), new Cache2Spe());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTaskStatus(JSONObject param, String status) {
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
log.info(InterfaceLogType.ACS_TO_LMS.getDesc());
|
||||
// 指令执行中
|
||||
JSONObject task = taskTable.query("task_id = '" + param.getString("task_id") + "'").uniqueResult(0);
|
||||
AcsTaskEnum taskType = AcsTaskEnum.getType(task.getString("task_type"), "TASK_");
|
||||
try {
|
||||
SpeHandles.get(taskType.name()).handle(param, status, task);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
log.error(OPT_NAME + "updateStatus error:{}", ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
public SpeMachineryTask() {
|
||||
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_MAC.name() ,new Spe2Spe());
|
||||
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_CACHE.name() ,new Spe2Cache());
|
||||
SpeHandles.put(AcsTaskEnum.TASK_CACHELINE_OUT.name() ,new Cache2Spe());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createTask(JSONObject form) {
|
||||
String start_point_code = form.getString("point_code1");
|
||||
String next_point_code = form.getString("point_code2");
|
||||
String vehicle_code = form.getString("vehicle_code");
|
||||
String type = form.getString("type");
|
||||
if(StrUtil.isEmpty(start_point_code)) {
|
||||
throw new BadRequestException("起点不能为空!");
|
||||
}
|
||||
if(StrUtil.isEmpty(next_point_code)) {
|
||||
throw new BadRequestException("终点不能为空!");
|
||||
}
|
||||
if(StrUtil.isEmpty(vehicle_code)) {
|
||||
throw new BadRequestException("载具不能为空!");
|
||||
}
|
||||
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("task_id", taskdtl_id);
|
||||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.put("task_type", type);
|
||||
task.put("task_status", "01");
|
||||
task.put("start_point_code", start_point_code);
|
||||
task.put("next_point_code", next_point_code);
|
||||
task.put("vehicle_code", vehicle_code);
|
||||
task.put("handle_class", this.getClass().getName());
|
||||
task.put("finished_type", "01");
|
||||
task.put("is_delete", "0");
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
task.put("create_id", currentUserId);
|
||||
task.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("update_optid", currentUserId);
|
||||
task.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
task.put("create_time", DateUtil.now());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("priority", "1");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
||||
return taskdtl_id;
|
||||
}
|
||||
@Override
|
||||
public void updateTaskStatus(JSONObject param,String status) {
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
log.info(InterfaceLogType.ACS_TO_LMS.getDesc());
|
||||
// 指令执行中
|
||||
JSONObject task = taskTable.query("task_id = '" + param.getString("taskId") + "'").uniqueResult(0);
|
||||
AcsTaskEnum taskType = AcsTaskEnum.getType(task.getString("task_type"),"TASK_");
|
||||
try {
|
||||
SpeHandles.get(taskType.name()).handle(param,status,task);
|
||||
}catch (Exception ex){
|
||||
log.error(OPT_NAME+"updateStatus error:{}",ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String taskId) {
|
||||
log.info(OPT_NAME + "cancel taskID:{}", taskId);
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
//专机-专机
|
||||
//专机-缓存线
|
||||
//缓存线出库
|
||||
taskTable.update(MapOf.of("task_status", StatusEnum.TASK_CANNEL.getCode()), "task_id = '" + taskId + "'");
|
||||
}
|
||||
|
||||
interface SpeStatusHandler{
|
||||
void handle(JSONObject param, String status, JSONObject task);
|
||||
}
|
||||
@Override
|
||||
public String createTask(JSONObject form) {
|
||||
String start_point_code = form.getString("start_point_code");
|
||||
String next_point_code = form.getString("next_point_code");
|
||||
String return_point_code = form.getString("return_point_code");
|
||||
String vehicle_code = form.getString("vehicle_code");
|
||||
String type = form.getString("type");
|
||||
if (StrUtil.isEmpty(start_point_code)) {
|
||||
throw new BadRequestException("起点不能为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(next_point_code)) {
|
||||
throw new BadRequestException("终点不能为空!");
|
||||
}
|
||||
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("task_id", taskdtl_id);
|
||||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.put("task_type", type);
|
||||
task.put("task_status", StatusEnum.TASK_CREATE.getCode());
|
||||
task.put("task_name", AcsTaskEnum.getType(type,"TASK_").getDesc());
|
||||
task.put("point_code1", start_point_code);
|
||||
task.put("point_code2", next_point_code);
|
||||
task.put("point_code3", return_point_code);
|
||||
task.put("asc_system_type", AcsTaskEnum.ACSSYSTEM_NB.getCode());
|
||||
task.put("vehicle_code", vehicle_code);
|
||||
task.put("handle_class", this.getClass().getName());
|
||||
task.put("finished_type", "01");
|
||||
task.put("is_delete", "0");
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
task.put("create_id", currentUserId);
|
||||
task.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("update_optid", currentUserId);
|
||||
task.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
task.put("create_time", DateUtil.now());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("priority", "1");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
||||
return taskdtl_id;
|
||||
}
|
||||
|
||||
class Spe2Spe implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta, JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta, "status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||
switch(status) {
|
||||
case STATUS_START:
|
||||
taskTable.update(MapOf.of("task_status", StatusEnum.TASK_RUNNING.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
|
||||
break;
|
||||
case STATUS_FINISH:
|
||||
taskTable.update(MapOf.of("task_status", StatusEnum.TASK_FINISH.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
|
||||
//到专机:更新设备上料位物料数量
|
||||
String point_code2 = task.getString("point_code2");
|
||||
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||
task.getDouble("material_qty");
|
||||
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||
break;
|
||||
default:
|
||||
log.error(OPT_NAME + "未定义任务状态:{}", sta);
|
||||
throw new BadRequestException(OPT_NAME + "未定义任务状态:" + sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Spe2Cache implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta, JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta, "status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
String workprocedureCode = param.getString("workorder_code");
|
||||
String inboxtxm = param.getString("inboxtxm");
|
||||
String outboxtxm = param.getString("outboxtxm");
|
||||
switch(status) {
|
||||
case STATUS_START:
|
||||
taskTable.update(MapOf.of("task_status", StatusEnum.TASK_RUNNING.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
case STATUS_FINISH:
|
||||
taskTable.update(MapOf.of("task_status", StatusEnum.TASK_FINISH.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
|
||||
cacheVehTable.insert(MapOf.of("quantity", task.getString("material_qty"), "material_id", task.getString("material_id"), "vehicle_code", inboxtxm, "vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode(),
|
||||
@Override
|
||||
public void cancel(String taskId) {
|
||||
log.info(OPT_NAME+"cancel taskID:{}",taskId);
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
//专机-专机
|
||||
//专机-缓存线
|
||||
//缓存线出库
|
||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_CANNEL.getCode()),"task_id = '"+taskId+"'");
|
||||
|
||||
}
|
||||
interface SpeStatusHandler{
|
||||
void handle(JSONObject param,String status,JSONObject task);
|
||||
}
|
||||
class Spe2Spe implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta,JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||
|
||||
switch (status){
|
||||
case STATUS_START:
|
||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||
break;
|
||||
case STATUS_FINISH:
|
||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_FINISH.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||
//到专机:更新设备上料位物料数量
|
||||
String point_code2 = task.getString("point_code2");
|
||||
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||
task.getDouble("material_qty");
|
||||
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||
break;
|
||||
default:
|
||||
log.error(OPT_NAME+"未定义任务状态:{}",sta);
|
||||
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
class Spe2Cache implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta,JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
String workprocedureCode = param.getString("workorder_code");
|
||||
String inboxtxm = param.getString("inboxtxm");
|
||||
String outboxtxm = param.getString("outboxtxm");
|
||||
switch (status){
|
||||
case STATUS_START:
|
||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
case STATUS_FINISH:
|
||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_FINISH.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||
cacheVehTable.insert(MapOf.of("quantity", task.getString("material_qty"),
|
||||
"material_id", task.getString("material_id"),
|
||||
"vehicle_code", inboxtxm,
|
||||
"vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode(),
|
||||
//工单,工序?
|
||||
"workorder_code", workprocedureCode, "create_time", DateUtil.now(), "update_time", DateUtil.now()
|
||||
"workorder_code", workprocedureCode,
|
||||
"create_time", DateUtil.now(),
|
||||
"update_time", DateUtil.now()
|
||||
//物料规格,物料名称 从物料信息表关联查询
|
||||
));
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException(OPT_NAME + "未定义任务状态:" + sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
));
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
class Cache2Spe implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta,JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||
String outboxtxm = param.getString("outboxtxm");
|
||||
|
||||
class Cache2Spe implements SpeStatusHandler{
|
||||
@Override
|
||||
public void handle(JSONObject param, String sta, JSONObject task) {
|
||||
AcsTaskEnum status = AcsTaskEnum.getType(sta, "status_");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||
String outboxtxm = param.getString("outboxtxm");
|
||||
switch(status) {
|
||||
case STATUS_START:
|
||||
taskTable.update(MapOf.of("task_status", StatusEnum.TASK_RUNNING.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
case STATUS_FINISH:
|
||||
taskTable.update(MapOf.of("task_status", StatusEnum.TASK_FINISH.getCode(), "update_name", "acs", "update_time", DateUtil.now()), "task_id = '" + task.getString("task_id") + "'");
|
||||
String point_code2 = task.getString("point_code2");
|
||||
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||
task.getDouble("material_qty");
|
||||
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException(OPT_NAME + "未定义任务状态:" + sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (status){
|
||||
case STATUS_START:
|
||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
case STATUS_FINISH:
|
||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_FINISH.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||
|
||||
String point_code2 = task.getString("point_code2");
|
||||
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||
task.getDouble("material_qty");
|
||||
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
dev.inupperlimit_qty - dev.deviceinstor_qty as deviceQty,
|
||||
FROM
|
||||
sch_cacheline_position
|
||||
LEFT JOIN pdm_bi_device dev ON sch_cacheline_position.cacheLine_code = dev.cacheLine_code
|
||||
LEFT JOIN pdm_bi_device dev ON sch_cacheline_position.cacheline_code = dev.cacheline_code
|
||||
LEFT JOIN MD_PB_StorageVehicleExt ON sch_cacheline_position.vehicle_code = MD_PB_StorageVehicleExt.storagevehicle_code
|
||||
WHERE
|
||||
dev.device_code = 输入.device_code
|
||||
|
||||
Binary file not shown.
@@ -17,13 +17,16 @@
|
||||
输入.search TYPEAS s_string
|
||||
输入.point_type TYPEAS s_string
|
||||
输入.area_type TYPEAS s_string
|
||||
输入.qty 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
|
||||
输入.vehicle_status TYPEAS s_string
|
||||
输入.device_code TYPEAS s_string
|
||||
输入.point_code TYPEAS s_string
|
||||
输入.region_code TYPEAS s_string
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
@@ -51,7 +54,7 @@
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
next_de.inupperlimit_qty - next_de.deviceinstor_qty - IFNULL( sum( material_qty ), 0 ) AS currentQty,
|
||||
next_de.cacheLine_code,
|
||||
next_de.cacheline_code,
|
||||
next.*
|
||||
FROM
|
||||
sch_base_point p
|
||||
@@ -60,9 +63,9 @@
|
||||
LEFT JOIN sch_base_task ON next.point_code = sch_base_task.point_code2 and next.product_area = sch_base_task.product_area
|
||||
WHERE
|
||||
p.device_code = 输入.device_code
|
||||
AND next_de.material_id = 输入.material_id;
|
||||
AND next_de.material_id = 输入.material_id
|
||||
AND sch_base_task.task_status < 7
|
||||
ENDSELECT
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -75,62 +78,83 @@
|
||||
sch_base_point a
|
||||
LEFT JOIN sch_base_point b ON a.device_code = b.device_code
|
||||
WHERE
|
||||
a.point_code = 输入.point_code;
|
||||
AND b.point_type = 输入.point_type;
|
||||
a.point_code = 输入.point_code
|
||||
AND b.point_type = 输入.point_type
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
pdm_bi_device.inupperlimit_qty - ifnull( sum( sch_base_task.material_qty ), 0 ) - pdm_bi_device.deviceinstor_qty AS currentQty,
|
||||
pdm_bi_device.device_code,
|
||||
sch_base_point.region_code,
|
||||
sch_base_point.point_code
|
||||
FROM
|
||||
sch_base_point
|
||||
LEFT JOIN pdm_bi_device ON sch_base_point.device_code = pdm_bi_device.device_code
|
||||
LEFT JOIN sch_base_task ON sch_base_point.point_code = point_code2 and task_status<7
|
||||
WHERE 1=1
|
||||
OPTION 输入.region_code <> ""
|
||||
ch_base_point.region_code = 输入.region_code
|
||||
ENDOPTION
|
||||
OPTION 输入.device_code <> ""
|
||||
ch_base_point.device_code = 输入.device_code
|
||||
ENDOPTION
|
||||
GROUP BY
|
||||
device_code
|
||||
HAVING currentQty> 输入.qty
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
IF 输入.flag = "3"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
pdm_bi_device.inupperlimit_qty - ifnull( sum( sch_base_task.material_qty ), 0 ) - pdm_bi_device.deviceinstor_qty AS currentQty,
|
||||
pdm_bi_device.device_code,
|
||||
sch_base_point.region_code,
|
||||
sch_base_point.point_code
|
||||
FROM
|
||||
sch_base_point
|
||||
LEFT JOIN pdm_bi_device ON sch_base_point.device_code = pdm_bi_device.device_code
|
||||
LEFT JOIN sch_base_task ON sch_base_point.point_code = point_code2 and task_status<7
|
||||
WHERE 1=1
|
||||
OPTION 输入.region_code <> ""
|
||||
sch_base_point.region_code = 输入.region_code
|
||||
ENDOPTION
|
||||
OPTION 输入.device_code <> ""
|
||||
sch_base_point.device_code = 输入.device_code
|
||||
ENDOPTION
|
||||
GROUP BY
|
||||
device_code
|
||||
HAVING currentQty> 输入.qty
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
( SELECT * FROM pdm_bi_devicerunstatusrecord
|
||||
where device_code in ( 输入.device_code )
|
||||
ORDER BY order_num DESC LIMIT 999999 ) a
|
||||
GROUP BY
|
||||
device_code
|
||||
HAVING status_type = '02'
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
IF 输入.flag = "4"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
( SELECT * FROM pdm_bi_devicerunstatusrecord
|
||||
where device_code in ( 输入.device_code )
|
||||
ORDER BY order_num DESC LIMIT 999999 ) a
|
||||
GROUP BY
|
||||
device_code
|
||||
HAVING status_type = '02'
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "5"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
sch_base_region.region_code,
|
||||
sch_base_point.point_code,
|
||||
GROUP_CONCAT(b.point_code) as pointCollent
|
||||
FROM
|
||||
sch_base_region
|
||||
LEFT JOIN sch_base_point ON sch_base_region.region_code = sch_base_point.region_code
|
||||
LEFT JOIN sch_base_point b ON sch_base_region.region_code = b.region_code AND b.point_code IN ( 输入.point_code )
|
||||
WHERE
|
||||
sch_base_region.MERGE = '1'
|
||||
AND sch_base_point.point_code IN ( 输入.point_code )
|
||||
GROUP BY sch_base_point.point_code
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "6"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
v.vehicle_code,v.vehicle_status,v.material_id
|
||||
FROM
|
||||
sch_cacheline_vehilematerial v
|
||||
LEFT JOIN sch_cacheline_position p ON p.vehicle_code = v.vehicle_code
|
||||
WHERE p.vehicle_code <> '' and
|
||||
v.vehicle_status = 输入.vehicle_status
|
||||
OPTION 输入.material_id <> ""
|
||||
v.material_id = 输入.material_id
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "5"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
sch_base_region.region_code,
|
||||
sch_base_point.point_code,
|
||||
GROUP_CONCAT(b.point_code) as pointCollent
|
||||
FROM
|
||||
sch_base_region
|
||||
LEFT JOIN sch_base_point ON sch_base_region.region_code = sch_base_point.region_code
|
||||
LEFT JOIN sch_base_point b ON sch_base_region.region_code = b.region_code AND b.point_code IN ( 输入.point_code )
|
||||
WHERE
|
||||
sch_base_region.MERGE = '1'
|
||||
AND sch_base_point.point_code IN ( 输入.point_code )
|
||||
GROUP BY sch_base_point.point_code;
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
Reference in New Issue
Block a user