From fad63be580dc8ddef06b9f502e4551227e14d438 Mon Sep 17 00:00:00 2001
From: 张磊磊 <201175954@qq.com>
Date: 星期五, 24 十一月 2023 13:41:26 +0800
Subject: [PATCH] 苏州地磅数据加工入库
---
hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/concret/controller/MixingPlantNewScheduled.java | 45 +++++++++++++++
hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/weigh/mapper/WeighMapper.java | 8 ++
hd/pipe/materialsManage/src/main/resources/mapping/WeighMapper.xml | 96 ++++++++++++++++++++++++++++++++
3 files changed, 149 insertions(+), 0 deletions(-)
diff --git a/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/concret/controller/MixingPlantNewScheduled.java b/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/concret/controller/MixingPlantNewScheduled.java
index bcd04d3..c70f37a 100644
--- a/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/concret/controller/MixingPlantNewScheduled.java
+++ b/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/concret/controller/MixingPlantNewScheduled.java
@@ -4,6 +4,7 @@
import com.thhy.materials.modules.biz.concret.entity.dto.DicetName;
import com.thhy.materials.modules.biz.concret.entity.dto.TMinxingPlant;
import com.thhy.materials.modules.biz.concret.entity.dto.WeighDto;
+import com.thhy.materials.modules.biz.weigh.entity.TWeighbridge;
import com.thhy.materials.modules.biz.weigh.mapper.WeighMapper;
import com.thhy.materials.modules.biz.weigh.service.WeighService;
import org.redisson.api.RLock;
@@ -192,6 +193,50 @@
}
+ //苏州项目------- 地磅入库 记录,及库存修改
+ @Scheduled(fixedRate = 2000000) // 每隔3秒执行一次任务
+ public void weighbridge() {
+ //查询搅拌 所有类型
+ List<DicetName> dictList = weighService.dictList();
+ List<TWeighbridge> tWeighbridges = weighMapper.weighbridgeListType();
+ for (DicetName dicetName : dictList){
+ for (TWeighbridge weighbridge :tWeighbridges){
+ if(dicetName.getDictName().equals(weighbridge.getMatname())){
+ //开始的库存
+ Double materialValue = weighMapper.materialStockValue(dicetName.getDictId());
+ //净重
+ String jweight = weighbridge.getJweight();
+ HashMap<String, Object> hashMap = new HashMap<>();
+ hashMap.put("id","");
+ hashMap.put("type",1);
+ hashMap.put("opType",1);
+ hashMap.put("materialName",dicetName.getDictId());
+ hashMap.put("materialValue",Double.valueOf(jweight));
+ hashMap.put("beforeStock",materialValue);
+ BigDecimal b1 = new BigDecimal(jweight);
+ BigDecimal b2 = new BigDecimal(materialValue);
+ double v1 = b1.add(b2).doubleValue();
+ hashMap.put("afterStock",v1);
+ hashMap.put("companyId","031e3dd577e8ed28e96aa69b");
+ RLock lock = redissonclient.getLock("materlock");
+ if(!lock.isLocked()) {
+ lock.lock(10, TimeUnit.SECONDS);
+ //插入记录表//苏州项目(入库计入增加)
+ weighMapper.materialStockRecordIns(hashMap);
+ //更改记录值
+ weighMapper.materialStockRecordUp(dicetName.getDictId(),b1.add(b2).doubleValue());
+ lock.unlock();
+ }
+
+ weighMapper.weighbridgeUpdateType(weighbridge.getWeighbridgeId());
+ }
+ }
+
+
+ }
+
+
+ }
}
diff --git a/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/weigh/mapper/WeighMapper.java b/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/weigh/mapper/WeighMapper.java
index cde8c15..9b87258 100644
--- a/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/weigh/mapper/WeighMapper.java
+++ b/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/weigh/mapper/WeighMapper.java
@@ -73,4 +73,12 @@
void netWeighUpdateNew(@Param("byId") Integer byId,@Param("netWeight") double netWeight);
List<TWeighbridge> weighbridgeList(Map<String, Object> values);
+
+ List<TWeighbridge> weighbridgeListType();
+
+ Double materialStockValue(String dictId);
+
+ void materialStockRecordIns(HashMap<String, Object> hashMap);
+
+ void weighbridgeUpdateType(Integer weighbridgeId);
}
diff --git a/hd/pipe/materialsManage/src/main/resources/mapping/WeighMapper.xml b/hd/pipe/materialsManage/src/main/resources/mapping/WeighMapper.xml
index ddadc5f..55cbeb7 100644
--- a/hd/pipe/materialsManage/src/main/resources/mapping/WeighMapper.xml
+++ b/hd/pipe/materialsManage/src/main/resources/mapping/WeighMapper.xml
@@ -615,4 +615,100 @@
order by weighbridge_id desc
</select>
+ <select id="weighbridgeListType" resultType="com.thhy.materials.modules.biz.weigh.entity.TWeighbridge">
+ select
+ weighbridge_id as weighbridgeId,
+ id,
+ code,
+ orgName,
+ supplyOrgName,
+ carNumber,
+ driverName,
+ matName,
+ matModel,
+ mPoundTime,
+ mPoundWeight,
+ mPoundName,
+ pPoundTime,
+ pPoundWeight,
+ pPoundName,
+ jPoundWeight,
+ buckleWeight,
+ mWeight,
+ pWeight,
+ jWeight,
+ wareName,
+ fileImage,
+ types
+ from t_weighbridge where
+ types=1
+ </select>
+ <select id="materialStockValue" resultType="java.lang.Double">
+ select material_value as materialValue
+ from t_material_stock where material_name=#{dictId}
+ </select>
+
+
+ <insert id="materialStockRecordIns" >
+ insert into t_material_stock_record
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ id,
+ <if test="createDate != null">
+ create_date,
+ </if>
+ <if test="type != null">
+ type,
+ </if>
+ <if test="opType != null">
+ op_type,
+ </if>
+ <if test="materialName != null">
+ material_name,
+ </if>
+ <if test="materialValue != null">
+ material_value,
+ </if>
+ <if test="beforeStock != null">
+ before_stock,
+ </if>
+ <if test="afterStock != null">
+ after_stock,
+ </if>
+ <if test="companyId != null">
+ company_id,
+ </if>
+ </trim>
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
+ REPLACE(UUID(),'-',''),
+ <if test="createDate != null">
+ #{createDate,jdbcType=TIMESTAMP},
+ </if>
+ <if test="type != null">
+ #{type,jdbcType=INTEGER},
+ </if>
+ <if test="opType != null">
+ #{opType,jdbcType=INTEGER},
+ </if>
+ <if test="materialName != null">
+ #{materialName,jdbcType=VARCHAR},
+ </if>
+ <if test="materialValue != null">
+ #{materialValue,jdbcType=DOUBLE},
+ </if>
+ <if test="beforeStock != null">
+ #{beforeStock,jdbcType=DOUBLE},
+ </if>
+ <if test="afterStock != null">
+ #{afterStock,jdbcType=DOUBLE},
+ </if>
+ <if test="companyId != null">
+ #{companyId},
+ </if>
+ </trim>
+ </insert>
+ <update id="weighbridgeUpdateType" >
+ update t_weighbridge set
+ types=2
+ where weighbridge_id=#{weighbridgeId}
+ </update>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3