新增异常物料进入异常堆,移除工艺不一致导致的拒绝进入
This commit is contained in:
@@ -307,4 +307,10 @@ public class IndustryMaterialController extends BaseController
|
||||
industryMaterialService.deleteIndustryMaterialByState(1L);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public AjaxResult delete(@PathVariable("id") String id){
|
||||
return toAjax(industryMaterialService.delIndustryMaterialById(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public interface IIndustryMaterialService
|
||||
* @param industryMaterial batchId state=1
|
||||
* @return
|
||||
*/
|
||||
IndustryMaterialVo resourceToWorkAndCreateStep(IndustryMaterial industryMaterial);
|
||||
List<IndustryMaterialVo> resourceToWorkAndCreateStep(IndustryMaterial industryMaterial);
|
||||
|
||||
/**
|
||||
* 异常料切换
|
||||
@@ -133,4 +133,7 @@ public interface IIndustryMaterialService
|
||||
*/
|
||||
boolean clearNotProcessMaterial();
|
||||
|
||||
int toCheckErrorMaterial(List<IndustryMaterialVo> successList);
|
||||
|
||||
int delIndustryMaterialById(String id);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
|
||||
System.out.println("触发四辊数据写入");
|
||||
// 这个大小等于0 表示四辊没有东西再轧制了可以进行放行
|
||||
if (industryMaterialVos1.isEmpty()){
|
||||
if (industryMaterialVos1.isEmpty()) {
|
||||
IndustryBatch industryBatch = new IndustryBatch();
|
||||
industryBatch.setBatchSize((long) industryMaterialVos.size());
|
||||
industryBatchService.insertIndustryBatch(industryBatch);
|
||||
@@ -161,7 +161,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
IndustryMaterial industryMaterial = new IndustryMaterial();
|
||||
industryMaterial.setState(0L);
|
||||
List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectAbnormalList(industryMaterial);
|
||||
if (industryMaterialVos.isEmpty()){
|
||||
if (industryMaterialVos.isEmpty()) {
|
||||
|
||||
// 代表状态至少是 1 2 3 4 5 6
|
||||
return false;
|
||||
@@ -170,6 +170,87 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int toCheckErrorMaterial(List<IndustryMaterialVo> successList) {
|
||||
if (successList.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
if (successList.size() ==1) {
|
||||
// 如果只有一个料直接返回就行了 肯定没问题
|
||||
return 1;
|
||||
}
|
||||
// 这里successList至少有两个,拿出来第一个作为基准物料工艺
|
||||
|
||||
|
||||
IndustryMaterialVo firstMaterialVo = successList.get(0);
|
||||
for (IndustryMaterialVo industryMaterialVo : successList) {
|
||||
if (!Objects.equals(industryMaterialVo.getSpecification(), firstMaterialVo.getSpecification())
|
||||
||
|
||||
!Objects.equals(industryMaterialVo.getTechnology(), firstMaterialVo.getTechnology())
|
||||
) {
|
||||
// 将不同的状态改为异常
|
||||
industryMaterialVo.setState(3L);
|
||||
industryMaterialMapper.updateIndustryMaterial(industryMaterialVo);
|
||||
// 接下来更新他对应的第一个道次将其改为异常
|
||||
IndustryStep industryStep = new IndustryStep();
|
||||
industryStep.setMaterialId(industryMaterialVo.getId());
|
||||
List<IndustryStepVo> industryStepVos = industryStepMapper.selectIndustryStepList(industryStep);
|
||||
if (!industryStepVos.isEmpty()) {
|
||||
IndustryStepVo industryStepVo = industryStepVos.get(0);
|
||||
// 将其异常处理
|
||||
industryStepVo.setState(2L);
|
||||
industryStepMapper.updateIndustryStep(industryStepVo);
|
||||
}
|
||||
// 如果校验到此物料的规格和工艺不相同则返回2提醒前端
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delIndustryMaterialById(String id) {
|
||||
IndustryMaterialVo industryMaterialVo = industryMaterialMapper.selectIndustryMaterialById(id);
|
||||
Long batchId = industryMaterialVo.getBatchId();
|
||||
IndustryBatchVo industryBatchVo = industryBatchService.selectIndustryBatchById(batchId);
|
||||
industryBatchVo.setBatchSize(industryBatchVo.getBatchSize() - 1);
|
||||
industryBatchService.updateIndustryBatch(industryBatchVo);
|
||||
// 删除此数据
|
||||
industryMaterialMapper.deleteIndustryMaterialById(id);
|
||||
List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectIndustryMaterialByBatchId(batchId);
|
||||
// 进行重新排列
|
||||
for (int i = 1; i <= industryMaterialVos.size(); i++) {
|
||||
industryMaterialVos.get(i).setSort((long) i);
|
||||
industryMaterialMapper.updateIndustryMaterial(industryMaterialVos.get(i));
|
||||
}
|
||||
|
||||
// 下面处理redis的问题
|
||||
// redis记录了sort batchSize 以及左右摄像头里面的缓存数据
|
||||
// 处理sort直接拿出来-1就可以了
|
||||
Long sort = redisCache.getCacheObject("sort");
|
||||
Long size = redisCache.getCacheObject("size");
|
||||
sort-=1;
|
||||
size-=1;
|
||||
redisCache.setCacheObject("sort",sort);
|
||||
redisCache.setCacheObject("size",size);
|
||||
|
||||
// 接下来处理左右摄像头数据
|
||||
// leftId和rightId
|
||||
// 判断左摄像头的id是否与当前删除的相同如果相同则删除此缓存
|
||||
if (id.equals(redisCache.getCacheObject("leftId"))) {
|
||||
redisCache.deleteObject("leftId");
|
||||
s7PLC.writeString("DB4.30","\u0000\u0000\u0000\u0000");
|
||||
|
||||
}
|
||||
if (id.equals(redisCache.getCacheObject("rightId"))) {
|
||||
redisCache.deleteObject("rightId");
|
||||
s7PLC.writeString("DB44.30","\u0000\u0000\u0000\u0000");
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增钽靶主类
|
||||
@@ -218,7 +299,6 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param industryMaterial batchId
|
||||
* @return
|
||||
*/
|
||||
@@ -250,6 +330,8 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
public int start(IndustryMaterial industryMaterial) {
|
||||
// 拿到当前正在进行的批次
|
||||
List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectIndustryMaterialList(industryMaterial);
|
||||
// 二次检查是否有和第一个物料不同工艺规格的,如果没有在放行
|
||||
toCheckErrorMaterial(industryMaterialVos);
|
||||
IndustryMaterialVo firstMaterial = new IndustryMaterialVo();
|
||||
for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) {
|
||||
if (industryMaterialVo.getState() != 3L) {
|
||||
@@ -304,7 +386,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
if ("1".equals(mode)) {
|
||||
// 精轧
|
||||
momResource.setDevicesCode("00401020934");
|
||||
}else{
|
||||
} else {
|
||||
// 粗轧
|
||||
momResource.setDevicesCode("00401020935");
|
||||
}
|
||||
@@ -333,11 +415,11 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
// 查询批次列表
|
||||
// 查询当前批次状态1的列表
|
||||
List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectIndustryMaterialList(industryMaterial);
|
||||
if (industryMaterialVos.isEmpty() ) {
|
||||
if (industryMaterialVos.isEmpty()) {
|
||||
// 如果为空列表则直接返回,全部发生异常了
|
||||
return Constants.COMPLETE_PROCESS;
|
||||
}
|
||||
if (industryMaterialVos.size() == 1){
|
||||
if (industryMaterialVos.size() == 1) {
|
||||
// 或者判断列表是否只有一个对象 如果是的话则不需要更新字段operation
|
||||
return 0;
|
||||
}
|
||||
@@ -370,7 +452,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
if (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) {
|
||||
next = i;
|
||||
break;
|
||||
@@ -692,27 +774,27 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public IndustryMaterialVo resourceToWorkAndCreateStep(IndustryMaterial industryMaterial) {
|
||||
public List<IndustryMaterialVo> resourceToWorkAndCreateStep(IndustryMaterial industryMaterial) {
|
||||
IndustryMaterialVo industryMaterialVo = new IndustryMaterialVo();
|
||||
industryMaterialVo.setBatchId(industryMaterial.getBatchId());
|
||||
// 获得该批次的所有原料
|
||||
List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectIndustryMaterialList(industryMaterialVo);
|
||||
|
||||
// 首先查看是否有该批次的料
|
||||
if (Objects.nonNull(industryMaterialVos.get(0))) {
|
||||
if (Objects.nonNull(industryMaterialVos) && !industryMaterialVos.isEmpty()) {
|
||||
// 检测他们的工艺是否相同
|
||||
IndustryMaterialVo firstIndustryMaterial = industryMaterialVos.get(0);
|
||||
for (IndustryMaterialVo materialVo : industryMaterialVos) {
|
||||
if (!Objects.equals(firstIndustryMaterial.getTechnology(), materialVo.getTechnology())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// IndustryMaterialVo firstIndustryMaterial = industryMaterialVos.get(0);
|
||||
// for (IndustryMaterialVo materialVo : industryMaterialVos) {
|
||||
// if (!Objects.equals(firstIndustryMaterial.getTechnology(), materialVo.getTechnology())) {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
for (IndustryMaterialVo materialVo : industryMaterialVos) {
|
||||
materialVo.setState(1L);
|
||||
updateIndustryMaterial(materialVo);
|
||||
}
|
||||
// 到了这里表示工艺都相同返回1
|
||||
return firstIndustryMaterial;
|
||||
return industryMaterialVos;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -744,9 +826,6 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
Long size = redisCache.getCacheObject("size");
|
||||
|
||||
if (Objects.isNull(sort) || Objects.isNull(batchId) || sort >= 9L || Objects.isNull(size)) {
|
||||
|
||||
|
||||
|
||||
IndustryBatch industryBatch = new IndustryBatch();
|
||||
industryBatch.setBatchSize(0L);
|
||||
batchId = industryBatchService.insertIndustryBatch(industryBatch);
|
||||
@@ -773,7 +852,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
|
||||
if ("1".equals(mode)) {
|
||||
Long materialLock = redisCache.getCacheObject("materialLock");
|
||||
if (Objects.isNull(materialLock) || materialLock !=1L) {
|
||||
if (Objects.isNull(materialLock) || materialLock != 1L) {
|
||||
// 如果没有获取到锁对象就向里面写一个锁对象
|
||||
redisCache.setCacheObject("materialLock", 0L, 100, TimeUnit.HOURS);
|
||||
}
|
||||
@@ -786,8 +865,6 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
// 进入这里说明它是个新料,但是可能会出现id相同的问题,则直接删掉原有料
|
||||
IndustryMaterial industryMaterial = new IndustryMaterial();
|
||||
industryMaterial.setSort(sort);
|
||||
|
||||
|
||||
Float diameter = s7PLC.readFloat32("DB4.10");
|
||||
Double diameterLeft = MathUtils.floatToDouble(diameter);
|
||||
|
||||
@@ -907,7 +984,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
pos = i;
|
||||
}
|
||||
}
|
||||
if (pos+1 == industryMaterialVos.size()) {
|
||||
if (pos + 1 == industryMaterialVos.size()) {
|
||||
// 表示是最后一个
|
||||
return 0L;
|
||||
}
|
||||
@@ -922,8 +999,8 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
|
||||
redis2Cache.deleteObject("leftId");
|
||||
redis2Cache.deleteObject("rightId");
|
||||
|
||||
s7PLC.writeString("DB4.30","\u0000\u0000\u0000\u0000");
|
||||
s7PLC.writeString("DB44.30","\u0000\u0000\u0000\u0000");
|
||||
s7PLC.writeString("DB4.30", "\u0000\u0000\u0000\u0000");
|
||||
s7PLC.writeString("DB44.30", "\u0000\u0000\u0000\u0000");
|
||||
industryMaterialMapper.deleteIndustryMaterialByState(0L);
|
||||
}
|
||||
|
||||
|
||||
@@ -441,44 +441,49 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
|
||||
|
||||
@Override
|
||||
public int createStep(IndustryMaterial industryMaterial) {
|
||||
IndustryMaterialVo success = industryMaterialService.resourceToWorkAndCreateStep(industryMaterial);
|
||||
if (Objects.nonNull(success)) {
|
||||
// 进入这里说明工艺没问题接下里根据工艺表创建道次
|
||||
// 判断当前是粗轧还是精轧
|
||||
IndustryTechnology industryTechnology = new IndustryTechnology();
|
||||
industryTechnology.setTechnologyId(success.getTechnology());
|
||||
industryTechnology.setDiameter(success.getDiameter());
|
||||
industryTechnology.setSpecification(success.getSpecification());
|
||||
if (Objects.equals(mode, "0")) {
|
||||
// 粗轧
|
||||
industryTechnology.setState(0L);
|
||||
} else {
|
||||
industryTechnology.setState(1L);
|
||||
}
|
||||
List<IndustryTechnologyVo> industryTechnologyVos = industryTechnologyService.selectIndustryTechnologyList(industryTechnology);
|
||||
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;
|
||||
List<IndustryMaterialVo> successList = industryMaterialService.resourceToWorkAndCreateStep(industryMaterial);
|
||||
if (Objects.nonNull(successList) && !successList.isEmpty()) {
|
||||
// 20250809 为了将不同工艺的物料生成不同工艺的道次,此处应该根据每一快物料生成对应的道次数据
|
||||
for (IndustryMaterialVo success : successList) {
|
||||
// 进入这里说明工艺没问题接下里根据工艺表创建道次
|
||||
// 判断当前是粗轧还是精轧
|
||||
IndustryTechnology industryTechnology = new IndustryTechnology();
|
||||
industryTechnology.setTechnologyId(success.getTechnology());
|
||||
industryTechnology.setDiameter(success.getDiameter());
|
||||
industryTechnology.setSpecification(success.getSpecification());
|
||||
if (Objects.equals(mode, "0")) {
|
||||
// 粗轧
|
||||
industryTechnology.setState(0L);
|
||||
} else {
|
||||
industryTechnology.setState(1L);
|
||||
}
|
||||
}
|
||||
// 拿到第一个物料对应的工艺要生成的所有道次
|
||||
List<IndustryTechnologyVo> industryTechnologyVos = industryTechnologyService.selectIndustryTechnologyList(industryTechnology);
|
||||
// List<IndustryMaterialVo> industryMaterialVos = industryMaterialService.selectIndustryMaterialByBatchId(industryMaterial.getBatchId());
|
||||
// 添加特判 当工艺表为空时通知前端无此工艺不可进入轧制页面
|
||||
// if (industryTechnologyVos.isEmpty()) {
|
||||
// // 把状态改回去
|
||||
// success.setState(0L);
|
||||
// industryMaterialMapper.updateIndustryMaterial(success);
|
||||
// return Constants.NOT_HAVE_TECHNOLOGY;
|
||||
// }
|
||||
|
||||
// TODO 将道次为空的也放入异常
|
||||
|
||||
for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) {
|
||||
// 也就是说这里不管下面的物料是否为此工艺也按照此工艺生成道次只不过不需要操作
|
||||
for (IndustryTechnologyVo industryTechnologyVo : industryTechnologyVos) {
|
||||
IndustryStep industryStep = getIndustryStep(industryMaterial, industryMaterialVo, industryTechnologyVo);
|
||||
IndustryStep industryStep = getIndustryStep(industryMaterial, success, industryTechnologyVo);
|
||||
insertIndustryStep(industryStep);
|
||||
}
|
||||
industryMaterialVo.setStepSize((long) industryTechnologyVos.size());
|
||||
industryMaterialService.updateIndustryMaterial(industryMaterialVo);
|
||||
success.setStepSize((long) industryTechnologyVos.size());
|
||||
industryMaterialService.updateIndustryMaterial(success);
|
||||
|
||||
}
|
||||
return 1;
|
||||
|
||||
// 到这里其实就已经完成了进入轧制的操作 接下来进行异常处理也就是将除去第一物料的其他物料工艺直接进行对比
|
||||
// 出现问题则返回2代表存在工艺和规格不同的情况,且已经将异常料推入异常
|
||||
// return 1为正常 2为异常且已经推入异常处理
|
||||
return industryMaterialService.toCheckErrorMaterial(successList);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -521,13 +526,13 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
|
||||
Long materialLock = redis2Cache.getCacheObject("materialLock");
|
||||
|
||||
// DONE 这里还有一个问题来自,他拿到的锁标志是0代表四辊正在工作 有一个种可能来自四辊工作但是都是未轧制的(state==0),这个时候应该删除然后直接进入
|
||||
if (Objects.nonNull(materialLock) && materialLock == 0L){
|
||||
if (Objects.nonNull(materialLock) && materialLock == 0L) {
|
||||
// 这个时候要加一个方法 如果是状态为0的直接全部clear然后改锁标志
|
||||
|
||||
// 这里的返回值如果是true则代表虽然四辊站住锁了但是物料未轧制。 返回值是true的情况就已经将state的都删掉了
|
||||
// 根据二辊优先原则,将二辊未轧制数据直接删除解除锁让新数据进来。
|
||||
boolean flag = industryMaterialService.clearNotProcessMaterial();
|
||||
if (flag){
|
||||
boolean flag = industryMaterialService.clearNotProcessMaterial();
|
||||
if (flag) {
|
||||
// 删除后将锁标志改为空也就是直接删除锁
|
||||
redis2Cache.deleteObject("materialLock");
|
||||
// 删除后重新获取供下方使用
|
||||
@@ -535,14 +540,14 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
|
||||
}
|
||||
|
||||
// 如果上面的bool返回的是false 则代表四辊中有数据进行轧制此时应该巩固锁不让二辊物料进入
|
||||
else{
|
||||
redis2Cache.setCacheObject("materialLock", 0L,3000,TimeUnit.HOURS);
|
||||
else {
|
||||
redis2Cache.setCacheObject("materialLock", 0L, 3000, TimeUnit.HOURS);
|
||||
}
|
||||
}
|
||||
if (Objects.isNull(materialLock) || materialLock != 0L) {
|
||||
|
||||
// 如果是空就写一个1进去占住锁
|
||||
redis2Cache.setCacheObject("materialLock", 1L,3000,TimeUnit.HOURS);
|
||||
redis2Cache.setCacheObject("materialLock", 1L, 3000, TimeUnit.HOURS);
|
||||
// 然后把非异常的东西都赛里面
|
||||
IndustryMaterialVo industryMaterialVo = new IndustryMaterialVo();
|
||||
industryMaterialVo.setBatchId(industryStep.getBatchId());
|
||||
|
||||
Reference in New Issue
Block a user