Compare commits

...

10 Commits

Author SHA1 Message Date
7c9e61bb2b 丽水后端 2026-04-29 09:06:44 +08:00
f1f7319062 修复bug 2025-08-21 10:09:55 +08:00
7c0d58e25b 修复bug 2025-08-13 11:39:51 +08:00
5ba6b29075 修复bug 2025-08-13 10:58:54 +08:00
79b06a2ed3 修复bug 2025-08-13 10:18:13 +08:00
b64237d408 修复bug 2025-08-12 22:17:51 +08:00
39a4962bdb 修复bug 2025-08-11 18:31:21 +08:00
0ddca88df9 修复bug 2025-08-11 18:18:40 +08:00
0cb646a867 修复bug 2025-08-11 18:11:19 +08:00
b2db4e735d 修复bug 2025-08-11 17:27:40 +08:00
8 changed files with 103 additions and 33 deletions

View File

@@ -176,6 +176,7 @@ public class IndustryMaterialController extends BaseController
IndustryStep industryStep = new IndustryStep();
industryStep.setStep(1L);
industryStep.setDelFlag(0L);
industryStep.setBatchId(industryMaterial.getBatchId());
industryStepService.start(industryStep);
return success(industryMaterialService.start(industryMaterial));
}

View File

@@ -14,12 +14,12 @@ industry:
captchaType: math
# 0为粗轧1为精轧
mode: 1
mode: 0
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8082
port: 8081
servlet:
# 应用的访问路径
context-path: /
@@ -73,7 +73,7 @@ spring:
# 地址
host: localhost
# 端口默认为6379
port: 6380
port: 6379
# 数据库索引
database: 0
# 密码
@@ -143,7 +143,7 @@ xss:
urlPatterns: /system/*,/monitor/*,/tool/*
ipAddress: 10.20.10.29
ipAddress: 10.20.10.30
httpIp: http://10.20.10.158

View File

@@ -92,4 +92,7 @@ public interface IndustryMaterialMapper
List<IndustryMaterialVo> selectIndustryMaterialListAndNotFinish();
List<IndustryMaterialVo> selectIndustryListRecord(IndustryMaterial industryMaterial);
void updateIndustryMaterialByBatchId(IndustryMaterial params);
}

View File

@@ -116,7 +116,7 @@ public interface IIndustryMaterialService
void deleteIndustryMaterialByState(Long state);
String insertIndustryMaterialToSlaveDataSource(List<IndustryMaterialVo> industryMaterialVos);
String insertIndustryMaterialToSlaveDataSource(List<IndustryMaterialVo> industryMaterialVos, Long aLong);
/**3
*
@@ -136,4 +136,7 @@ public interface IIndustryMaterialService
int toCheckErrorMaterial(List<IndustryMaterialVo> successList);
int delIndustryMaterialById(String id);
void clearSystem();
}

View File

@@ -119,23 +119,31 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
@Override
@DataSource(value = DataSourceType.SLAVE)
public String insertIndustryMaterialToSlaveDataSource(List<IndustryMaterialVo> industryMaterialVos) {
public String insertIndustryMaterialToSlaveDataSource(List<IndustryMaterialVo> industryMaterialVos,Long insertBatchId) {
// 直接删掉扫入并且未轧制的,写入二辊数据到四辊机器里面
clearSystem();
// TODO 这里需要查一下数据库查看是否有正在轧或者说是未轧的情况 state=0,1,3,4
// TODO 这里需要查一下数据库查看是否有正在轧或者说是未轧的情况 state=1,3,4
List<IndustryMaterialVo> industryMaterialVos1 = industryMaterialMapper.selectIndustryMaterialListAndNotFinish();
System.out.println("触发四辊数据写入");
// 这个大小等于0 表示四辊没有东西再轧制了可以进行放行
if (industryMaterialVos1.isEmpty()) {
IndustryBatch industryBatch = new IndustryBatch();
industryBatch.setBatchSize((long) industryMaterialVos.size());
industryBatchService.insertIndustryBatch(industryBatch);
if (Objects.nonNull(insertBatchId)) {
IndustryBatchVo industryBatchVo = industryBatchService.selectIndustryBatchById(insertBatchId);
industryBatchVo.setBatchSize(industryBatchVo.getBatchSize() + 1);
industryBatchService.updateIndustryBatch(industryBatchVo);
}else{
IndustryBatch industryBatch = new IndustryBatch();
industryBatch.setBatchSize((long) industryMaterialVos.size());
industryBatchService.insertIndustryBatch(industryBatch);
insertBatchId = industryBatch.getId();
redis2Cache.setCacheObject("insertBatchId", insertBatchId,3000,TimeUnit.HOURS);
}
for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) {
industryMaterialVo.setState(0L);
industryMaterialVo.setStepSize(null);
industryMaterialVo.setBatchId(industryBatch.getId());
industryMaterialVo.setBatchId(insertBatchId);
industryMaterialVo.setDelFlag(0L);
industryMaterialVo.setFinalDiameter(null);
industryMaterialVo.setOperation(0L);
@@ -309,7 +317,6 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) {
if (Objects.nonNull(industryMaterialVo.getId())) {
industryMaterialMapper.submitMaterial(industryMaterialVo);
// 将异常的道次恢复成初始料
IndustryStep industryStep = new IndustryStep();
industryStep.setBatchId(industryMaterialVo.getBatchId());
@@ -784,12 +791,6 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
// 首先查看是否有该批次的料
if (Objects.nonNull(industryMaterialVos) && !industryMaterialVos.isEmpty()) {
// 检测他们的工艺是否相同
// 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);
@@ -809,6 +810,10 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
*/
@Override
public void getMaterialData() {
//打印leftId和rightId
System.out.println("监测到id-leftId或者rightId");
System.out.println("leftId:" + redisCache.getCacheObject("leftId"));
System.out.println("rightId:" + redisCache.getCacheObject("rightId"));
IndustryMaterial material = new IndustryMaterial();
material.setState(1L);
if (!industryMaterialMapper.selectIndustryMaterialList2(material).isEmpty()) {
@@ -843,8 +848,11 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
// 小于9则一直接受来料
String industryMaterialId = s7PLC.readString("DB4.30", 64);
System.out.println("industryMaterialId----------:" + industryMaterialId);
industryMaterialId = industryMaterialId.replace("\u0000", "");
System.out.println("industryMaterialId----------:" + industryMaterialId);
// 读取是否有此id
String leftId = redisCache.getCacheObject("leftId");
// 不为空表示读到了
@@ -877,6 +885,10 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
String specification = s7PLC.readString("DB4.162", 128);
specification = specification.replace("\u0000", "");
System.out.println(" diameter:" + diameterLeft);
System.out.println(" width:" + widthLeft);
System.out.println(" technology:" + technology);
System.out.println(" specification:" + specification);
industryMaterial.setDiameter(diameterLeft);
industryMaterial.setTechnology(technology);
@@ -901,12 +913,14 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
redisCache.setCacheObject("size", size);
}
System.out.println("sort:---" + sort);
// 小于9则一直接受来料
if (sort < 9L) {
// industryMaterialId = (String) PLCUtils.getPLCData(connector,ipAddress, 44, 30, "string", 64, 10,MbFlag);
industryMaterialId = s7PLC.readString("DB44.30", 64);
System.out.println("industryMaterialId----------:" + industryMaterialId);
industryMaterialId = industryMaterialId.replace("\u0000", "");
System.out.println("industryMaterialId----------:" + industryMaterialId);
// 读取是否有此id
String rightId = (String) redisCache.getCacheObject("rightId");
// 不为空表示读到了
@@ -994,7 +1008,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService {
@DataSource(value = DataSourceType.SLAVE)
private void clearSystem() {
public void clearSystem() {
redis2Cache.deleteObject("sort");
redis2Cache.deleteObject("batchId");
redis2Cache.deleteObject("leftId");

View File

@@ -13,6 +13,7 @@ import com.industry.common.plc.PLCSystemData;
import com.industry.common.utils.DateUtils;
import com.industry.common.utils.Threads;
import com.industry.work.domain.IndustryBatch;
import com.industry.work.domain.IndustryMaterial;
import com.industry.work.domain.IndustryStep;
import com.industry.work.domain.IndustryTechnology;
@@ -397,6 +398,8 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
// 如果当前模式是4辊
if ("1".equals(mode)) {
redisCache.deleteObject("materialLock");
redis2Cache.deleteObject("insertBatchId");
redis2Cache.deleteObject("originBatchId");
}
// 如果当前模式是2辊
@@ -406,14 +409,18 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
if (Objects.isNull(materialLock) || materialLock != 0L) {
// 如果是空就写一个1进去占住锁
redis2Cache.setCacheObject("materialLock", 1L);
Long originBatchId = redis2Cache.getCacheObject("originBatchId");
if (Objects.isNull(originBatchId) || !originBatchId.equals(industryStep.getBatchId())) {
industryMaterialService.clearSystem();
}
// 然后把非异常的东西都赛里面
industryMaterialVo = new IndustryMaterialVo();
industryMaterialVo.setBatchId(industryStep.getBatchId());
industryMaterialVo.setState(6L);
List<IndustryMaterialVo> industryMaterialVos1 = industryMaterialMapper.selectIndustryMaterialList1(industryMaterialVo);
String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos1);
Long insertBatchId = redis2Cache.getCacheObject("insertBatchId");
System.out.println(result);
String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos1,Objects.nonNull(insertBatchId)?insertBatchId:null);
}
}
@@ -444,10 +451,18 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
// 将状态改为了轧制中
List<IndustryMaterialVo> successList = industryMaterialService.resourceToWorkAndCreateStep(industryMaterial);
if (Objects.nonNull(successList) && !successList.isEmpty()) {
for (IndustryMaterialVo success : successList) {
// 强行对齐batch数据避免batch出现比实际多的情况导致开始轧制失败
IndustryBatch industryBatch = new IndustryBatch();
industryBatch.setId(industryMaterial.getBatchId());
industryBatch.setBatchSize((long) successList.size());
industryBatchService.updateIndustryBatch(industryBatch);
for (IndustryMaterialVo success : successList) {
// 进入这里说明工艺没问题接下里根据工艺表创建道次
// 判断当前是粗轧还是精轧
IndustryTechnology industryTechnology = new IndustryTechnology();
@@ -467,8 +482,10 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
// 校验是否都存在道次 如果有一个不存在此工艺直接返回不做任何操作
if (industryTechnologyVos.isEmpty()) {
// 把状态改回去
success.setState(0L);
industryMaterialMapper.updateIndustryMaterial(success);
IndustryMaterial params = new IndustryMaterial();
params.setState(0L);
params.setBatchId(success.getBatchId());
industryMaterialMapper.updateIndustryMaterialByBatchId(params);
return Constants.NOT_HAVE_TECHNOLOGY;
}
@@ -491,11 +508,12 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
List<IndustryTechnologyVo> industryTechnologyVos = industryTechnologyService.selectIndustryTechnologyList(industryTechnology);
// 添加特判 当工艺表为空时通知前端无此工艺不可进入轧制页面
System.out.println("生成道次");
// 也就是说这里不管下面的物料是否为此工艺也按照此工艺生成道次只不过不需要操作
for (IndustryTechnologyVo industryTechnologyVo : industryTechnologyVos) {
System.out.println(industryTechnologyVo);
IndustryStep industryStep = getIndustryStep(industryMaterial, success, industryTechnologyVo);
insertIndustryStep(industryStep);
industryStepMapper.insertIndustryStep(industryStep);
}
success.setStepSize((long) industryTechnologyVos.size());
industryMaterialService.updateIndustryMaterial(success);
@@ -540,6 +558,8 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
// 如果当前模式是4辊
if ("1".equals(mode)) {
redisCache.deleteObject("materialLock");
redis2Cache.deleteObject("insertBatchId");
redis2Cache.deleteObject("originBatchId");
}
// 如果当前模式是2辊
@@ -568,15 +588,19 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
}
if (Objects.isNull(materialLock) || materialLock != 0L) {
// 如果是空就写一个1进去占住锁
redis2Cache.setCacheObject("materialLock", 1L, 3000, TimeUnit.HOURS);
redis2Cache.setCacheObject("originBatchId", industryStep.getBatchId(), 3000, TimeUnit.HOURS);
// 然后把非异常的东西都赛里面
// 直接删掉扫入并且未轧制的,写入二辊数据到四辊机器里面
industryMaterialService.clearSystem();
IndustryMaterialVo industryMaterialVo = new IndustryMaterialVo();
industryMaterialVo.setBatchId(industryStep.getBatchId());
industryMaterialVo.setState(2L);
List<IndustryMaterialVo> industryMaterialVos = industryMaterialMapper.selectIndustryMaterialList1(industryMaterialVo);
String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos);
System.out.println(result);
String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos, null);
}
}
@@ -648,6 +672,7 @@ public class IndustryStepServiceImpl implements IIndustryStepService {
@Override
public void start(IndustryStep industryStep) {
industryStep.setState(0L);
List<IndustryStepVo> industryStepVos = industryStepMapper.selectIndustryStepList(industryStep);
if (!industryStepVos.isEmpty()) {
IndustryStepVo firstStep = industryStepVos.get(0);

View File

@@ -271,7 +271,7 @@
</select>
<select id="selectIndustryMaterialListAndNotFinish"
resultMap="IndustryMaterialResult">
select * from industry_material where state!=0 and state!=1 and state!=3 and state!=4 and state!=5
select * from industry_material where state=1 or state=3 or state=4 or state=5
</select>
@@ -373,6 +373,30 @@
set state=#{state}
where id = #{materialId}
</update>
<update id="updateIndustryMaterialByBatchId">
update industry_material
<trim prefix="SET" suffixOverrides=",">
<if test="specification != null">specification = #{specification},</if>
<if test="technology != null">technology = #{technology},</if>
<if test="operation != null">operation = #{operation},</if>
<if test="diameter != null">diameter = #{diameter},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="state != null">state = #{state},</if>
<if test="stepSize != null">step_size = #{stepSize},</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="finalDiameter2 != null">final_diameter2 = #{finalDiameter2},</if>
<if test="weight != null">weight = #{weight},</if>
<if test="width != null">width = #{width},</if>
</trim>
where batch_id = #{batchId}
</update>
<delete id="deleteIndustryMaterialByIds" parameterType="String">

View File

@@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectIndustryTechnologyList" parameterType="IndustryTechnology" resultMap="IndustryTechnologyResult">
<include refid="selectIndustryTechnologyVo"/>
<where>
<if test="technologyId != null and technologyId != ''"> and technology_id = #{technologyId}</if>
<if test="technologyId != null"> and technology_id = #{technologyId}</if>
<if test="step != null "> and step = #{step}</if>
<if test="reduction != null "> and reduction = #{reduction}</if>
<if test="thicknessFront != null "> and thickness_front = #{thicknessFront}</if>