Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -27,11 +27,10 @@ public enum AcsTaskEnum {
|
||||
TASK_CACHELINE_OUT("3","缓存线出库任务"),
|
||||
|
||||
//回调状态
|
||||
STATUS_START("1","开始取货"),
|
||||
STATUS_RUNDING("2","放货中"),
|
||||
STATUS_FINISH("3","完成"),
|
||||
STATUS_CANNEL("4","取消"),
|
||||
|
||||
STATUS_START("1","执行中"),
|
||||
STATUS_FINISH("2","完成"),
|
||||
STATUS_CANNEL("3","取消"),
|
||||
//专机请求
|
||||
REQUEST_CALLTYPE_FULL("1","满料请求"),
|
||||
REQUEST_CALLTYPE_EMP("2","缺料请求"),
|
||||
;
|
||||
|
||||
@@ -1,21 +1,93 @@
|
||||
package org.nl.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.common.DataTypeEnum;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class DataBaseConfig {
|
||||
@Value("${erp.oracle.enabled}")
|
||||
private boolean oracleIsConnect;
|
||||
@Value("${erp.oracle.jdbcurl}")
|
||||
private String oracleJdbcUrl;
|
||||
@Value("${erp.oracle.username}")
|
||||
private String oracleUserName;
|
||||
@Value("${erp.oracle.password}")
|
||||
private String oraclePassword;
|
||||
|
||||
@Primary
|
||||
@Bean(name = "dataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
||||
public DataSource dataSource() {
|
||||
return new DruidDataSource();
|
||||
}
|
||||
|
||||
@Bean(name = "dataSource1")
|
||||
@ConditionalOnExpression("${erp.oracle.enabled:true}")
|
||||
public DataSource dataSource1() {
|
||||
System.out.println("是否连接oracle:"+oracleIsConnect);
|
||||
System.out.println("erp.oracle.jdbcurl:"+oracleJdbcUrl);
|
||||
System.out.println("erp.oracle.username:"+oracleUserName);
|
||||
System.out.println("erp.oracle.password:"+oraclePassword);
|
||||
log.info("是否连接oracle:"+oracleIsConnect);
|
||||
log.info("erp.oracle.jdbcurl:"+oracleJdbcUrl);
|
||||
log.info("erp.oracle.username:"+oracleUserName);
|
||||
log.info("erp.oracle.password:"+oraclePassword);
|
||||
|
||||
String jdbcUrl = oracleJdbcUrl;
|
||||
String userName = oracleUserName;
|
||||
String password =oraclePassword;
|
||||
|
||||
DruidDataSource druidDataSource = new DruidDataSource();
|
||||
String className;
|
||||
try {
|
||||
className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("Get class name error: =" + jdbcUrl);
|
||||
}
|
||||
if (StrUtil.isEmpty(className)) {
|
||||
DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
|
||||
if (null == dataTypeEnum) {
|
||||
throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
|
||||
}
|
||||
druidDataSource.setDriverClassName(dataTypeEnum.getDriver());
|
||||
} else {
|
||||
druidDataSource.setDriverClassName(className);
|
||||
}
|
||||
|
||||
|
||||
druidDataSource.setUrl(jdbcUrl);
|
||||
druidDataSource.setUsername(userName);
|
||||
druidDataSource.setPassword(password);
|
||||
// 配置获取连接等待超时的时间
|
||||
druidDataSource.setMaxWait(3000);
|
||||
// 配置初始化大小、最小、最大
|
||||
druidDataSource.setInitialSize(5);
|
||||
druidDataSource.setMinIdle(5);
|
||||
druidDataSource.setMaxActive(10);
|
||||
|
||||
// 如果链接出现异常则直接判定为失败而不是一直重试
|
||||
druidDataSource.setBreakAfterAcquireFailure(true);
|
||||
try {
|
||||
druidDataSource.init();
|
||||
} catch (SQLException e) {
|
||||
log.error("Exception during pool initialization", e);
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
return druidDataSource;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.wms;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
@@ -17,6 +18,7 @@ import java.util.Map;
|
||||
* @author zds 2018-12-27 16:33:50
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class WebServiceUtil {
|
||||
/**
|
||||
*
|
||||
@@ -63,8 +65,8 @@ public class WebServiceUtil {
|
||||
int responseCode = connection.getResponseCode();
|
||||
String ret="默认值";
|
||||
|
||||
if(200 == responseCode){//表示服务端响应成功
|
||||
|
||||
if(200 == responseCode){//表示服务端响应成功
|
||||
log.info("请求成功!");
|
||||
//获取当前连接请求返回的数据流
|
||||
InputStream is = connection.getInputStream();
|
||||
|
||||
@@ -98,6 +100,7 @@ public class WebServiceUtil {
|
||||
connection.disconnect();
|
||||
}
|
||||
os.close();
|
||||
log.info("返回参数ret为:"+ret);
|
||||
return ret;
|
||||
// return result;
|
||||
}
|
||||
@@ -127,7 +130,7 @@ public class WebServiceUtil {
|
||||
sb.append("</urn:"+method+">");
|
||||
sb.append("</soapenv:Body>");
|
||||
sb.append("</soapenv:Envelope>");
|
||||
System.out.println("getXML发送数据-----------------"+sb.toString());
|
||||
log.info("getXML组织参数为-----------------"+sb.toString());
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@ package org.nl.wms.basedata.master.rest;
|
||||
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.anno.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
|
||||
@@ -90,9 +91,8 @@ public class MaterialbaseController {
|
||||
@Log("物料同步")
|
||||
@ApiOperation("物料同步")
|
||||
//@PreAuthorize("@el.check('materialtype:list')")
|
||||
public ResponseEntity<Object> synchronize(@RequestBody Map whereJson) {
|
||||
materialBaseService.synchronize(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
public ResponseEntity<Object> synchronize(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(materialBaseService.synchronize(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("查询产品系列类型")
|
||||
|
||||
@@ -89,7 +89,7 @@ public interface MaterialbaseService {
|
||||
*/
|
||||
JSONObject getMaterOptType(String materOpt_code);
|
||||
|
||||
void synchronize(Map whereJson);
|
||||
JSONObject synchronize(JSONObject whereJson);
|
||||
|
||||
JSONArray getProductSeries(String parent_class_id);
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -104,19 +104,9 @@ public class CachelineRegionRelationServiceImpl implements CachelineRegionRelati
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(String[] ids) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_cacheline_region_relation");
|
||||
for (String relation_id: ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("relation_id", String.valueOf(relation_id));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_time", DateUtil.now());
|
||||
wo.update(param);
|
||||
wo.delete("relation_id = '" + relation_id + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* <<
|
||||
* Davinci
|
||||
* ==
|
||||
* Copyright (C) 2016 - 2019 EDP
|
||||
* ==
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* >>
|
||||
*
|
||||
*/
|
||||
|
||||
package org.nl.wms.common;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author /
|
||||
*/
|
||||
@Slf4j
|
||||
@SuppressWarnings({"unchecked","all"})
|
||||
public enum DataTypeEnum {
|
||||
|
||||
/** mysql */
|
||||
MYSQL("mysql", "mysql", "com.mysql.jdbc.Driver", "`", "`", "'", "'"),
|
||||
|
||||
/** oracle */
|
||||
ORACLE("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
/** sql server */
|
||||
SQLSERVER("sqlserver", "sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
/** h2 */
|
||||
H2("h2", "h2", "org.h2.Driver", "`", "`", "\"", "\""),
|
||||
|
||||
/** phoenix */
|
||||
PHOENIX("phoenix", "hbase phoenix", "org.apache.phoenix.jdbc.PhoenixDriver", "", "", "\"", "\""),
|
||||
|
||||
/** mongo */
|
||||
MONGODB("mongo", "mongodb", "mongodb.jdbc.MongoDriver", "`", "`", "\"", "\""),
|
||||
|
||||
/** sql4es */
|
||||
ELASTICSEARCH("sql4es", "elasticsearch", "nl.anchormen.sql4es.jdbc.ESDriver", "", "", "'", "'"),
|
||||
|
||||
/** presto */
|
||||
PRESTO("presto", "presto", "com.facebook.presto.jdbc.PrestoDriver", "", "", "\"", "\""),
|
||||
|
||||
/** moonbox */
|
||||
MOONBOX("moonbox", "moonbox", "moonbox.jdbc.MbDriver", "`", "`", "`", "`"),
|
||||
|
||||
/** cassandra */
|
||||
CASSANDRA("cassandra", "cassandra", "com.github.adejanovski.cassandra.jdbc.CassandraDriver", "", "", "'", "'"),
|
||||
|
||||
/** click house */
|
||||
CLICKHOUSE("clickhouse", "clickhouse", "ru.yandex.clickhouse.ClickHouseDriver", "", "", "\"", "\""),
|
||||
|
||||
/** kylin */
|
||||
KYLIN("kylin", "kylin", "org.apache.kylin.jdbc.Driver", "\"", "\"", "\"", "\""),
|
||||
|
||||
/** vertica */
|
||||
VERTICA("vertica", "vertica", "com.vertica.jdbc.Driver", "", "", "'", "'"),
|
||||
|
||||
/** sap */
|
||||
HANA("sap", "sap hana", "com.sap.db.jdbc.Driver", "", "", "'", "'"),
|
||||
|
||||
/** impala */
|
||||
IMPALA("impala", "impala", "com.cloudera.impala.jdbc41.Driver", "", "", "'", "'");
|
||||
|
||||
private String feature;
|
||||
private String desc;
|
||||
private String driver;
|
||||
private String keywordPrefix;
|
||||
private String keywordSuffix;
|
||||
private String aliasPrefix;
|
||||
private String aliasSuffix;
|
||||
|
||||
private static final String JDBC_URL_PREFIX = "jdbc:";
|
||||
|
||||
DataTypeEnum(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix, String aliasPrefix, String aliasSuffix) {
|
||||
this.feature = feature;
|
||||
this.desc = desc;
|
||||
this.driver = driver;
|
||||
this.keywordPrefix = keywordPrefix;
|
||||
this.keywordSuffix = keywordSuffix;
|
||||
this.aliasPrefix = aliasPrefix;
|
||||
this.aliasSuffix = aliasSuffix;
|
||||
}
|
||||
|
||||
public static DataTypeEnum urlOf(String jdbcUrl) {
|
||||
String url = jdbcUrl.toLowerCase().trim();
|
||||
for (DataTypeEnum dataTypeEnum : values()) {
|
||||
if (url.startsWith(JDBC_URL_PREFIX + dataTypeEnum.feature)) {
|
||||
try {
|
||||
Class<?> aClass = Class.forName(dataTypeEnum.getDriver());
|
||||
if (null == aClass) {
|
||||
throw new RuntimeException("Unable to get driver instance for jdbcUrl: " + jdbcUrl);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Unable to get driver instance: " + jdbcUrl);
|
||||
}
|
||||
return dataTypeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getFeature() {
|
||||
return feature;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public String getKeywordPrefix() {
|
||||
return keywordPrefix;
|
||||
}
|
||||
|
||||
public String getKeywordSuffix() {
|
||||
return keywordSuffix;
|
||||
}
|
||||
|
||||
public String getAliasPrefix() {
|
||||
return aliasPrefix;
|
||||
}
|
||||
|
||||
public String getAliasSuffix() {
|
||||
return aliasSuffix;
|
||||
}
|
||||
}
|
||||
@@ -44,11 +44,11 @@ public class AcsToWmsController {
|
||||
return new ResponseEntity<>(acsToWmsService.receiveTaskStatusAcs(string), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/orderFinish")
|
||||
@PostMapping("/orderStatus")
|
||||
@Log("ACS给WMS下发工单完成状态")
|
||||
@ApiOperation("ACS给WMS下发工单完成状态")
|
||||
public ResponseEntity<Object> orderFinish(@RequestBody String string) {
|
||||
return new ResponseEntity<>(acsToWmsService.orderFinish(string), HttpStatus.OK);
|
||||
public ResponseEntity<Object> orderFinish(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(acsToWmsService.orderStatus(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/feedDeviceStatusType")
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.anno.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.WorkerOrderEnum;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -64,6 +65,11 @@ public class WmsToAcsController {
|
||||
return new ResponseEntity<>(wmsToAcsService.order(arr), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.nl.common.enums.WorkerOrderEnum
|
||||
* @param whereJson
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/orderStatusUpdate")
|
||||
@Log("WMS向acs发送强制完成")
|
||||
@ApiOperation("WMS强制完成向acs发送强制完成")
|
||||
|
||||
@@ -40,7 +40,7 @@ public interface AcsToWmsService {
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> orderFinish(String string);
|
||||
Map<String, Object> orderStatus(JSONObject param);
|
||||
|
||||
/**
|
||||
* ACS给WMS反馈设备状态状态
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.nl.wms.sch.service.TaskService;
|
||||
import org.nl.wms.sch.service.dto.TaskDto;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -29,11 +30,12 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
private final TaskService taskService;
|
||||
private final AgvInstService agvInstService;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private AgvInstService agvInstService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> apply(JSONObject jsonObject) {
|
||||
@@ -70,15 +72,15 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
JSONArray errArr = new JSONArray();
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject row = array.getJSONObject(i);
|
||||
String task_uuid = row.getString("task_uuid");
|
||||
TaskDto taskDto = taskService.findById(task_uuid);
|
||||
String task_id = row.getString("task_id");
|
||||
TaskDto taskDto = taskService.findById(task_id);
|
||||
String processing_class = taskDto.getHandle_class();
|
||||
//1:执行中,2:完成 ,3:acs取消
|
||||
String acs_task_status = row.getString("task_status");
|
||||
String message = "";
|
||||
String status = "";
|
||||
if ("1".equals(acs_task_status)) {
|
||||
status = AcsTaskEnum.STATUS_RUNDING.getCode();
|
||||
status = AcsTaskEnum.STATUS_START.getCode();
|
||||
}
|
||||
if ("2".equals(acs_task_status)) {
|
||||
status = AcsTaskEnum.STATUS_FINISH.getCode();
|
||||
@@ -101,7 +103,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
log.info("任务状态更新失败:{}", message);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("task_uuid", task_uuid);
|
||||
json.put("task_id", task_id);
|
||||
json.put("message", message);
|
||||
errArr.add(json);
|
||||
|
||||
@@ -111,7 +113,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
log.info("任务状态更新失败:{}", message);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("task_uuid", task_uuid);
|
||||
json.put("task_id", task_id);
|
||||
json.put("message", message);
|
||||
errArr.add(json);
|
||||
|
||||
@@ -132,14 +134,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> orderFinish(String string) {
|
||||
public Map<String, Object> orderStatus(JSONObject orderJson) {
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
JSONObject orderJson = JSONObject.parseObject(string);
|
||||
String ext_order_id = orderJson.getString("ext_order_id");
|
||||
String ext_order_id = orderJson.getString("workorder_id");
|
||||
// JSONArray array = JSONArray.parseArray(string);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("MPS_BD_ProduceShiftOrder");
|
||||
//TODO: 表未维护
|
||||
WQLObject wo = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("produceorder_id", ext_order_id);
|
||||
map.put("order_status", "04");
|
||||
|
||||
@@ -44,7 +44,7 @@ public class AgvInstService {
|
||||
WQLObject basePoint = WQLObject.getWQLObject("sch_base_point");
|
||||
WQLObject cacheLineSearch = WQLObject.getWQLObject("SCH_cacheLine_region_relation");
|
||||
try {
|
||||
String workorder = param.getString("workorder_code");
|
||||
String workorder = param.getString("workorder_code");//
|
||||
String point_code = param.getString("point_code");
|
||||
String quantity = param.getString("quantity");
|
||||
//1.PDM_produce_workOrder
|
||||
|
||||
@@ -22,12 +22,15 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
for (Object o : arr) {
|
||||
JSONObject task = (JSONObject) o;
|
||||
JSONObject param = new JSONObject(MapOf.of("task_id", task.getString("task_id")
|
||||
, "task_type", task.getString("task_type")
|
||||
, "acs_task_type", task.getString("acs_task_type")
|
||||
, "start_point_code", task.getString("point_code1")
|
||||
, "next_point_code", task.getString("point_code2")
|
||||
, "return_point_code", task.getString("point_code3")
|
||||
, "task_group_id", task.getString("task_group_id")
|
||||
, "priority", task.getString("priority")
|
||||
, "task_group_id", task.getString("is_send")
|
||||
, "vehicle_code", task.getString("vehicle_code")
|
||||
, "agv_system_type", task.getString("agv_system_type")
|
||||
));
|
||||
form.add(param);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
|
||||
package org.nl.wms.ext.sap.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
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.common.anno.Log;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.sap.service.WmsToSapService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhouz
|
||||
* @date 2021-07-21
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "wms发送sap")
|
||||
@RequestMapping("/api/sap/")
|
||||
@Slf4j
|
||||
public class WmsToSapController {
|
||||
private final WmsToSapService wmsToSapService;
|
||||
|
||||
@PostMapping("/getMater")
|
||||
@Log("获取物料基础信息")
|
||||
@ApiOperation("获取物料基础信息")
|
||||
public ResponseEntity<Object> getMater(@RequestBody JSONObject form) {
|
||||
return new ResponseEntity<>(wmsToSapService.getMater(form), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getSaleOrder")
|
||||
@Log("获取销售订单")
|
||||
@ApiOperation("获取销售订单")
|
||||
public ResponseEntity<Object> getSaleOrder(@RequestBody JSONObject form) {
|
||||
return new ResponseEntity<>(wmsToSapService.getSaleOrder(form), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getDeliveryNote")
|
||||
@Log("获取物料基础信息")
|
||||
@ApiOperation("获取物料基础信息")
|
||||
public ResponseEntity<Object> getDeliveryNote(@RequestBody JSONObject form) {
|
||||
return new ResponseEntity<>(wmsToSapService.getDeliveryNote(form), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.nl.wms.ext.sap.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface WmsToSapService {
|
||||
/**
|
||||
* WMS客户端--->SAP服务端
|
||||
* 获取物料信息
|
||||
*
|
||||
* @param form
|
||||
* @return JSONObject
|
||||
*/
|
||||
|
||||
JSONObject getMater(JSONObject form);
|
||||
|
||||
/**
|
||||
* WMS客户端--->SAP服务端
|
||||
* 获取销售订单
|
||||
*
|
||||
* @param form
|
||||
* @return JSONObject
|
||||
*/
|
||||
|
||||
JSONObject getSaleOrder(JSONObject form);
|
||||
|
||||
/**
|
||||
* WMS客户端--->SAP服务端
|
||||
* 获取交货单
|
||||
*
|
||||
* @param form
|
||||
* @return JSONObject
|
||||
*/
|
||||
|
||||
JSONObject getDeliveryNote(JSONObject form);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
package org.nl.wms.ext.sap.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.github.pagehelper.util.StringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.XML;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.nl.wms.WebServiceUtil;
|
||||
import org.nl.wms.ext.sap.service.WmsToSapService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WmsToSapServiceImpl implements WmsToSapService {
|
||||
|
||||
@Override
|
||||
public JSONObject getMater(JSONObject form) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getDateStr(int day) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date todayDate = new Date();
|
||||
long beforeTime = (todayDate.getTime() / 1000) - 60 * 60 * 24 * day;
|
||||
todayDate.setTime(beforeTime * 1000);
|
||||
String beforeDate = formatter.format(todayDate);
|
||||
return beforeDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getSaleOrder(JSONObject form) {
|
||||
log.info("导入方法开始");
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/zfg_ecc_to_zhwl/800/zfg_ecc_to_zhwl/binding";
|
||||
String method = "ZfmGetSo";
|
||||
|
||||
if (StrUtil.equals(form.getString("is_auto"), "1")) {
|
||||
form.put("IErdatFrm", getDateStr(1));
|
||||
form.put("IErdatTo", getDateStr(0));
|
||||
form.put("IVbeln", ""); // 非必填字段
|
||||
}
|
||||
|
||||
String bill_code = form.getString("bill_code");
|
||||
String date_begin = form.getString("date_begin");
|
||||
String date_end = form.getString("date_end");
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("IVbeln", "");
|
||||
map.put("IErdatFrm", "");
|
||||
map.put("IErdatTo", "");
|
||||
if (StrUtil.isNotEmpty(bill_code)) {
|
||||
map.put("IVbeln", bill_code);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(date_begin)) {
|
||||
map.put("IErdatFrm", date_begin);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(date_end)) {
|
||||
map.put("IErdatTo", date_end);
|
||||
}
|
||||
|
||||
JSONObject ZfmGetSoResponse = null;
|
||||
try {
|
||||
String response = WebServiceUtil.process(url, method, map);
|
||||
JSONObject ret = JSONObject.parseObject(XML.toJSONObject(response).toString());
|
||||
log.info("getXML发送数据-----------------" + ret.toString());
|
||||
JSONObject Envelope = ret.getJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.getJSONObject("soap-env:Body");
|
||||
ZfmGetSoResponse = Body.getJSONObject("n0:ZfmGetSoResponse");
|
||||
String check = ZfmGetSoResponse.getString("OResultcode");
|
||||
if ("1005".equals(check)) {
|
||||
System.out.println(ZfmGetSoResponse.getString("OResultmsg"));
|
||||
throw new BadRequestException("sap返回:" + ZfmGetSoResponse.getString("OResultmsg"));
|
||||
} else if (!"1000".equals(check)) {
|
||||
throw new BadRequestException("sap返回:" + ZfmGetSoResponse.getString("OResultmsg"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JSONObject TZtsalesorder = ZfmGetSoResponse.getJSONObject("TZtsalesorder");
|
||||
log.info("TZtsalesorder为:" + TZtsalesorder.toString());
|
||||
JSONArray item = TZtsalesorder.getJSONArray("item");
|
||||
|
||||
if (TZtsalesorder == null || item == null || item.size() == 0) {
|
||||
result.put("message", "sap无可同步数据");
|
||||
return result;
|
||||
}
|
||||
|
||||
int err_num = 0;
|
||||
for (int i = 0; i < item.size(); i++) {
|
||||
JSONObject row = item.getJSONObject(i);
|
||||
boolean need_update = false;
|
||||
JSONObject sale_jo = WQLObject.getWQLObject("pcs_sale_order").query("sale_code = '" + row.getString("Vbeln") + "' AND seq_no = '" + row.getString("Posnr") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(sale_jo)) {
|
||||
sale_jo = new JSONObject();
|
||||
sale_jo.put("sale_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
} else {
|
||||
need_update = true;
|
||||
if (!sale_jo.getString("status").equals("10")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
sale_jo.put("is_success", "1");
|
||||
sale_jo.put("sale_code", row.getString("Vbeln"));
|
||||
sale_jo.put("seq_no", row.getString("Posnr"));
|
||||
sale_jo.put("sale_type", row.getString("Auart"));
|
||||
String material_code = row.getString("Matnr").replaceAll("^(0+)", "");
|
||||
//获取物料对应的物料标识
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("MD_ME_MaterialBase").query("material_code = '" + material_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(mater_jo)) {
|
||||
sale_jo.put("material_id", "0");
|
||||
sale_jo.put("is_success", "0");
|
||||
sale_jo.put("remark", "未查询到该销售订单对应的物料主数据:" + material_code);
|
||||
err_num++;
|
||||
} else {
|
||||
String material_id = mater_jo.getString("material_id");
|
||||
sale_jo.put("material_id", material_id);
|
||||
}
|
||||
sale_jo.put("status", "10");
|
||||
sale_jo.put("sale_qty", row.getString("Kwmeng"));
|
||||
sale_jo.put("produce_seq", "1");
|
||||
String cust_code = row.getString("Kunnr");
|
||||
JSONObject cust_jo = WQLObject.getWQLObject("md_cs_customerbase").query("cust_code = '" + cust_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(cust_jo)) {
|
||||
sale_jo.put("cust_id", cust_jo.getString("cust_id"));
|
||||
sale_jo.put("cust_code", cust_jo.getString("cust_code"));
|
||||
sale_jo.put("cust_name", cust_jo.getString("cust_name"));
|
||||
} else {
|
||||
sale_jo.put("is_success", "0");
|
||||
sale_jo.put("remark", "未查询到该销售订单对应的客户信息:" + cust_code);
|
||||
err_num++;
|
||||
}
|
||||
String unit_code = row.getString("Vrkme");
|
||||
JSONObject unit_jo = WQLObject.getWQLObject("md_pb_measureunit").query("unit_name = '" + unit_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(unit_jo)) {
|
||||
sale_jo.put("qty_unit_id", "0");
|
||||
sale_jo.put("remark", "未查询到该销售订单对应的单位信息:" + unit_code);
|
||||
err_num++;
|
||||
} else {
|
||||
sale_jo.put("qty_unit_id", unit_jo.getString("measure_unit_id"));
|
||||
}
|
||||
sale_jo.put("plandeliver_date", row.getString("Edaut"));
|
||||
sale_jo.put("create_id", SecurityUtils.getCurrentUserId());
|
||||
sale_jo.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
sale_jo.put("create_time", DateUtil.now());
|
||||
sale_jo.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
sale_jo.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
sale_jo.put("update_time", DateUtil.now());
|
||||
|
||||
if (need_update) {
|
||||
WQLObject.getWQLObject("pcs_sale_order").update(sale_jo);
|
||||
} else {
|
||||
WQLObject.getWQLObject("pcs_sale_order").insert(sale_jo);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (err_num > 0) {
|
||||
result.put("message", "导入成功!一共导入:" + item.size() + "条数据,其中有误数据:" + err_num + "条!");
|
||||
} else {
|
||||
result.put("message", "导入成功!一共导入:" + item.size() + "条数据!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeliveryNote(JSONObject form) {
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/zfg_ecc_to_zhwl/800/zfg_ecc_to_zhwl/binding";
|
||||
String method = "ZfmGetDnZjwl";
|
||||
|
||||
if (StrUtil.equals(form.getString("is_auto"), "1")) {
|
||||
form.put("IErdatFrm", getDateStr(1));
|
||||
form.put("IErdatTo", getDateStr(0));
|
||||
form.put("IVbeln", ""); // 非必填字段
|
||||
}
|
||||
|
||||
String bill_code = form.getString("bill_code");
|
||||
String date_begin = form.getString("date_begin");
|
||||
String date_end = form.getString("date_end");
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("IVbeln", "");
|
||||
map.put("IErdatFrm", "");
|
||||
map.put("IErdatTo", "");
|
||||
if (StrUtil.isNotEmpty(bill_code)) {
|
||||
map.put("IVbeln", bill_code);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(date_begin)) {
|
||||
map.put("IErdatFrm", date_begin);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(date_end)) {
|
||||
map.put("IErdatTo", date_end);
|
||||
}
|
||||
|
||||
JSONObject ZfmGetSoResponse = null;
|
||||
try {
|
||||
String response = WebServiceUtil.process(url, method, map);
|
||||
JSONObject ret = JSONObject.parseObject(XML.toJSONObject(response).toString());
|
||||
log.info("getXML发送数据-----------------" + ret.toString());
|
||||
JSONObject Envelope = ret.getJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.getJSONObject("soap-env:Body");
|
||||
ZfmGetSoResponse = Body.getJSONObject("n0:ZfmGetDnZjwlResponse");
|
||||
String check = ZfmGetSoResponse.getString("OResultcode");
|
||||
if ("1005".equals(check)) {
|
||||
System.out.println(ZfmGetSoResponse.getString("OResultmsg"));
|
||||
throw new BadRequestException("sap返回:" + ZfmGetSoResponse.getString("OResultmsg"));
|
||||
} else if (!"1000".equals(check)) {
|
||||
throw new BadRequestException("sap返回:" + ZfmGetSoResponse.getString("OResultmsg"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
log.info(ZfmGetSoResponse.toString());
|
||||
JSONObject TZtsalesorder = ZfmGetSoResponse.getJSONObject("TZtdn");
|
||||
log.info("TZtsalesorder数据为:-------------------" + TZtsalesorder.toString());
|
||||
JSONArray item = TZtsalesorder.getJSONArray("item");
|
||||
log.info(item.size() + "");
|
||||
|
||||
if (TZtsalesorder == null || item == null || item.size() == 0) {
|
||||
result.put("message", "sap无可同步数据");
|
||||
return result;
|
||||
}
|
||||
|
||||
int err_num = 0;
|
||||
for (int i = 0; i < item.size(); i++) {
|
||||
boolean need_update = false;
|
||||
JSONObject row = item.getJSONObject(i);
|
||||
JSONObject deliver_jo = WQLObject.getWQLObject("pcs_delivery_order").query("deliver_code = '" + row.getString("Vbeln") + "' AND seq_no = '" + row.getString("Posnr") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(deliver_jo)) {
|
||||
deliver_jo = new JSONObject();
|
||||
deliver_jo.put("deliver_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
} else {
|
||||
need_update = true;
|
||||
if (!deliver_jo.getString("status").equals("10")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
deliver_jo.put("deliver_code", row.getString("Vbeln"));
|
||||
deliver_jo.put("seq_no", row.getString("Posnr"));
|
||||
deliver_jo.put("deliver_type", row.getString("Lfart"));
|
||||
String material_code = row.getString("Matnr").replaceAll("^(0+)", "");
|
||||
//获取物料对应的物料标识
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("MD_ME_MaterialBase").query("material_code = '" + material_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(mater_jo)) {
|
||||
deliver_jo.put("material_id", "0");
|
||||
deliver_jo.put("is_success", "0");
|
||||
deliver_jo.put("remark", "未查询到该交货单对应的物料主数据:" + material_code);
|
||||
err_num++;
|
||||
} else {
|
||||
String material_id = mater_jo.getString("material_id");
|
||||
deliver_jo.put("material_id", material_id);
|
||||
}
|
||||
deliver_jo.put("status", "10");
|
||||
deliver_jo.put("delivery_qty", row.getString("Lfimg"));
|
||||
String cust_code = row.getString("Kunnr");
|
||||
JSONObject cust_jo = WQLObject.getWQLObject("md_cs_customerbase").query("cust_code = '" + cust_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(cust_jo)) {
|
||||
deliver_jo.put("cust_id", cust_jo.getString("cust_id"));
|
||||
deliver_jo.put("cust_code", cust_jo.getString("cust_code"));
|
||||
deliver_jo.put("cust_name", cust_jo.getString("cust_name"));
|
||||
} else {
|
||||
deliver_jo.put("is_success", "0");
|
||||
deliver_jo.put("remark", "未查询到该交货单对应的客户信息:" + cust_code);
|
||||
err_num++;
|
||||
}
|
||||
String unit_code = row.getString("Vrkme");
|
||||
JSONObject unit_jo = WQLObject.getWQLObject("md_pb_measureunit").query("unit_name = '" + unit_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(unit_jo)) {
|
||||
deliver_jo.put("qty_unit_id", "0");
|
||||
deliver_jo.put("remark", "未查询到该交货单对应的单位信息:" + unit_code);
|
||||
err_num++;
|
||||
} else {
|
||||
deliver_jo.put("qty_unit_id", unit_jo.getString("measure_unit_id"));
|
||||
}
|
||||
String sale_code = row.getString("Vgbel");
|
||||
String seq_no = row.getString("Vgpos");
|
||||
JSONObject sale_jo = WQLObject.getWQLObject("pcs_sale_order").query("sale_code = '" + sale_code + "' AND seq_no = '" + seq_no + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(sale_jo)) {
|
||||
deliver_jo.put("remark", "未查询到该交货单对应的销售订单:" + unit_code + "行号为:" + seq_no);
|
||||
deliver_jo.put("is_success", "0");
|
||||
} else {
|
||||
deliver_jo.put("sale_id", sale_jo.getString("sale_id"));
|
||||
deliver_jo.put("sale_code", sale_jo.getString("sale_code"));
|
||||
deliver_jo.put("sale_seq_no", sale_jo.getString("seq_no"));
|
||||
}
|
||||
deliver_jo.put("create_id", SecurityUtils.getCurrentUserId());
|
||||
deliver_jo.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
deliver_jo.put("create_time", DateUtil.now());
|
||||
deliver_jo.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
deliver_jo.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
deliver_jo.put("update_time", DateUtil.now());
|
||||
if (need_update) {
|
||||
WQLObject.getWQLObject("pcs_delivery_order").update(deliver_jo);
|
||||
} else {
|
||||
WQLObject.getWQLObject("pcs_delivery_order").insert(deliver_jo);
|
||||
}
|
||||
}
|
||||
if (err_num > 0) {
|
||||
result.put("message", "导入成功!一共导入:" + item.size() + "条数据,其中有误数据:" + err_num + "条!");
|
||||
} else {
|
||||
result.put("message", "导入成功!一共导入:" + item.size() + "条数据!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
[交易说明]
|
||||
交易名: 库区分页查询
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
|
||||
|
||||
输入.flag TYPEAS s_string
|
||||
输入.import_date1 TYPEAS s_string
|
||||
输入.import_date2 TYPEAS s_string
|
||||
输入.import_date3 TYPEAS s_string
|
||||
输入.import_date4 TYPEAS s_string
|
||||
输入.begin_time TYPEAS s_string
|
||||
输入.end_time TYPEAS s_string
|
||||
|
||||
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
QUERY
|
||||
SELECT
|
||||
mater.*
|
||||
FROM
|
||||
V_SAP_ORG mater
|
||||
WHERE 1=1
|
||||
OPTION 输入.import_date3 <> ""
|
||||
(pp.UPDATED_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
|
||||
OR
|
||||
pp.CREATE_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
|
||||
)
|
||||
ENDOPTION
|
||||
OPTION 输入.begin_time <> ""
|
||||
mater.EDIT_TIME >= to_date(输入.begin_time,'yyyy-mm-dd HH24:MI:SS')
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
mater.EDIT_TIME <= to_date(输入.end_time,'yyyy-mm-dd HH24:MI:SS')
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
QUERY
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
ITEM
|
||||
WHERE
|
||||
(UPDATED_DATE > to_date(输入.import_date2,'yyyy-mm-dd HH24:MI:SS')
|
||||
OR
|
||||
CREATE_DATE > to_date(输入.import_date2,'yyyy-mm-dd HH24:MI:SS')
|
||||
)
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
pp.*
|
||||
FROM
|
||||
PURCHASE pp
|
||||
WHERE 1=1
|
||||
OPTION 输入.import_date3 <> ""
|
||||
(pp.UPDATED_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
|
||||
OR
|
||||
pp.CREATE_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
|
||||
)
|
||||
ENDOPTION
|
||||
OPTION 输入.begin_time <> ""
|
||||
pp.CREATE_DATE >= to_date(输入.begin_time,'yyyy-mm-dd HH24:MI:SS')
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
pp.CREATE_DATE <= to_date(输入.end_time,'yyyy-mm-dd HH24:MI:SS')
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
QUERY
|
||||
SELECT
|
||||
pp.*
|
||||
FROM
|
||||
SALE_OUT pp
|
||||
WHERE 1=1
|
||||
|
||||
OPTION 输入.begin_time <> ""
|
||||
pp.dbilldate >= 输入.begin_time
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
pp.dbilldate <= 输入.end_time
|
||||
ENDOPTION
|
||||
OPTION 输入.fbillflag <> ""
|
||||
pp.fbillflag = 输入.fbillflag
|
||||
ENDOPTION
|
||||
OPTION 输入.vbillcode <> ""
|
||||
pp.vbillcode like 输入.vbillcode
|
||||
ENDOPTION
|
||||
OPTION 输入.cmaterialvid <> ""
|
||||
pp.cmaterialvid = 输入.cmaterialvid
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "5"
|
||||
QUERY
|
||||
SELECT
|
||||
pp.*
|
||||
FROM
|
||||
PURCHASE_IN pp
|
||||
WHERE 1=1
|
||||
OPTION 输入.import_date4 <> ""
|
||||
pp.CREATIONTIME > 输入.import_date4
|
||||
ENDOPTION
|
||||
OPTION 输入.begin_time <> ""
|
||||
pp.CREATIONTIME >= 输入.begin_time
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
pp.CREATIONTIME <= 输入.end_time
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.mps.rest;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -34,7 +36,6 @@ public class ProduceWorkorderController {
|
||||
@GetMapping
|
||||
@Log("查询工单管理")
|
||||
@ApiOperation("查询工单管理")
|
||||
//@PreAuthorize("@el.check('produceWorkorder:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(produceWorkorderService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
@@ -47,6 +48,14 @@ public class ProduceWorkorderController {
|
||||
produceWorkorderService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@PostMapping("/submits")
|
||||
@Log("新增工单管理")
|
||||
@ApiOperation("新增工单管理")
|
||||
//@PreAuthorize("@el.check('produceWorkorder:add')")
|
||||
public ResponseEntity<Object> submit(@Validated @RequestBody ProduceWorkorderDto dto) {
|
||||
produceWorkorderService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改工单管理")
|
||||
@@ -57,9 +66,16 @@ public class ProduceWorkorderController {
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PutMapping("/submits")
|
||||
@Log("工单下发")
|
||||
@ApiOperation("工单下发")
|
||||
public ResponseEntity<Object> submits(@RequestBody List<String> param) {
|
||||
produceWorkorderService.submits(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("删除工单管理")
|
||||
@ApiOperation("删除工单管理")
|
||||
//@PreAuthorize("@el.check('produceWorkorder:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
produceWorkorderService.deleteAll(ids);
|
||||
@@ -77,7 +93,6 @@ public class ProduceWorkorderController {
|
||||
@PostMapping("/getDtl")
|
||||
@Log("获取当前工单下的工单生产记录")
|
||||
@ApiOperation("获取当前工单下的工单生产记录")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:list')")
|
||||
public ResponseEntity<Object> getDtl(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(produceWorkorderService.getDtl(param), HttpStatus.OK);
|
||||
}
|
||||
@@ -85,7 +100,6 @@ public class ProduceWorkorderController {
|
||||
@PostMapping("/forceFinish")
|
||||
@Log("工单强制完成")
|
||||
@ApiOperation("工单强制完成")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:list')")
|
||||
public ResponseEntity<Object> forceFinish(@RequestBody JSONObject param) {
|
||||
produceWorkorderService.forceFinish(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -28,67 +28,13 @@ import java.util.Map;
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "工单管理")
|
||||
@Api(tags = "一体机工单管理")
|
||||
@RequestMapping("/api/produceshiftorder")
|
||||
@Slf4j
|
||||
public class ProduceshiftorderController {
|
||||
|
||||
private final ProduceshiftorderService produceshiftorderService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询工单")
|
||||
@ApiOperation("查询工单")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(produceshiftorderService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增工单")
|
||||
@ApiOperation("新增工单")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody ProduceshiftorderDto dto) {
|
||||
produceshiftorderService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping("/addRows")
|
||||
@Log("批量新增工单")
|
||||
@ApiOperation("批量新增工单")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody List<ProduceshiftorderDto> rows) {
|
||||
for (ProduceshiftorderDto dto : rows) {
|
||||
produceshiftorderService.create(dto);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改工单")
|
||||
@ApiOperation("修改工单")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody ProduceshiftorderDto dto) {
|
||||
produceshiftorderService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除工单")
|
||||
@ApiOperation("删除工单")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
produceshiftorderService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/submits")
|
||||
@Log("工单下发")
|
||||
@ApiOperation("工单下发")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:edit')")
|
||||
public ResponseEntity<Object> submits(@RequestBody JSONObject param) {
|
||||
produceshiftorderService.submits(param);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/getDevice")
|
||||
@Log("根据登录用户设备下拉")
|
||||
@@ -141,31 +87,6 @@ public class ProduceshiftorderController {
|
||||
return new ResponseEntity<>(produceshiftorderService.getReportWork(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/forceFinish")
|
||||
@Log("工单强制完成")
|
||||
@ApiOperation("工单强制完成")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:list')")
|
||||
public ResponseEntity<Object> forceFinish(@RequestBody JSONObject param) {
|
||||
produceshiftorderService.forceFinish(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getDtl")
|
||||
@Log("获取当前工单下的工单生产记录")
|
||||
@ApiOperation("获取当前工单下的工单生产记录")
|
||||
//@PreAuthorize("@el.check('produceshiftorder:list')")
|
||||
public ResponseEntity<Object> getDtl(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(produceshiftorderService.getDtl(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/excelImport")
|
||||
@Log("excel导入")
|
||||
@ApiOperation("excel导入")
|
||||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
produceshiftorderService.excelImport(file, request);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getNotWorkDeviceByWorkproceduceId")
|
||||
@Log("根据工序查询没有工单的设备")
|
||||
@ApiOperation("根据工序查询没有工单的设备")
|
||||
|
||||
@@ -80,6 +80,13 @@ public interface ProduceWorkorderService {
|
||||
*/
|
||||
JSONArray getDtl(JSONObject param);
|
||||
|
||||
/**
|
||||
* 工单下发
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
void submits(List<String> param);
|
||||
|
||||
/**
|
||||
* 强制完成
|
||||
* @param param
|
||||
|
||||
@@ -66,11 +66,6 @@ public interface ProduceshiftorderService {
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 工单下发
|
||||
* @param param
|
||||
*/
|
||||
void submits(JSONObject param);
|
||||
|
||||
/**
|
||||
* 根据当前登录用户下拉
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
@@ -41,6 +42,8 @@ import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
@@ -187,8 +190,8 @@ public class ProduceWorkorderServiceImpl implements ProduceWorkorderService {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("workorder_id", String.valueOf(workorder_id));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_id", currentUserId);
|
||||
param.put("update_name", nickName);
|
||||
param.put("update_time", DateUtil.now());
|
||||
wo.update(param);
|
||||
}
|
||||
@@ -212,6 +215,21 @@ public class ProduceWorkorderServiceImpl implements ProduceWorkorderService {
|
||||
return resultJSONArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submits(List<String> param) {
|
||||
if (param == null || param.size()==0){
|
||||
return;
|
||||
}
|
||||
String sql = param.stream().collect(Collectors.joining("','"));
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
WQLObject wo = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
wo.update(MapOf.of("workorder_status", WorkerOrderEnum.SEND.getCode()
|
||||
,"update_id", currentUserId,"update_name"
|
||||
, nickName,"update_time", DateUtil.now())
|
||||
,"workorder_id in ('"+sql+"')");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void forceFinish(JSONObject param) {
|
||||
@@ -237,7 +255,7 @@ public class ProduceWorkorderServiceImpl implements ProduceWorkorderService {
|
||||
produceorderMap.put("update_name", nickName);
|
||||
produceorderMap.put("update_time", DateUtil.now());
|
||||
produceorderMap.put("realproduceend_date", DateUtil.now());
|
||||
wo.update(produceorderMap);
|
||||
wo.update(produceorderMap,"workorder_id = '"+workorder_id+"'");
|
||||
JSONObject jsonObject = wo.query("workorder_id = '" + workorder_id + "'").uniqueResult(0);
|
||||
String real_qty = jsonObject.getString("real_qty");
|
||||
if (StrUtil.isEmpty(real_qty)) {
|
||||
|
||||
@@ -59,6 +59,8 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
|
||||
@Autowired
|
||||
ISysUserService userService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String produceorder_code = MapUtil.getStr(whereJson, "produceorder_code");
|
||||
@@ -204,19 +206,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void submits(JSONObject param) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
|
||||
param.put("order_status", "01");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_time", DateUtil.now());
|
||||
wo.update(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getDevice(JSONObject param) {
|
||||
|
||||
@@ -50,12 +50,14 @@ public class DeliveryOrderServiceImpl implements DeliveryOrderService {
|
||||
String begin_time = MapUtil.getStr(whereJson, "begin_time");
|
||||
String end_time = MapUtil.getStr(whereJson, "end_time");
|
||||
String status = MapUtil.getStr(whereJson, "status");
|
||||
String is_success = MapUtil.getStr(whereJson, "is_success");
|
||||
String product_series = "";
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("flag", "1");
|
||||
map.put("begin_time", begin_time);
|
||||
map.put("end_time", end_time);
|
||||
map.put("status", status);
|
||||
map.put("is_success", is_success);
|
||||
if (StrUtil.isNotEmpty(material)) {
|
||||
map.put("material", "%" + material + "%");
|
||||
}
|
||||
|
||||
@@ -50,12 +50,14 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
||||
String begin_time = MapUtil.getStr(whereJson, "begin_time");
|
||||
String end_time = MapUtil.getStr(whereJson, "end_time");
|
||||
String status = MapUtil.getStr(whereJson, "status");
|
||||
String is_success = MapUtil.getStr(whereJson, "is_success");
|
||||
String product_series = "";
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("flag", "1");
|
||||
map.put("begin_time", begin_time);
|
||||
map.put("end_time", end_time);
|
||||
map.put("status", status);
|
||||
map.put("is_success", is_success);
|
||||
if (StrUtil.isNotEmpty(sale_code)) {
|
||||
map.put("sale_code", "%" + sale_code + "%");
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
输入.material TYPEAS s_string
|
||||
输入.product_series TYPEAS f_string
|
||||
输入.status TYPEAS s_string
|
||||
输入.is_success TYPEAS s_string
|
||||
输入.begin_time TYPEAS s_string
|
||||
输入.end_time TYPEAS s_string
|
||||
|
||||
@@ -62,6 +63,9 @@
|
||||
OPTION 输入.status <> ""
|
||||
deliveryorder.status = 输入.status
|
||||
ENDOPTION
|
||||
OPTION 输入.is_success <> ""
|
||||
deliveryorder.is_success = 输入.is_success
|
||||
ENDOPTION
|
||||
OPTION 输入.product_series <> ""
|
||||
material.product_series in 输入.product_series
|
||||
ENDOPTION
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
输入.material TYPEAS s_string
|
||||
输入.product_series TYPEAS f_string
|
||||
输入.status TYPEAS s_string
|
||||
输入.is_success TYPEAS s_string
|
||||
输入.begin_time TYPEAS s_string
|
||||
输入.end_time TYPEAS s_string
|
||||
|
||||
@@ -62,6 +63,9 @@
|
||||
OPTION 输入.status <> ""
|
||||
saleorder.status = 输入.status
|
||||
ENDOPTION
|
||||
OPTION 输入.is_success <> ""
|
||||
saleorder.is_success = 输入.is_success
|
||||
ENDOPTION
|
||||
OPTION 输入.product_series <> ""
|
||||
material.product_series in 输入.product_series
|
||||
ENDOPTION
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -16,6 +16,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class AbstractAcsTask {
|
||||
|
||||
|
||||
private static final String OPT_NAME = "acs回调#";
|
||||
|
||||
public abstract void updateTaskStatus(JSONObject taskObj,String status);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.ext.sap.service.WmsToSapService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AutoImportDeliverOrder {
|
||||
private final WmsToSapService wmsToSapService;
|
||||
|
||||
public void run() {
|
||||
//通过ACS接口获取温度
|
||||
JSONObject form = new JSONObject();
|
||||
form.put("is_auto", "1");
|
||||
wmsToSapService.getDeliveryNote(form);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.sap.service.WmsToSapService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AutoImportSaleOrder {
|
||||
private final WmsToSapService wmsToSapService;
|
||||
|
||||
public void run() {
|
||||
//通过ACS接口获取温度
|
||||
JSONObject form = new JSONObject();
|
||||
form.put("is_auto", "1");
|
||||
wmsToSapService.getSaleOrder(form);
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,13 @@ import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.basedata.master.service.ClassstandardService;
|
||||
import org.nl.wms.basedata.master.service.dto.ClassstandardDto;
|
||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||
import org.nl.wms.ext.acs.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.nl.wms.sch.service.TaskService;
|
||||
import org.nl.wms.sch.service.dto.TaskDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -36,11 +40,13 @@ import java.util.Map;
|
||||
* @date 2021-08-19
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class TaskServiceImpl implements TaskService {
|
||||
|
||||
private final ClassstandardService classstandardService;
|
||||
@Autowired
|
||||
private ClassstandardService classstandardService;
|
||||
@Autowired
|
||||
private AcsToWmsService acsToWmsService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map form, Pageable page) {
|
||||
@@ -176,55 +182,35 @@ public class TaskServiceImpl implements TaskService {
|
||||
|
||||
@Override
|
||||
public void operation(Map<String, Object> map) {
|
||||
WmsToAcsServiceImpl wms = new WmsToAcsServiceImpl();
|
||||
String task_id = MapUtil.getStr(map, "task_id");
|
||||
String method_name = MapUtil.getStr(map, "method_name");
|
||||
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
if (taskObj.getString("task_status").equals(TaskStatusEnum.FINISHED.getCode())) throw new BadRequestException("任务已完成!");
|
||||
// 任务处理类
|
||||
String processing_class = taskObj.getString("handle_class");
|
||||
String message = "";
|
||||
// 根据任务类型获取对应的任务操作类
|
||||
try {
|
||||
Class<?> clz = Class.forName(processing_class);
|
||||
Object obj = clz.newInstance();
|
||||
// 调用每个任务类的method_name()强制结束方法
|
||||
Method m;
|
||||
JSONObject result;
|
||||
if (method_name.equals("immediateNotifyAcs")) { // 立即下发不需要参数
|
||||
m = obj.getClass().getMethod(method_name);
|
||||
result = (JSONObject) m.invoke(obj);
|
||||
} else {
|
||||
m = obj.getClass().getMethod(method_name, String.class);
|
||||
result = (JSONObject) m.invoke(obj, task_id);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(result)) return;
|
||||
JSONArray arr = result.getJSONArray("errArr");
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_task");
|
||||
if (ObjectUtil.isNotEmpty(arr)) {
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("task_id", json.getString("task_id"));
|
||||
param.put("remark", json.getString("message"));
|
||||
wo.update(param);
|
||||
}
|
||||
throw new BadRequestException("任务操作失败!");
|
||||
} else {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("task_id", task_id);
|
||||
param.put("remark", "操作成功");
|
||||
wo.update(param);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
if (ObjectUtil.isNull(e.getTargetException().getMessage())) {
|
||||
message = e.getTargetException().toString();
|
||||
} else {
|
||||
message = e.getTargetException().getMessage();
|
||||
}
|
||||
throw new BadRequestException(message);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new BadRequestException("任务操作失败!");
|
||||
|
||||
switch (method_name) { // forceFinish, cancel
|
||||
case "immediateNotifyAcs":
|
||||
JSONArray array = new JSONArray();
|
||||
array.add(taskObj);
|
||||
wms.issueTaskToAcs(array);
|
||||
break;
|
||||
case "forceFinish":
|
||||
JSONArray finish = new JSONArray();
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("task_id", task_id);
|
||||
res.put("task_status", "2");
|
||||
finish.add(res);
|
||||
acsToWmsService.receiveTaskStatusAcs(JSON.toJSONString(finish));
|
||||
break;
|
||||
case "cancel":
|
||||
JSONArray cancel = new JSONArray();
|
||||
JSONObject res2 = new JSONObject();
|
||||
res2.put("task_id", task_id);
|
||||
res2.put("task_status", "1");
|
||||
cancel.add(res2);
|
||||
acsToWmsService.receiveTaskStatusAcs(JSON.toJSONString(cancel));
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -24,6 +24,7 @@ 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回调# ";
|
||||
@@ -116,8 +117,6 @@ public class SpeMachineryTask extends AbstractAcsTask {
|
||||
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_RUNDING:
|
||||
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")+"'");
|
||||
//到专机:更新设备上料位物料数量
|
||||
@@ -146,8 +145,6 @@ public class SpeMachineryTask extends AbstractAcsTask {
|
||||
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_RUNDING:
|
||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||
break;
|
||||
case STATUS_FINISH:
|
||||
|
||||
@@ -38,13 +38,14 @@ public class TaskScheduleService {
|
||||
private ReentrantLock lock = new ReentrantLock();
|
||||
private final WmsToAcsService wmsToAcsService;
|
||||
|
||||
@Scheduled(cron = "0/10 * * * * ?")
|
||||
@Scheduled(cron = "0/30 * * * * ?")
|
||||
public void taskPublish(){
|
||||
boolean islock = lock.tryLock();
|
||||
try {
|
||||
if (islock){
|
||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||
JSONArray all = taskTable.query("task_type < '" + StatusEnum.TASK_PUBLISH + "'").getResultJSONArray(0);
|
||||
//查询所有自动下发的任务
|
||||
JSONArray all = taskTable.query("is_auto_issue = '1' and task_type < '" + StatusEnum.TASK_PUBLISH + "'").getResultJSONArray(0);
|
||||
//分区域:不同区域调用不同acs接口
|
||||
log.info("TaskScheduleService#taskPublish all_task:{}",all.size());
|
||||
Map<String, List<Object>> areaCollent = all.stream().collect(Collectors.groupingBy(o -> ((JSONObject) o).getString("product_area")));
|
||||
@@ -65,8 +66,10 @@ public class TaskScheduleService {
|
||||
String taskGroupId = IdUtil.getStringId();
|
||||
JSONObject task = (JSONObject) o;
|
||||
String taskId = task.getString("task_id");
|
||||
task.put("is_send","1");
|
||||
if (taskGroupMap.get(taskId) != null){
|
||||
task.put("task_group_id",taskGroupMap.get(taskId));
|
||||
task.put("is_send","0");
|
||||
continue;
|
||||
}
|
||||
String start = task.getString("point_code1");
|
||||
@@ -96,10 +99,15 @@ public class TaskScheduleService {
|
||||
String waitingTaskId = waitingTask.stream().map(a -> ((JSONObject) a).getString("task_id")).collect(Collectors.joining(","));
|
||||
String MergeId = Merge.stream().map(a -> ((JSONObject) a).getString("task_id")).collect(Collectors.joining(","));
|
||||
log.info("TaskScheduleService#taskPublish notMerge:{},waitingTask:{},merge:{}",notMergeID,waitingTaskId,MergeId);
|
||||
//下发任务:一次暂时下发十条:同一个区域任务不超过10条
|
||||
JSONArray form = new JSONArray();
|
||||
Merge.addAll(notMerge);
|
||||
JSONArray jsonArray = new JSONArray(Merge);
|
||||
//批量更新任务状态,is_send,task_group_id
|
||||
for (Object task : Merge) {
|
||||
JSONObject task1 = (JSONObject) task;
|
||||
task1.put("task_type",StatusEnum.TASK_PUBLISH.getCode());
|
||||
taskTable.update(task1,"task_id = '"+task1.getString("task_id")+"'");
|
||||
}
|
||||
//缓存线任务待确认是否生成多个
|
||||
wmsToAcsService.issueTaskToAcs(jsonArray);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user