|
|
|
package com.glxp.api.controller.thrsys;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.api.entity.system.SyncDataBustypeEntity;
|
|
|
|
import com.glxp.api.entity.system.SyncUploadDataSetEntity;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrOrderUploadBustypesEntity;
|
|
|
|
import com.glxp.api.req.system.DeleteRequest;
|
|
|
|
import com.glxp.api.service.system.SyncUploadDataBustypeService;
|
|
|
|
import com.glxp.api.service.system.SyncUploadDataSetService;
|
|
|
|
import com.glxp.api.service.thrsys.ThrOrderUploadBustypesService;
|
|
|
|
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.Arrays;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
public class ThirdUploadSetController {
|
|
|
|
@Resource
|
|
|
|
SyncUploadDataSetService syncUploadDataSetService;
|
|
|
|
@Resource
|
|
|
|
ThrOrderUploadBustypesService thrOrderUploadBustypesService;
|
|
|
|
|
|
|
|
@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
|
|
|
|
) {
|
|
|
|
boolean b = syncUploadDataSetService.insert(syncUploadDataSetEntity);
|
|
|
|
if (!b) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
|
|
|
}
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("system/third/syncData/getBus")
|
|
|
|
@GetMapping("/system/third/syncData/getBus")
|
|
|
|
public BaseResponse getBuslist() {
|
|
|
|
|
|
|
|
List<ThrOrderUploadBustypesEntity> thrOrderUploadBustypesEntities = thrOrderUploadBustypesService.list();
|
|
|
|
return ResultVOUtils.success(thrOrderUploadBustypesEntities);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 添加单据类型
|
|
|
|
@AuthRuleAnnotation("system/third/syncData/addBus")
|
|
|
|
@PostMapping("/system/third/syncData/addBus")
|
|
|
|
public BaseResponse addBus(@RequestBody @Valid SyncUploadDataSetEntity syncUploadDataSetEntity
|
|
|
|
) {
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(syncUploadDataSetEntity.getBusTypes())) {
|
|
|
|
return ResultVOUtils.error(500, "未选入单据类型");
|
|
|
|
}
|
|
|
|
List<ThrOrderUploadBustypesEntity> bustypesEntities = syncUploadDataSetEntity.getBusTypes();
|
|
|
|
if (CollUtil.isNotEmpty(bustypesEntities)) {
|
|
|
|
for (ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity : bustypesEntities) {
|
|
|
|
if (!thrOrderUploadBustypesService.isExit(thrOrderUploadBustypesEntity.getAction())) {
|
|
|
|
thrOrderUploadBustypesEntity.setOrderStatus(3);
|
|
|
|
thrOrderUploadBustypesEntity.setUpdateTime(new Date());
|
|
|
|
thrOrderUploadBustypesEntity.setCreateTime(new Date());
|
|
|
|
thrOrderUploadBustypesEntity.setId(null);
|
|
|
|
thrOrderUploadBustypesEntity.setOrderSource(Arrays.asList("2"));
|
|
|
|
thrOrderUploadBustypesEntity.setId(null);
|
|
|
|
thrOrderUploadBustypesService.save(thrOrderUploadBustypesEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 移除单据类型
|
|
|
|
@AuthRuleAnnotation("system/third/syncData/removeBus")
|
|
|
|
@PostMapping("/system/third/syncData/removeBus")
|
|
|
|
public BaseResponse removeBus(@RequestBody @Valid DeleteRequest deleteRequest
|
|
|
|
) {
|
|
|
|
thrOrderUploadBustypesService.removeById(deleteRequest.getId());
|
|
|
|
return ResultVOUtils.success("删除成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 单据类型编辑
|
|
|
|
@AuthRuleAnnotation("system/third/syncData/editBus")
|
|
|
|
@PostMapping("/system/third/syncData/editBus")
|
|
|
|
public BaseResponse editBus(@RequestBody @Valid ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity
|
|
|
|
) {
|
|
|
|
thrOrderUploadBustypesService.updateById(thrOrderUploadBustypesEntity);
|
|
|
|
return ResultVOUtils.success("更新成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
//编辑
|
|
|
|
@AuthRuleAnnotation("system/third/syncData/update")
|
|
|
|
@GetMapping("/system/third/syncData/update")
|
|
|
|
public BaseResponse update(@RequestBody @Valid SyncUploadDataSetEntity syncUploadDataSetEntity) {
|
|
|
|
|
|
|
|
// 保存更新后的数据集信息
|
|
|
|
boolean b = syncUploadDataSetService.updateById(syncUploadDataSetEntity);
|
|
|
|
if (!b) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
|
|
|
}
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
}
|
|
|
|
}
|