|
|
|
package com.glxp.api.controller.thrsys;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
import com.glxp.api.annotation.Log;
|
|
|
|
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.constant.BusinessType;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrSystemBusApiEntity;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrSystemEntity;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
|
|
|
|
import com.glxp.api.httpClient.serviceClient.ErpBasicClient;
|
|
|
|
import com.glxp.api.req.thrsys.FilterBasicThirdSysDetailRequest;
|
|
|
|
import com.glxp.api.req.thrsys.FilterBasicThirdSysRequest;
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
import com.glxp.api.res.thrsys.BasicThirdSysResponse;
|
|
|
|
import com.glxp.api.service.thrsys.IThrBusTypeOriginService;
|
|
|
|
import com.glxp.api.service.thrsys.ThrSystemBusApiService;
|
|
|
|
import com.glxp.api.service.thrsys.ThrSystemDetailService;
|
|
|
|
import com.glxp.api.service.thrsys.ThrSystemService;
|
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
|
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;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
public class ThrSystemController {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private ThrSystemService thrSystemService;
|
|
|
|
@Resource
|
|
|
|
private ThrSystemDetailService thrSystemDetailService;
|
|
|
|
@Resource
|
|
|
|
ThrSystemBusApiService thrSystemBusApiService;
|
|
|
|
@Resource
|
|
|
|
private IThrBusTypeOriginService thrBusTypeOriginService;
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/udiwms/basic/thirdsys/filter")
|
|
|
|
public BaseResponse filter(FilterBasicThirdSysRequest filterBasicThirdSysRequest,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
List<ThrSystemEntity> basicThirdSysEntities;
|
|
|
|
|
|
|
|
basicThirdSysEntities = thrSystemService.filterBasicThiSys(filterBasicThirdSysRequest);
|
|
|
|
|
|
|
|
PageInfo<ThrSystemEntity> pageInfo;
|
|
|
|
pageInfo = new PageInfo<>(basicThirdSysEntities);
|
|
|
|
PageSimpleResponse<ThrSystemEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
|
pageSimpleResponse.setList(basicThirdSysEntities);
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 扫码精灵获取第三方系统列表
|
|
|
|
*/
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@GetMapping("/udiwms/basic/thirdsys/get")
|
|
|
|
public BaseResponse get(FilterBasicThirdSysRequest filterBasicThirdSysRequest,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
List<ThrSystemEntity> basicThirdSysEntities;
|
|
|
|
basicThirdSysEntities = thrSystemService.filterBasicThiSys(filterBasicThirdSysRequest);
|
|
|
|
List<BasicThirdSysResponse> basicThirdSysResponses = basicThirdSysEntities.stream().map(item ->
|
|
|
|
{
|
|
|
|
BasicThirdSysResponse basicThirdSysResponse = new BasicThirdSysResponse();
|
|
|
|
BeanUtil.copyProperties(item, basicThirdSysResponse);
|
|
|
|
return basicThirdSysResponse;
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
basicThirdSysResponses.add(new BasicThirdSysResponse("ybbm", "医保编码"));
|
|
|
|
basicThirdSysResponses.add(new BasicThirdSysResponse("sptm", "商品条码"));
|
|
|
|
basicThirdSysResponses.add(new BasicThirdSysResponse("udiCode", "UDI最小销售标识"));
|
|
|
|
return ResultVOUtils.success(basicThirdSysResponses);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/udiwms/basic/thirdsys/selectIp")
|
|
|
|
public BaseResponse selectIp(FilterBasicThirdSysDetailRequest filterBasicThirdSysDetailRequest,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
ThrSystemEntity thrSystemEntity = thrSystemService.selectByThirdId(filterBasicThirdSysDetailRequest.getThirdSysFk());
|
|
|
|
return ResultVOUtils.success(thrSystemEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/udiwms/basic/thirdsys/update")
|
|
|
|
@Log(title = "第三方系统", businessType = BusinessType.UPDATE)
|
|
|
|
public BaseResponse save(@RequestBody @Valid ThrSystemEntity thrSystemEntity,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
if (thrSystemEntity != null) {
|
|
|
|
//校验系统名称
|
|
|
|
if (StrUtil.isBlank(thrSystemEntity.getThirdName())) {
|
|
|
|
return ResultVOUtils.error(500, "系统名称不能为空");
|
|
|
|
}
|
|
|
|
//校验系统名称是否重复
|
|
|
|
boolean exists = thrSystemService.selectThirdNameExists(thrSystemEntity.getThirdId(), thrSystemEntity.getThirdName());
|
|
|
|
if (exists) {
|
|
|
|
return ResultVOUtils.error(500, "第三方系统名称重复");
|
|
|
|
}
|
|
|
|
|
|
|
|
ThrSystemEntity temp = thrSystemService.selectByThirdId(thrSystemEntity.getThirdId());
|
|
|
|
|
|
|
|
if (!thrSystemEntity.getEnabled()) {
|
|
|
|
//如操作为禁用第三方系统,则需要判断是否是最后一个启用的第三方系统,需要保留至少启用一个第三方系统
|
|
|
|
FilterBasicThirdSysRequest filterBasicThirdSysRequest = new FilterBasicThirdSysRequest();
|
|
|
|
filterBasicThirdSysRequest.setEnabled(true);
|
|
|
|
int count = thrSystemService.countThirdSys(filterBasicThirdSysRequest);
|
|
|
|
if (count == 1) {
|
|
|
|
return ResultVOUtils.error(500, "至少需需用一个第三方系统!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (thrSystemEntity.getMainSys() && !thrSystemEntity.getEnabled()) {
|
|
|
|
return ResultVOUtils.error(500, "主系统必须启用");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thrSystemEntity.getMainSys()) {
|
|
|
|
List<ThrSystemEntity> basicThirdSysEntities = thrSystemService.filterBasicThiSys(new FilterBasicThirdSysRequest());
|
|
|
|
for (ThrSystemEntity thrSystemEntity1 : basicThirdSysEntities) {
|
|
|
|
thrSystemEntity1.setMainSys(false);
|
|
|
|
thrSystemService.updateBasicThiSys(thrSystemEntity1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
thrSystemService.updateBasicThiSys(thrSystemEntity);
|
|
|
|
} else {
|
|
|
|
ResultVOUtils.error(999, "参数错误");
|
|
|
|
}
|
|
|
|
return ResultVOUtils.success("更新成功");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/udiwms/basic/thirdsys/filterDetail")
|
|
|
|
public BaseResponse filterDetail(FilterBasicThirdSysDetailRequest filterBasicThirdSysDetailRequest,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
List<ThrSystemDetailEntity> basicThirdSysEntities;
|
|
|
|
basicThirdSysEntities = thrSystemDetailService.filterBasicThirdSysDetail(filterBasicThirdSysDetailRequest);
|
|
|
|
PageInfo<ThrSystemDetailEntity> pageInfo;
|
|
|
|
pageInfo = new PageInfo<>(basicThirdSysEntities);
|
|
|
|
PageSimpleResponse<ThrSystemDetailEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
|
pageSimpleResponse.setList(basicThirdSysEntities);
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/udiwms/basic/thirdsys/filterDetailByKey")
|
|
|
|
public BaseResponse filterDetailByKey(FilterBasicThirdSysDetailRequest filterBasicThirdSysDetailRequest,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.
|
|
|
|
selectByKey(filterBasicThirdSysDetailRequest.getKey(), filterBasicThirdSysDetailRequest.getThirdSysFk());
|
|
|
|
return ResultVOUtils.success(thrSystemDetailEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/udiwms/basic/thirdsys/saveDetail")
|
|
|
|
@Log(title = "第三方系统", businessType = BusinessType.UPDATE)
|
|
|
|
public BaseResponse saveDetail(@RequestBody @Valid ThrSystemDetailEntity thrSystemDetailEntity,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
if (thrSystemDetailEntity != null) {
|
|
|
|
thrSystemDetailService.updateBasicThirdSysDetail(thrSystemDetailEntity);
|
|
|
|
} else {
|
|
|
|
ResultVOUtils.error(999, "参数错误");
|
|
|
|
}
|
|
|
|
return ResultVOUtils.success("更新成功");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 启用第三方系统接口
|
|
|
|
*
|
|
|
|
* @param list
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PostMapping("/udiwms/basic/thirdsys/updateInterfaceStatus")
|
|
|
|
@Log(title = "第三方系统", businessType = BusinessType.UPDATE)
|
|
|
|
public BaseResponse updateInterfaceStatus(@RequestBody List<ThrSystemDetailEntity> list) {
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
|
|
}
|
|
|
|
thrSystemDetailService.updateInterfaceStatus(list);
|
|
|
|
return ResultVOUtils.success("添加成功");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/udiwms/basic/thirdsys/filterBusTypeDetail")
|
|
|
|
public BaseResponse filterBusTypeDetail(FilterBasicThirdSysDetailRequest filterBasicThirdSysDetailRequest,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
List<ThrSystemBusApiEntity> basicThirdSysEntities = thrSystemBusApiService.filterSysBusApi(filterBasicThirdSysDetailRequest);
|
|
|
|
|
|
|
|
PageInfo<ThrSystemBusApiEntity> pageInfo;
|
|
|
|
pageInfo = new PageInfo<>(basicThirdSysEntities);
|
|
|
|
PageSimpleResponse<ThrSystemBusApiEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
|
pageSimpleResponse.setList(basicThirdSysEntities);
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/udiwms/basic/thirdsys/saveBusTypeDetail")
|
|
|
|
@Log(title = "第三方系统", businessType = BusinessType.UPDATE)
|
|
|
|
public BaseResponse saveBusTypeDetail(@RequestBody @Valid ThrSystemBusApiEntity thrSystemBusApiEntity,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
if (thrSystemBusApiEntity != null) {
|
|
|
|
thrSystemBusApiService.updateSysBusApi(thrSystemBusApiEntity);
|
|
|
|
} else {
|
|
|
|
ResultVOUtils.error(999, "参数错误");
|
|
|
|
}
|
|
|
|
return ResultVOUtils.success("更新成功");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 第三方系统 业务单据提交接口添加/更新单据类型
|
|
|
|
*
|
|
|
|
* @param thrSystemBusApiEntity
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PostMapping("/udiwms/basic/thirdsys/saveBusTypes")
|
|
|
|
@Log(title = "第三方系统", businessType = BusinessType.INSERT)
|
|
|
|
public BaseResponse saveBusTypes(@RequestBody ThrSystemBusApiEntity thrSystemBusApiEntity) {
|
|
|
|
if (null == thrSystemBusApiEntity || null == thrSystemBusApiEntity.getType()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean result = thrSystemBusApiService.saveBusTypes(thrSystemBusApiEntity);
|
|
|
|
if (result) {
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
}
|
|
|
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/udiwms/basic/thirdsys/delete")
|
|
|
|
@Log(title = "第三方系统", businessType = BusinessType.DELETE)
|
|
|
|
public BaseResponse delete(Integer id) {
|
|
|
|
if (null == id) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
|
|
}
|
|
|
|
boolean result = thrSystemBusApiService.delete(id);
|
|
|
|
if (result) {
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
}
|
|
|
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 测试第三方服务连通性
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PostMapping("/udiwms/basic/thirdsys/testThirdService")
|
|
|
|
public BaseResponse testThirdService(@RequestBody ThrSystemEntity thrSystemEntity) {
|
|
|
|
return thrSystemDetailService.testThirdService(thrSystemEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
ErpBasicClient erpBasicClient;
|
|
|
|
|
|
|
|
@PostMapping("/udiwms/basic/thirdsys/testThirdInter")
|
|
|
|
public BaseResponse testThirdInter(@RequestBody ThrSystemEntity thrSystemEntity) {
|
|
|
|
return erpBasicClient.testThridConnect(thrSystemEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|