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.
306 lines
12 KiB
Java
306 lines
12 KiB
Java
package com.glxp.api.controller.sync;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
import com.glxp.api.annotation.Log;
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
import com.glxp.api.constant.BusinessType;
|
|
import com.glxp.api.constant.SyncDelType;
|
|
import com.glxp.api.controller.BaseController;
|
|
import com.glxp.api.dao.dev.DeviceInfoMapper;
|
|
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
|
|
import com.glxp.api.entity.basic.BasicCorpEntity;
|
|
import com.glxp.api.entity.basic.UdiRelevanceEntity;
|
|
import com.glxp.api.entity.dev.DeviceInfoEntity;
|
|
import com.glxp.api.entity.inv.DeviceInspectTaskDetailEntity;
|
|
import com.glxp.api.entity.inv.DeviceInspectTaskEntity;
|
|
import com.glxp.api.entity.sync.SyncEditLogEntity;
|
|
import com.glxp.api.entity.sync.SyncEditTypeEntity;
|
|
import com.glxp.api.entity.thrsys.CodeRel;
|
|
import com.glxp.api.httpClient.ErpBasicClient;
|
|
import com.glxp.api.req.basic.*;
|
|
import com.glxp.api.req.system.DeleteCompanyFileRequest;
|
|
import com.glxp.api.req.system.DeleteRequest;
|
|
import com.glxp.api.service.auth.InvBusUserService;
|
|
import com.glxp.api.service.auth.WarehouseBussinessTypeService;
|
|
import com.glxp.api.service.basic.*;
|
|
import com.glxp.api.service.inout.*;
|
|
import com.glxp.api.service.inout.impl.IoCodeService;
|
|
import com.glxp.api.service.inout.impl.IoCodeTempService;
|
|
import com.glxp.api.service.inv.DeviceInspectTaskDetailService;
|
|
import com.glxp.api.service.inv.DeviceInspectTaskService;
|
|
import com.glxp.api.service.sync.SyncEditLogService;
|
|
import com.glxp.api.service.sync.SyncEditTypeService;
|
|
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 java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
|
|
@RestController
|
|
public class SyncDelController extends BaseController {
|
|
|
|
@Resource
|
|
SyncEditLogService syncEditLogService;
|
|
@Resource
|
|
SyncEditTypeService syncEditTypeService;
|
|
@Resource
|
|
UdiRelevanceService udiRelevanceService;
|
|
@Resource
|
|
IoCodeService codeService;
|
|
@Resource
|
|
CompanyProductRelevanceService companyProductRelevanceService;
|
|
@Resource
|
|
UdiProductService udiProductService;
|
|
@Resource
|
|
UdiRlSupService udiRlSupService;
|
|
@Resource
|
|
BasicCorpService basicUnitMaintainService;
|
|
@Resource
|
|
private IBasicBussinessTypeService basicBussinessTypeService;
|
|
@Resource
|
|
IoOrderService orderService;
|
|
@Resource
|
|
InvBusUserService invBusUserService;
|
|
@Resource
|
|
WarehouseBussinessTypeService warehouseBussinessTypeService;
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/basicData/deleteBasicData")
|
|
public BaseResponse downloadProducts(@RequestBody BasicDataRequest basicDataRequest) {
|
|
BaseResponse baseResponse = null;
|
|
switch (basicDataRequest.getKey()) {
|
|
case SyncDelType.BASIC_MAINTAIN:
|
|
//耗材字典
|
|
baseResponse = deleteById(basicDataRequest.getDeleteRequest());
|
|
//插入日志
|
|
insertLog(basicDataRequest.getDeleteBasicDataRequest(), baseResponse);
|
|
//插入操作数据类型记录表
|
|
insertType(basicDataRequest.getDeleteBasicDataRequest());
|
|
break;
|
|
case SyncDelType.BASIC_MANAGE:
|
|
//供应商器械信息
|
|
baseResponse = deleteCompanyProductRelevance(basicDataRequest.getDeleteCompanyFileRequest());
|
|
//插入日志
|
|
insertLog(basicDataRequest.getDeleteBasicDataRequest(), baseResponse);
|
|
//插入操作数据类型记录表
|
|
insertType(basicDataRequest.getDeleteBasicDataRequest());
|
|
break;
|
|
case SyncDelType.BASIC_CORP_MAINTAIN:
|
|
//往来信息维护
|
|
baseResponse = deleteBasicUnitMaintain(basicDataRequest.getDeleteRequest());
|
|
//插入日志
|
|
insertLog(basicDataRequest.getDeleteBasicDataRequest(), baseResponse);
|
|
//插入操作数据类型记录表
|
|
insertType(basicDataRequest.getDeleteBasicDataRequest());
|
|
break;
|
|
case SyncDelType.BASIC_BUSINESS_TYPE:
|
|
//单据类型设置
|
|
baseResponse = deleteBussinessType(basicDataRequest.getDeleteRequest());
|
|
//插入日志
|
|
insertLog(basicDataRequest.getDeleteBasicDataRequest(), baseResponse);
|
|
//插入操作数据类型记录表
|
|
insertType(basicDataRequest.getDeleteBasicDataRequest());
|
|
break;
|
|
case SyncDelType.DEV_TASK:
|
|
|
|
baseResponse = deleteDevTask(basicDataRequest.getDeviceInspectTaskEntity());
|
|
//插入日志
|
|
insertLog(basicDataRequest.getDeleteBasicDataRequest(), baseResponse);
|
|
//插入操作数据类型记录表
|
|
insertType(basicDataRequest.getDeleteBasicDataRequest());
|
|
break;
|
|
case SyncDelType.DEVICE_INFO_DATA:
|
|
|
|
baseResponse = deleteDevInfoData(basicDataRequest.getDeleteDeviceInfoEntity());
|
|
//插入日志
|
|
insertLog(basicDataRequest.getDeleteBasicDataRequest(), baseResponse);
|
|
//插入操作数据类型记录表
|
|
insertType(basicDataRequest.getDeleteBasicDataRequest());
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return ResultVOUtils.success(baseResponse);
|
|
}
|
|
|
|
|
|
public void insertLog(DeleteBasicDataRequest deleteBasicDataRequest, BaseResponse response) {
|
|
SyncEditLogEntity syncEditLogEntity = new SyncEditLogEntity();
|
|
syncEditLogEntity.setRecordCode(deleteBasicDataRequest.getRecordCode());
|
|
syncEditLogEntity.setOperType(2);
|
|
syncEditLogEntity.setDataType(deleteBasicDataRequest.getDataType());
|
|
syncEditLogEntity.setParam(deleteBasicDataRequest.getParam());
|
|
syncEditLogEntity.setJsonResult(JSON.toJSONString(response.getData()));
|
|
syncEditLogEntity.setDirectType(2);
|
|
syncEditLogEntity.setOperUser(deleteBasicDataRequest.getUserId());
|
|
syncEditLogEntity.setUpdateTime(new Date());
|
|
syncEditLogService.insertLog(syncEditLogEntity);
|
|
}
|
|
|
|
public void insertType(DeleteBasicDataRequest deleteBasicDataRequest) {
|
|
SyncEditTypeEntity syncEditTypeEntity = new SyncEditTypeEntity();
|
|
syncEditTypeEntity.setCode(deleteBasicDataRequest.getDataType());
|
|
syncEditTypeEntity.setName(deleteBasicDataRequest.getName());
|
|
syncEditTypeService.insertType(syncEditTypeEntity);
|
|
}
|
|
|
|
public BaseResponse deleteById(DeleteRequest deleteRequest) {
|
|
|
|
String ids = deleteRequest.getId();
|
|
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectById(Long.parseLong(ids));
|
|
if (udiRelevanceEntity != null && udiRelevanceEntity.getUuid() != null) {
|
|
if (codeService.isExitByRelId(udiRelevanceEntity.getId() + "")) {
|
|
return ResultVOUtils.error(500, "该产品已关联单据,无法删除!");
|
|
}
|
|
if (companyProductRelevanceService.isExitByRelId(udiRelevanceEntity.getId() + "")) {
|
|
return ResultVOUtils.error(500, "该产品已被已被供应商选入,无法删除!");
|
|
}
|
|
}
|
|
|
|
udiRelevanceService.deleteById(ids);
|
|
List<UdiRelevanceEntity> udiRelevanceEntities = udiRelevanceService.selectByUuid(udiRelevanceEntity.getUuid());
|
|
if (udiRelevanceEntities == null || udiRelevanceEntities.isEmpty()) {
|
|
udiProductService.deleteByUuid(udiRelevanceEntity.getUuid());
|
|
}
|
|
return ResultVOUtils.success("删除成功");
|
|
}
|
|
|
|
|
|
public BaseResponse deleteCompanyProductRelevance(DeleteCompanyFileRequest deleteCompanyFileRequest) {
|
|
boolean b = udiRlSupService.deleteById(deleteCompanyFileRequest.getId());
|
|
return ResultVOUtils.success("成功");
|
|
}
|
|
|
|
|
|
public BaseResponse deleteBasicUnitMaintain(DeleteRequest deleteRequest) {
|
|
|
|
|
|
String id = deleteRequest.getId();
|
|
BasicCorpEntity basicUnitMaintainEntity = basicUnitMaintainService.selectById(id);
|
|
|
|
basicUnitMaintainService.deleteById(id);
|
|
|
|
|
|
return ResultVOUtils.success("删除成功");
|
|
}
|
|
|
|
|
|
public BaseResponse deleteBussinessType(DeleteRequest deleteRequest) {
|
|
|
|
// if (bindingResult.hasErrors()) {
|
|
// return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
// }
|
|
String id = deleteRequest.getId();
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.selectById(id);
|
|
|
|
//判断是否存在该单据类型单据
|
|
boolean isExitOrder = orderService.isExitByAction(bussinessTypeEntity.getAction());
|
|
if (isExitOrder) {
|
|
return ResultVOUtils.error(500, "已存在该类型扫码单据,无法删除!");
|
|
}
|
|
|
|
//判断是否被仓库绑定
|
|
boolean isExitUser = invBusUserService.isExitByAction(bussinessTypeEntity.getAction());
|
|
if (isExitUser) {
|
|
return ResultVOUtils.error(500, "该单据类型已被用户绑定,请先移除后删除!");
|
|
}
|
|
|
|
//判断是否被用户绑定
|
|
boolean isExitInv = warehouseBussinessTypeService.isExitByAction(bussinessTypeEntity.getAction());
|
|
if (isExitInv) {
|
|
return ResultVOUtils.error(500, "该单据类型已被仓库绑定,请先移除后删除!");
|
|
}
|
|
|
|
|
|
return basicBussinessTypeService.deleteBussinessType(id) == true ? ResultVOUtils.success("删除成功") : ResultVOUtils.error(500, "删除失败,系统繁忙");
|
|
}
|
|
|
|
@Resource
|
|
DeviceInspectTaskService deviceInspectTaskService;
|
|
@Resource
|
|
DeviceInspectTaskDetailService deviceInspectTaskDetailService;
|
|
|
|
public BaseResponse deleteDevTask(DeviceInspectTaskEntity deviceInspectTaskEntity) {
|
|
deviceInspectTaskService.removeById(deviceInspectTaskEntity.getId());
|
|
deviceInspectTaskDetailService.remove(new QueryWrapper<DeviceInspectTaskDetailEntity>().eq("taskOrderIdFk", deviceInspectTaskEntity.getOrderId()));
|
|
return ResultVOUtils.success("删除成功");
|
|
}
|
|
|
|
@Resource
|
|
DeviceInfoMapper deviceInfoMapper;
|
|
|
|
public BaseResponse deleteDevInfoData(DeviceInfoEntity deviceInfoEntity) {
|
|
deviceInfoMapper.delete(new QueryWrapper<DeviceInfoEntity>().eq("deviceCode", deviceInfoEntity.getDeviceCode()));
|
|
return ResultVOUtils.success("删除成功");
|
|
}
|
|
|
|
@Resource
|
|
private IoCodeTempService codeTempService;
|
|
@Resource
|
|
IoOrderDetailBizService orderDetailBizService;
|
|
@Resource
|
|
IoOrderDetailCodeService orderDetailCodeService;
|
|
|
|
/**
|
|
* 同步删除单据
|
|
*/
|
|
@AuthRuleAnnotation("")
|
|
@Log(title = "单据同步删除", businessType = BusinessType.DELETE)
|
|
@PostMapping("/udiwms/sync/order/delete")
|
|
public BaseResponse deleteOrder(@RequestBody DeleteRequest deleteRequest) {
|
|
List<String> delBillNos = new ArrayList<>();
|
|
if (CollUtil.isNotEmpty(deleteRequest.getBillNos())) {
|
|
delBillNos.addAll(deleteRequest.getBillNos());
|
|
} else {
|
|
delBillNos.add(deleteRequest.getBillNo());
|
|
}
|
|
orderService.deleteInvByBillNo(delBillNos);
|
|
for (String billNo : delBillNos) {
|
|
orderService.deleteByBillNo(billNo);
|
|
orderDetailBizService.deleteByOrderId(billNo);
|
|
orderDetailCodeService.deleteByOrderId(billNo);
|
|
codeTempService.deleteByBillNo(billNo);
|
|
codeService.deleteCodeByOrderId(billNo);
|
|
}
|
|
return ResultVOUtils.success("同步删除成功");
|
|
}
|
|
|
|
|
|
@Resource
|
|
ErpBasicClient erpBasicClient;
|
|
|
|
/**
|
|
* 转发获取多码融合
|
|
*/
|
|
@PostMapping("/spms/udchs/codeRe/list")
|
|
public BaseResponse getCodeRelDetail(@RequestBody CodeRel codeRel) {
|
|
return erpBasicClient.getCodeRelDetail(codeRel);
|
|
}
|
|
|
|
/**
|
|
* 转发获取多码融合
|
|
*/
|
|
@PostMapping("/udiwms/relCode/checkCode")
|
|
public BaseResponse checkCode(@RequestBody List<String> codeList) {
|
|
return erpBasicClient.checkCode(codeList);
|
|
}
|
|
|
|
/**
|
|
* 转发更新多码融合
|
|
*/
|
|
@PostMapping("/spms/udchs/codeRe/update")
|
|
public BaseResponse updateCodeRelDetail(@RequestBody CodeRel codeRel) {
|
|
return erpBasicClient.updateCodeRelDetail(codeRel);
|
|
}
|
|
|
|
}
|