|
@@ -1,17 +1,22 @@
|
|
|
package com.xy.service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xy.collections.list.JArrayList;
|
|
|
import com.xy.collections.list.JList;
|
|
|
import com.xy.collections.map.JMap;
|
|
|
import com.xy.dto.DeviceQualityDto;
|
|
|
+import com.xy.dto.DeviceQualityValueDto;
|
|
|
import com.xy.entity.DeviceInfo;
|
|
|
import com.xy.entity.DeviceQuality;
|
|
|
+import com.xy.entity.SysDictRedis;
|
|
|
import com.xy.mapper.DeviceInfoMapper;
|
|
|
import com.xy.mapper.DeviceQualityMapper;
|
|
|
import com.xy.utils.*;
|
|
|
+import com.xy.utils.enums.DeviceEnum;
|
|
|
+import com.xy.utils.enums.DeviceSonEnum;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -41,6 +46,8 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
|
|
|
private DeviceInfoMapper deviceInfoMapper;
|
|
|
|
|
|
+ private DeviceQualityValueServiceImpl deviceQualityValueService;
|
|
|
+
|
|
|
@PostMapping("page")
|
|
|
@ApiOperation("分页查询")
|
|
|
public R<PageBean<DeviceQualityDto.Vo>> page(@RequestBody DeviceQualityDto.Page page) {
|
|
@@ -54,21 +61,58 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
return R.ok(toPageBean(DeviceQualityDto.Vo.class, iPage));
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("list")
|
|
|
+ @ApiOperation("集合查询")
|
|
|
+ public R<List<DeviceQualityDto.Vo>> list(@RequestBody DeviceQualityDto.SelectList selectList) {
|
|
|
+ LambdaQueryWrapper<DeviceQuality> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(selectList, DeviceQuality.class)
|
|
|
+ .in(DeviceQuality::getQualityId, selectList.getQualityIds())
|
|
|
+ .in(DeviceQuality::getDeviceId, selectList.getDeviceIds())
|
|
|
+ .build();
|
|
|
+ List<DeviceQuality> list = list(lambdaQueryWrapper);
|
|
|
+ return R.ok(copy(DeviceQualityDto.Vo.class, list));
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("update")
|
|
|
@ApiOperation("修改")
|
|
|
public R update(@RequestBody List<DeviceQualityDto.Vo> vos) {
|
|
|
List<DeviceQuality> deviceQualities = copy(DeviceQuality.class, vos);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
for (DeviceQuality deviceQuality : deviceQualities) {
|
|
|
- if (deviceQuality.getQualityState() != null || deviceQuality.getFactoryState() != null) {
|
|
|
+ if (deviceQuality.getQualityState() != null) {
|
|
|
deviceQuality.setQualityAuditUserId(AuthorizeUtils.getLoginId(Long.class));
|
|
|
}
|
|
|
+ if (deviceQuality.getFactoryState() != null) {
|
|
|
+ deviceQuality.setFactoryAuditUserId(AuthorizeUtils.getLoginId(Long.class));
|
|
|
+ }
|
|
|
deviceQuality.setUpdateTime(now);
|
|
|
}
|
|
|
updateBatchById(deviceQualities);
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("rest")
|
|
|
+ @ApiOperation("重置某项质检")
|
|
|
+ public R rest(@RequestBody DeviceQualityDto.Rest rest) {
|
|
|
+ SysDictRedis sysDictRedis1 = SysDictUtils.get(DeviceEnum.DEVICE_QUALITY_STATUS.getKey(), DeviceSonEnum.DEVICE_QUALITY_STATUS_QUALIFIED.getKey());
|
|
|
+ SysDictRedis sysDictRedis2 = SysDictUtils.get(DeviceEnum.DEVICE_FACTORY_STATUS.getKey(), DeviceSonEnum.DEVICE_FACTORY_STATUS_CAN_SHIPPED.getKey());
|
|
|
+ DeviceQuality deviceQuality = getById(rest.getQualityId());
|
|
|
+ if (sysDictRedis1.getValue().equals(deviceQuality.getQualityState()) || sysDictRedis2.getValue().equals(deviceQuality.getFactoryState())) {
|
|
|
+ return R.fail("设备已合格或已出厂");
|
|
|
+ }
|
|
|
+ //修改质检
|
|
|
+ UpdateWrapper<DeviceQuality> updateWrapper = new UpdateWrapper<DeviceQuality>()
|
|
|
+ .set(rest.getType() + "_begin_time", LocalDateTime.now())
|
|
|
+ .set(rest.getType() + "_end_time", null)
|
|
|
+ .eq(StringTools.humpToLine(LambdaUtils.getProperty(DeviceQuality::getQualityId)), rest.getQualityId());
|
|
|
+ update(updateWrapper);
|
|
|
+ //修改质检属性
|
|
|
+ DeviceQualityValueDto.Update update = new DeviceQualityValueDto.Update()
|
|
|
+ .setType(rest.getType());
|
|
|
+ update.setQualityId(rest.getQualityId());
|
|
|
+ deviceQualityValueService.update(update);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("save")
|
|
|
@ApiOperation("添加")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -82,6 +126,7 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
//获取已有质检信息
|
|
|
List<DeviceQuality> deviceQualities = list(new LambdaQueryWrapper<DeviceQuality>().in(DeviceQuality::getDeviceId, deviceIds));
|
|
|
JMap<Long, List<DeviceQuality>> deviceQualitieJMap = new JArrayList<>(deviceQualities).toMap(DeviceQuality::getDeviceId).group();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
//封装修改和添加对象
|
|
|
for (DeviceQualityDto.Vo save : vos) {
|
|
|
DeviceQuality deviceQuality = new DeviceQuality().setDeviceId(save.getDeviceId());
|
|
@@ -90,7 +135,13 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
return R.fail(save.getDeviceId() + "设备不存在");
|
|
|
}
|
|
|
deviceQuality.setDeviceType(deviceInfo.getDeviceType())
|
|
|
- .setCreateTime(LocalDateTime.now());
|
|
|
+ .setCreateTime(now)
|
|
|
+ .setTradeStateBeginTime(now)
|
|
|
+ .setLockerStateBeginTime(now)
|
|
|
+ .setTempratureStateBeginTime(now)
|
|
|
+ .setImitateTestStateBeginTime(now)
|
|
|
+ .setSystemStateBeginTime(now)
|
|
|
+ .setSettingStateBeginTime(now);
|
|
|
List<DeviceQuality> list = deviceQualitieJMap.get(deviceQuality.getDeviceId());
|
|
|
if (Emptys.check(list)) {
|
|
|
JList<Integer> qualityIds = new JArrayList<>(list).getProperty(DeviceQuality::getQualityId);
|
|
@@ -106,20 +157,13 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
}
|
|
|
//添加
|
|
|
saveBatch(saves);
|
|
|
+ //添加质检属性
|
|
|
+ List<DeviceQualityValueDto.Vo> deviceQualityValueDtoVos = new ArrayList<>(saves.size());
|
|
|
+ saves.forEach(deviceQuality -> deviceQualityValueDtoVos.add(new DeviceQualityValueDto.Vo().setQualityId(deviceQuality.getQualityId())));
|
|
|
+ deviceQualityValueService.save(deviceQualityValueDtoVos);
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
- @PostMapping("list")
|
|
|
- @ApiOperation("集合查询")
|
|
|
- public R<List<DeviceQualityDto.Vo>> list(@RequestBody DeviceQualityDto.SelectList selectList) {
|
|
|
- LambdaQueryWrapper<DeviceQuality> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(selectList, DeviceQuality.class)
|
|
|
- .in(DeviceQuality::getQualityId, selectList.getQualityIds())
|
|
|
- .in(DeviceQuality::getDeviceId, selectList.getDeviceIds())
|
|
|
- .build();
|
|
|
- List<DeviceQuality> list = list(lambdaQueryWrapper);
|
|
|
- return R.ok(copy(DeviceQualityDto.Vo.class, list));
|
|
|
- }
|
|
|
-
|
|
|
@PostMapping("getQrCode")
|
|
|
@ApiOperation("获取二维码")
|
|
|
public R<String> getQrCode(@RequestBody DeviceQualityDto.Qrcode qrcode) {
|