You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-wms-java/src/main/java/com/glxp/api/controller/thrsys/ThirdUploadSetController.java

90 lines
3.8 KiB
Java

package com.glxp.api.controller.thrsys;
3 years ago
import cn.hutool.core.bean.BeanUtil;
3 years ago
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
3 years ago
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
3 years ago
import com.glxp.api.entity.system.SyncDataBustypeEntity;
import com.glxp.api.entity.system.SyncUploadDataSetEntity;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
import com.glxp.api.req.thrsys.FilterBasicThirdSysRequest;
3 years ago
import com.glxp.api.service.system.SyncUploadDataBustypeService;
import com.glxp.api.service.system.SyncUploadDataSetService;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import org.springframework.validation.BindingResult;
3 years ago
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@RestController
public class ThirdUploadSetController {
@Resource
SyncUploadDataSetService syncUploadDataSetService;
@Resource
SyncUploadDataBustypeService syncUploadDataBustypeService;
@AuthRuleAnnotation("system/third/syncData/config")
@GetMapping("/system/third/syncData/config")
public BaseResponse list() {
SyncUploadDataSetEntity syncDataSetResponse = syncUploadDataSetService.selectSet();
return ResultVOUtils.success(syncDataSetResponse);
}
@AuthRuleAnnotation("system/third/syncData/save")
@PostMapping("/system/third/syncData/save")
public BaseResponse save(@RequestBody @Valid SyncUploadDataSetEntity syncUploadDataSetEntity
) {
List<SyncDataBustypeEntity> busTypes = syncUploadDataSetEntity.getBusTypes();
syncUploadDataBustypeService.deleteAll();
if (CollUtil.isNotEmpty(busTypes))
syncUploadDataBustypeService.inserts(busTypes);
syncUploadDataSetEntity.setBusTypes(null);
boolean b = syncUploadDataSetService.insert(syncUploadDataSetEntity);
if (!b) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
return ResultVOUtils.success();
}
//编辑
@AuthRuleAnnotation("system/third/syncData/update")
@GetMapping("/system/third/syncData/update")
public BaseResponse update(@RequestBody @Valid SyncUploadDataSetEntity syncUploadDataSetEntity) {
// 获取需要更新的数据集ID
Long dataSetId = Long.valueOf(syncUploadDataSetEntity.getId());
// 根据数据集ID查询原有数据集信息
SyncUploadDataSetEntity oldDataSet = syncUploadDataSetService.getById(dataSetId);
if (oldDataSet == null) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
// // 更新数据集信息
// oldDataSet.setName(syncUploadDataSetEntity.getName());
// oldDataSet.setDescription(syncUploadDataSetEntity.getDescription());
// oldDataSet.setUpdateTime(new Date());
// 更新数据集业务类型信息
// List<SyncDataBustypeEntity> busTypes = syncUploadDataSetEntity.getBusTypes();
// syncUploadDataBustypeService.deleteByDataSetId(dataSetId);
// if (CollUtil.isNotEmpty(busTypes)) {
// for (SyncDataBustypeEntity busType : busTypes) {
// busType.setDataSetId(dataSetId);
// }
// syncUploadDataBustypeService.inserts(busTypes);
// }
// 保存更新后的数据集信息
boolean b = syncUploadDataSetService.updateById(oldDataSet);
if (!b) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
return ResultVOUtils.success();
}
3 years ago
}