大规模优化

This commit is contained in:
2024-12-25 18:08:41 +08:00
parent 8187160185
commit b8793b7621
13 changed files with 295 additions and 286 deletions

View File

@@ -48,22 +48,6 @@ public class IndustryBatchController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
/**
* 导出批次总表列表
@PreAuthorize("@ss.hasPermi('work:batch:export')")
@Log(title = "批次总表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IndustryBatch industryBatch)
{
List<IndustryBatch> list = industryBatchService.selectIndustryBatchList(industryBatch);
ExcelUtil<IndustryBatch> util = new ExcelUtil<IndustryBatch>(IndustryBatch.class);
util.exportExcel(response, list, "批次总表数据");
}
*/
/** /**
* 获取批次总表详细信息 * 获取批次总表详细信息
*/ */

View File

@@ -49,20 +49,6 @@ public class IndustryFaultController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
/**
* 导出故障管理列表
@PreAuthorize("@ss.hasPermi('system:fault:export')")
@Log(title = "故障管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IndustryFault industryFault)
{
List<IndustryFault> list = industryFaultService.selectIndustryFaultList(industryFault);
ExcelUtil<IndustryFault> util = new ExcelUtil<IndustryFault>(IndustryFault.class);
util.exportExcel(response, list, "故障管理数据");
}
*/
/** /**
* 获取故障管理详细信息 * 获取故障管理详细信息
*/ */

View File

@@ -71,7 +71,6 @@ public class IndustryMaterialController extends BaseController
/** /**
* 查询钽靶主类列表 * 查询钽靶主类列表
*/ */
//@PreAuthorize("@ss.hasPermi('system:material:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(IndustryMaterial industryMaterial) public TableDataInfo list(IndustryMaterial industryMaterial)
{ {
@@ -82,9 +81,8 @@ public class IndustryMaterialController extends BaseController
/** /**
* 查询钽靶主类列表 * 查询钽靶主类列表,和上述接口差在只会查单一状态的列表
*/ */
//@PreAuthorize("@ss.hasPermi('system:material:list')")
@GetMapping("/list1") @GetMapping("/list1")
public TableDataInfo list1(IndustryMaterial industryMaterial) public TableDataInfo list1(IndustryMaterial industryMaterial)
{ {
@@ -117,23 +115,6 @@ public class IndustryMaterialController extends BaseController
List<IndustryMaterialVo> list = industryMaterialService.selectAbnormalList(industryMaterial); List<IndustryMaterialVo> list = industryMaterialService.selectAbnormalList(industryMaterial);
return getDataTable(list); return getDataTable(list);
} }
/**
* 导出钽靶主类列表
@PreAuthorize("@ss.hasPermi('system:material:export')")
@Log(title = "钽靶主类", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IndustryMaterial industryMaterial)
{
List<IndustryMaterial> list = industryMaterialService.selectIndustryMaterialList(industryMaterial);
ExcelUtil<IndustryMaterial> util = new ExcelUtil<IndustryMaterial>(IndustryMaterial.class);
util.exportExcel(response, list, "钽靶主类数据");
}
*/
/** /**
* 获取钽靶主类详细信息 * 获取钽靶主类详细信息
*/ */
@@ -194,7 +175,6 @@ public class IndustryMaterialController extends BaseController
IndustryStep industryStep = new IndustryStep(); IndustryStep industryStep = new IndustryStep();
industryStep.setStep(1L); industryStep.setStep(1L);
industryStep.setDelFlag(0L); industryStep.setDelFlag(0L);
industryStepService.start(industryStep); industryStepService.start(industryStep);
return success(industryMaterialService.start(industryMaterial)); return success(industryMaterialService.start(industryMaterial));
} }
@@ -280,19 +260,23 @@ public class IndustryMaterialController extends BaseController
@GetMapping("/nextStepFlag") @GetMapping("/nextStepFlag")
public AjaxResult nextStepFlag(){ public AjaxResult nextStepFlag(){
Long flag = redisCache.getCacheObject("nextStepFlag"); Long flag = redisCache.getCacheObject("nextStepFlag");
if (flag==0L){ if (Objects.nonNull(flag) && flag==0L){
return AjaxResult.success(0); return AjaxResult.success(0);
}else{
return AjaxResult.success(1);
} }
return AjaxResult.success(1);
} }
@GetMapping("/nextStepFlagError") @GetMapping("/nextStepFlagError")
public AjaxResult nextStepFlagError(){ public AjaxResult nextStepFlagError(){
Long flag = redisCache.getCacheObject("nextStepFlagError"); Long flag = redisCache.getCacheObject("nextStepFlagError");
if (flag==0L){ if (Objects.nonNull(flag) && flag==0L){
return AjaxResult.success(0); return AjaxResult.success(0);
}else{
return AjaxResult.success(1);
} }
return AjaxResult.success(1);
} }
@GetMapping("/clear") @GetMapping("/clear")

View File

@@ -62,20 +62,6 @@ public class IndustryStepController extends BaseController
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/**
* 导出钽靶道次表列表
@PreAuthorize("@ss.hasPermi('system:step:export')")
@Log(title = "钽靶道次表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IndustryStep industryStep)
{
List<IndustryStep> list = industryStepService.selectIndustryStepList(industryStep);
ExcelUtil<IndustryStep> util = new ExcelUtil<IndustryStep>(IndustryStep.class);
util.exportExcel(response, list, "钽靶道次表数据");
}
*/
/** /**
* 获取钽靶道次表详细信息 * 获取钽靶道次表详细信息
*/ */

View File

@@ -6,16 +6,16 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://localhost:3306/industry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://49.233.157.185:3306/industry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: root password: WANGyu11!
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
enabled: false enabled: false
url: jdbc:mysql://localhost:3306/industry2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://49.233.157.185:3306/industry2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: root password: WANGyu11!
# 初始连接数 # 初始连接数
initialSize: 5 initialSize: 5
# 最小连接池数量 # 最小连接池数量

View File

@@ -37,8 +37,8 @@ server:
# 日志配置 # 日志配置
logging: logging:
level: level:
com.industry: error com.industry: debug
org.springframework: error org.springframework: debug
# 用户配置 # 用户配置
user: user:
@@ -71,13 +71,13 @@ spring:
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址
host: localhost host: 49.233.157.185
# 端口默认为6379 # 端口默认为6379
port: 6379 port: 6379
# 数据库索引 # 数据库索引
database: 0 database: 0
# 密码 # 密码
password: password: WANGyu11!
# 连接超时时间 # 连接超时时间
timeout: 10000 timeout: 10000
lettuce: lettuce:
@@ -92,11 +92,11 @@ spring:
max-wait: -1 max-wait: -1
redis2: redis2:
# 地址 # 地址
host: localhost host: 49.233.157.185
# 端口号 # 端口号
port: 6379 port: 6379
# 密码 # 密码
password: password: WANGyu11!
# 连接超时时间 # 连接超时时间
timeout: 10000 timeout: 10000
# 数据库索引 # 数据库索引

View File

@@ -10,6 +10,22 @@ import io.jsonwebtoken.Claims;
*/ */
public class Constants public class Constants
{ {
/**
* 轧制结束
*/
public static final int COMPLETE_PROCESS = 2;
/**
* 无此工艺
*/
public static final int NOT_HAVE_TECHNOLOGY = 2;
/**
* 为处理此道次
*/
public static final int NOT_PROCESS = 2;
/** /**
* UTF-8 字符集 * UTF-8 字符集
*/ */
@@ -165,6 +181,7 @@ public class Constants
*/ */
public static final String[] JOB_WHITELIST_STR = { "com.industry.quartz.task" }; public static final String[] JOB_WHITELIST_STR = { "com.industry.quartz.task" };
/** /**
* 定时任务违规的字符 * 定时任务违规的字符
*/ */

View File

@@ -73,7 +73,7 @@ public interface IIndustryMaterialService
int start(IndustryMaterial industryMaterial); int start(IndustryMaterial industryMaterial);
String nextMaterial(IndustryMaterialDto industryMaterialDto); int nextMaterial(IndustryMaterialDto industryMaterialDto);
int updateIndustryMaterialStateByBatchId(Long batchId); int updateIndustryMaterialStateByBatchId(Long batchId);
@@ -96,6 +96,7 @@ public interface IIndustryMaterialService
/** /**
* 检测工艺是否相同 不相同返回0 相同返回1并且根据工艺表创建道次对象 * 检测工艺是否相同 不相同返回0 相同返回1并且根据工艺表创建道次对象
*
* @param industryMaterial batchId state=1 * @param industryMaterial batchId state=1
* @return * @return
*/ */
@@ -108,7 +109,7 @@ public interface IIndustryMaterialService
*/ */
public int checkFlagError(IndustryMaterialDto material); public int checkFlagError(IndustryMaterialDto material);
String nextError(IndustryMaterialDto industryMaterialDto); int nextError(IndustryMaterialDto industryMaterialDto);
List<IndustryMaterialVo> selectIndustryMaterialList1(IndustryMaterial industryMaterial); List<IndustryMaterialVo> selectIndustryMaterialList1(IndustryMaterial industryMaterial);

View File

@@ -75,7 +75,7 @@ public interface IIndustryStepService
* @param industryStep * @param industryStep
* @return * @return
*/ */
String nextStep(IndustryStep industryStep); int nextStep(IndustryStep industryStep);
int finish(Long batchId); int finish(Long batchId);
@@ -92,7 +92,7 @@ public interface IIndustryStepService
int createStep(IndustryMaterial industryMaterial); int createStep(IndustryMaterial industryMaterial);
public String nextStepError(IndustryStep industryStep); public int nextStepError(IndustryStep industryStep);
/** /**
* 获取当前运行这批料中道次最小的道次对应的材料id * 获取当前运行这批料中道次最小的道次对应的材料id
@@ -101,7 +101,7 @@ public interface IIndustryStepService
*/ */
String getSmallStepMaterialId(IndustryMaterial industryMaterial); String getSmallStepMaterialId(IndustryMaterial industryMaterial);
String finishError(Long batchId); int finishError(Long batchId);
/** /**

View File

@@ -1,7 +1,5 @@
package com.industry.work.service.impl; package com.industry.work.service.impl;
import java.io.IOException;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -10,6 +8,7 @@ import java.util.concurrent.TimeUnit;
import com.github.xingshuangs.iot.protocol.s7.service.S7PLC; import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
import com.industry.common.annotation.DataSource; import com.industry.common.annotation.DataSource;
import com.industry.common.constant.Constants;
import com.industry.common.core.redis.RedisCache; import com.industry.common.core.redis.RedisCache;
import com.industry.common.enums.DataSourceType; import com.industry.common.enums.DataSourceType;
@@ -209,7 +208,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
break; break;
} }
} }
// 判断是否存在一个 // 判断是否存在一个
if (Objects.isNull(firstMaterial.getBatchId())) { if (Objects.isNull(firstMaterial.getBatchId())) {
return 0; return 0;
} }
@@ -221,7 +220,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
// 判断是否已经开始 // 判断是否已经开始
industryMaterial.setOperation(1L); industryMaterial.setOperation(1L);
if (industryMaterialMapper.selectIndustryMaterialList(industryMaterial).size() != 0) { if (!industryMaterialMapper.selectIndustryMaterialList(industryMaterial).isEmpty()) {
// 如果size不为零说明已经有正在进行中的了 // 如果size不为零说明已经有正在进行中的了
// 提醒前端已经开始了,无需重新开始 // 提醒前端已经开始了,无需重新开始
return 0; return 0;
@@ -234,10 +233,11 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
redisCache.setCacheObject("materialFlag", 1L, 100, TimeUnit.HOURS); redisCache.setCacheObject("materialFlag", 1L, 100, TimeUnit.HOURS);
redisCache.setCacheObject("nextStepFlag", 0L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlag", 0L, 100, TimeUnit.HOURS);
for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) { // TODO PLC
MomResource momResource = getMomResource(industryMaterialVo); // for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) {
momService.processPowerOn(momResource); // MomResource momResource = getMomResource(industryMaterialVo);
} // momService.processPowerOn(momResource);
// }
return 1; return 1;
} }
@@ -265,30 +265,32 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
@Override @Override
@Transactional @Transactional
public String nextMaterial(IndustryMaterialDto industryMaterialDto) { public int nextMaterial(IndustryMaterialDto industryMaterialDto) {
if (industryMaterialDto.getStepFlag() == 0L) {
return 0;
}
int pos = -1; // 初始化 IndustryMaterial
IndustryMaterial industryMaterial = new IndustryMaterial(); IndustryMaterial industryMaterial = new IndustryMaterial();
industryMaterial.setBatchId(industryMaterialDto.getBatchId()); industryMaterial.setBatchId(industryMaterialDto.getBatchId());
Long state = industryMaterialDto.getState(); int pos = -1;
if (industryMaterialDto.getStepFlag() == 0L) {
return "当前未处理,你跳个鸡毛"; // 设置状态
}
// 3代表的是该批次中存在道次异常下面的查询时直接跳过这个批次 // 3代表的是该批次中存在道次异常下面的查询时直接跳过这个批次
state = state == 3 ? 1 : state;
// 查询下一个应该将operation改为 1 的批次 并且为同一状态 // 查询下一个应该将operation改为 1 的批次 并且为同一状态
Long state = (industryMaterialDto.getState() == 3) ? 1 : industryMaterialDto.getState();
industryMaterial.setState(state); industryMaterial.setState(state);
// 查询批次列表
// 查询当前批次状态1的列表
List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectIndustryMaterialList(industryMaterial); List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectIndustryMaterialList(industryMaterial);
if (industryMaterialVos.isEmpty() ) {
// 判断是否为空列表 // 如果为空列表则直接返回,全部发生异常了
if (industryMaterialVos.size() == 0) { return Constants.COMPLETE_PROCESS;
// 空列表返回2 通知前端改变操作方向 - -> +
return "2";
} }
if (industryMaterialVos.size() == 1){
// 判断列表是否只有一个对象 如果是的话则不需要更新字段operation // 或者判断列表是否只有一个对象 如果是的话则不需要更新字段operation
if (industryMaterialVos.size() == 1) { return 0;
return "0";
} }
// 记录当前正在运行的是第几个 // 记录当前正在运行的是第几个
@@ -301,11 +303,13 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
// 将现在正在运行的批次状态改为0 // 将现在正在运行的批次状态改为0
industryMaterialDto.setOperation(0L); industryMaterialDto.setOperation(0L);
updateIndustryMaterial(industryMaterialDto); updateIndustryMaterial(industryMaterialDto);
IndustryMaterialVo industryMaterialVo; IndustryMaterialVo industryMaterialVo;
Long materialFlag = redisCache.getCacheObject("materialFlag"); Long materialFlag = redisCache.getCacheObject("materialFlag");
// 处理是向上走还是向下走 // 处理是向上走还是向下走
int next = -1;
if (materialFlag == 0L) { if (materialFlag == 0L) {
int next = -1; // 此if为向上走
// 找到上一个正常的 // 找到上一个正常的
for (int i = pos - 1; i >= 0; i--) { for (int i = pos - 1; i >= 0; i--) {
if (industryMaterialVos.get(i).getState() == 1L) { if (industryMaterialVos.get(i).getState() == 1L) {
@@ -313,19 +317,22 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
break; break;
} }
} }
// 降序 // 往上走
if (next == -1) { if (next == -1) {
//走到这next如果还为-1表示这是最头上那个了 就要修改顺序 // 将批次改成他的下一个正常的
redisCache.setCacheObject("materialFlag", 1L, 100, TimeUnit.HOURS); // 找到下一个正常的
industryMaterialVo = industryMaterialVos.get(pos); for (int i =pos+1; i < industryMaterialVos.size(); i++) {
industryMaterialVo.setOperation(1L); if (industryMaterialVos.get(i).getState() == 1L) {
updateIndustryMaterial(industryMaterialVo); next = i;
return "下道次"; break;
}
}
industryMaterialVo = industryMaterialVos.get(next);
redisCache.setCacheObject("nextStepFlag", 1L, 100, TimeUnit.HOURS);
} else { } else {
industryMaterialVo = industryMaterialVos.get(next); industryMaterialVo = industryMaterialVos.get(next);
} }
} else { } else {
int next = -1;
// 找到下一个正常的 // 找到下一个正常的
for (int i = pos + 1; i < industryMaterialVos.size(); i++) { for (int i = pos + 1; i < industryMaterialVos.size(); i++) {
if (industryMaterialVos.get(i).getState() == 1L) { if (industryMaterialVos.get(i).getState() == 1L) {
@@ -334,20 +341,23 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
} }
} }
if (next == -1) { if (next == -1) {
// 改变方向由向下改为向上
redisCache.setCacheObject("materialFlag", 0L, 100, TimeUnit.HOURS); // 找到上一个正常的
for (int i = pos - 1; i >= 0; i--) {
industryMaterialVo = industryMaterialVos.get(pos); if (industryMaterialVos.get(i).getState() == 1L) {
industryMaterialVo.setOperation(1L); next = i;
updateIndustryMaterial(industryMaterialVo); break;
return "下道次"; }
}
industryMaterialVo = industryMaterialVos.get(next);
redisCache.setCacheObject("nextStepFlag", 1L, 100, TimeUnit.HOURS);
} else { } else {
industryMaterialVo = industryMaterialVos.get(next); industryMaterialVo = industryMaterialVos.get(next);
} }
} }
industryMaterialVo.setOperation(1L); industryMaterialVo.setOperation(1L);
updateIndustryMaterial(industryMaterialVo); updateIndustryMaterial(industryMaterialVo);
return "1"; return 1;
} }
@Override @Override
@@ -390,13 +400,12 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
public int abnormalStart(IndustryMaterial industryMaterial, String materialId) { public int abnormalStart(IndustryMaterial industryMaterial, String materialId) {
industryMaterial.setOperation(1L); industryMaterial.setOperation(1L);
if (industryMaterialMapper.selectIndustryMaterialList(industryMaterial).size() != 0) { if (!industryMaterialMapper.selectIndustryMaterialList(industryMaterial).isEmpty()) {
// 如果size不为零说明已经有正在进行中的了 // 如果size不为零说明已经有正在进行中的了
// 提醒前端已经开始了,无需重新开始 // 提醒前端已经开始了,无需重新开始
return 0; return 0;
} }
IndustryMaterialVo firstMaterial = selectIndustryMaterialById(materialId); IndustryMaterialVo firstMaterial = selectIndustryMaterialById(materialId);
// 到这里没有return出去 表示该批次未开始
// 拿到序号为第一的将其操作中设置成1 // 拿到序号为第一的将其操作中设置成1
firstMaterial.setOperation(1L); firstMaterial.setOperation(1L);
@@ -419,7 +428,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
* 检查是否为左侧正常批次的最后一个或者第一个,是的话向前端给一个提示要求点击下道次 * 检查是否为左侧正常批次的最后一个或者第一个,是的话向前端给一个提示要求点击下道次
* *
* @param material * @param material
* @return * @return 0表示无需切换道次 1表示需要切换道次
*/ */
@Override @Override
public int checkFlag(IndustryMaterialDto material) { public int checkFlag(IndustryMaterialDto material) {
@@ -435,7 +444,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
// 判断列表是否只有一个对象 如果是的话则不需要更新字段operation // 判断列表是否只有一个对象 如果是的话则不需要更新字段operation
if (industryMaterialVos.size() == 1) { if (industryMaterialVos.size() == 1) {
redisCache.setCacheObject("nextStepFlag", 1L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlag", 1L, 100, TimeUnit.HOURS);
return 0; return 1;
} }
// 记录当前正在运行的是第几个 // 记录当前正在运行的是第几个
int pos = -1; int pos = -1;
@@ -443,7 +452,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
int end = -1; int end = -1;
int flag = 1; int flag = 1;
for (int i = 0; i < industryMaterialVos.size(); i++) { for (int i = 0; i < industryMaterialVos.size(); i++) {
if (industryMaterialVos.get(i).getState() != 3 && flag == 1) { if (industryMaterialVos.get(i).getState() != 3L && flag == 1) {
start = i; start = i;
flag = 0; flag = 0;
} }
@@ -463,16 +472,16 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
if (start == pos) { if (start == pos) {
// 向上升并且已经升到头了 // 向上升并且已经升到头了
redisCache.setCacheObject("nextStepFlag", 1L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlag", 1L, 100, TimeUnit.HOURS);
return 0; return 1;
} }
} else { } else {
if (end == pos) { if (end == pos) {
redisCache.setCacheObject("nextStepFlag", 1L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlag", 1L, 100, TimeUnit.HOURS);
return 0; return 1;
} }
} }
redisCache.setCacheObject("nextStepFlag", 0L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlag", 0L, 100, TimeUnit.HOURS);
return 1; return 0;
} }
@@ -497,7 +506,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
// 判断列表是否只有一个对象 如果是的话则不需要更新字段operation // 判断列表是否只有一个对象 如果是的话则不需要更新字段operation
if (industryMaterialVos.size() == 1) { if (industryMaterialVos.size() == 1) {
redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS);
return 0; return 1;
} }
// 记录当前正在运行的是第几个 // 记录当前正在运行的是第几个
int pos = -1; int pos = -1;
@@ -527,64 +536,63 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
if (start == pos) { if (start == pos) {
redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS);
// 向上升并且已经升到头了 // 向上升并且已经升到头了
return 0; return 1;
} }
} else { } else {
if (end == pos) { if (end == pos) {
redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS);
return 0; return 1;
} }
} }
redisCache.setCacheObject("nextStepFlagError", 0L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlagError", 0L, 100, TimeUnit.HOURS);
return 1; return 0;
} }
@Override @Override
public String nextError(IndustryMaterialDto industryMaterialDto) { public int nextError(IndustryMaterialDto industryMaterialDto) {
int pos = -1; if (industryMaterialDto.getStepFlag() == 0L) {
return 0;
}
// 初始化
IndustryMaterial industryMaterial = new IndustryMaterial(); IndustryMaterial industryMaterial = new IndustryMaterial();
industryMaterial.setBatchId(industryMaterialDto.getBatchId()); industryMaterial.setBatchId(industryMaterialDto.getBatchId());
int pos = -1;
Long state = industryMaterialDto.getState(); Long state = industryMaterialDto.getState();
if (industryMaterialDto.getStepFlag() == 0L) {
return "未处理";
}
// 3代表的是该批次中存在道次异常下面的查询时直接跳过这个批次 // 3代表的是该批次中存在道次异常下面的查询时直接跳过这个批次
state = state == 3 ? 5 : state; state = state == 3 ? 5 : state;
// 查询下一个应该将operation改为 1 的批次 并且为同一状态 // 查询下一个应该将operation改为 1 的批次 并且为同一状态
industryMaterial.setState(state); industryMaterial.setState(state);
industryMaterial.setDelFlag(1L);
// 查出连同正在运行的道次以及左边料物信息 // 查出连同正在运行的道次以及左边料物信息
List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectIndustryMaterialAndStepList(industryMaterial); List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectIndustryMaterialAndStepList(industryMaterial);
// 判断是否为空列表 // 判断是否为空列表
if (industryMaterialVos.size() == 0) { if (industryMaterialVos.isEmpty()) {
// 空列表返回2 通知前端改变操作方向 - -> + // 为空则直接返回,表示全部异常了
return "2"; return Constants.COMPLETE_PROCESS;
} }
// 判断列表是否只有一个对象 如果是的话则不需要更新字段operation // 判断列表是否只有一个对象 如果是的话则不需要更新字段operation
if (industryMaterialVos.size() == 1) { if (industryMaterialVos.size() == 1) {
return "0"; redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS);
return 1;
} }
// 记录当前正在运行的是第几个 // 记录当前正在运行的是第几个
for (int i = 0; i < industryMaterialVos.size(); i++) { for (int i = 0; i < industryMaterialVos.size(); i++) {
if (industryMaterialDto.getId().equals(industryMaterialVos.get(i).getId())) { if (industryMaterialDto.getId().equals(industryMaterialVos.get(i).getId())) {
pos = i; pos = i;
} }
} }
// 将现在正在运行的批次状态改为0 // 将现在正在运行的批次状态改为0
industryMaterialDto.setOperation(0L); industryMaterialDto.setOperation(0L);
updateIndustryMaterial(industryMaterialDto); updateIndustryMaterial(industryMaterialDto);
IndustryMaterialVo industryMaterialVo; IndustryMaterialVo industryMaterialVo;
Long materialFlag = redisCache.getCacheObject("materialFlagError"); Long materialFlag = redisCache.getCacheObject("materialFlagError");
// 处理是向上走还是向下走 // 处理是向上走还是向下走
int next = -1;
if (materialFlag == 0L) { if (materialFlag == 0L) {
int next = -1;
// 找到上一个正常的 // 找到上一个正常的
for (int i = pos - 1; i >= 0; i--) { for (int i = pos - 1; i >= 0; i--) {
if (industryMaterialVos.get(i).getState() == 5L && industryMaterialVos.get(i).getIndustryStepVo().getState() == 0L) { if (industryMaterialVos.get(i).getState() == 5L && industryMaterialVos.get(i).getIndustryStepVo().getState() == 0L) {
@@ -595,17 +603,20 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
// 降序 // 降序
if (next == -1) { if (next == -1) {
//走到这next如果还为-1表示这是最头上那个了 就要修改顺序 //走到这next如果还为-1表示这是最头上那个了 就要修改顺序
redisCache.setCacheObject("materialFlagError", 1L, 100, TimeUnit.HOURS);
industryMaterialVo = industryMaterialVos.get(pos); // 找到下一个正常的
industryMaterialVo.setOperation(1L); for (int i = pos + 1; i < industryMaterialVos.size(); i++) {
updateIndustryMaterial(industryMaterialVo); if (industryMaterialVos.get(i).getState() == 5L && industryMaterialVos.get(i).getIndustryStepVo().getState() == 0L) {
return "下道次"; next = i;
break;
}
}
industryMaterialVo = industryMaterialVos.get(next);
redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS);
} else { } else {
industryMaterialVo = industryMaterialVos.get(next); industryMaterialVo = industryMaterialVos.get(next);
} }
} else { } else {
int next = -1;
// 找到下一个正常的 // 找到下一个正常的
for (int i = pos + 1; i < industryMaterialVos.size(); i++) { for (int i = pos + 1; i < industryMaterialVos.size(); i++) {
if (industryMaterialVos.get(i).getState() == 5L && industryMaterialVos.get(i).getIndustryStepVo().getState() == 0L) { if (industryMaterialVos.get(i).getState() == 5L && industryMaterialVos.get(i).getIndustryStepVo().getState() == 0L) {
@@ -615,19 +626,21 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
} }
if (next == -1) { if (next == -1) {
redisCache.setCacheObject("materialFlagError", 0L, 100, TimeUnit.HOURS); for (int i = pos - 1; i >= 0; i--) {
industryMaterialVo = industryMaterialVos.get(pos); if (industryMaterialVos.get(i).getState() == 5L && industryMaterialVos.get(i).getIndustryStepVo().getState() == 0L) {
industryMaterialVo.setOperation(1L); next = i;
updateIndustryMaterial(industryMaterialVo); break;
return "下道次"; }
}
industryMaterialVo = industryMaterialVos.get(next);
redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS);
} else { } else {
industryMaterialVo = industryMaterialVos.get(next); industryMaterialVo = industryMaterialVos.get(next);
} }
} }
industryMaterialVo.setOperation(1L); industryMaterialVo.setOperation(1L);
updateIndustryMaterial(industryMaterialVo); updateIndustryMaterial(industryMaterialVo);
return "1"; return 1;
} }
@@ -669,7 +682,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
public void getMaterialData() { public void getMaterialData() {
IndustryMaterial material = new IndustryMaterial(); IndustryMaterial material = new IndustryMaterial();
material.setState(1L); material.setState(1L);
if (industryMaterialMapper.selectIndustryMaterialList2(material).size() > 0) { if (!industryMaterialMapper.selectIndustryMaterialList2(material).isEmpty()) {
// 进入这个if 说明现在有正在轧制的料,则不进行入料,并且删除这些键 // 进入这个if 说明现在有正在轧制的料,则不进行入料,并且删除这些键
redisCache.deleteObject("sort"); redisCache.deleteObject("sort");
@@ -847,7 +860,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
pos = i; pos = i;
} }
} }
if (pos - 1 == industryMaterialVos.size()) { if (pos+1 == industryMaterialVos.size()) {
// 表示是最后一个 // 表示是最后一个
return 0L; return 0L;
} }

View File

@@ -3,9 +3,9 @@ package com.industry.work.service.impl;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer;
import com.github.xingshuangs.iot.protocol.s7.service.S7PLC; import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
import com.industry.common.constant.Constants;
import com.industry.common.core.redis.Redis2Cache; import com.industry.common.core.redis.Redis2Cache;
import com.industry.common.core.redis.RedisCache; import com.industry.common.core.redis.RedisCache;
import com.industry.common.plc.PLCSystemData; import com.industry.common.plc.PLCSystemData;
@@ -65,16 +65,12 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
@Autowired @Autowired
private S7PLC s7PLC; private S7PLC s7PLC;
@Value("${ipAddress}")
private String ipAddress;
@Value("${mode}") @Value("${mode}")
private String mode; private String mode;
@Autowired @Autowired
private Redis2Cache redis2Cache; private Redis2Cache redis2Cache;
/** /**
* 查询钽靶道次表 * 查询钽靶道次表
* *
@@ -145,14 +141,12 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
@Override @Override
public List<IndustryStepVo> selectIndustryStepListByProcess(IndustryStep industryStep) { public List<IndustryStepVo> selectIndustryStepListByProcess(IndustryStep industryStep) {
String materialId = industryStep.getMaterialId(); String materialId = industryStep.getMaterialId();
Long batchId = industryStep.getBatchId(); Long batchId = industryStep.getBatchId();
industryStep.setMaterialId(materialId); industryStep.setMaterialId(materialId);
industryStep.setBatchId(batchId); industryStep.setBatchId(batchId);
List<IndustryStepVo> industryStepVos = industryStepMapper.selectIndustryStepList(industryStep); List<IndustryStepVo> industryStepVos = industryStepMapper.selectIndustryStepList(industryStep);
if (industryStepVos.size() == 0) { if (industryStepVos.isEmpty()) {
// 表示该批次没有出现道次 直接return // 表示该批次没有出现道次 直接return
industryStep = new IndustryStep(); industryStep = new IndustryStep();
industryStep.setMaterialId(materialId); industryStep.setMaterialId(materialId);
@@ -179,87 +173,98 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
@Override @Override
@Transactional @Transactional
public String nextStep(IndustryStep industryStep) { public int nextStep(IndustryStep industryStep) {
Long tag = redisCache.getCacheObject("nextStepFlag"); Long tag = redisCache.getCacheObject("nextStepFlag");
if (tag != 1L) { if (tag != 1L) {
return "未到下道次"; // nextStepFlag为切换道次的标志位当其为1时需要进行切换道次否则不用切换道次
return 0;
} }
S7PLC s7PLC2 = new S7PLC(EPlcType.S1500, ipAddress); // TODO PLC
s7PLC2.setConnectTimeout(60000); // 将切换道次改为true
s7PLC2.setReceiveTimeout(60000); // s7PLC.writeBoolean("DB15.1.2",true);
s7PLC2.writeBoolean("DB15.1.2",true);
while (!s7PLC2.readBoolean("DB15.1.2")){ // 判断当前切换是否转化过来成true 没有则再发
Threads.sleep(500); // while (!s7PLC.readBoolean("DB15.1.2")){
// Threads.sleep(500);
// }
// 当当前的到此为true时候将其置 5s延迟 使其切换道次
// if (s7PLC.readBoolean("DB15.1.2")){
Threads.sleep(5000);
// 更新该批次中的全部道次的 "操作中" 字段为0
IndustryStep step = new IndustryStep();
step.setBatchId(industryStep.getBatchId());
step.setOperation(0L);
industryStepMapper.updateIndustryStepByBatchId(step);
IndustryStep industryStep1 = new IndustryStep();
industryStep1.setBatchId(industryStep.getBatchId());
Long newStep = industryStep.getStep() + 1L;
industryStep1.setStep(newStep);
// 查询下一步还有没有
List<IndustryStepVo> industryStepVos = selectIndustryStepList(industryStep1);
if (industryStepVos.isEmpty()) {
// 等于0说明没有下一步了 通知前端处理下一批
return 2;
} }
if (s7PLC2.readBoolean("DB15.1.2")){ // 如果不为0 说明该批次依然有道次未处理
// 获取第一个 将其operation改为1
industryStep1.setOperation(1L);
// 更新一下下一步的状态
industryStepMapper.updateIndustryStepByBatchId(industryStep1);
// TODO 向plc发送当前道次
// s7PLC.writeInt32("DB16.0", Math.toIntExact(newStep));
//以及剩余道次
Long num = industryStepMapper.selectMaxStepNum(industryStep.getBatchId());
// s7PLC.writeInt32("M854", Math.toIntExact(num - newStep));
Long materialFlag = redisCache.getCacheObject("materialFlag");
redisCache.setCacheObject("nextStepFlag", 0L, 100, TimeUnit.HOURS);
redisCache.setCacheObject("materialFlag", materialFlag == 1L ? 0L : 1L, 100, TimeUnit.HOURS);
// s7PLC.writeBoolean("DB15.1.2",false);
// s7PLC.writeFloat32("DB15.118",industryStepVos.get(0).getSetValue().floatValue());
Threads.sleep(5000); // 设定值确认
// 更新该批次中的全部道次的 "操作中" 字段为0 // s7PLC.writeBoolean("DB15.0.3",true);
IndustryStep step = new IndustryStep();
step.setBatchId(industryStep.getBatchId()); // while (s7PLC.readBoolean("DB15.0.3")){
// s7PLC.writeBoolean("DB15.0.3",false);
// }
// }
step.setOperation(0L); // while (s7PLC.readBoolean("DB15.1.2")){
industryStepMapper.updateIndustryStepByBatchId(step); // Threads.sleep(500);
// }
IndustryStep industryStep1 = new IndustryStep(); return 1;
industryStep1.setBatchId(industryStep.getBatchId());
Long newStep = industryStep.getStep() + 1L;
industryStep1.setStep(newStep);
// 查询下一步还有没有
List<IndustryStepVo> industryStepVos = selectIndustryStepList(industryStep1);
if (industryStepVos.size() == 0) {
// 等于0说明没有下一步了 通知前端处理下一批
return "2";
}
// 如果不为0 说明该批次依然有道次未处理
// 获取第一个 将其operation改为1
industryStep1.setOperation(1L);
// 更新一下下一步的状态
industryStepMapper.updateIndustryStepByBatchId(industryStep1);
// TODO 向plc发送当前道次
s7PLC2.writeInt32("DB16.0", Math.toIntExact(newStep));
// 当前厚度
// s7PLC2.writeFloat32("DB16.6", industryStepVos.get(0).get);
//以及剩余道次
Long num = industryStepMapper.selectMaxStepNum(industryStep.getBatchId());
s7PLC2.writeInt32("M854", Math.toIntExact(num - newStep));
redisCache.setCacheObject("nextStepFlag", 0L, 100, TimeUnit.HOURS);
s7PLC2.writeBoolean("DB15.1.2",false);
s7PLC2.writeFloat32("DB15.118",industryStepVos.get(0).getSetValue().floatValue());
s7PLC2.writeBoolean("DB15.0.3",true);
while (s7PLC2.readBoolean("DB15.0.3")){
s7PLC2.writeBoolean("DB15.0.3",false);
}
}
while (s7PLC2.readBoolean("DB15.1.2")){
Threads.sleep(500);
}
s7PLC2.close();
return "1";
} }
@Override @Override
@Transactional @Transactional
public String nextStepError(IndustryStep industryStep) { public int nextStepError(IndustryStep industryStep) {
s7PLC.writeBoolean("DB15.1.2",true);
while (!s7PLC.readBoolean("DB15.1.2")){
Threads.sleep(500);
// TODO PLC
Long tag = redisCache.getCacheObject("nextStepFlagError");
if (tag != 1L) {
// nextStepFlag为切换道次的标志位当其为1时需要进行切换道次否则不用切换道次
return 0;
} }
if (s7PLC.readBoolean("DB15.1.2")){
// s7PLC.writeBoolean("DB15.1.2", true);
// while (!s7PLC.readBoolean("DB15.1.2")) {
// Threads.sleep(500);
//
// }
// if (s7PLC.readBoolean("DB15.1.2")) {
Threads.sleep(5000); Threads.sleep(5000);
// 更新该批次中的全部道次的 "操作中" 字段为0 // 更新该批次中的全部道次的 "操作中" 字段为0
IndustryStep step = new IndustryStep(); IndustryStep step = new IndustryStep();
@@ -278,7 +283,7 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
List<IndustryStepVo> industryStepVos = industryStepMapper.selectErrorIndustryStepList(industryStep1); List<IndustryStepVo> industryStepVos = industryStepMapper.selectErrorIndustryStepList(industryStep1);
if (industryStepVos.isEmpty()) { if (industryStepVos.isEmpty()) {
// 等于0说明没有下一步了 通知前端处理下一批 // 等于0说明没有下一步了 通知前端处理下一批
return "2"; return 2;
} }
// 如果不为0 说明该批次依然有道次未处理 // 如果不为0 说明该批次依然有道次未处理
@@ -290,34 +295,33 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
industryStepMapper.updateIndustryStepByBatchId(industryStep1); industryStepMapper.updateIndustryStepByBatchId(industryStep1);
// TODO 向plc发送当前道次 // TODO 向plc发送当前道次
s7PLC.writeInt32("DB16.0", Math.toIntExact(newStep)); // s7PLC.writeInt32("DB16.0", Math.toIntExact(newStep));
// 当前厚度
// s7PLC2.writeFloat32("DB16.6", industryStepVos.get(0).get);
//以及剩余道次 //以及剩余道次
Long num = industryStepMapper.selectMaxStepNum(industryStep.getBatchId()); Long num = industryStepMapper.selectMaxStepNum(industryStep.getBatchId());
s7PLC.writeInt32("M854", Math.toIntExact(num - newStep)); // s7PLC.writeInt32("M854", Math.toIntExact(num - newStep));
Long materialFlagError = redisCache.getCacheObject("materialFlagError");
redisCache.setCacheObject("nextStepFlagError", 0L, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlagError", 0L, 100, TimeUnit.HOURS);
redisCache.setCacheObject("materialFlagError", materialFlagError==1L?0L:1L, 100, TimeUnit.HOURS);
s7PLC.writeBoolean("DB15.1.2",false); // s7PLC.writeBoolean("DB15.1.2", false);
//
// s7PLC.writeFloat32("DB15.118", industryStepVos.get(0).getSetValue().floatValue());
// s7PLC.writeBoolean("DB15.0.3", true);
s7PLC.writeFloat32("DB15.118",industryStepVos.get(0).getSetValue().floatValue()); // while (s7PLC.readBoolean("DB15.0.3")) {
s7PLC.writeBoolean("DB15.0.3",true); // s7PLC.writeBoolean("DB15.0.3", false);
// }
while (s7PLC.readBoolean("DB15.0.3")){ // }
s7PLC.writeBoolean("DB15.0.3",false);
}
}
while (s7PLC.readBoolean("DB15.1.2")){ // while (s7PLC.readBoolean("DB15.1.2")) {
Threads.sleep(500); // Threads.sleep(500);
} // }
return "1"; return 1;
} }
@Override @Override
@@ -335,7 +339,6 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
} }
} }
// TODO 将现在的道次改为运行中 目前的策略是小道次完成后再对齐
industryStep.setStep(smallStep.getStep()); industryStep.setStep(smallStep.getStep());
industryStep.setOperation(1L); industryStep.setOperation(1L);
industryStep.setState(null); industryStep.setState(null);
@@ -345,13 +348,16 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
// TODO 缺少测试 // TODO 缺少测试
@Override @Override
public String finishError(Long batchId) { public int finishError(Long batchId) {
// 表示该批次全部处理完毕 // 表示该批次全部处理完毕
// 查询这里所有的异常料 完成了将其更新成6 // 查询这里所有的异常料 完成了将其更新成6
IndustryMaterialVo industryMaterialVo = new IndustryMaterialVo(); IndustryMaterialVo industryMaterialVo = new IndustryMaterialVo();
industryMaterialVo.setState(5L); industryMaterialVo.setState(5L);
industryMaterialVo.setBatchId(batchId);
industryMaterialVo.setDelFlag(1L);
List<IndustryMaterialVo> industryMaterialVos = industryMaterialService.selectAbnormalList(industryMaterialVo); List<IndustryMaterialVo> industryMaterialVos = industryMaterialService.selectAbnormalList(industryMaterialVo);
System.out.println(industryMaterialVos);
for (IndustryMaterialVo materialVo : industryMaterialVos) { for (IndustryMaterialVo materialVo : industryMaterialVos) {
materialVo.setState(6L); materialVo.setState(6L);
materialVo.setOperation(0L); materialVo.setOperation(0L);
@@ -365,17 +371,17 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
industryStepMapper.updateAllIndustryStepByBatchId(industryStep); industryStepMapper.updateAllIndustryStepByBatchId(industryStep);
// 如果当前模式是4辊 // 如果当前模式是4辊
if ("1".equals(mode)){ if ("1".equals(mode)) {
redisCache.deleteObject("materialLock"); redisCache.deleteObject("materialLock");
} }
// 如果当前模式是2辊 // 如果当前模式是2辊
if ("0".equals(mode)){ if ("0".equals(mode)) {
// 2辊需要把当前材料提交到四辊库中 // 2辊需要把当前材料提交到四辊库中
Long materialLock = redis2Cache.getCacheObject("materialLock"); Long materialLock = redis2Cache.getCacheObject("materialLock");
if (Objects.isNull(materialLock) & materialLock!=0L){ if (Objects.isNull(materialLock) & materialLock != 0L) {
// 如果是空就写一个1进去占住锁 // 如果是空就写一个1进去占住锁
redis2Cache.setCacheObject("materialLock",1L); redis2Cache.setCacheObject("materialLock", 1L);
// 然后把非异常的东西都赛里面 // 然后把非异常的东西都赛里面
industryMaterialVo = new IndustryMaterialVo(); industryMaterialVo = new IndustryMaterialVo();
industryMaterialVo.setBatchId(industryStep.getBatchId()); industryMaterialVo.setBatchId(industryStep.getBatchId());
@@ -385,13 +391,15 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
} }
} }
s7PLC.writeBoolean("DB15.1.2",false); // TODO PLC
return null; //s7PLC.writeBoolean("DB15.1.2", false);
return 1;
} }
/** /**
* 查询数量 * 查询数量
*
* @param batchId * @param batchId
* @return * @return
*/ */
@@ -421,26 +429,45 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
} }
List<IndustryTechnologyVo> industryTechnologyVos = industryTechnologyService.selectIndustryTechnologyList(industryTechnology); List<IndustryTechnologyVo> industryTechnologyVos = industryTechnologyService.selectIndustryTechnologyList(industryTechnology);
List<IndustryMaterialVo> industryMaterialVos = industryMaterialService.selectIndustryMaterialByBatchId(industryMaterial.getBatchId()); List<IndustryMaterialVo> industryMaterialVos = industryMaterialService.selectIndustryMaterialByBatchId(industryMaterial.getBatchId());
// 添加特判 当工艺表为空时通知前端无此工艺不可进入轧制页面
if (industryTechnologyVos.isEmpty()) {
// 把状态改回去
if (Objects.nonNull(industryMaterialVos.get(0))) {
for (IndustryMaterialVo materialVo : industryMaterialVos) {
materialVo.setState(0L);
industryMaterialMapper.updateIndustryMaterial(materialVo);
}
return Constants.NOT_HAVE_TECHNOLOGY;
}
}
for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) { for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) {
for (IndustryTechnologyVo industryTechnologyVo : industryTechnologyVos) { for (IndustryTechnologyVo industryTechnologyVo : industryTechnologyVos) {
IndustryStep industryStep = new IndustryStep(); IndustryStep industryStep = getIndustryStep(industryMaterial, industryMaterialVo, industryTechnologyVo);
industryStep.setStep(industryTechnologyVo.getStep());
industryStep.setSetValue(industryTechnologyVo.getSetValue());
industryStep.setReduction(industryTechnologyVo.getReduction());
industryStep.setAngle(industryTechnologyVo.getAngle());
industryStep.setMaterialId(industryMaterialVo.getId());
industryStep.setBatchId(industryMaterial.getBatchId());
insertIndustryStep(industryStep); insertIndustryStep(industryStep);
} }
industryMaterialVo.setStepSize((long) industryTechnologyVos.size()); industryMaterialVo.setStepSize((long) industryTechnologyVos.size());
industryMaterialService.updateIndustryMaterial(industryMaterialVo); industryMaterialService.updateIndustryMaterial(industryMaterialVo);
} }
return 1; return 1;
} }
return 0; return 0;
} }
private static IndustryStep getIndustryStep(IndustryMaterial industryMaterial, IndustryMaterialVo
industryMaterialVo, IndustryTechnologyVo industryTechnologyVo) {
IndustryStep industryStep = new IndustryStep();
industryStep.setStep(industryTechnologyVo.getStep());
industryStep.setSetValue(industryTechnologyVo.getSetValue());
industryStep.setReduction(industryTechnologyVo.getReduction());
industryStep.setAngle(industryTechnologyVo.getAngle());
industryStep.setMaterialId(industryMaterialVo.getId());
industryStep.setBatchId(industryMaterial.getBatchId());
return industryStep;
}
@Override @Override
public int finish(Long batchId) { public int finish(Long batchId) {
@@ -457,17 +484,17 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
redisCache.deleteObject("size"); redisCache.deleteObject("size");
// 如果当前模式是4辊 // 如果当前模式是4辊
if ("1".equals(mode)){ if ("1".equals(mode)) {
redisCache.deleteObject("materialLock"); redisCache.deleteObject("materialLock");
} }
// 如果当前模式是2辊 // 如果当前模式是2辊
if ("0".equals(mode)){ if ("0".equals(mode)) {
// 2辊需要把当前材料提交到四辊库中 // 2辊需要把当前材料提交到四辊库中
Long materialLock = redis2Cache.getCacheObject("materialLock"); Long materialLock = redis2Cache.getCacheObject("materialLock");
if (Objects.isNull(materialLock) & materialLock!=0L){ if (Objects.isNull(materialLock) & materialLock != 0L) {
// 如果是空就写一个1进去占住锁 // 如果是空就写一个1进去占住锁
redis2Cache.setCacheObject("materialLock",1L); redis2Cache.setCacheObject("materialLock", 1L);
// 然后把非异常的东西都赛里面 // 然后把非异常的东西都赛里面
IndustryMaterialVo industryMaterialVo = new IndustryMaterialVo(); IndustryMaterialVo industryMaterialVo = new IndustryMaterialVo();
industryMaterialVo.setBatchId(industryStep.getBatchId()); industryMaterialVo.setBatchId(industryStep.getBatchId());
@@ -476,7 +503,9 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos); industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos);
} }
} }
s7PLC.writeBoolean("DB15.1.2",false);
// TODO PLC
// s7PLC.writeBoolean("DB15.1.2", false);
return 1; return 1;
} }
@@ -544,13 +573,15 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
@Override @Override
public void start(IndustryStep industryStep) { public void start(IndustryStep industryStep) {
List<IndustryStepVo> industryStepVos = industryStepMapper.selectIndustryStepList(industryStep); List<IndustryStepVo> industryStepVos = industryStepMapper.selectIndustryStepList(industryStep);
if (!industryStepVos.isEmpty()){
s7PLC.writeFloat32("DB15.118",industryStepVos.get(0).getSetValue().floatValue()); // TODO PLC
s7PLC.writeBoolean("DB15.0.3",true); // if (!industryStepVos.isEmpty()){
while (s7PLC.readBoolean("DB15.0.3")){ // s7PLC.writeFloat32("DB15.118",industryStepVos.get(0).getSetValue().floatValue());
s7PLC.writeBoolean("DB15.0.3",false); // s7PLC.writeBoolean("DB15.0.3",true);
} // while (s7PLC.readBoolean("DB15.0.3")){
} // s7PLC.writeBoolean("DB15.0.3",false);
// }
// }
industryStep.setOperation(1L); industryStep.setOperation(1L);
industryStepMapper.start(industryStep); industryStepMapper.start(industryStep);
} }

View File

@@ -61,12 +61,13 @@
<if test="diameter != null ">and diameter = #{diameter}</if> <if test="diameter != null ">and diameter = #{diameter}</if>
<if test="batchId != null ">and batch_id = #{batchId}</if> <if test="batchId != null ">and batch_id = #{batchId}</if>
<if test="sort != null ">and sort = #{sort}</if> <if test="sort != null ">and sort = #{sort}</if>
<if test="state != null ">and state = #{state} or state=3</if> <if test="state != null ">and (state = #{state} or state=3)</if>
<if test="stepSize != null ">and step_size = #{stepSize}</if> <if test="stepSize != null ">and step_size = #{stepSize}</if>
<if test="finalWidth != null and finalWidth != ''">and final_width = #{finalWidth}</if> <if test="finalWidth != null and finalWidth != ''">and final_width = #{finalWidth}</if>
<if test="finalDiameter != null and finalDiameter != ''">and final_diameter = #{finalDiameter}</if> <if test="finalDiameter != null and finalDiameter != ''">and final_diameter = #{finalDiameter}</if>
<if test="weight != null and weight != ''">and weight = #{weight}</if> <if test="weight != null and weight != ''">and weight = #{weight}</if>
<if test="width != null and width != ''">and width = #{width}</if> <if test="width != null and width != ''">and width = #{width}</if>
<if test="delFlag != null and delFlag != ''">and del_flag = #{delFlag}</if>
</where> </where>
order by sort order by sort
</select> </select>
@@ -292,7 +293,9 @@
<if test="delFlag != null">del_flag,</if> <if test="delFlag != null">del_flag,</if>
<if test="stepSize != null">step_size,</if> <if test="stepSize != null">step_size,</if>
<if test="finalWidth != null">final_width,</if> <if test="finalWidth != null">final_width,</if>
<if test="finalWidth2 != null">final_width2,</if>
<if test="finalDiameter != null">final_diameter,</if> <if test="finalDiameter != null">final_diameter,</if>
<if test="finalDiameter2 != null">final_diameter2,</if>
<if test="weight != null">weight,</if> <if test="weight != null">weight,</if>
<if test="width != null">width,</if> <if test="width != null">width,</if>
</trim> </trim>
@@ -312,7 +315,9 @@
<if test="state != null">#{state},</if> <if test="state != null">#{state},</if>
<if test="stepSize != null">#{stepSize},</if> <if test="stepSize != null">#{stepSize},</if>
<if test="finalWidth != null">#{finalWidth},</if> <if test="finalWidth != null">#{finalWidth},</if>
<if test="finalWidth2 != null">#{finalWidth2},</if>
<if test="finalDiameter != null">#{finalDiameter},</if> <if test="finalDiameter != null">#{finalDiameter},</if>
<if test="finalDiameter2 != null">#{finalDiameter2},</if>
<if test="weight != null">#{weight},</if> <if test="weight != null">#{weight},</if>
<if test="width != null">#{width},</if> <if test="width != null">#{width},</if>
</trim> </trim>
@@ -335,7 +340,9 @@
<if test="state != null">state = #{state},</if> <if test="state != null">state = #{state},</if>
<if test="stepSize != null">step_size = #{stepSize},</if> <if test="stepSize != null">step_size = #{stepSize},</if>
<if test="finalWidth != null">final_width = #{finalWidth},</if> <if test="finalWidth != null">final_width = #{finalWidth},</if>
<if test="finalWidth2 != null">final_width2 = #{finalWidth2},</if>
<if test="finalDiameter != null">final_diameter = #{finalDiameter},</if> <if test="finalDiameter != null">final_diameter = #{finalDiameter},</if>
<if test="finalDiameter2 != null">final_diameter2 = #{finalDiameter2},</if>
<if test="weight != null">weight = #{weight},</if> <if test="weight != null">weight = #{weight},</if>
<if test="width != null">width = #{width},</if> <if test="width != null">width = #{width},</if>
</trim> </trim>
@@ -349,7 +356,7 @@
<if test="state == 0">state =1,</if> <if test="state == 0">state =1,</if>
<if test="state == 1">state =2,</if> <if test="state == 1">state =2,</if>
<if test="state == 3">state =4,</if> <if test="state == 3">state =4,</if>
<if test="state == 4">state =5,</if> <if test="state == 4 and delFlag ==1">state =5,</if>
<if test="state == 5">state =6,</if> <if test="state == 5">state =6,</if>
</trim> </trim>
where id = #{id} where id = #{id}

View File

@@ -114,7 +114,6 @@
and step.del_flag=0 and step.del_flag=0
and step.batch_id = #{batchId} and step.batch_id = #{batchId}
and im.state =1 and im.state =1
</select> </select>
@@ -126,6 +125,7 @@
and step.del_flag=1 and step.del_flag=1
and step.batch_id = #{batchId} and step.batch_id = #{batchId}
and im.state =5 and im.state =5
and im.del_flag=1
</select> </select>
<select id="selectMaxStepNum" resultType="java.lang.Long" parameterType="Long"> <select id="selectMaxStepNum" resultType="java.lang.Long" parameterType="Long">