吊挂管理-运行记录数据同步 2.13

zhc4dev
zhc077 2 years ago
parent 1f43e80bae
commit e7bf12157e
  1. 6
      ant-design-vue-jeecg/src/views/hanger/HangerManage.vue
  2. 13
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hanger/controller/HangRecordController.java
  3. 8
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hanger/controller/ZyHangPointController.java
  4. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hanger/service/IHangRecordService.java
  5. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hanger/service/IZyHangPointService.java
  6. 79
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hanger/service/impl/HangRecordServiceImpl.java
  7. 13
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hanger/service/impl/ZyHangPointServiceImpl.java

@ -33,7 +33,7 @@
import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {getAction, postAction} from "@api/manage";
import {getAction, postAction, putAction} from "@api/manage";
import {filterObj, pushIfNotExist, randomNumber, randomUUID} from "@/utils/util";
import {JVXETypes} from '@/components/jeecg/JVxeTable'
@ -130,7 +130,7 @@ export default {
url: {
list: "/org.jeecg.modules.hanger/zyHang/getPointById",
getStationList: "/jeecg-boot/org.jeecg.modules.hanger/zyHang/getStationList",
syncHangRecord: "/org.jeecg.modules.productplan/zyPlanProcess/syncHangRecord",
syncHangRecord: "/org.jeecg.modules.hanger/hangRecord/syncHangRecord",
addBatch: "/org.jeecg.modules.hanger/zyHangPoint/addBatch",
},
loadRouteType: false,
@ -195,7 +195,7 @@ export default {
//
syncHangRecord() {
this.loading = true;
getAction(this.url.syncHangRecord, {"code": this.code}).then((res) => {
putAction(this.url.syncHangRecord, {"hangCode": this.code}).then((res) => {
if (res.success) {
this.$message.success("操作成功");
} else {

@ -11,6 +11,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.hanger.entity.HangRecord;
import org.jeecg.modules.hanger.entity.ZyHangPoint;
import org.jeecg.modules.hanger.service.IHangRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -56,6 +57,18 @@ public class HangRecordController extends JeecgController<HangRecord, IHangRecor
return Result.OK(pageList);
}
/**
* 根据吊挂编号-增量同步吊挂运行记录
* @param hangRecord
* @return
*/
@ApiOperation(value = "吊挂工位表-同步生产记录表数据到吊挂运行记录表", notes = "吊挂工位表-同步生产记录表数据到吊挂运行记录表")
@PutMapping(value = "/syncHangRecord")
public Result<?> syncHangRecord(@RequestBody HangRecord hangRecord) {
hangRecordService.syncHangRecord(hangRecord);
return Result.OK();
}
/**
* 添加
*

@ -65,14 +65,6 @@ public class ZyHangPointController extends JeecgController<ZyHangPoint, IZyHangP
return Result.OK(zyHangPointService.getLastPointCode());
}
@ApiOperation(value = "吊挂工位表-同步生产记录表数据到吊挂运行记录表", notes = "吊挂工位表-同步生产记录表数据到吊挂运行记录表")
@GetMapping(value = "/syncHangRecord")
public Result<?> syncHangRecord(ZyHangPoint zyHangPoint) {
zyHangPointService.syncHangRecord(zyHangPoint);
return Result.OK();
}
@ApiOperation(value = "吊挂工位表-工站、工位绑定批量添加", notes = "吊挂工位表-工站、工位绑定批量添加")
@PostMapping(value = "/addBatch")
public Result<?> addBatch(@RequestBody List<ZyHangPoint> pointList) {

@ -11,5 +11,5 @@ import org.jeecg.modules.hanger.entity.HangRecord;
* @Version: V1.0
*/
public interface IHangRecordService extends IService<HangRecord> {
void syncHangRecord(HangRecord hangRecord);
}

@ -17,6 +17,4 @@ public interface IZyHangPointService extends IService<ZyHangPoint> {
String getLastPointCode();
void addBatch(List<ZyHangPoint> pointList);
void syncHangRecord(ZyHangPoint zyHangPoint);
}

@ -1,11 +1,30 @@
package org.jeecg.modules.hanger.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.github.classgraph.utils.VersionFinder;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.demo.productrecord.entity.ProductRecord;
import org.jeecg.modules.demo.productrecord.service.IProductRecordService;
import org.jeecg.modules.hanger.entity.HangRecord;
import org.jeecg.modules.hanger.entity.ZyHang;
import org.jeecg.modules.hanger.entity.ZyHangPoint;
import org.jeecg.modules.hanger.mapper.HangRecordMapper;
import org.jeecg.modules.hanger.service.IHangRecordService;
import org.jeecg.modules.hanger.service.IZyHangPointService;
import org.jeecg.modules.hanger.service.IZyHangService;
import org.jeecg.modules.team.service.IStationService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
/**
* @Description: 吊挂运行记录表
@ -16,4 +35,64 @@ import org.springframework.stereotype.Service;
@Service
public class HangRecordServiceImpl extends ServiceImpl<HangRecordMapper, HangRecord> implements IHangRecordService {
@Autowired
private IStationService iStationService;
@Autowired
private IZyHangService iZyHangService;
@Autowired
private IZyHangPointService iZyHangPointService;
@Autowired
private IProductRecordService iProductRecordService;
@Override
@Transactional(readOnly = false, rollbackFor = Exception.class)
public void syncHangRecord(HangRecord hangRecord) {
ZyHang one = iZyHangService.getOne(new LambdaQueryWrapper<ZyHang>().eq(ZyHang::getCode, hangRecord.getHangCode()));
Optional.ofNullable(one).orElseThrow(() -> new JeecgBootException("吊挂不存在!"));
List<ZyHangPoint> pointList = iZyHangPointService.list(new LambdaQueryWrapper<ZyHangPoint>().eq(ZyHangPoint::getCode, hangRecord.getHangCode()));
//没有配置工站时,不同步运行记录
if (ObjectUtils.isEmpty(pointList)) return;
//查询每一工站是否已有同步过的工站运行记录数据,
// 有同步过则根据生产记录表创建时间为条件增量同步,
// 未同步过则全量同步
pointList.forEach(e -> {
List<HangRecord> saveList;
List<HangRecord> pointRecordList = this.list(new LambdaQueryWrapper<HangRecord>()
.eq(HangRecord::getHangCode, hangRecord.getHangCode())
.eq(HangRecord::getPoint, e.getPoint())
.orderByDesc(HangRecord::getCreateTime)
);
if (!ObjectUtils.isEmpty(pointRecordList)) {//该工站已同步过,增量同步
Date createTime = pointRecordList.get(0).getCreateTime();
List<ProductRecord> productRecords = iProductRecordService.list(new LambdaQueryWrapper<ProductRecord>()
.eq(ProductRecord::getStationId, e.getStationId())
.gt(ProductRecord::getCreateTime, createTime)
);
saveList = this.convertHangRecord(one.getCode(), e.getPoint(), productRecords);
} else {//该工站未同步过
List<ProductRecord> productRecords = iProductRecordService.list(new LambdaQueryWrapper<ProductRecord>()
.eq(ProductRecord::getStationId, e.getStationId())
);
saveList = this.convertHangRecord(one.getCode(), e.getPoint(), productRecords);
}
this.saveBatch(saveList);
});
}
private List<HangRecord> convertHangRecord(final String hangCode, final String point, List<ProductRecord> productRecords) {
List<HangRecord> saveList = new LinkedList<>();
Optional.ofNullable(productRecords).orElse(new LinkedList<>()).forEach(obj -> {
HangRecord hangRecord1 = new HangRecord();
BeanUtils.copyProperties(obj, hangRecord1);
hangRecord1.setHangCode(hangCode);
hangRecord1.setPoint(point);
saveList.add(hangRecord1);
});
return saveList;
}
}

@ -4,12 +4,9 @@ package org.jeecg.modules.hanger.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.hanger.entity.ZyHang;
import org.jeecg.modules.hanger.entity.ZyHangPoint;
import org.jeecg.modules.hanger.mapper.ZyHangPointMapper;
import org.jeecg.modules.hanger.service.IZyHangPointService;
import org.jeecg.modules.hanger.service.IZyHangService;
import org.jeecg.modules.team.entity.Station;
import org.jeecg.modules.team.service.IStationService;
import org.springframework.beans.factory.annotation.Autowired;
@ -32,9 +29,6 @@ public class ZyHangPointServiceImpl extends ServiceImpl<ZyHangPointMapper, ZyHan
@Autowired
private IStationService iStationService;
@Autowired
private IZyHangService iZyHangService;
@Override
public String getLastPointCode() {
List<ZyHangPoint> pointList = this.list(new LambdaQueryWrapper<ZyHangPoint>().orderByDesc(ZyHangPoint::getPoint));
@ -63,11 +57,4 @@ public class ZyHangPointServiceImpl extends ServiceImpl<ZyHangPointMapper, ZyHan
});
this.saveOrUpdateBatch(pointList);
}
@Override
public void syncHangRecord(ZyHangPoint zyHangPoint) {
ZyHang zyHang = iZyHangService.getOne(new LambdaQueryWrapper<ZyHang>().eq(ZyHang::getCode, zyHangPoint.getCode()));
Optional.ofNullable(zyHang).orElseThrow(() -> new JeecgBootException(zyHangPoint.getCode() + "不存在"));
//TODO
}
}

Loading…
Cancel
Save