23 changed files with 1128 additions and 273 deletions
@ -1,206 +0,0 @@ |
|||
/* |
|||
* Copyright 2019-2020 Zheng Jie |
|||
* |
|||
* 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.common.mnt.util; |
|||
|
|||
import com.alibaba.druid.pool.DruidDataSource; |
|||
import com.alibaba.druid.util.StringUtils; |
|||
import com.google.common.collect.Lists; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.io.BufferedReader; |
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.InputStreamReader; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.sql.*; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author / |
|||
*/ |
|||
@Slf4j |
|||
public class SqlUtils { |
|||
|
|||
public static final String COLON = ":"; |
|||
|
|||
|
|||
/** |
|||
* 获取数据源 |
|||
* |
|||
* @param jdbcUrl / |
|||
* @param userName / |
|||
* @param password / |
|||
* @return DataSource |
|||
*/ |
|||
private static DataSource getDataSource(String jdbcUrl, String userName, String password) { |
|||
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 (StringUtils.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(1); |
|||
druidDataSource.setMinIdle(1); |
|||
druidDataSource.setMaxActive(1); |
|||
|
|||
// 如果链接出现异常则直接判定为失败而不是一直重试
|
|||
druidDataSource.setBreakAfterAcquireFailure(true); |
|||
try { |
|||
druidDataSource.init(); |
|||
} catch (SQLException e) { |
|||
log.error("Exception during pool initialization", e); |
|||
throw new RuntimeException(e.getMessage()); |
|||
} |
|||
|
|||
return druidDataSource; |
|||
} |
|||
|
|||
private static Connection getConnection(String jdbcUrl, String userName, String password) { |
|||
DataSource dataSource = getDataSource(jdbcUrl, userName, password); |
|||
Connection connection = null; |
|||
try { |
|||
connection = dataSource.getConnection(); |
|||
} catch (Exception ignored) {} |
|||
try { |
|||
int timeOut = 5; |
|||
if (null == connection || connection.isClosed() || !connection.isValid(timeOut)) { |
|||
log.info("connection is closed or invalid, retry get connection!"); |
|||
connection = dataSource.getConnection(); |
|||
} |
|||
} catch (Exception e) { |
|||
log.error("create connection error, jdbcUrl: {}", jdbcUrl); |
|||
throw new RuntimeException("create connection error, jdbcUrl: " + jdbcUrl); |
|||
} |
|||
return connection; |
|||
} |
|||
|
|||
private static void releaseConnection(Connection connection) { |
|||
if (null != connection) { |
|||
try { |
|||
connection.close(); |
|||
} catch (Exception e) { |
|||
log.error(e.getMessage(),e); |
|||
log.error("connection close error:" + e.getMessage()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
public static void closeResult(ResultSet rs) { |
|||
if (rs != null) { |
|||
try { |
|||
rs.close(); |
|||
} catch (Exception e) { |
|||
log.error(e.getMessage(),e); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static boolean testConnection(String jdbcUrl, String userName, String password) { |
|||
Connection connection = null; |
|||
try { |
|||
connection = getConnection(jdbcUrl, userName, password); |
|||
if (null != connection) { |
|||
return true; |
|||
} |
|||
} catch (Exception e) { |
|||
log.info("Get connection failed:" + e.getMessage()); |
|||
} finally { |
|||
releaseConnection(connection); |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
public static String executeFile(String jdbcUrl, String userName, String password, File sqlFile) { |
|||
Connection connection = getConnection(jdbcUrl, userName, password); |
|||
try { |
|||
batchExecute(connection, readSqlList(sqlFile)); |
|||
} catch (Exception e) { |
|||
log.error("sql脚本执行发生异常:{}",e.getMessage()); |
|||
return e.getMessage(); |
|||
}finally { |
|||
releaseConnection(connection); |
|||
} |
|||
return "success"; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 批量执行sql |
|||
* @param connection / |
|||
* @param sqlList / |
|||
*/ |
|||
public static void batchExecute(Connection connection, List<String> sqlList) throws SQLException { |
|||
Statement st = connection.createStatement(); |
|||
for (String sql : sqlList) { |
|||
if (sql.endsWith(";")) { |
|||
sql = sql.substring(0, sql.length() - 1); |
|||
} |
|||
st.addBatch(sql); |
|||
} |
|||
st.executeBatch(); |
|||
} |
|||
|
|||
/** |
|||
* 将文件中的sql语句以;为单位读取到列表中 |
|||
* @param sqlFile / |
|||
* @return / |
|||
* @throws Exception e |
|||
*/ |
|||
private static List<String> readSqlList(File sqlFile) throws Exception { |
|||
List<String> sqlList = Lists.newArrayList(); |
|||
StringBuilder sb = new StringBuilder(); |
|||
try (BufferedReader reader = new BufferedReader(new InputStreamReader( |
|||
new FileInputStream(sqlFile), StandardCharsets.UTF_8))) { |
|||
String tmp; |
|||
while ((tmp = reader.readLine()) != null) { |
|||
log.info("line:{}", tmp); |
|||
if (tmp.endsWith(";")) { |
|||
sb.append(tmp); |
|||
sqlList.add(sb.toString()); |
|||
sb.delete(0, sb.length()); |
|||
} else { |
|||
sb.append(tmp); |
|||
} |
|||
} |
|||
if (!"".endsWith(sb.toString().trim())) { |
|||
sqlList.add(sb.toString()); |
|||
} |
|||
} |
|||
|
|||
return sqlList; |
|||
} |
|||
|
|||
} |
@ -1,23 +0,0 @@ |
|||
package org.nl.config; |
|||
|
|||
import com.alibaba.druid.pool.DruidDataSource; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
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; |
|||
|
|||
@Configuration |
|||
@Slf4j |
|||
public class DataBaseConfig { |
|||
|
|||
@Primary |
|||
@Bean(name = "dataSource") |
|||
@ConfigurationProperties(prefix = "spring.datasource.druid") |
|||
public DataSource dataSource() { |
|||
return new DruidDataSource(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,167 @@ |
|||
package org.nl.wms.ext.fab.controller; |
|||
|
|||
import cn.dev33.satoken.annotation.SaIgnore; |
|||
import cn.hutool.core.lang.Assert; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import io.swagger.annotations.Api; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.base.TableDataInfo; |
|||
import org.nl.common.enums.VehicleTypeEnum; |
|||
import org.nl.common.logging.annotation.Log; |
|||
import org.nl.config.MapOf; |
|||
import org.nl.wms.ext.fab.service.dto.*; |
|||
import org.nl.wms.ext.fab.service.impl.FabServiceImpl; |
|||
import org.nl.wms.sch.point.service.ISchBasePointService; |
|||
import org.nl.wms.sch.point.service.dto.PointMaterialInfo; |
|||
import org.nl.wms.sch.region.service.ISchBaseRegionService; |
|||
import org.nl.wms.sch.region.service.dao.SchBaseRegion; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@Api(tags = "fab相关接口") |
|||
@RequestMapping("/api/fab") |
|||
@Slf4j |
|||
@SaIgnore |
|||
public class FabController { |
|||
|
|||
@Autowired |
|||
private ISchBaseRegionService iSchBaseRegionService; |
|||
@Autowired |
|||
private ISchBasePointService iSchBasePointService; |
|||
@Autowired |
|||
private FabServiceImpl fabService; |
|||
|
|||
|
|||
/** |
|||
* 设备工序列表 |
|||
* @return |
|||
*/ |
|||
@Log("设备工序列表") |
|||
@GetMapping("/regionList") |
|||
public ResponseEntity<TableDataInfo<List<LB>>> regionList(){ |
|||
List<SchBaseRegion> regionList = iSchBaseRegionService.getRegionList(new SchBaseRegion()); |
|||
List result = new ArrayList<>(); |
|||
for (SchBaseRegion schBaseRegion : regionList) { |
|||
result.add(MapOf.of("label",schBaseRegion.getRegion_name(),"value",schBaseRegion.getRegion_code())); |
|||
} |
|||
return new ResponseEntity(TableDataInfo.build(result), HttpStatus.OK); |
|||
} |
|||
|
|||
/** |
|||
* 根据工序获取设备点位信息 |
|||
* @return |
|||
*/ |
|||
@Log("根据工序获取设备点位信息") |
|||
@GetMapping("/regionPoints") |
|||
public ResponseEntity<Map> regionPoints(String regionCode){ |
|||
Assert.notBlank(regionCode,"请求参数不能为空"); |
|||
SchBaseRegion baseRegion = iSchBaseRegionService.getOne(new QueryWrapper<SchBaseRegion>().eq("region_code", regionCode)); |
|||
String regionPoints = baseRegion.getRegion_points(); |
|||
JSONObject pointConfig = JSON.parseObject(regionPoints); |
|||
return new ResponseEntity(pointConfig, HttpStatus.OK); |
|||
} |
|||
|
|||
/** |
|||
* 根据工序查询订单 |
|||
* @param regionCode |
|||
* @return |
|||
*/ |
|||
@Log("根据工序查询工单") |
|||
@GetMapping("/regionOrder") |
|||
public ResponseEntity<TableDataInfo<OrderMater>> regionOrder(String regionCode){ |
|||
List<OrderMater> orderMaters = fabService.getOrderBycode(regionCode); |
|||
return new ResponseEntity(TableDataInfo.build(orderMaters), HttpStatus.OK); |
|||
} |
|||
|
|||
/** |
|||
* 根据工单查询匹配库存 |
|||
* @param order |
|||
* @param regionCode |
|||
* @return |
|||
*/ |
|||
@Log("根据工单查询匹配库存") |
|||
@GetMapping("/getMaterListByOrder") |
|||
public ResponseEntity<TableDataInfo<List<PointMaterialInfo>>> getMaterListByOrder(String order,String regionCode){ |
|||
List<PointMaterialInfo> structList = iSchBasePointService.getStructList(regionCode, null); |
|||
return new ResponseEntity(TableDataInfo.build(structList), HttpStatus.OK); |
|||
} |
|||
|
|||
/** |
|||
* 呼叫库存物料 |
|||
* @param MaterInfo |
|||
* @return |
|||
*/ |
|||
@Log("呼叫库存物料") |
|||
@PostMapping("/callMater") |
|||
public ResponseEntity<TableDataInfo> callMater(@RequestBody CallMaterVo MaterInfo){ |
|||
JSONObject toJSON = (JSONObject)JSON.toJSON(MaterInfo); |
|||
fabService.createAgvTask(toJSON,"cmt"); |
|||
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK); |
|||
} |
|||
|
|||
/** |
|||
* 呼叫空料框 |
|||
* @return |
|||
*/ |
|||
@Log("呼叫空料框") |
|||
@PostMapping("/callEmp") |
|||
public ResponseEntity<TableDataInfo> callEmp(@RequestBody CallEmpVo callEmpVo){ |
|||
JSONObject toJSON = (JSONObject)JSON.toJSON(callEmpVo); |
|||
fabService.createAgvTask(toJSON,"cnt"); |
|||
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK); |
|||
} |
|||
|
|||
/** |
|||
* 叫料点回库 |
|||
* @return |
|||
*/ |
|||
@Log("叫料点回库") |
|||
@PostMapping("/sendVehicle") |
|||
public ResponseEntity<TableDataInfo> sendVehicle(@RequestBody SendVehicleVo sendVehicleVo){ |
|||
JSONObject toJSON = (JSONObject)JSON.toJSON(sendVehicleVo); |
|||
Integer qty = sendVehicleVo.getMaterial_qty(); |
|||
if (qty.intValue()==0){ |
|||
fabService.createAgvTask(toJSON,"snt"); |
|||
}else { |
|||
fabService.createAgvTask(toJSON,"smt"); |
|||
} |
|||
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK); |
|||
} |
|||
|
|||
/** |
|||
* 载具类型列表 |
|||
* @return |
|||
*/ |
|||
@Log("载具类型列表") |
|||
@PostMapping("/vehicleType") |
|||
public ResponseEntity<TableDataInfo<List<LB>>> vehicleType(){ |
|||
List<LB> result = new ArrayList<>(); |
|||
for (VehicleTypeEnum value : VehicleTypeEnum.values()) { |
|||
result.add(LB.builder().label(value.getVehicleName()).value(value.getVehicleCode()).build()); |
|||
} |
|||
return new ResponseEntity(TableDataInfo.build(result), HttpStatus.OK); |
|||
} |
|||
|
|||
/** |
|||
* 工序下料 |
|||
* @param MaterInfo |
|||
* @return |
|||
*/ |
|||
@Log("工序下料") |
|||
@PostMapping("/sendMater") |
|||
public ResponseEntity<TableDataInfo> sendMater(@RequestBody SendMaterVo MaterInfo){ |
|||
JSONObject toJSON = (JSONObject)JSON.toJSON(MaterInfo); |
|||
fabService.createAgvTask(toJSON,"smt"); |
|||
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,37 @@ |
|||
package org.nl.wms.ext.fab.controller; |
|||
|
|||
import cn.dev33.satoken.annotation.SaIgnore; |
|||
import io.swagger.annotations.Api; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.base.TableDataInfo; |
|||
import org.nl.common.logging.annotation.Log; |
|||
import org.nl.wms.ext.fab.service.dto.*; |
|||
import org.nl.wms.ext.fab.service.impl.FabServiceImpl; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@Api(tags = "fab同步接口") |
|||
@RequestMapping("/api/fabSync") |
|||
@Slf4j |
|||
@SaIgnore |
|||
public class FabSycnController { |
|||
|
|||
@Autowired |
|||
private FabServiceImpl fabService; |
|||
/** |
|||
* 手动同步fab物料状态 |
|||
* @return |
|||
*/ |
|||
@Log("手动同步fab") |
|||
@GetMapping("/sync") |
|||
public ResponseEntity<LB> regionList(List<String> orders){ |
|||
fabService.syncFab(orders); |
|||
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,39 @@ |
|||
package org.nl.wms.ext.fab.service.dao; |
|||
|
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
public class FabConsumptionDo implements Serializable { |
|||
// 唯一标识
|
|||
private String MSGID; |
|||
/** |
|||
* 压机作业计划号 |
|||
*/ |
|||
private String PWORKSCHE_ID; |
|||
/** |
|||
* 配料作业计划号 |
|||
*/ |
|||
private String FWORKSCHE_ID; |
|||
/** |
|||
* 配料批次号 |
|||
*/ |
|||
private String FPROBATCH; |
|||
/** |
|||
* 配料吨袋号 |
|||
*/ |
|||
private String FBAGCODE; |
|||
/** |
|||
* 泥料仓库编号 |
|||
*/ |
|||
private String LOGT; |
|||
/** |
|||
* 出库数量 |
|||
*/ |
|||
private BigDecimal OUT_NUMBER; |
|||
|
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package org.nl.wms.ext.fab.service.dao.mapper; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.nl.wms.database.material.service.dao.MdBaseMaterial; |
|||
import org.nl.wms.ext.fab.service.dao.FabConsumptionDo; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
public interface FabRequestMapper { |
|||
|
|||
@DS("sqlserver") |
|||
List<MdBaseMaterial> getMesMaterialInfos(@Param("time") String time); |
|||
|
|||
@DS("sqlserver") |
|||
List<JSONObject> getMesMaterialInfos2(); |
|||
|
|||
/** |
|||
* 根据工序查看FAb的订单列表 |
|||
* @param regionCode |
|||
* @return |
|||
*/ |
|||
@DS("sqlserver") |
|||
List<FabConsumptionDo> getMWorkOrderInfos(@Param("regionCode") String regionCode); |
|||
} |
@ -0,0 +1,33 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="org.nl.wms.ext.fab.service.dao.mapper.FabRequestMapper"> |
|||
<insert id="getMesMaterialInfos" parameterType="org.nl.wms.ext.fab.service.dao.FabConsumptionDo"> |
|||
INSERT INTO "LMSTELCOM"."RECEIVE_MUDMATERIEL_OUT"( MSGID, PWORKSCHE_ID, OUT_FINNUM, PRESSUNIT, FBAGCODE, LOGT |
|||
, SENDTIM |
|||
, CREATE_TM, OP_FLAG, SLEEP_TIME) |
|||
VALUES ( #{MSGID}, #{PWORKSCHE_ID}, #{OUT_FINNUM}, #{PRESSUNIT}, #{FBAGCODE}, #{LOGT} |
|||
, #{SENDTIM}, #{CREATE_TM}, #{OP_FLAG}, #{SLEEP_TIME}) |
|||
</insert> |
|||
<insert id="getMesMaterialInfos2" parameterType="org.nl.wms.ext.fab.service.dao.FabConsumptionDo"> |
|||
INSERT INTO "LMSTELCOM"."RECEIVE_R_SEMIPRODUCT"( MSGID, FORDER_NO, PWORKSCHE_ID, FPRODUCT_MATERIAL_ID |
|||
, FPRODUCT_MATERIAL_NAME, FMATSPEC, FMATMODEL, BATCHNO, PRESSUNIT |
|||
, FTEAM, TRAY_NO, PRO_SUBNUM |
|||
, PRO_SUBUNIT, CHECKERIN_TIM, PRODATE, CREATE_TM, OP_FLAG) |
|||
VALUES ( #{MSGID}, #{FORDER_NO}, #{PWORKSCHE_ID} |
|||
, #{FPRODUCT_MATERIAL_ID}, #{FPRODUCT_MATERIAL_NAME}, #{FMATSPEC}, #{FMATMODEL}, #{BATCHNO}, #{PRESSUNIT} |
|||
, #{FTEAM}, #{TRAY_NO}, #{PRO_SUBNUM}, #{PRO_SUBUNIT}, #{CHECKERIN_TIM}, #{PRODATE}, #{CREATE_TM} |
|||
, #{OP_FLAG}) |
|||
</insert> |
|||
<insert id="getMWorkOrderInfos" parameterType="org.nl.wms.ext.fab.service.dao.FabConsumptionDo"> |
|||
INSERT INTO "LMSTELCOM"."RECEIVE_CS_SEMIPROINFO_IN"( MSGID, FORDER_NO, PWORKSCHE_ID, PRESSUNIT, FSCHEDULE_ID |
|||
, FPRODUCT_MATERIAL_ID, FPRODUCT_MATERIAL_NAME, FMATSPEC |
|||
, FMATMODEL, BATCHNO, FTEAM, TRAY_NO, PRO_SUBNUM |
|||
, PRO_SUBUNIT, CHECKERIN_TIM, PRODATE, CREATE_TM, OP_FLAG) |
|||
VALUES ( #{MSGID}, #{FORDER_NO}, #{PWORKSCHE_ID} |
|||
, #{PRESSUNIT}, #{FSCHEDULE_ID}, #{FPRODUCT_MATERIAL_ID}, #{FPRODUCT_MATERIAL_NAME}, #{FMATSPEC} |
|||
, #{FMATMODEL} |
|||
, #{BATCHNO}, #{FTEAM}, #{TRAY_NO}, #{PRO_SUBNUM}, #{PRO_SUBUNIT}, #{CHECKERIN_TIM}, #{PRODATE} |
|||
, #{CREATE_TM} |
|||
, #{OP_FLAG}) |
|||
</insert> |
|||
</mapper> |
@ -0,0 +1,19 @@ |
|||
package org.nl.wms.ext.fab.service.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class CallEmpVo { |
|||
/** |
|||
* 呼叫点位(...OUT1) |
|||
*/ |
|||
private String device_code; |
|||
/** |
|||
* 托盘类型 |
|||
*/ |
|||
private String vehicle_type; |
|||
/** |
|||
* 设备工序 |
|||
*/ |
|||
private String regin_code; |
|||
} |
@ -0,0 +1,35 @@ |
|||
package org.nl.wms.ext.fab.service.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class CallMaterVo { |
|||
/** |
|||
* 货位 |
|||
*/ |
|||
public String point_code; |
|||
/** |
|||
* 载具编码 |
|||
*/ |
|||
public String vehicle_code; |
|||
/** |
|||
* 物料id |
|||
*/ |
|||
public String material_id; |
|||
/** |
|||
* 订单号 |
|||
*/ |
|||
public String order_code; |
|||
/** |
|||
* 物料数量 |
|||
*/ |
|||
public String material_qty; |
|||
/** |
|||
* 呼叫点位(IN1,IN2) |
|||
*/ |
|||
public String device_code; |
|||
/** |
|||
* 设备工序 |
|||
*/ |
|||
public String region_code; |
|||
} |
@ -0,0 +1,17 @@ |
|||
package org.nl.wms.ext.fab.service.dto; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Builder |
|||
public class LB { |
|||
/** |
|||
* 标签 |
|||
*/ |
|||
private String label; |
|||
/** |
|||
* 值 |
|||
*/ |
|||
private String value; |
|||
} |
@ -0,0 +1,32 @@ |
|||
package org.nl.wms.ext.fab.service.dto; |
|||
|
|||
public class OrderMater { |
|||
/** |
|||
* 物料号 |
|||
*/ |
|||
public String material_id; |
|||
/** |
|||
* 物料类型 |
|||
*/ |
|||
public String material_type; |
|||
/** |
|||
* 订单号 |
|||
*/ |
|||
public String order_code; |
|||
/** |
|||
* 工序 |
|||
*/ |
|||
public String region_code; |
|||
/** |
|||
* 物料数量 |
|||
*/ |
|||
public String material_qty; |
|||
/** |
|||
* 交期时间 |
|||
*/ |
|||
public String dua_date; |
|||
/** |
|||
* 客户编码 |
|||
*/ |
|||
public String custom; |
|||
} |
@ -0,0 +1,39 @@ |
|||
package org.nl.wms.ext.fab.service.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class SendMaterVo { |
|||
/** |
|||
* 载具编码 |
|||
*/ |
|||
public String vehicle_code; |
|||
/** |
|||
* 物料id |
|||
*/ |
|||
public String material_id; |
|||
/** |
|||
* 订单号 |
|||
*/ |
|||
public String order_code; |
|||
/** |
|||
* 合格数量 |
|||
*/ |
|||
public Integer material_qty; |
|||
/** |
|||
* 地面点位(IN1,IN2) |
|||
*/ |
|||
public String device_code; |
|||
/** |
|||
* 设备工序 |
|||
*/ |
|||
public String region_code; |
|||
/** |
|||
* 指定区域 |
|||
*/ |
|||
public String target_region_code; |
|||
/** |
|||
* 是否报功 |
|||
*/ |
|||
public Boolean has_report; |
|||
} |
@ -0,0 +1,21 @@ |
|||
package org.nl.wms.ext.fab.service.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class SendVehicleVo { |
|||
|
|||
/** |
|||
* 物料数量 |
|||
*/ |
|||
public Integer material_qty; |
|||
/** |
|||
* 地面点位(IN1,IN2) |
|||
*/ |
|||
public String device_code; |
|||
/** |
|||
* 设备工序 |
|||
*/ |
|||
public String region_code; |
|||
|
|||
} |
@ -0,0 +1,88 @@ |
|||
package org.nl.wms.ext.fab.service.impl; |
|||
|
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.wms.ext.acs.service.dto.to.BaseResponse; |
|||
import org.nl.wms.ext.fab.service.dao.FabConsumptionDo; |
|||
import org.nl.wms.ext.fab.service.dao.mapper.FabRequestMapper; |
|||
import org.nl.wms.ext.fab.service.dto.*; |
|||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
|||
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; |
|||
import org.nl.wms.sch.task_manage.task.tasks.handheld.CallEmptyTask; |
|||
import org.nl.wms.sch.task_manage.task.tasks.pcoperation.PcOperationCMTask; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class FabServiceImpl { |
|||
|
|||
@Resource |
|||
private FabRequestMapper fabRequestMapper; |
|||
@Autowired |
|||
private ISchBaseVehiclematerialgroupService iSchBaseVehiclematerialgroupService; |
|||
/** |
|||
* pc呼叫满料 |
|||
*/ |
|||
@Autowired |
|||
private PcOperationCMTask pcOperationCMTask; |
|||
/** |
|||
* 呼叫空料笼 |
|||
*/ |
|||
@Autowired |
|||
private CallEmptyTask callEmptyTask; |
|||
|
|||
|
|||
public void syncFab(List<String> orders) { |
|||
if (CollectionUtils.isEmpty(orders)){ |
|||
//查询所有组盘表800号
|
|||
// List<SchBaseVehiclematerialgroup> list = iSchBaseVehiclematerialgroupService.groupOrderCode();
|
|||
// for (SchBaseVehiclematerialgroup schBaseVehiclematerialgroup : list) {
|
|||
//
|
|||
// }
|
|||
} |
|||
} |
|||
|
|||
public List<OrderMater> getOrderBycode(String regionCode) { |
|||
List<OrderMater> result = new ArrayList<>(); |
|||
List<FabConsumptionDo> mWorkOrderInfos = fabRequestMapper.getMWorkOrderInfos(regionCode); |
|||
for (FabConsumptionDo mWorkOrderInfo : mWorkOrderInfos) { |
|||
OrderMater orderMater = new OrderMater(); |
|||
result.add(orderMater); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
public void createAgvTask(JSONObject form,String type) { |
|||
JSONObject param = new JSONObject(); |
|||
|
|||
switch (type){ |
|||
case "cmt": |
|||
CallMaterVo callMaterVo = form.toJavaObject(CallMaterVo.class); |
|||
param.put("device_code",callMaterVo.getDevice_code()); |
|||
param.put("config_code","PcOperationCMTask"); |
|||
param.put("vehicle_code",callMaterVo.getVehicle_code()); |
|||
param.put("ext_data",callMaterVo); |
|||
pcOperationCMTask.apply(param); |
|||
break; |
|||
case "cnt": |
|||
CallEmpVo callEmpVo = form.toJavaObject(CallEmpVo.class); |
|||
param.put("device_code",callEmpVo.getDevice_code()); |
|||
param.put("config_code","PcOperationCNTask"); |
|||
param.put("ext_data",callEmpVo); |
|||
callEmptyTask.apply(param); |
|||
break; |
|||
case "smt": |
|||
SendMaterVo sendMaterVo = form.toJavaObject(SendMaterVo.class); |
|||
break; |
|||
case "snt": |
|||
SendVehicleVo sendVehicleVo = form.toJavaObject(SendVehicleVo.class); |
|||
break; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,165 @@ |
|||
package org.nl.wms.sch.task_manage.task.tasks.pcoperation; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.enums.GoodsEnum; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.system.service.notice.ISysNoticeService; |
|||
import org.nl.wms.database.vehicle.service.IMdBaseVehicleService; |
|||
import org.nl.wms.database.vehicle.service.dao.MdBaseVehicle; |
|||
import org.nl.wms.ext.acs.service.dto.to.BaseResponse; |
|||
import org.nl.wms.ext.fab.service.dto.CallMaterVo; |
|||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
|||
import org.nl.wms.sch.point.service.ISchBasePointService; |
|||
import org.nl.wms.sch.point.service.dao.SchBasePoint; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskService; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; |
|||
import org.nl.wms.sch.task.service.dao.SchBaseTask; |
|||
import org.nl.wms.sch.task_manage.AbstractTask; |
|||
import org.nl.wms.sch.task_manage.GeneralDefinition; |
|||
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; |
|||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum; |
|||
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
|||
import org.nl.wms.util.PointUtils; |
|||
import org.nl.wms.util.TaskUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* sorting呼叫满料 |
|||
*/ |
|||
@Slf4j |
|||
@Component(value = "PcOperationCMTask") |
|||
public class PcOperationCMTask extends AbstractTask { |
|||
|
|||
|
|||
private static final String TASK_CONFIG_CODE = "PcOperationCMTask"; |
|||
@Autowired |
|||
private ISchBasePointService pointService; |
|||
@Autowired |
|||
private ISchBaseTaskService taskService; |
|||
@Autowired |
|||
private ISysNoticeService noticeService; |
|||
@Autowired |
|||
private ISchBasePointService schBasePointService; |
|||
@Autowired |
|||
private IMdBaseVehicleService iMdBaseVehicleService; |
|||
|
|||
@Override |
|||
protected void create() throws BadRequestException { |
|||
// 获取任务:叫满眶时候已经确认物料
|
|||
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
|||
for (SchBaseTask task : tasks) { |
|||
TaskUtils.setUpdateByAcs(task); |
|||
// 找起点
|
|||
CallMaterVo callMaterVo = JSONObject.parseObject(task.getRequest_param(), CallMaterVo.class); |
|||
MdBaseVehicle vehicle = iMdBaseVehicleService.getOne(new QueryWrapper<MdBaseVehicle>().eq("vehicle_code", callMaterVo.getVehicle_code())); |
|||
if(ObjectUtil.isEmpty(vehicle)) throw new BadRequestException("载具不存在"); |
|||
SchBasePoint structPoint = schBasePointService.getOne(new QueryWrapper<SchBasePoint>() |
|||
.eq("vehicle_code", vehicle) |
|||
.eq("is_lock",false)); |
|||
if (ObjectUtil.isEmpty(structPoint)) { |
|||
task.setRemark("未找到所需点位!"); |
|||
taskService.updateById(task); |
|||
// 消息通知
|
|||
noticeService.createNotice("未找到所需点位!", TASK_CONFIG_CODE + task.getTask_code(), |
|||
NoticeTypeEnum.WARN.getCode()); |
|||
continue; |
|||
} |
|||
taskService.update(new UpdateWrapper<SchBaseTask>() |
|||
.set("task_status",TaskStatus.CREATED.getCode()) |
|||
.set("point_code1",structPoint.getPoint_code()) |
|||
.eq("task_id",task.getTask_id())); |
|||
pointService.update(new UpdateWrapper<SchBasePoint>() |
|||
.set("ing_task_code",task.getTask_code()) |
|||
.set("is_lock",true) |
|||
.set("point_status", GoodsEnum.OUT_OF_STOCK.getValue()) |
|||
.eq("point_code",structPoint.getPoint_code())); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
protected void updateStatus(String task_code, TaskStatus status) { |
|||
//TODO:完成任务的时候将int_task_code的清除
|
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void forceFinish(String task_code) { |
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); |
|||
} |
|||
|
|||
@Override |
|||
public void cancel(String task_code) { |
|||
//TODO:取消任务的时候将int_task_code的清除
|
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); |
|||
} |
|||
|
|||
@Override |
|||
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) { |
|||
|
|||
} |
|||
|
|||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); |
|||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); |
|||
// 起点清空
|
|||
if (ObjectUtil.isNotEmpty(schBasePoint)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint); |
|||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, startPoint) |
|||
.set(SchBasePoint::getIs_lock, false).set(SchBasePoint::getVehicle_code,null)); |
|||
} |
|||
String point_code2 = taskObj.getPoint_code2(); |
|||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); |
|||
if (ObjectUtil.isNotEmpty(schBasePoint2)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint2); |
|||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code2) |
|||
.set(SchBasePoint::getIs_lock, false)); |
|||
} |
|||
// 任务完成
|
|||
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_FINISH); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); |
|||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); |
|||
// 起点清空
|
|||
if (ObjectUtil.isNotEmpty(schBasePoint)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint); |
|||
pointService.updateById(schBasePoint); |
|||
} |
|||
String point_code2 = taskObj.getPoint_code2(); |
|||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); |
|||
if (ObjectUtil.isNotEmpty(schBasePoint2)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint2); |
|||
pointService.updateById(schBasePoint2); |
|||
} |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL); |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,162 @@ |
|||
package org.nl.wms.sch.task_manage.task.tasks.pcoperation; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.enums.GoodsEnum; |
|||
import org.nl.common.enums.VehicleEnum; |
|||
import org.nl.common.enums.VehicleTypeEnum; |
|||
import org.nl.common.enums.region.RegionEnum; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.system.service.notice.ISysNoticeService; |
|||
import org.nl.wms.ext.acs.service.dto.to.BaseResponse; |
|||
import org.nl.wms.ext.fab.service.dto.CallEmpVo; |
|||
import org.nl.wms.ext.fab.service.dto.CallMaterVo; |
|||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
|||
import org.nl.wms.sch.point.service.ISchBasePointService; |
|||
import org.nl.wms.sch.point.service.dao.SchBasePoint; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskService; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; |
|||
import org.nl.wms.sch.task.service.dao.SchBaseTask; |
|||
import org.nl.wms.sch.task_manage.AbstractTask; |
|||
import org.nl.wms.sch.task_manage.GeneralDefinition; |
|||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum; |
|||
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
|||
import org.nl.wms.util.PointUtils; |
|||
import org.nl.wms.util.TaskUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* sorting呼叫空托 |
|||
*/ |
|||
@Slf4j |
|||
@Component(value = "PcOperationCNTask") |
|||
public class PcOperationCNTask extends AbstractTask { |
|||
|
|||
private static String Vehicle_Type = VehicleEnum.XL.getCode(); |
|||
|
|||
private static final String TASK_CONFIG_CODE = "PcOperationCNTask"; |
|||
@Autowired |
|||
private ISchBasePointService pointService; |
|||
@Autowired |
|||
private ISchBaseTaskService taskService; |
|||
@Autowired |
|||
private ISchBaseTaskconfigService taskConfigService; |
|||
@Autowired |
|||
private ISysNoticeService noticeService; |
|||
@Autowired |
|||
private ISchBasePointService schBasePointService; |
|||
@Autowired |
|||
private ISchBaseVehiclematerialgroupService schBaseVehiclematerialgroupService; |
|||
|
|||
@Override |
|||
protected void create() throws BadRequestException { |
|||
// 获取任务
|
|||
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
|||
for (SchBaseTask task : tasks) { |
|||
TaskUtils.setUpdateByAcs(task); |
|||
// 找起点
|
|||
CallEmpVo callMaterVo = JSONObject.parseObject(task.getRequest_param(), CallEmpVo.class); |
|||
|
|||
SchBasePoint basePoint = schBasePointService.selectByEmptyCage(RegionEnum.DDLK.getRegion_code(), |
|||
callMaterVo.getVehicle_type(),GoodsEnum.EMPTY_PALLETS.getValue(),false,task); |
|||
if (basePoint==null){ |
|||
task.setRemark("未找到所需空料笼"); |
|||
taskService.updateById(task); |
|||
continue; |
|||
} |
|||
taskService.update(new UpdateWrapper<SchBaseTask>() |
|||
.set("task_status",TaskStatus.CREATED.getCode()) |
|||
.set("point_code1",basePoint.getPoint_code()).eq("task_id",task.getTask_id())); |
|||
pointService.update(new UpdateWrapper<SchBasePoint>() |
|||
.set("ing_task_code",task.getTask_code()) |
|||
.set("is_lock",true) |
|||
.set("point_status", GoodsEnum.OUT_OF_STOCK.getValue()) |
|||
.eq("point_code",basePoint.getPoint_code())); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
protected void updateStatus(String task_code, TaskStatus status) { |
|||
//TODO:完成任务的时候将int_task_code的清除
|
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void forceFinish(String task_code) { |
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); |
|||
} |
|||
|
|||
@Override |
|||
public void cancel(String task_code) { |
|||
//TODO:取消任务的时候将int_task_code的清除
|
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); |
|||
} |
|||
|
|||
@Override |
|||
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) { |
|||
|
|||
} |
|||
|
|||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); |
|||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); |
|||
// 起点清空
|
|||
if (ObjectUtil.isNotEmpty(schBasePoint)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint); |
|||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, startPoint) |
|||
.set(SchBasePoint::getIs_lock, false).set(SchBasePoint::getVehicle_code,null)); |
|||
} |
|||
String point_code2 = taskObj.getPoint_code2(); |
|||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); |
|||
if (ObjectUtil.isNotEmpty(schBasePoint2)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint2); |
|||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code2) |
|||
.set(SchBasePoint::getIs_lock, false)); |
|||
} |
|||
// 任务完成
|
|||
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_FINISH); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); |
|||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); |
|||
// 起点清空
|
|||
if (ObjectUtil.isNotEmpty(schBasePoint)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint); |
|||
pointService.updateById(schBasePoint); |
|||
} |
|||
String point_code2 = taskObj.getPoint_code2(); |
|||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); |
|||
if (ObjectUtil.isNotEmpty(schBasePoint2)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint2); |
|||
pointService.updateById(schBasePoint2); |
|||
} |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL); |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,190 @@ |
|||
package org.nl.wms.sch.task_manage.task.tasks.pcoperation; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.nl.common.enums.GoodsEnum; |
|||
import org.nl.common.enums.region.RegionEnum; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.system.service.notice.ISysNoticeService; |
|||
import org.nl.wms.ext.acs.service.dto.to.BaseResponse; |
|||
import org.nl.wms.ext.fab.service.dto.CallEmpVo; |
|||
import org.nl.wms.ext.fab.service.dto.SendMaterVo; |
|||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
|||
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; |
|||
import org.nl.wms.sch.point.service.ISchBasePointService; |
|||
import org.nl.wms.sch.point.service.dao.SchBasePoint; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskService; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; |
|||
import org.nl.wms.sch.task.service.dao.SchBaseTask; |
|||
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; |
|||
import org.nl.wms.sch.task_manage.AbstractTask; |
|||
import org.nl.wms.sch.task_manage.GeneralDefinition; |
|||
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; |
|||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum; |
|||
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
|||
import org.nl.wms.util.PointUtils; |
|||
import org.nl.wms.util.TaskUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* sorting将满料放到线边库 |
|||
*/ |
|||
@Slf4j |
|||
@Component(value = "PcOperationSMTTask") |
|||
public class PcOperationSMTTask extends AbstractTask { |
|||
|
|||
|
|||
private static final String TASK_CONFIG_CODE = "PcOperationSMTTask"; |
|||
@Autowired |
|||
private ISchBasePointService pointService; |
|||
@Autowired |
|||
private ISchBaseTaskService taskService; |
|||
@Autowired |
|||
private ISchBaseTaskconfigService taskConfigService; |
|||
@Autowired |
|||
private ISysNoticeService noticeService; |
|||
@Autowired |
|||
private ISchBasePointService schBasePointService; |
|||
@Autowired |
|||
private ISchBaseVehiclematerialgroupService schBaseVehiclematerialgroupService; |
|||
|
|||
@Override |
|||
protected void create() throws BadRequestException { |
|||
// 获取任务
|
|||
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
|||
|
|||
for (SchBaseTask task : tasks) { |
|||
TaskUtils.setUpdateByAcs(task); |
|||
// 找起点
|
|||
SendMaterVo sendMaterVo = JSONObject.parseObject(task.getRequest_param(), SendMaterVo.class); |
|||
//判断是否指定到外协区
|
|||
String targetRegionCode = sendMaterVo.getTarget_region_code(); |
|||
SchBasePoint schBasePoint = null; |
|||
if (!StringUtils.isEmpty(targetRegionCode)){ |
|||
|
|||
}else { |
|||
// 根据对接位查找对应的载具类型
|
|||
schBasePoint = schBasePointService.selectByRegionCode(task.getRegion_code(),task.getVehicle_code(),"1"); |
|||
} |
|||
if (ObjectUtil.isEmpty(schBasePoint)) { |
|||
task.setRemark("未找到所需点位!"); |
|||
taskService.updateById(task); |
|||
// 消息通知
|
|||
noticeService.createNotice("未找到所需点位!", TASK_CONFIG_CODE + task.getTask_code(), |
|||
NoticeTypeEnum.WARN.getCode()); |
|||
continue; |
|||
} |
|||
//删除组盘记录生成新的
|
|||
schBaseVehiclematerialgroupService.remove(new QueryWrapper<SchBaseVehiclematerialgroup>().eq("vehicle_code",sendMaterVo.getVehicle_code())); |
|||
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup(); |
|||
schBaseVehiclematerialgroup.setVehicle_code(sendMaterVo.getVehicle_code()); |
|||
schBaseVehiclematerialgroup.setPoint_code(schBasePoint.getPoint_code()); |
|||
schBaseVehiclematerialgroup.setMaterial_id(sendMaterVo.getMaterial_id()); |
|||
schBaseVehiclematerialgroup.setMaterial_qty(sendMaterVo.getMaterial_qty()); |
|||
schBaseVehiclematerialgroup.setRegion_code(sendMaterVo.getRegion_code()); |
|||
schBaseVehiclematerialgroup.setOrder_code(sendMaterVo.getOrder_code()); |
|||
schBaseVehiclematerialgroup.setHas_work(true); |
|||
schBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup); |
|||
// 设置终点并修改创建成功状态
|
|||
task.setPoint_code2(schBasePoint.getPoint_code()); |
|||
task.setVehicle_type(schBasePoint.getCan_vehicle_type()); |
|||
task.setRemark(""); |
|||
task.setTask_status(TaskStatus.CREATED.getCode()); |
|||
taskService.updateById(task); |
|||
|
|||
//更新点位
|
|||
schBasePoint.setPoint_status(GoodsEnum.IN_STOCK.getValue()); |
|||
schBasePoint.setIng_task_code(task.getTask_code()); |
|||
PointUtils.setUpdateByAcs(schBasePoint); |
|||
pointService.updateById(schBasePoint); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
protected void updateStatus(String task_code, TaskStatus status) { |
|||
//TODO:完成任务的时候将int_task_code的清除
|
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void forceFinish(String task_code) { |
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); |
|||
} |
|||
|
|||
@Override |
|||
public void cancel(String task_code) { |
|||
//TODO:取消任务的时候将int_task_code的清除
|
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); |
|||
} |
|||
|
|||
@Override |
|||
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) { |
|||
|
|||
} |
|||
|
|||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); |
|||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); |
|||
// 起点清空
|
|||
if (ObjectUtil.isNotEmpty(schBasePoint)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint); |
|||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, startPoint) |
|||
.set(SchBasePoint::getIs_lock, false)); |
|||
} |
|||
String point_code2 = taskObj.getPoint_code2(); |
|||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); |
|||
if (ObjectUtil.isNotEmpty(schBasePoint2)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint2); |
|||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code2) |
|||
.set(SchBasePoint::getIs_lock, false)); |
|||
} |
|||
// 任务完成
|
|||
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_FINISH); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); |
|||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); |
|||
// 起点清空
|
|||
if (ObjectUtil.isNotEmpty(schBasePoint)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint); |
|||
pointService.updateById(schBasePoint); |
|||
} |
|||
String point_code2 = taskObj.getPoint_code2(); |
|||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); |
|||
if (ObjectUtil.isNotEmpty(schBasePoint2)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint2); |
|||
pointService.updateById(schBasePoint2); |
|||
} |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL); |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,3 @@ |
|||
ALTER TABLE sch_base_vehiclematerialgroup |
|||
ADD COLUMN `due_date` varchar(63) DEFAULT null COMMENT '交期'; |
|||
ADD COLUMN `has_work` tinyint(1) DEFAULT 0 COMMENT '当前工序已加工判断防止重复生产'; |
Loading…
Reference in new issue