feat():设备信息

master
jiyufei 2 months ago
parent 9c224ed3d1
commit c96c89bbfe

@ -11,6 +11,7 @@ import jnpf.base.UserInfo;
import jnpf.base.model.ColumnDataModel; import jnpf.base.model.ColumnDataModel;
import jnpf.database.model.superQuery.SuperJsonModel; import jnpf.database.model.superQuery.SuperJsonModel;
import jnpf.entity.YysDeviceEntity; import jnpf.entity.YysDeviceEntity;
import jnpf.entity.YysDeviceMaterialEntity;
import jnpf.mapper.YysDeviceMapper; import jnpf.mapper.YysDeviceMapper;
import jnpf.model.QueryModel; import jnpf.model.QueryModel;
import jnpf.model.yysdevice.YysDeviceConstant; import jnpf.model.yysdevice.YysDeviceConstant;
@ -326,6 +327,11 @@ public class YysDeviceServiceImpl extends ServiceImpl<YysDeviceMapper, YysDevice
} }
boolean result = this.saveOrUpdate(entity); boolean result = this.saveOrUpdate(entity);
if (result) { if (result) {
//删掉绑定物料重新添加
LambdaQueryWrapper<YysDeviceMaterialEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YysDeviceMaterialEntity::getDeviceCode, entity.getDeviceCode());
yysDeviceMaterialService.remove(wrapper);
yysDeviceMaterialService.saveBatch(yysDeviceForm.getData());
//向设备维保表同步数据 //向设备维保表同步数据
yysDeviceUpkeepService.syncSaveOrUpdate(entity); yysDeviceUpkeepService.syncSaveOrUpdate(entity);
} }
@ -347,6 +353,6 @@ public class YysDeviceServiceImpl extends ServiceImpl<YysDeviceMapper, YysDevice
if (StringUtils.isBlank(yysDeviceForm.getDeviceCode())) { if (StringUtils.isBlank(yysDeviceForm.getDeviceCode())) {
return "绑定失败,设备编码不能为空"; return "绑定失败,设备编码不能为空";
} }
return yysDeviceMaterialService.saveData(yysDeviceForm.getDeviceCode(),yysDeviceForm.getData()); return yysDeviceMaterialService.saveData(yysDeviceForm.getDeviceCode(), yysDeviceForm.getData());
} }
} }

@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.*; import java.util.*;
@ -78,6 +79,8 @@ public class YysDeviceController {
@Autowired @Autowired
private YysDeviceService yysDeviceService; private YysDeviceService yysDeviceService;
@Resource
private YysDeviceMaterialService yysDeviceMaterialService;
@Autowired @Autowired
private ConfigValueUtil configValueUtil; private ConfigValueUtil configValueUtil;
@ -93,9 +96,15 @@ public class YysDeviceController {
public ActionResult list(@RequestBody YysDevicePagination yysDevicePagination) throws IOException { public ActionResult list(@RequestBody YysDevicePagination yysDevicePagination) throws IOException {
List<YysDeviceEntity> list = yysDeviceService.getList(yysDevicePagination); List<YysDeviceEntity> list = yysDeviceService.getList(yysDevicePagination);
List<Map<String, Object>> realList = new ArrayList<>(); List<Map<String, Object>> realList = new ArrayList<>();
//查询设备绑定物料信息
List<YysDeviceMaterialEntity> list1 = yysDeviceMaterialService.list();
Map<String, List<YysDeviceMaterialEntity>> collect = list1.stream().collect(Collectors.groupingBy(YysDeviceMaterialEntity::getDeviceCode));
for (YysDeviceEntity entity : list) { for (YysDeviceEntity entity : list) {
Map<String, Object> yysDeviceMap = JsonUtil.entityToMap(entity); Map<String, Object> yysDeviceMap = JsonUtil.entityToMap(entity);
yysDeviceMap.put("id", yysDeviceMap.get("id")); yysDeviceMap.put("id", yysDeviceMap.get("id"));
if (collect.containsKey(entity.getDeviceCode())) {
yysDeviceMap.put("data", collect.get(entity.getDeviceCode()));
}
//副表数据 //副表数据
//子表数据 //子表数据
realList.add(yysDeviceMap); realList.add(yysDeviceMap);

Loading…
Cancel
Save