| | |
| | | package com.thhy.materials.modules.biz.concret.controller; |
| | | |
| | | |
| | | import com.thhy.materials.modules.biz.concret.entity.SysSteel; |
| | | 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; |
| | |
| | | |
| | | } |
| | | |
| | | //苏州项目------- 地磅入库 记录,及库存修改 |
| | | @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()); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | //苏州项目------- 地磅入库 记录,及库存修改 钢筋 |
| | | @Scheduled(fixedRate = 2000000) // 每隔3秒执行一次任务 |
| | | public void weighbridgeSteel() { |
| | | //查询搅拌 所有类型 |
| | | List<SysSteel> steels = weighService.steelType(); |
| | | |
| | | List<TWeighbridge> tWeighbridges = weighMapper.weighbridgeListType(); |
| | | for (SysSteel steel : steels){ |
| | | for (TWeighbridge weighbridge :tWeighbridges){ |
| | | if(steel.getSteelName().equals(weighbridge.getMatname())&&steel.getSteelModel().equals(weighbridge.getMatmodel())){ |
| | | //净重 |
| | | String jweight = weighbridge.getJweight(); |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | hashMap.put("id",""); |
| | | hashMap.put("steelId",steel.getSteelId()); |
| | | hashMap.put("stockType",1); |
| | | hashMap.put("changeStock",jweight); |
| | | hashMap.put("companyId","031e3dd577e8ed28e96aa69b"); |
| | | BigDecimal b1 = new BigDecimal(jweight); |
| | | BigDecimal b2 = new BigDecimal(steel.getStock()); |
| | | RLock lock = redissonclient.getLock("materlock"); |
| | | if(!lock.isLocked()) { |
| | | lock.lock(10, TimeUnit.SECONDS); |
| | | //插入记录表//苏州项目(入库计入增加) |
| | | weighMapper.steelRecordIn(hashMap); |
| | | //更改记录值 |
| | | weighMapper.steelUp(steel.getSteelId(),b1.add(b2).doubleValue()); |
| | | lock.unlock(); |
| | | } |
| | | weighMapper.weighbridgeUpdateType(weighbridge.getWeighbridgeId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |