ww
chengqf 2 years ago
parent b6a5016b01
commit 782b6e58c8

@ -1,84 +0,0 @@
package com.glxp.api.controller.inout;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.inout.IoCodeEntity;
import com.glxp.api.req.inout.FilterCodeRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.IoCodeResponse;
import com.glxp.api.service.inout.IoCodeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
*
*/
@RestController
public class IoCodeController extends BaseController {
@Resource
private IoCodeService ioCodeService;
/**
*
*
* @param filterCodeRequest
* @return
*/
@GetMapping("/udiwms/inout/code/filterList")
public BaseResponse filterList(FilterCodeRequest filterCodeRequest) {
List<IoCodeResponse> list = ioCodeService.filterList(filterCodeRequest);
PageInfo<IoCodeResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
/**
*
*
* @return
*/
@GetMapping("/udiwms/inout/code/findByOrderId")
public BaseResponse findAllByOrderId(FilterCodeRequest filterCodeRequest) {
List<IoCodeResponse> list = ioCodeService.filterList(filterCodeRequest);
PageInfo<IoCodeResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.success(pageInfo);
}
/**
*
*/
@AuthRuleAnnotation("")
@GetMapping("spms/inout/dlcode/findByOrderId")
public BaseResponse downloadCodesByOrderId(String orderId) {
List<IoCodeEntity> codeEntityList = ioCodeService.findByOrderId(orderId);
PageInfo<IoCodeEntity> pageInfo;
pageInfo = new PageInfo<>(codeEntityList);
PageSimpleResponse<IoCodeEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(codeEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
/**
*
*
* @param filterCodeRequest
* @return
*/
@GetMapping("/udiwms/inout/code/getCodeListForEdit")
public BaseResponse getCodeListForEdit(FilterCodeRequest filterCodeRequest) {
List<IoCodeResponse> list = ioCodeService.getCodeListForEdit(filterCodeRequest);
PageInfo<IoCodeResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
}

@ -1,125 +0,0 @@
package com.glxp.api.controller.inout;
import cn.hutool.core.util.IdUtil;
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.controller.BaseController;
import com.glxp.api.entity.inout.IoCodeLostEntity;
import com.glxp.api.entity.inout.IoCodeTempEntity;
import com.glxp.api.req.inout.IoCodeLostRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.IoCodeLostResponse;
import com.glxp.api.service.inout.IoCodeLostService;
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.Date;
import java.util.List;
@RestController
public class IoCodeLostController extends BaseController {
@Resource
IoCodeLostService codeLostService;
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/getCodeLost")
public BaseResponse getCodeLost(@RequestBody @Valid IoCodeLostRequest ioCodeLostEntity, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<IoCodeLostResponse> list = codeLostService.selectLost(ioCodeLostEntity);
PageInfo<IoCodeLostResponse> pageInfo;
pageInfo = new PageInfo<>(list);
PageSimpleResponse<IoCodeLostResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(list);
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/updateCodeLost")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse updateCodeLost(@RequestBody @Valid IoCodeLostEntity ioCodeLostEntity, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
codeLostService.update(ioCodeLostEntity);
return ResultVOUtils.success("成功");
}
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/saveTabCode")
public BaseResponse saveCode(@RequestBody IoCodeTempEntity codeTempEntity) {
if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo()) && codeTempEntity.getSerialNo().length() > 20) {
return ResultVOUtils.error(500, "无效条码!序列号超出最大范围,不予缓存");
}
if (StrUtil.isNotEmpty(codeTempEntity.getBatchNo()) && codeTempEntity.getBatchNo().length() > 20) {
return ResultVOUtils.error(500, "无效条码!批次号超出最大范围,不予缓存");
}
if (StrUtil.isBlank(codeTempEntity.getSerialNo()) && StrUtil.isBlank(codeTempEntity.getBatchNo())) {
return ResultVOUtils.error(500, "批次号不能为空!,不予缓存");
}
if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) {
return ResultVOUtils.error(500, "有序列号不予缓存");
}
IoCodeLostEntity codeLostEntity = codeLostService.findByCode(codeTempEntity.getCode());
IoCodeLostEntity insertEntity = null;
if (codeLostEntity == null) {
insertEntity = new IoCodeLostEntity();
insertEntity.setCreateTime(new Date());
} else {
insertEntity = codeLostEntity;
}
insertEntity.setCode(codeTempEntity.getCode());
insertEntity.setBatchNo(codeTempEntity.getBatchNo());
insertEntity.setProduceDate(codeTempEntity.getProduceDate());
insertEntity.setExpireDate(codeTempEntity.getExpireDate());
insertEntity.setSerialNo(codeTempEntity.getSerialNo());
insertEntity.setSupId(codeTempEntity.getSupId());
insertEntity.setUpdateTime(new Date());
insertEntity.setCreateTime(new Date());
if (codeLostEntity != null) {
codeLostService.update(insertEntity);
} else {
insertEntity.setId(IdUtil.getSnowflakeNextId());
codeLostService.insert(insertEntity);
}
return ResultVOUtils.success("修改成功!");
}
//获取验收单据业务详情
@AuthRuleAnnotation("")
@GetMapping("/warehouse/inout/getTabCode")
public BaseResponse getTabCode(String code) {
if (StrUtil.isBlank(code)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
IoCodeLostEntity codeLostEntity = codeLostService.findByCode(code);
if (codeLostEntity == null)
return ResultVOUtils.error(500, "未缓存!");
return ResultVOUtils.success(codeLostEntity);
}
}

@ -1,736 +0,0 @@
package com.glxp.api.controller.inout;
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.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.auth.InvBusUserEntity;
import com.glxp.api.entity.auth.InvWarehouseEntity;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
import com.glxp.api.entity.basic.EntrustReceEntity;
import com.glxp.api.entity.inout.*;
import com.glxp.api.req.auth.FilterInvBusUserRequest;
import com.glxp.api.req.basic.BasicEntrustRecRequest;
import com.glxp.api.req.inout.*;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.IoOrderDetailBizResponse;
import com.glxp.api.res.inout.IoOrderDetailCodeResponse;
import com.glxp.api.res.inout.IoOrderResponse;
import com.glxp.api.res.inout.PdaBusOrderResponse;
import com.glxp.api.service.auth.InvBusUserService;
import com.glxp.api.service.auth.InvWarehouseService;
import com.glxp.api.service.basic.EntrustReceService;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.inout.*;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OrderNoTypeBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Slf4j
@RestController
public class IoOrderController extends BaseController {
@Resource
private IoOrderService orderService;
@Resource
private IBasicBussinessTypeService basicBussinessTypeService;
@Resource
private IoCodeTempService codeTempService;
@Resource
private IoCheckInoutService checkInoutService;
@Resource
IoOrderDetailBizService orderDetailBizService;
@Resource
IoOrderDetailCodeService orderDetailCodeService;
@Resource
IoAddInoutService ioAddInoutService;
@Resource
IoCheckInoutService ioCheckInoutService;
/**
*
*
* @param filterOrderRequest
* @return
*/
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/order/filter")
public BaseResponse filterOrder(FilterOrderRequest filterOrderRequest) {
if (StrUtil.isNotBlank(filterOrderRequest.getStatusType())) {
orderService.setFilterStatus(filterOrderRequest);
}
if (StrUtil.isNotBlank(filterOrderRequest.getVueType())) {
orderService.setActions(filterOrderRequest);
}
if (StrUtil.isNotEmpty(filterOrderRequest.getSupInoivceSearch())) {
orderService.setInvoiceFiltes(filterOrderRequest);
}
if (filterOrderRequest.getSourceLocalType() != null) {
if (filterOrderRequest.getSourceLocalType() == 1) {
filterOrderRequest.setSourceTypes(Arrays.asList(1, 2, 3, 4, 5));
} else {
filterOrderRequest.setSourceTypes(Arrays.asList(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17));
}
}
String customerId = getCustomerId();
if (!customerId.equals("110")) {
filterOrderRequest.setFromCorp(customerId);
}
List<IoOrderResponse> list = orderService.filterList(filterOrderRequest);
PageInfo<IoOrderResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/order/filterList")
public BaseResponse filterOrderList(FilterOrderRequest filterOrderRequest) {
if (StrUtil.isNotBlank(filterOrderRequest.getStatusType())) {
orderService.setFilterStatus(filterOrderRequest);
}
if (StrUtil.isNotBlank(filterOrderRequest.getVueType())) {
orderService.setActions(filterOrderRequest);
}
if (StrUtil.isNotEmpty(filterOrderRequest.getSupInoivceSearch())) {
orderService.setInvoiceFiltes(filterOrderRequest);
}
if (filterOrderRequest.getSourceLocalType() != null) {
if (filterOrderRequest.getSourceLocalType() == 1) {
filterOrderRequest.setSourceTypes(Arrays.asList(1, 2, 3, 4, 5));
} else {
filterOrderRequest.setSourceTypes(Arrays.asList(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17));
}
}
String customerId = getCustomerId();
if (!customerId.equals("110")) {
filterOrderRequest.setFromCorp(customerId);
}
List<IoOrderResponse> list = orderService.getfilterList(filterOrderRequest);
for (IoOrderResponse ioOrderResponse : list) {
if(ioOrderResponse.getCheckStatus() == null){
ioOrderResponse.setCheckStatus(0+"");
}
FilterOrderDetailCodeRequest filterOrderDetailCodeRequest = new FilterOrderDetailCodeRequest();
filterOrderDetailCodeRequest.setOrderIdFk(ioOrderResponse.getBillNo());
List<IoOrderDetailCodeResponse> ioOrderDetailCodeResponses = orderDetailBizService.getfilterList(filterOrderDetailCodeRequest);
BigDecimal amount=new BigDecimal(0.00);
for (IoOrderDetailCodeResponse ioOrderDetailCodeRespons : ioOrderDetailCodeResponses) {
if(ioOrderDetailCodeRespons.getCount() != 0 && ioOrderDetailCodeRespons.getPrice()!=null ) {
amount = amount.add(new BigDecimal(ioOrderDetailCodeRespons.getCount()).multiply(ioOrderDetailCodeRespons.getPrice()));
}
}
ioOrderResponse.setAllAmount(amount);
}
PageInfo<IoOrderResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/preInorder/filter")
public BaseResponse filterPreInorder(FilterOrderRequest filterOrderRequest) {
filterOrderRequest.setVueType(Constant.ORDER_ACTION_SUP_PREIN);
orderService.setActions(filterOrderRequest);
List<IoOrderResponse> list = orderService.filterList(filterOrderRequest);
PageInfo<IoOrderResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
@GetMapping("/udiwms/inout/order/filterInvoice")
public BaseResponse filterInvoice(FilterOrderRequest filterOrderRequest) {
filterOrderRequest.setDealStatuses(Arrays.asList(2, 3));
filterOrderRequest.setStatuses(Arrays.asList(7, 5, 10));
String customerId = getCustomerId();
if (!customerId.equals("110")) {
filterOrderRequest.setFromCorp(customerId);
}
List<IoOrderResponse> list = orderService.filterList(filterOrderRequest);
PageInfo<IoOrderResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
//新增业务-立即提交
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/submitBiz")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse submitBiz(@RequestBody AddOrderRequest addOrderRequest) {
//校验单据是否已完成
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(addOrderRequest.getBillNo());
if (CollUtil.isEmpty(orderDetailBizEntities)) {
return ResultVOUtils.error(500, "请先录入产品!");
}
String vailKey = "";
for (IoOrderDetailBizEntity orderDetailBizEntity : orderDetailBizEntities) {
if (orderDetailBizEntity.getBindRlFk() == null) {
return ResultVOUtils.error(500, orderDetailBizEntity.getCoName() + "该产品未指定唯一耗材编码!");
}
if (StrUtil.isEmpty(orderDetailBizEntity.getSupId())) {
return ResultVOUtils.error(500, orderDetailBizEntity.getCoName() + "该产品未指定供应商!");
}
if (orderDetailBizEntity.getCount() == 0) {
return ResultVOUtils.error(500, orderDetailBizEntity.getCoName() + "产品数量不能为0");
}
if (addOrderRequest.getFromVailPi() != 2 &&
StrUtil.isEmpty(orderDetailBizEntity.getBatchNo())
&& StrUtil.isEmpty(orderDetailBizEntity.getProductDate())
&& StrUtil.isEmpty(orderDetailBizEntity.getExpireDate())) {
return ResultVOUtils.error(500, orderDetailBizEntity.getCoName() + "三期不能全为空!");
}
}
IoOrderEntity orderEntity = orderService.findByBillNo(addOrderRequest.getBillNo());
ioAddInoutService.dealBusProcess(orderEntity, addOrderRequest.getFromVailPi());
return ResultVOUtils.success("提交成功!");
}
//新增扫码单据-立即提交
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/submitCodes")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse submitCodes(@RequestBody AddOrderRequest addOrderRequest) {
//校验单据是否已完成
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(addOrderRequest.getBillNo());
if (CollUtil.isEmpty(orderDetailCodeEntities)) {
return ResultVOUtils.error(500, "单据未扫码或扫码校验无法通过,提交失败,请检查后重新提交!");
}
IoOrderEntity orderEntity = orderService.findByBillNo(addOrderRequest.getBillNo());
ioAddInoutService.dealProcess(orderEntity);
//不需要手动校验,则走正常单据校验处理流程
if (!ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
ioCheckInoutService.check(orderEntity.getBillNo());
}
return ResultVOUtils.success("提交成功,等待处理!");
}
//新增业务单据,新增扫码单据,等待校验-草稿保存
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/saveOrderWeb")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse saveOrderWeb(@RequestBody AddOrderRequest addOrderRequest) {
IoOrderEntity orderEntity = new IoOrderEntity();
if (StrUtil.isEmpty(addOrderRequest.getAction()))
return ResultVOUtils.error(500, "单据类型不能为空");
orderEntity.setAction(addOrderRequest.getAction());
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(addOrderRequest.getAction());
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
orderEntity.setFromCorp(addOrderRequest.getFromCorp());
orderEntity.setRemark(addOrderRequest.getRemark());
orderEntity.setFromInvCode(addOrderRequest.getFromInvCode());
orderEntity.setDeptCode(addOrderRequest.getDeptCode());
orderEntity.setBillNo(addOrderRequest.getBillNo());
orderEntity.setInvCode(addOrderRequest.getInvCode());
orderService.updateByBillNo(orderEntity);
IoCodeTempEntity warehouseEntity = new IoCodeTempEntity();
warehouseEntity.setOrderId(orderEntity.getBillNo());
warehouseEntity.setAction(orderEntity.getAction());
warehouseEntity.setMainAction(orderEntity.getMainAction());
warehouseEntity.setDeptCode(orderEntity.getDeptCode());
warehouseEntity.setInvCode(orderEntity.getInvCode());
codeTempService.updateByOrderId(warehouseEntity);
return ResultVOUtils.success("保存成功!");
}
//等待校验-立即提交
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/submitOrderWeb")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse submitOrderWeb(@RequestBody AddOrderRequest addOrderRequest) {
//校验单据是否已完成
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(addOrderRequest.getBillNo());
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(addOrderRequest.getBillNo());
if (CollUtil.isEmpty(orderDetailCodeEntities)) {
return ResultVOUtils.error(500, "单据还未扫码或和扫码校验存在异常无法提交!");
}
if (checkInoutService.checkManual(addOrderRequest.getBillNo())) {
if (CollUtil.isNotEmpty(orderDetailBizEntities)) {
String errMsg = checkInoutService.bizOrderCheck(orderDetailBizEntities, orderDetailCodeEntities);
if (StrUtil.isNotEmpty(errMsg)) {
return ResultVOUtils.error(500, errMsg);
}
errMsg = checkInoutService.codeOrderCheck(orderDetailCodeEntities, orderDetailBizEntities);
if (StrUtil.isNotEmpty(errMsg)) {
return ResultVOUtils.error(500, errMsg);
}
saveOrderWeb(addOrderRequest);
IoOrderEntity orderEntity = orderService.findByBillNo(addOrderRequest.getBillNo());
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
orderService.update(orderEntity);
checkInoutService.check(addOrderRequest.getBillNo());
} else {
return ResultVOUtils.error(500, "单据校验提交失败,请先录入业务单据!");
}
} else {
IoOrderEntity orderEntity = orderService.findByBillNo(addOrderRequest.getBillNo());
ioAddInoutService.dealProcess(orderEntity);
checkInoutService.check(addOrderRequest.getBillNo());
return ResultVOUtils.success("提交成功!");
}
return ResultVOUtils.success("提交成功!");
}
//带配货-立即提交
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/waitAllocate/submitOrderWeb")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse submitWaitAllocateWeb(@RequestBody AddOrderRequest addOrderRequest) {
//校验单据是否已完成
IoOrderEntity orderEntity = orderService.findByBillNo(addOrderRequest.getBillNo());
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(addOrderRequest.getBillNo());
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(addOrderRequest.getBillNo());
if (CollUtil.isEmpty(orderDetailCodeEntities)) {
return ResultVOUtils.error(500, "单据还未扫码或和扫码校验存在异常无法提交!");
}
String errMsg = checkInoutService.bizNoPiCheck(orderDetailBizEntities, orderEntity);
if (StrUtil.isNotEmpty(errMsg)) {
return ResultVOUtils.error(500, errMsg);
}
orderDetailBizService.deleteByOrderId(addOrderRequest.getBillNo());
for (IoOrderDetailCodeEntity orderDetailCodeEntity : orderDetailCodeEntities) {
IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity();
BeanUtils.copyProperties(orderDetailCodeEntity, orderDetailBizEntity);
orderDetailBizEntity.setId(null);
getSomeBiz(orderDetailBizEntities, orderDetailBizEntity);
orderDetailBizService.insert(orderDetailBizEntity);
}
saveOrderWeb(addOrderRequest);
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
orderService.update(orderEntity);
ioAddInoutService.dealProcess(orderEntity);
checkInoutService.check(addOrderRequest.getBillNo());
return ResultVOUtils.success("提交成功!");
}
public void getSomeBiz(List<IoOrderDetailBizEntity> orderDetailBizEntities, IoOrderDetailBizEntity resutBizEntity) {
for (IoOrderDetailBizEntity orderDetailBizEntity : orderDetailBizEntities) {
if (orderDetailBizEntity.getBindRlFk().longValue() == resutBizEntity.getBindRlFk().longValue()) {
resutBizEntity.setCertCode(orderDetailBizEntity.getCertCode());
resutBizEntity.setPrice(orderDetailBizEntity.getPrice());
}
}
}
@Resource
IoCodeService codeService;
//未校验单据删除
@AuthRuleAnnotation("")
@PostMapping("udiwms/inout/order/delete")
@Log(title = "单据管理", businessType = BusinessType.DELETE)
public BaseResponse deletById(@RequestBody DeleteRequest deleteRequest) {
orderService.deleteByBillNo(deleteRequest.getBillNo());
orderDetailBizService.deleteByOrderId(deleteRequest.getBillNo());
orderDetailCodeService.deleteByOrderId(deleteRequest.getBillNo());
codeTempService.deleteByBillNo(deleteRequest.getBillNo());
codeService.deleteCodeByOrderId(deleteRequest.getBillNo());
return ResultVOUtils.success("删除成功!");
}
//已验收单据删除、单据编辑删除等
@AuthRuleAnnotation("")
@PostMapping("udiwms/inout/order/finish/delete")
@Log(title = "单据管理", businessType = BusinessType.DELETE)
public BaseResponse deleteById(@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("删除成功!");
}
//单据编辑,条码减一
@AuthRuleAnnotation("")
@PostMapping("udiwms/inout/code/finish/delete")
@Log(title = "单据管理", businessType = BusinessType.DELETE)
public BaseResponse deleteCodeById(@RequestBody IoCodeEntity codeEntity) {
orderService.deleteInvCode(codeEntity.getOrderId(), codeEntity.getCode());
return ResultVOUtils.success("删除成功!");
}
//已验收单据撤回
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/order/received/rollback")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse rollbackOrder(String billNo) {
if (StrUtil.isBlank(billNo)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
IoOrderEntity orderEntity = orderService.findByBillNo(billNo);
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
if (StrUtil.isNotEmpty(orderEntity.getSupplementNo()) || StrUtil.isNotEmpty(orderEntity.getUllageSupNo())) {
return ResultVOUtils.error(500, "单据已补单,无法撤回!");
}
if (orderEntity.getSyncStatus() != null && orderEntity.getSyncStatus() == 1) {
return ResultVOUtils.error(500, "单据已同步,无法撤回!");
}
boolean result = orderService.rollbackOrder(billNo);
if (result) {
return ResultVOUtils.success();
}
return ResultVOUtils.error(ResultEnum.NOT_NETWORK, "撤回失败");
} else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_REW) {
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK_SUCCESS);
orderService.update(orderEntity);
return ResultVOUtils.success("撤回成功!");
} else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
if (StrUtil.isBlank(billNo)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
boolean result = orderService.rollbackUnReOrder(billNo);
if (result) {
return ResultVOUtils.success("撤回成功!");
}
return ResultVOUtils.error(ResultEnum.NOT_NETWORK, "撤回失败");
}
return ResultVOUtils.error(ResultEnum.NOT_NETWORK, "撤回失败");
}
//已校验单据撤回到等待处理
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/order/unReceive/rollback")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse rollUnReceivebackOrder(String billNo) {
if (StrUtil.isBlank(billNo)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
boolean result = orderService.rollbackUnReOrder(billNo);
if (result) {
return ResultVOUtils.success("撤回成功!");
}
return ResultVOUtils.error(ResultEnum.NOT_NETWORK, "撤回失败");
}
//手持终端获取未处理业务单据进行校验
@AuthRuleAnnotation("")
@GetMapping("/udiwms/erpOrder/filter")
public BaseResponse filterErpOrder(FilterOrderRequest filterOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
if (StrUtil.isEmpty(filterOrderRequest.getAction()))
return ResultVOUtils.error(500, "单据类型不能为空!");
List<IoOrderResponse> orderResponses = orderService.filterList(filterOrderRequest);
List<PdaBusOrderResponse> erpOrderResponses = new ArrayList<>();
if (CollUtil.isNotEmpty(orderResponses)) {
for (IoOrderResponse orderResponse : orderResponses) {
PdaBusOrderResponse pdaBusOrderResponse = new PdaBusOrderResponse();
BeanUtils.copyProperties(orderResponse, pdaBusOrderResponse);
FilterOrderDetailBizRequest filterOrderDetailBizRequest = new FilterOrderDetailBizRequest();
filterOrderDetailBizRequest.setOrderIdFk(orderResponse.getBillNo());
List<IoOrderDetailBizResponse> orderDetailBizEntities = orderDetailBizService.filterList(filterOrderDetailBizRequest);
pdaBusOrderResponse.setOrderDetailBizResponses(orderDetailBizEntities);
erpOrderResponses.add(pdaBusOrderResponse);
}
}
PageInfo<IoOrderResponse> pageInfo;
pageInfo = new PageInfo<>(orderResponses);
PageSimpleResponse<PdaBusOrderResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(erpOrderResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
@Resource
EntrustReceService entrustReceService;
@Resource
InvBusUserService invBusUserService;
//手持终端下载扫码单据进行审核
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/order/download")
public BaseResponse downloadOrder(FilterOrderRequest filterOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
Long userId = null;
if (filterOrderRequest.getWmsUserId() != null) {
userId = filterOrderRequest.getWmsUserId();
} else userId = getUserId();
List<EntrustReceEntity> entrustReceEntities;
List<InvBusUserEntity> warehouseUserEntities = null;
IoOrderEntity stockOrderEntity = orderService.findByBillNo(filterOrderRequest.getBillNo());
if (stockOrderEntity == null) {
return ResultVOUtils.error(500, "单据未找到!");
} else if (stockOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
//1.校验是否为委托验收人
if (!stockOrderEntity.isEntrustEnd()) {
BasicEntrustRecRequest basicEntrustRecRequest = new BasicEntrustRecRequest();
basicEntrustRecRequest.setAction(stockOrderEntity.getAction());
basicEntrustRecRequest.setEntrustUser(userId);
basicEntrustRecRequest.setCurInv(stockOrderEntity.getInvCode());
entrustReceEntities = entrustReceService.filterEntrustRec(basicEntrustRecRequest);
} else {
return ResultVOUtils.error(500, "单据已委托验收完成!");
}
//2.校验是否为用户所属单据类型
if (StrUtil.isNotEmpty(stockOrderEntity.getDeptCode())) {
FilterInvBusUserRequest filterInvBusUserRequest = new FilterInvBusUserRequest();
filterInvBusUserRequest.setSubInvCode(stockOrderEntity.getInvCode());
filterInvBusUserRequest.setUserId(userId + "");
filterInvBusUserRequest.setScAction(stockOrderEntity.getAction());
warehouseUserEntities = invBusUserService.filterInvBusUser(filterInvBusUserRequest);
}
if (CollUtil.isEmpty(warehouseUserEntities) && CollUtil.isEmpty(entrustReceEntities)) {
return ResultVOUtils.error(500, "权限不足,无法验收!");
}
} else if (stockOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
return ResultVOUtils.error(500, "单据已审核!");
} else {
return ResultVOUtils.error(500, "非未审核单据!");
}
List<IoOrderResponse> orderEntityList = orderService.filterList(filterOrderRequest);
PageInfo<IoOrderResponse> pageInfo;
pageInfo = new PageInfo<>(orderEntityList);
PageSimpleResponse<IoOrderResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(orderEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
/**
*
*
* @param billNo
* @return
*/
@GetMapping("udiwms/inout/order/filterOrderTrace")
public BaseResponse filterOrderTrace(String billNo) {
if (StrUtil.isBlank(billNo)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
List<IoOrderEntity> list = orderService.filterOrderTrace(billNo);
List<IoOrderResponse> responses = orderService.findResponse(list);
return ResultVOUtils.success(responses);
}
/**
*
*
* @return
*/
@PostMapping("/udiwms/inout/order/updateOrderInfo")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse updateOrderInfo(@RequestBody OrderEditRequest orderEditRequest) {
if (null == orderEditRequest || CollUtil.isEmpty(orderEditRequest.getOrderIds())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
orderService.updateOrderInfo(orderEditRequest);
return ResultVOUtils.success();
}
/**
*
*
* @param uploadOrderRequest
* @return
*/
@GetMapping("/udiwms/inout/order/upload/filter")
public BaseResponse filterUploadOrder(FilterUploadOrderRequest uploadOrderRequest) {
List<IoOrderResponse> list = orderService.filterUploadOrderList(uploadOrderRequest);
PageInfo<IoOrderResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
/**
*
*
* @param billNo
* @return
*/
@GetMapping("/udiwms/inout/order/submitToThrSys")
public BaseResponse submitToThrSys(@RequestParam("billNo") String billNo) {
if (StrUtil.isBlank(billNo)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
return orderService.submitToThrSys(billNo);
}
@PostMapping("/udiwms/inout/order/updateOrderDetailBiz")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse updateOrderDetailBiz(@RequestBody IoOrderDetailBizEntity ioOrderDetailBizEntity) {
if (null == ioOrderDetailBizEntity) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
// ioOrderDetailBizEntity.setCheckFileName(ioOrderDetailBizEntity.getCheckFileName().substring(0,ioOrderDetailBizEntity.getCheckFileName().length() - 4));
orderDetailBizService.updateOrderDetailBiz(ioOrderDetailBizEntity);
return ResultVOUtils.success();
}
@PostMapping("/udiwms/inout/order/updateOrder")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse updateOrder(@RequestBody IoOrderEntity ioOrderEntity) {
orderService.updateByBillNo(ioOrderEntity);
return ResultVOUtils.success();
}
@Resource
GennerOrderUtils gennerOrderUtils;
@Resource
InvWarehouseService invWarehouseService;
@AuthRuleAnnotation("")
@PostMapping("/udiwms/stock/order/change")
public BaseResponse stockOrderChange(@RequestBody AddOrderChangeRequest addOrderChangeRequest) {
IoOrderEntity originOrder = orderService.findByBillNo(addOrderChangeRequest.getOrderId());
IoOrderEntity newOrder = new IoOrderEntity();
List<IoCodeEntity> originCodes = codeService.findByOrderId(originOrder.getBillNo());
newOrder.setCreateTime(new Date());
newOrder.setFromCorp(addOrderChangeRequest.getFromCorp());
newOrder.setFromInvCode(addOrderChangeRequest.getFromInvCode());
if (addOrderChangeRequest.getFromInvCode() != null) {
InvWarehouseEntity fromInv = invWarehouseService.findByInvSubByCode(addOrderChangeRequest.getFromInvCode());
newOrder.setFromDeptCode(fromInv.getParentId());
}
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(addOrderChangeRequest.getInvCode());
newOrder.setInvCode(addOrderChangeRequest.getInvCode());
newOrder.setDeptCode(invWarehouseEntity.getParentId());
newOrder.setCorpOrderId(CustomUtil.getId() + "x");
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeService.findByAction(addOrderChangeRequest.getAction());
newOrder.setAction(addOrderChangeRequest.getAction());
newOrder.setMainAction(basicBussinessTypeEntity.getMainAction());
newOrder.setExportStatus(0); //设置导出状态为未导出
newOrder.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//设置单据未草稿状态
newOrder.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE); //设置验收状态为未验收
newOrder.setFromType(ConstantStatus.FROM_COPY);
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(addOrderChangeRequest.getAction());
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trim(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
String supplementOrderNo = orderNo;
newOrder.setBillNo(supplementOrderNo);
newOrder.setReplicateNo(null); //新单据的复制单号置空
originOrder.setReplicateNo(orderNo);
List<IoCodeTempEntity> supplementCodes = new ArrayList<>();
List<IoCodeEntity> products = addOrderChangeRequest.getProducts();
originCodes.forEach(
code -> {
//复制选中的产品
for (IoCodeEntity product : products) {
if (product.getRelId().equals(code.getRelId())) {
if ((StrUtil.isNotBlank(product.getBatchNo()) && StrUtil.isNotBlank(code.getBatchNo()) && product.getBatchNo().equals(code.getBatchNo()))
|| (StrUtil.isBlank(product.getBatchNo()) && StrUtil.isBlank(code.getBatchNo()))) {
IoCodeTempEntity supplementCode = new IoCodeTempEntity();
BeanUtil.copyProperties(code, supplementCode);
supplementCode.setCode(product.getCode());
supplementCode.setInvCode(newOrder.getInvCode());
supplementCode.setDeptCode(newOrder.getDeptCode());
supplementCode.setOrderId(newOrder.getBillNo());
supplementCode.setCorpOrderId(newOrder.getCorpOrderId());
//查询补单设置
supplementCode.setAction(newOrder.getAction());
supplementCode.setMainAction(newOrder.getMainAction());
supplementCode.setUpdateTime(new Date());
supplementCode.setCreateTime(new Date());
supplementCode.setId(null);
supplementCodes.add(supplementCode);
break;
}
}
}
}
);
newOrder.setUpdateTime(new Date());
orderService.insertOrder(newOrder);
codeTempService.insertBatch(supplementCodes);
orderService.update(originOrder);
return ResultVOUtils.success();
}
}

@ -1,668 +0,0 @@
package com.glxp.api.controller.inout;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
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.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.auth.InvWarehouseEntity;
import com.glxp.api.entity.basic.BasicBusTypeChangeEntity;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
import com.glxp.api.entity.basic.BasicCorpEntity;
import com.glxp.api.entity.basic.UdiRlSupEntity;
import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.purchase.PurOrderDetailEntity;
import com.glxp.api.entity.purchase.PurOrderEntity;
import com.glxp.api.entity.system.SystemParamConfigEntity;
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
import com.glxp.api.entity.thrsys.ThrOrderEntity;
import com.glxp.api.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.api.req.inout.*;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.basic.UdiRelevanceResponse;
import com.glxp.api.res.inout.IoOrderDetailBizResponse;
import com.glxp.api.res.inout.IoOrderDetailCodeResponse;
import com.glxp.api.res.inout.IoOrderInvoiceResponse;
import com.glxp.api.service.auth.InvWarehouseService;
import com.glxp.api.service.basic.*;
import com.glxp.api.service.inout.*;
import com.glxp.api.service.purchase.PurOrderDetailService;
import com.glxp.api.service.purchase.PurOrderService;
import com.glxp.api.service.purchase.SupCertService;
import com.glxp.api.service.purchase.SupProductService;
import com.glxp.api.service.system.SystemParamConfigService;
import com.glxp.api.service.thrsys.ThrOrderDetailService;
import com.glxp.api.service.thrsys.ThrOrderService;
import com.glxp.api.service.thrsys.ThrSystemBusApiService;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OrderNoTypeBean;
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 java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*/
@RestController
public class IoOrderDetailBizController extends BaseController {
@Resource
IoOrderService orderService;
@Resource
IoOrderDetailBizService orderDetailBizService;
@Resource
UdiRelevanceService udiRelevanceService;
@Resource
GennerOrderUtils gennerOrderUtils;
@Resource
private IBasicBussinessTypeService basicBussinessTypeService;
@Resource
InvWarehouseService invWarehouseService;
@Resource
private IoCheckInoutService ioCheckInoutService;
@Resource
IoOrderDetailCodeService orderDetailCodeService;
@Resource
ThrOrderService thrOrderService;
@Resource
ReceiveService receiveService;
@Resource
ReceivedetailService receivedetailService;
@Resource
IBasicBusTypeChangeService basicBusTypeChangeService;
@Resource
IoOrderInvoiceService ioOrderInvoiceService;
//获取单据业务详情---临时接口查询
@AuthRuleAnnotation("")
@GetMapping("udiwms/inout/order/draft/biz")
public BaseResponse getDraftsDetailCode(String orderId) {
List<IoOrderDetailBizEntity> orderEntityList = orderDetailBizService.checkOrderList(orderId);
PageSimpleResponse<IoOrderDetailBizEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(100l);
pageSimpleResponse.setList(orderEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
@Resource
SupProductService supProductService;
@Resource
SystemParamConfigService systemParamConfigService;
@Resource
SupCertService supCertService;
//录入业务单据详情
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/addBizProduct")
@Log(title = "单据管理", businessType = BusinessType.INSERT)
public BaseResponse addBizProduct(@RequestBody AddBizProductReqeust addBizProductReqeust) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("vail_product_cert");
// boolean isVailCert = systemParamConfigEntity.getParamValue().equals("1") ? true : false;
AuthAdmin authAdmin = getUser();
if (addBizProductReqeust.getRelId() == null && CollUtil.isEmpty(addBizProductReqeust.getDatas()))
return ResultVOUtils.error(500, "未选择产品信息");
if (addBizProductReqeust.getOrderEntity() == null)
return ResultVOUtils.error(500, "未指定订单");
IoOrderEntity orderEntity = addBizProductReqeust.getOrderEntity();
IoOrderEntity isExit = orderService.findByBillNo(orderEntity.getBillNo());
if (StrUtil.isEmpty(orderEntity.getBillNo()) || isExit == null) {
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(orderEntity.getInvCode());
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
orderEntity.setBillNo(orderNo);
orderEntity.setCreateUser(authAdmin.getId() + "");
orderEntity.setCreateTime(new Date());
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
if (StrUtil.isNotEmpty(orderEntity.getFromInvCode())) {
InvWarehouseEntity fromEntity = invWarehouseService.findByInvSubByCode(orderEntity.getInvCode());
orderEntity.setFromDeptCode(fromEntity.getParentId());
}
orderEntity.setFromType(ConstantStatus.FROM_WEBNEW);
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
orderEntity.setCreateUser(authAdmin.getId() + "");
orderEntity.setCreateTime(new Date());
orderEntity.setUpdateUser(authAdmin.getId() + "");
orderEntity.setUpdateTime(new Date());
orderEntity.setCustomerId(authAdmin.getCustomerId() + "");
orderEntity.setDeptCode(invWarehouseEntity.getParentId());
orderEntity.setInvCode(orderEntity.getInvCode());
orderEntity.setBusType(bussinessTypeEntity.getBusType());
orderService.insertOrder(orderEntity);
}
List<AddBizProductReqeust> datas = new ArrayList<>();
if (CollUtil.isNotEmpty(addBizProductReqeust.getDatas())) {
datas.addAll(addBizProductReqeust.getDatas());
} else {
datas.add(addBizProductReqeust);
}
for (AddBizProductReqeust item : datas) {
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectSupGroupById(item.getRelId(), addBizProductReqeust.getSupId());
// todo 查询产品是否已经通过认证
// BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
// if (bussinessTypeEntity.getCheckCertExpire() == 2 && udiRelevanceResponse.isNeedCert()) {
// SupProductEntity supProductEntity = supProductService.findByManufactury(udiRelevanceResponse.getCpmctymc(), udiRelevanceResponse.getManufactory(), "");
// if (supProductEntity != null && (supProductEntity.getAuditStatus() == ConstantStatus.AUDIT_PASS || supProductEntity.getAuditStatus() == ConstantStatus.AUDIT_CHANGE_PASS)) {
//
// } else {
// return ResultVOUtils.error(500, "产品资质证书未通过审核!");
// }
// }
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
ioOrderDetailBizEntity.setOrderIdFk(orderEntity.getBillNo());
ioOrderDetailBizEntity.setBindRlFk(udiRelevanceResponse.getId());
ioOrderDetailBizEntity.setUuidFk(udiRelevanceResponse.getUuid());
ioOrderDetailBizEntity.setNameCode(udiRelevanceResponse.getNameCode());
ioOrderDetailBizEntity.setCoName(udiRelevanceResponse.getCpmctymc());
ioOrderDetailBizEntity.setCertCode(addBizProductReqeust.getZczbhhzbapzbh());
ioOrderDetailBizEntity.setYlqxzcrbarmc(udiRelevanceResponse.getYlqxzcrbarmc());
ioOrderDetailBizEntity.setManufacturer(udiRelevanceResponse.getManufactory());
ioOrderDetailBizEntity.setMeasname(udiRelevanceResponse.getMeasname());
ioOrderDetailBizEntity.setSpec(udiRelevanceResponse.getGgxh());
ioOrderDetailBizEntity.setPrice(udiRelevanceResponse.getPrice());
ioOrderDetailBizEntity.setProductDate(item.getProductDate());
ioOrderDetailBizEntity.setExpireDate(item.getExpireDate());
ioOrderDetailBizEntity.setBatchNo(item.getBatchNo());
ioOrderDetailBizEntity.setSupId(item.getSupId());
orderDetailBizService.insert(ioOrderDetailBizEntity);
}
orderEntity.setUpdateTime(new Date());
orderEntity.setUpdateUser(authAdmin.getId() + "");
orderService.update(orderEntity);
return ResultVOUtils.success(orderEntity);
}
//修改业务单据详情
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/updateBizProduct")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse updateBizProduct(@RequestBody IoOrderDetailBizEntity orderDetailBizEntity) {
boolean isExit = orderDetailBizService.isExit(orderDetailBizEntity.getBindRlFk(), orderDetailBizEntity.getBatchNo(), orderDetailBizEntity.getId(), orderDetailBizEntity.getOrderIdFk());
if (isExit) {
return ResultVOUtils.error(500, "存在相同产品,相同批次号,请检查后保存!");
}
return orderDetailBizService.update(orderDetailBizEntity) > 0 ? ResultVOUtils.success("保存成功!") : ResultVOUtils.error(500, "保存失败");
}
@Resource
ThrOrderDetailService thrOrderDetailService;
@Resource
ThrSystemBusApiService thrSystemBusApiService;
@Resource
UdiRlSupService udiRlSupService;
//选入第三方单据至业务单据
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/addThrOrder")
@Log(title = "单据管理", businessType = BusinessType.INSERT)
public BaseResponse addThrOrder(@RequestBody ThrOrderEntity thrOrderRequest) {
ThrOrderEntity thrOrderEntity = thrOrderService.findById(thrOrderRequest.getId());
if (thrOrderEntity == null) {
return ResultVOUtils.error(ResultEnum.DATA_NOT);
}
List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailService.selectByBillNo(thrOrderEntity.getBillNo());
//获取单据类型
ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiService.selectByThrBus(thrOrderEntity.getBillType(), thrOrderEntity.getThirdSysFk());
if (thrSystemBusApiEntity == null || StrUtil.isEmpty(thrSystemBusApiEntity.getCode())) {
return ResultVOUtils.error(500, "单据类型对照有误!");
}
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(thrSystemBusApiEntity.getCode());
AuthAdmin authAdmin = getUser();
//创建单据
IoOrderEntity orderEntity = new IoOrderEntity();
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
orderEntity.setBillNo(orderNo);
orderEntity.setCreateUser(authAdmin.getId() + "");
orderEntity.setCreateTime(new Date());
orderEntity.setUpdateUser(authAdmin.getId() + "");
orderEntity.setUpdateTime(new Date());
orderEntity.setCustomerId(authAdmin.getCustomerId() + "");
orderEntity.setCorpOrderId(thrOrderEntity.getBillNo());
orderEntity.setAction(bussinessTypeEntity.getAction());
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
orderEntity.setFromThrBillNo(thrOrderEntity.getBillNo());
//获取当前部门
if (StrUtil.isNotEmpty(thrOrderEntity.getInvCode())) {
InvWarehouseEntity invWarehouseEntity = invWarehouseService.selectByThrCode(thrOrderEntity.getInvCode(), thrOrderEntity.getThirdSysFk());
if (invWarehouseEntity != null) {
orderEntity.setDeptCode(invWarehouseEntity.getParentId());
orderEntity.setInvCode(invWarehouseEntity.getCode());
}
} else {
return ResultVOUtils.error(500, "第三方单据所属仓库不能为空!");
}
//获取往来信息
if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INNOR) {//内部调拨
InvWarehouseEntity invWarehouseEntity = invWarehouseService.selectByThrCode(thrOrderEntity.getCorpId(), thrOrderEntity.getThirdSysFk());
orderEntity.setFromDeptCode(invWarehouseEntity.getParentId());
orderEntity.setFromInvCode(invWarehouseEntity.getCode());
} else if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT) { //往来信息
BasicCorpEntity basicCorpEntity = basicCorpService.selectByThirdId(thrOrderEntity.getCorpId(), thrOrderEntity.getThirdSysFk());
orderEntity.setFromCorp(basicCorpEntity.getErpId());
} else {
orderEntity.setFromCorp(thrOrderEntity.getCorpId());
}
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
orderEntity.setFromType(ConstantStatus.FROM_THRORDER);
orderEntity.setOrderType(ConstantStatus.ORDER_TYPE_BIZ);
orderEntity.setBusType(bussinessTypeEntity.getBusType());
orderService.insertOrder(orderEntity);
for (ThrOrderDetailEntity thrOrderDetailEntity : thrOrderDetailEntities) {
thrOrderDetailEntity.getProductId();
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceService.selectListByThirdId(thrOrderDetailEntity.getProductId(), thrOrderEntity.getThirdSysFk());
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
UdiRelevanceResponse udiRelevanceResponse = null;
if (udiRelevanceEntities.size() == 1) {
udiRelevanceResponse = udiRelevanceEntities.get(0);
ioOrderDetailBizEntity.setBindRlFk(udiRelevanceResponse.getId());
ioOrderDetailBizEntity.setUuidFk(udiRelevanceResponse.getUuid());
ioOrderDetailBizEntity.setNameCode(udiRelevanceResponse.getNameCode());
ioOrderDetailBizEntity.setCoName(udiRelevanceResponse.getCpmctymc());
ioOrderDetailBizEntity.setCertCode(udiRelevanceResponse.getZczbhhzbapzbh());
ioOrderDetailBizEntity.setYlqxzcrbarmc(udiRelevanceResponse.getYlqxzcrbarmc());
ioOrderDetailBizEntity.setManufacturer(udiRelevanceResponse.getManufactory());
ioOrderDetailBizEntity.setMeasname(udiRelevanceResponse.getMeasname());
ioOrderDetailBizEntity.setSpec(udiRelevanceResponse.getGgxh());
ioOrderDetailBizEntity.setPrice(udiRelevanceResponse.getPrice());
} else {
ioOrderDetailBizEntity.setCoName(thrOrderDetailEntity.getCorpName());
ioOrderDetailBizEntity.setCertCode(thrOrderDetailEntity.getZczbhhzbapzbh());
ioOrderDetailBizEntity.setYlqxzcrbarmc(thrOrderDetailEntity.getYlqxzcrbarmc());
ioOrderDetailBizEntity.setManufacturer(thrOrderDetailEntity.getManufactory());
ioOrderDetailBizEntity.setSpec(thrOrderDetailEntity.getSpec());
ioOrderDetailBizEntity.setPrice(thrOrderDetailEntity.getPrice());
if (udiRelevanceEntities.size() > 1) {
String bindRlIds = "";
for (UdiRelevanceResponse temp : udiRelevanceEntities) {
bindRlIds = bindRlIds + "," + temp.getId();
}
ioOrderDetailBizEntity.setBindRlIds(bindRlIds.substring(1));
}
}
ioOrderDetailBizEntity.setOrderIdFk(orderEntity.getBillNo());
ioOrderDetailBizEntity.setProductDate(thrOrderDetailEntity.getProductDate());
ioOrderDetailBizEntity.setExpireDate(thrOrderDetailEntity.getExpireDate());
ioOrderDetailBizEntity.setBatchNo(thrOrderDetailEntity.getBatchNo());
ioOrderDetailBizEntity.setCount(thrOrderDetailEntity.getCount());
if (StrUtil.isNotEmpty(thrOrderDetailEntity.getSupId())) {
BasicCorpEntity basicCorpEntity = basicCorpService.selectByThirdId(thrOrderDetailEntity.getSupId(), thrOrderEntity.getThirdSysFk());
ioOrderDetailBizEntity.setSupId(basicCorpEntity.getErpId());
} else if (udiRelevanceResponse != null) {
List<UdiRlSupEntity> udiRlSupEntities = udiRlSupService.findByUdiRlId(udiRelevanceResponse.getId());
if (CollUtil.isNotEmpty(udiRlSupEntities) && udiRlSupEntities.size() == 1) {
ioOrderDetailBizEntity.setSupId(udiRlSupEntities.get(0).getCustomerId());
}
}
orderDetailBizService.insert(ioOrderDetailBizEntity);
}
thrOrderService.updateThrOrder(thrOrderEntity);
return ResultVOUtils.success("选入成功!");
}
@Resource
BasicCorpService basicCorpService;
//选入领用单据至业务单据
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/addReceiveOrder")
@Log(title = "单据管理", businessType = BusinessType.INSERT)
public BaseResponse addReceiveOrder(@RequestBody PurReceiveEntity purReceiveEntity,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
purReceiveEntity = receiveService.selectById(purReceiveEntity.getId());
List<PurReceiveDetailEntity> purReceiveDetailEntities = receivedetailService.selectByOrderId(purReceiveEntity.getBillNo());
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(purReceiveEntity.getBillType());
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(basicBusTypeChangeEntity.getTargetAction());
AuthAdmin authAdmin = getUser();
//创建单据
IoOrderEntity orderEntity = new IoOrderEntity();
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
orderEntity.setBillNo(orderNo);
orderEntity.setCreateUser(authAdmin.getId() + "");
orderEntity.setCreateTime(new Date());
orderEntity.setUpdateUser(authAdmin.getId() + "");
orderEntity.setUpdateTime(new Date());
orderEntity.setCustomerId(authAdmin.getCustomerId() + "");
orderEntity.setCorpOrderId(purReceiveEntity.getBillNo());
orderEntity.setAction(bussinessTypeEntity.getAction());
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
orderEntity.setDeptCode(purReceiveEntity.getTargetDeptCode());
orderEntity.setInvCode(purReceiveEntity.getTargetInvCode());
orderEntity.setFromReceiveBillNo(purReceiveEntity.getBillNo());
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
orderEntity.setFromType(ConstantStatus.FROM_RECEIVE);
orderEntity.setOrderType(ConstantStatus.ORDER_TYPE_BIZ);
orderEntity.setFromDeptCode(purReceiveEntity.getDeptCode());
orderEntity.setFromInvCode(purReceiveEntity.getInvCode());
orderEntity.setBusType(bussinessTypeEntity.getBusType());
orderService.insertOrder(orderEntity);
for (PurReceiveDetailEntity purReceiveDetailEntity : purReceiveDetailEntities) {
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectGroupById(purReceiveDetailEntity.getRelIdFk());
ioOrderDetailBizEntity.setOrderIdFk(orderEntity.getBillNo());
ioOrderDetailBizEntity.setBindRlFk(udiRelevanceResponse.getId());
ioOrderDetailBizEntity.setUuidFk(udiRelevanceResponse.getUuid());
ioOrderDetailBizEntity.setNameCode(udiRelevanceResponse.getNameCode());
ioOrderDetailBizEntity.setCoName(udiRelevanceResponse.getCpmctymc());
ioOrderDetailBizEntity.setCertCode(udiRelevanceResponse.getZczbhhzbapzbh());
ioOrderDetailBizEntity.setYlqxzcrbarmc(udiRelevanceResponse.getYlqxzcrbarmc());
ioOrderDetailBizEntity.setManufacturer(udiRelevanceResponse.getManufactory());
ioOrderDetailBizEntity.setMeasname(udiRelevanceResponse.getMeasname());
ioOrderDetailBizEntity.setSpec(udiRelevanceResponse.getGgxh());
ioOrderDetailBizEntity.setPrice(udiRelevanceResponse.getPrice());
ioOrderDetailBizEntity.setProductDate(purReceiveDetailEntity.getProductDate());
ioOrderDetailBizEntity.setExpireDate(purReceiveDetailEntity.getExpireDate());
ioOrderDetailBizEntity.setBatchNo(purReceiveDetailEntity.getBatchNo());
ioOrderDetailBizEntity.setSupId(purReceiveDetailEntity.getSupId());
ioOrderDetailBizEntity.setCount(purReceiveDetailEntity.getCount());
orderDetailBizService.insert(ioOrderDetailBizEntity);
}
return ResultVOUtils.success("选入成功!");
}
@Resource
PurOrderService purOrderService;
@Resource
PurOrderDetailService purOrderDetailService;
//选入领用单据至业务单据
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/addPurOrder")
@Log(title = "单据管理", businessType = BusinessType.INSERT)
public BaseResponse addPurOrder(@RequestBody PurOrderEntity purOrderEntity,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
purOrderEntity = purOrderService.selectById(purOrderEntity.getId());
List<PurOrderDetailEntity> purOrderDetailEntities = purOrderDetailService.findByOrderId(purOrderEntity.getId() + "");
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(purOrderEntity.getBillType());
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(basicBusTypeChangeEntity.getTargetAction());
AuthAdmin authAdmin = getUser();
//创建单据
IoOrderEntity orderEntity = new IoOrderEntity();
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
orderEntity.setBillNo(orderNo);
orderEntity.setCreateUser(authAdmin.getId() + "");
orderEntity.setCreateTime(new Date());
orderEntity.setUpdateUser(authAdmin.getId() + "");
orderEntity.setUpdateTime(new Date());
orderEntity.setCustomerId(authAdmin.getCustomerId() + "");
orderEntity.setCorpOrderId(purOrderEntity.getBillNo());
orderEntity.setAction(bussinessTypeEntity.getAction());
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
orderEntity.setDeptCode(purOrderEntity.getDeptCode());
orderEntity.setInvCode(purOrderEntity.getInvCode());
orderEntity.setFromReceiveBillNo(purOrderEntity.getBillNo());
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
orderEntity.setFromType(ConstantStatus.FROM_RECEIVE);
orderEntity.setOrderType(ConstantStatus.ORDER_TYPE_BIZ);
orderEntity.setBusType(bussinessTypeEntity.getBusType());
orderService.insertOrder(orderEntity);
for (PurOrderDetailEntity purReceiveDetailEntity : purOrderDetailEntities) {
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectGroupById(purReceiveDetailEntity.getProductId().longValue());
ioOrderDetailBizEntity.setOrderIdFk(orderEntity.getBillNo());
ioOrderDetailBizEntity.setBindRlFk(udiRelevanceResponse.getId());
ioOrderDetailBizEntity.setUuidFk(udiRelevanceResponse.getUuid());
ioOrderDetailBizEntity.setNameCode(udiRelevanceResponse.getNameCode());
ioOrderDetailBizEntity.setCoName(udiRelevanceResponse.getCpmctymc());
ioOrderDetailBizEntity.setCertCode(udiRelevanceResponse.getZczbhhzbapzbh());
ioOrderDetailBizEntity.setYlqxzcrbarmc(udiRelevanceResponse.getYlqxzcrbarmc());
ioOrderDetailBizEntity.setManufacturer(udiRelevanceResponse.getManufactory());
ioOrderDetailBizEntity.setMeasname(udiRelevanceResponse.getMeasname());
ioOrderDetailBizEntity.setSpec(udiRelevanceResponse.getGgxh());
ioOrderDetailBizEntity.setPrice(udiRelevanceResponse.getPrice());
ioOrderDetailBizEntity.setSupId(purReceiveDetailEntity.getSupId());
ioOrderDetailBizEntity.setCount(purReceiveDetailEntity.getCount());
orderDetailBizService.insert(ioOrderDetailBizEntity);
}
return ResultVOUtils.success("选入成功!");
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/delBizProduct")
@Log(title = "单据管理", businessType = BusinessType.DELETE)
public BaseResponse delBizProduct(@RequestBody DeleteRequest deleteRequest) {
IoOrderDetailBizEntity orderDetailBizEntity = orderDetailBizService.selectById(Long.parseLong(deleteRequest.getId()));
int result = orderDetailBizService.deleteById(Long.parseLong(deleteRequest.getId()));
if (result > 0) {
boolean r1 = orderDetailBizService.isExit(orderDetailBizEntity.getOrderIdFk());
boolean r2 = orderDetailCodeService.isExit(orderDetailBizEntity.getOrderIdFk());
if (!r1 && !r2) {
orderService.deleteByBillNo(orderDetailBizEntity.getOrderIdFk());
}
return ResultVOUtils.success("删除成功!");
}
return ResultVOUtils.error(500, "删除失败");
}
/**
*
*
* @param orderDetailBizRequest
* @return
*/
@GetMapping("/udiwms/inout/bizDetail/filterList")
public BaseResponse filterList(FilterOrderDetailBizRequest orderDetailBizRequest) {
List<IoOrderDetailBizResponse> list = orderDetailBizService.filterList(orderDetailBizRequest);
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(orderDetailBizRequest.getOrderIdFk());
ioCheckInoutService.bizOrderCheck2(list, orderDetailCodeEntities);
PageInfo<IoOrderDetailBizResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
// @GetMapping("/udiwms/inout/bizDetail/filterListInv")
// public BaseResponse filterListInv(FilterOrderDetailBizRequest orderDetailBizRequest) {
// List<IoOrderDetailBizResponse> list = orderDetailBizService.getfilterList(orderDetailBizRequest);
// List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(orderDetailBizRequest.getOrderIdFk());
// ioCheckInoutService.bizOrderCheck2(list, orderDetailCodeEntities);
// PageInfo<IoOrderDetailBizResponse> pageInfo = new PageInfo<>(list);
// return ResultVOUtils.page(pageInfo);
// }
@GetMapping("/udiwms/inout/bizDetail/filterListInvoice")
public BaseResponse filterListInvoice(FilterOrderDetailBizRequest orderDetailBizRequest) {
List<IoOrderInvoiceResponse> list = orderDetailBizService.filterListInv(orderDetailBizRequest);
PageInfo<IoOrderInvoiceResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/biz/updateBind")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse updateBindSup(@RequestBody BizBindUpdateRequest bizBindUpdateRequest) {
IoOrderDetailBizEntity orderDetailBizEntity = orderDetailBizService.selectById(bizBindUpdateRequest.getId());
if (bizBindUpdateRequest.getBindRlFk() != null)
orderDetailBizEntity.setBindRlFk(bizBindUpdateRequest.getBindRlFk());
if (StrUtil.isNotEmpty(bizBindUpdateRequest.getSupId())) {
orderDetailBizEntity.setSupId(bizBindUpdateRequest.getSupId());
}
orderDetailBizService.update(orderDetailBizEntity);
return ResultVOUtils.success("绑定成功");
}
/**
*
*
* @param
* @return
*/
@PostMapping("/udiwms/inout/biz/deleteById")
@Log(title = "发票管理", businessType = BusinessType.DELETE)
public BaseResponse deleteById(@RequestBody IoOrderInvoiceEntity ioOrderInvoiceEntity) {
IoOrderInvoiceResponse ioOrderInvoiceResponse = orderDetailBizService.selectByinvoiceId(ioOrderInvoiceEntity.getId());
//更改 登记状态
IoOrderDetailCodeEntity ioOrderDetailBizEntity = new IoOrderDetailCodeEntity();
FilterOrderDetailBizRequest filterOrderDetailBizRequest = new FilterOrderDetailBizRequest();
filterOrderDetailBizRequest.setOrderIdFk(ioOrderInvoiceEntity.getOrderIdFk());
ioOrderDetailBizEntity.setOrderIdFk(ioOrderInvoiceEntity.getOrderIdFk());
ioOrderDetailBizEntity.setId(ioOrderInvoiceResponse.getBizIdFk().longValue());
ioOrderInvoiceService.deleteByInvId(ioOrderInvoiceEntity.getId() + "");
List<IoOrderInvoiceResponse> list = orderDetailBizService.filterListInv(filterOrderDetailBizRequest);
if (list.size() == 0) {
ioOrderDetailBizEntity.setRegStatus(false);
}
orderDetailCodeService.updateOrderDetailBiz(ioOrderDetailBizEntity);
return ResultVOUtils.success();
}
/**
*
*
* @param ioOrderInvoiceRequest
* @return
*/
@PostMapping("/udiwms/inout/biz/updateById")
@Log(title = "发票管理", businessType = BusinessType.UPDATE)
public BaseResponse deleteById(@RequestBody IoOrderInvoiceRequest ioOrderInvoiceRequest) {
return ResultVOUtils.success(ioOrderInvoiceService.updateByInvId(ioOrderInvoiceRequest));
}
@PostMapping("/udiwms/inout/biz/insertInvoice")
@Log(title = "发票管理", businessType = BusinessType.INSERT)
public BaseResponse insertInvoice(@RequestBody IoOrderInvoiceEntity ioOrderInvoice) {
for (IoOrderDetailBizEntity ioOrderDetailBizEntity : ioOrderInvoice.getList()) {
IoOrderInvoiceEntity ioOrderInvoiceEntity = new IoOrderInvoiceEntity();
ioOrderInvoiceEntity.setOrderIdFk(ioOrderDetailBizEntity.getOrderIdFk());
ioOrderInvoiceEntity.setBindRlFk(ioOrderDetailBizEntity.getBindRlFk() + "");
ioOrderInvoiceEntity.setBatchNo(ioOrderDetailBizEntity.getBatchNo());
ioOrderInvoiceEntity.setProductDate(ioOrderDetailBizEntity.getProductDate());
ioOrderInvoiceEntity.setExpireDate(ioOrderDetailBizEntity.getExpireDate());
ioOrderInvoiceEntity.setBizIdFk(ioOrderDetailBizEntity.getId());
ioOrderInvoiceEntity.setCreateTime(new Date());
ioOrderInvoiceEntity.setUpdateTime(new Date());
ioOrderInvoiceEntity.setId(IdUtil.getSnowflakeNextId());
ioOrderInvoiceEntity.setMachineNo(ioOrderInvoice.getMachineNo());
ioOrderInvoiceEntity.setInvoiceCode(ioOrderInvoice.getInvoiceCode());
ioOrderInvoiceEntity.setInvoiceEncode(ioOrderInvoice.getInvoiceEncode());
ioOrderInvoiceEntity.setInvoiceDate(ioOrderInvoice.getInvoiceDate());
ioOrderInvoiceEntity.setPrice(ioOrderInvoice.getPrice());
ioOrderInvoiceEntity.setRemark(ioOrderInvoice.getRemark());
ioOrderInvoiceEntity.setLicenseUrl(ioOrderInvoice.getLicenseUrl());
boolean b = ioOrderInvoiceService.insertInvoice(ioOrderInvoiceEntity);
}
return ResultVOUtils.success("成功");
}
@PostMapping("/udiwms/inout/biz/updateorderBiz")
public BaseResponse updateorderBiz(@RequestBody List<IoOrderDetailCodeEntity> list) {
for (IoOrderDetailCodeEntity ioOrderDetailBizEntity : list) {
ioOrderDetailBizEntity.setRegStatus(true);
orderDetailCodeService.updateOrderDetailBiz(ioOrderDetailBizEntity);
}
return ResultVOUtils.success("成功");
}
/**
*
*
* @param orderDetailBizRequest
* @return
*/
@GetMapping("/udiwms/inout/bizDetail/filterBizOrderList")
public BaseResponse filterBizOrderList(FilterOrderDetailCodeRequest orderDetailBizRequest) {
List<IoOrderDetailCodeResponse> ioOrderDetailCodeResponses = orderDetailBizService.getfilterList(orderDetailBizRequest);
for (IoOrderDetailCodeResponse ioOrderDetailCodeRespons : ioOrderDetailCodeResponses) {
if (ioOrderDetailCodeRespons.getCount() != 0 && ioOrderDetailCodeRespons.getPrice() != null) {
ioOrderDetailCodeRespons.setAmount(new BigDecimal(ioOrderDetailCodeRespons.getCount()).multiply(ioOrderDetailCodeRespons.getPrice()));
}
String msg = "";
IoOrderInvoiceRequest ioOrderInvoiceEntity = new IoOrderInvoiceRequest();
ioOrderInvoiceEntity.setOrderIdFk(ioOrderDetailCodeRespons.getOrderIdFk());
ioOrderInvoiceEntity.setBizIdFk(ioOrderDetailCodeRespons.getId());
List<IoOrderInvoiceEntity> ioOrderInvoiceEntityList = ioOrderInvoiceService.selectOrderInvoice(ioOrderInvoiceEntity);
for (IoOrderInvoiceEntity obj : ioOrderInvoiceEntityList) {
if (StrUtil.isNotEmpty(obj.getInvoiceEncode())) {
msg += "," + obj.getInvoiceEncode();
}
}
if (msg.length() > 1) {
msg = msg.substring(1);
}
ioOrderDetailCodeRespons.setInvoiceCodes(msg);
}
PageInfo<IoOrderDetailCodeResponse> pageInfo = new PageInfo<>(ioOrderDetailCodeResponses);
return ResultVOUtils.page(pageInfo);
}
}

@ -1,64 +0,0 @@
package com.glxp.api.controller.inout;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
import com.glxp.api.entity.inout.IoOrderDetailCodeEntity;
import com.glxp.api.req.inout.FilterOrderDetailCodeRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.IoOrderDetailCodeResponse;
import com.glxp.api.service.inout.IoCheckInoutService;
import com.glxp.api.service.inout.IoOrderDetailBizService;
import com.glxp.api.service.inout.IoOrderDetailCodeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
*
*/
@RestController
public class IoOrderDetailCodeController {
@Resource
private IoOrderDetailCodeService ioOrderDetailCodeService;
@Resource
private IoCheckInoutService ioCheckInoutService;
@Resource
private IoOrderDetailBizService orderDetailBizService;
//获取新增扫码单据详情---临时接口查询
@AuthRuleAnnotation("")
@GetMapping("udiwms/inout/order/draft/detailCode")
public BaseResponse getDraftsDetailCode(String orderId) {
List<IoOrderDetailCodeEntity> orderEntityList = ioOrderDetailCodeService.checkOrderList(orderId);
List<IoOrderDetailCodeResponse> list = ioOrderDetailCodeService.getDetailCodeResponse(orderEntityList);
PageSimpleResponse<IoOrderDetailCodeResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(Long.valueOf(list.size()));
pageSimpleResponse.setList(list);
return ResultVOUtils.success(pageSimpleResponse);
}
/**
*
*
* @param detailCodeRequest
* @return
*/
@GetMapping("udiwms/inout/codeDetail/filterList")
public BaseResponse filterList(FilterOrderDetailCodeRequest detailCodeRequest) {
List<IoOrderDetailCodeResponse> list = ioOrderDetailCodeService.filterList(detailCodeRequest);
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(detailCodeRequest.getOrderIdFk());
ioCheckInoutService.codeOrderCheck2(list, orderDetailBizEntities);
PageInfo<IoOrderDetailCodeResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
}

@ -1,139 +0,0 @@
package com.glxp.api.controller.inout;
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.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.ConstantType;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
import com.glxp.api.entity.inout.IoOrderDetailCodeEntity;
import com.glxp.api.entity.inout.IoOrderEntity;
import com.glxp.api.req.inout.FilterCodeRequest;
import com.glxp.api.req.inout.FilterOrderDetailResultRequest;
import com.glxp.api.req.inout.FilterOrderRequest;
import com.glxp.api.res.inout.IoCodeResponse;
import com.glxp.api.res.inout.IoOrderDetailResultResponse;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.inout.*;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
*
*/
@RestController
public class IoOrderDetailResultController extends BaseController {
@Resource
IoOrderService orderService;
@Resource
private IoOrderDetailResultService orderDetailResultService;
@Resource
IBasicBussinessTypeService basicBussinessTypeService;
@Resource
IoCodeService codeService;
/**
*
*
* @param orderDetailResultRequest
* @return
*/
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/resultDetail/filterList")
public BaseResponse filterList(FilterOrderDetailResultRequest orderDetailResultRequest) {
List<IoOrderDetailResultResponse> list = orderDetailResultService.filterList(orderDetailResultRequest);
PageInfo<IoOrderDetailResultResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
/**
*
*
* @param orderDetailResultRequest
* @return
*/
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/resultDetail/filterOrderList")
public BaseResponse filterOrderList(FilterOrderDetailResultRequest orderDetailResultRequest) {
FilterOrderRequest filterOrderRequest = new FilterOrderRequest();
filterOrderRequest.setVueType(orderDetailResultRequest.getActionType());
List<String> actions = orderService.setActions(filterOrderRequest);
if (CollUtil.isEmpty(actions)) {
return ResultVOUtils.success("");
}
orderDetailResultRequest.setActions(actions);
List<IoOrderDetailResultResponse> list = orderDetailResultService.filterOrderList(orderDetailResultRequest);
for (IoOrderDetailResultResponse orderDetailResultResponse : list) {
if (orderDetailResultResponse.getMainAction().equals(ConstantType.TYPE_OUT)) {
orderDetailResultResponse.setOutCount(orderDetailResultResponse.getReCount());
orderDetailResultResponse.setInCount(0);
} else {
orderDetailResultResponse.setOutCount(0);
orderDetailResultResponse.setInCount(orderDetailResultResponse.getReCount());
}
}
PageInfo<IoOrderDetailResultResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
/**
* pda
*/
@AuthRuleAnnotation("")
@GetMapping(value = "/warehouse/inout/order/detail")
public BaseResponse orderDetail(FilterOrderDetailResultRequest filterErpOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
if (StrUtil.isEmpty(filterErpOrderRequest.getOrderIdFk())) {
return ResultVOUtils.error(500, "单据号不能为空!");
}
IoOrderEntity orderEntity = orderService.findByBillNo(filterErpOrderRequest.getOrderIdFk());
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
filterErpOrderRequest.setPage(null);
filterErpOrderRequest.setLimit(null);
List<IoOrderDetailResultResponse> list = orderDetailResultService.filterList(filterErpOrderRequest);
return ResultVOUtils.success(list);
}
@Resource
IoOrderDetailBizService orderDetailBizService;
@Resource
IoOrderDetailCodeService orderDetailCodeService;
@Resource
IoCheckInoutService checkInoutService;
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/wditCheck/filterList")
public BaseResponse waitCheckList(FilterOrderDetailResultRequest orderDetailResultRequest) {
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(orderDetailResultRequest.getOrderIdFk());
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(orderDetailResultRequest.getOrderIdFk());
return ResultVOUtils.success(checkInoutService.combineCheck(orderDetailBizEntities, orderDetailCodeEntities));
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/waitAllocate/filterList")
public BaseResponse waitAllocate(FilterOrderDetailResultRequest orderDetailResultRequest) {
IoOrderEntity orderEntity = orderService.findByBillNo(orderDetailResultRequest.getOrderIdFk());
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(orderDetailResultRequest.getOrderIdFk());
checkInoutService.bizNoPiCheck(orderDetailBizEntities, orderEntity);
return ResultVOUtils.success(orderDetailBizEntities);
}
}

@ -1,59 +0,0 @@
package com.glxp.api.controller.inout;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
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.dao.inout.IoOrderInvoiceMapper;
import com.glxp.api.entity.inout.IoOrderInvoiceEntity;
import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.idc.service.FileService;
import com.glxp.api.req.inout.RefreshInoiceRequest;
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.List;
@RestController
public class IoOrderInvoiceController {
@Resource
IoOrderInvoiceMapper orderInvoiceMapper;
@Resource
SpGetHttpClient spGetHttpClient;
@Resource
FileService fileService;
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/refrshInvoice")
@Log(title = "发票", businessType = BusinessType.INSERT)
public BaseResponse addBizProduct(@RequestBody RefreshInoiceRequest refreshInoiceRequest) {
BaseResponse baseResponse = spGetHttpClient.getIoOrderInvoices(refreshInoiceRequest);
if (baseResponse.getCode() == 20000) {
List<IoOrderInvoiceEntity> orderInvoiceEntities = BeanUtil.toBean(baseResponse.getData(),List.class);
if (CollUtil.isNotEmpty(orderInvoiceEntities)) {
List<String> syncFiles = new ArrayList<>();
for (IoOrderInvoiceEntity orderInvoiceEntity : orderInvoiceEntities) {
if (StrUtil.isNotEmpty(orderInvoiceEntity.getLicenseUrl())) {
syncFiles.add(orderInvoiceEntity.getLicenseUrl());
}
orderInvoiceMapper.insertOrUpdate(orderInvoiceEntity);
}
if (CollUtil.isNotEmpty(syncFiles)) {
fileService.download(syncFiles);
}
}
return ResultVOUtils.success("更新成功!");
} else
return baseResponse;
}
}

@ -1,573 +0,0 @@
package com.glxp.api.controller.inout;
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.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
import com.glxp.api.entity.basic.EntrustReceEntity;
import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.system.SystemParamConfigEntity;
import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.req.inout.FilterOrderDetailResultRequest;
import com.glxp.api.req.inout.ReviewFinishRequest;
import com.glxp.api.req.inout.ReviewSpmsRequest;
import com.glxp.api.req.inout.UpdateExportStatusRequest;
import com.glxp.api.req.sync.SpsSyncDataRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.AcceptOrderResponse;
import com.glxp.api.res.inout.IoOrderDetailResultResponse;
import com.glxp.api.res.inout.IoOrderResponse;
import com.glxp.api.res.sync.SpsSyncOrderResponse;
import com.glxp.api.service.auth.AuthAdminService;
import com.glxp.api.service.auth.InvBusUserService;
import com.glxp.api.service.basic.EntrustReceService;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.inout.*;
import com.glxp.api.service.sync.HeartService;
import com.glxp.api.service.system.SystemParamConfigService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OrderNoTypeBean;
import com.glxp.api.util.RedisUtil;
import com.glxp.api.util.udi.UdiCalCountUtil;
import lombok.extern.slf4j.Slf4j;
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 java.awt.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
//单据验收
@Slf4j
@RestController
public class IoOrderReviewController extends BaseController {
@Resource
private RedisUtil redisUtil;
@Resource
private IoOrderDetailResultService orderDetailResultService;
@Resource
IoOrderService orderService;
@Resource
IoCheckInoutService ioCheckInoutService;
//获取验收单据业务详情
@AuthRuleAnnotation("")
@GetMapping("/udiwms/stock/order/accept/getOrder")
public BaseResponse getAcceptOrder(String billNo) {
if (StrUtil.isBlank(billNo)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
AcceptOrderResponse acceptOrderEntity = new AcceptOrderResponse();
acceptOrderEntity.setBillNo(billNo);
List<IoOrderDetailResultResponse> datas = (List<IoOrderDetailResultResponse>) redisUtil.get(ConstantStatus.REDIS_BILLNO + billNo);
if (CollUtil.isNotEmpty(datas)) {
acceptOrderEntity.setOrderDetailEntities(datas);
acceptOrderEntity.setExitAccept(true);
} else {
FilterOrderDetailResultRequest filterOrderDetailResultRequest = new FilterOrderDetailResultRequest();
filterOrderDetailResultRequest.setOrderIdFk(billNo);
List<IoOrderDetailResultResponse> orderDetailResultResponses = orderDetailResultService.filterList(filterOrderDetailResultRequest);
acceptOrderEntity.setOrderDetailEntities(orderDetailResultResponses);
acceptOrderEntity.setExitAccept(false);
}
return ResultVOUtils.success(acceptOrderEntity);
}
//获取验收单据业务详情
@AuthRuleAnnotation("")
@GetMapping("/udiwms/stock/order/accept/getStatus")
public BaseResponse getStatus(String billNo) {
if (StrUtil.isBlank(billNo)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
AcceptOrderResponse acceptOrderEntity = new AcceptOrderResponse();
acceptOrderEntity.setBillNo(billNo);
List<IoOrderDetailResultResponse> datas = (List<IoOrderDetailResultResponse>) redisUtil.get(ConstantStatus.REDIS_BILLNO + billNo);
if (CollUtil.isNotEmpty(datas)) {
boolean isFinish = vailFinish(datas);
if (isFinish)
return ResultVOUtils.success("单据已验收完成");
else
return ResultVOUtils.error(500, "单据未验收完成");
} else {
return ResultVOUtils.error(500, "单据未验收完成");
}
}
//前端二次审核
@AuthRuleAnnotation("")
@PostMapping("/spms/inout/order/web/updateStatus")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse webUpdateStatus(@RequestBody ReviewFinishRequest updateExportStatusRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
IoOrderEntity orderEntity = orderService.findByBillNo(updateExportStatusRequest.getOrderId());
if (orderEntity == null) {
return ResultVOUtils.error(500, "未找到该业务单据");
}
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_REW) {
if (updateExportStatusRequest.isEntrust()) {
EntrustReceEntity entrustReceEntity = entrustReceService.findByUnique(orderEntity.getAction(), getUserId());
if (entrustReceEntity != null && StrUtil.isNotEmpty(entrustReceEntity.getEntrustAction())) {
transferOrder(orderEntity, entrustReceEntity);
}
}
if (orderEntity.getFromType() == ConstantStatus.FROM_UDISP)
spGetHttp.reviewOrder(updateExportStatusRequest, getUserId() + "");
return updateReview(getUser(), orderEntity);
} else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
return thirdUpdateReview(getUser(), orderEntity);
} else {
return ResultVOUtils.error(500, "当前单据状态非处于审核状态!");
}
}
//前端第三次验收
@AuthRuleAnnotation("")
@PostMapping("/spms/inout/order/third/updateStatus")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse thirdUpdateStatus(@RequestBody ReviewFinishRequest updateExportStatusRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
IoOrderEntity orderEntity = orderService.findByBillNo(updateExportStatusRequest.getOrderId());
if (orderEntity == null) {
return ResultVOUtils.error(500, "未找到该业务单据");
}
return thirdUpdateReview(getUser(), orderEntity);
}
@Resource
IoCodeService codeService;
@Resource
IoCodeTempService codeTempService;
@Resource
UdiCalCountUtil calCountUtil;
//前端扫码验收
@AuthRuleAnnotation("")
@PostMapping("/udiwms/stock/order/accept/addCode")
public BaseResponse acceptAddCode(@RequestBody AcceptOrderResponse acceptOrderEntity) {
IoOrderEntity stockOrderEntity = orderService.findByBillNo(acceptOrderEntity.getBillNo());
List<IoCodeEntity> codeList;
List<IoCodeEntity> codeEntityList = (List<IoCodeEntity>) redisUtil.get(ConstantStatus.REDIS_BILLNO_CODES + acceptOrderEntity.getBillNo());
if (CollUtil.isEmpty(codeEntityList)) {
codeList = codeService.findByOrderId(stockOrderEntity.getBillNo());
} else {
codeList = codeEntityList;
}
IoCodeEntity codeEntity = isExit(codeList, acceptOrderEntity.getCode());
if (codeEntity == null) {
return ResultVOUtils.error(500, "非此单UDI码");
}
int status = checkCodeExit(codeEntity.getCode(), codeList);
if (status == Constant.CHECK_REPEAT) {
return ResultVOUtils.error(500, "重复扫码!");
} else if (status == Constant.CHECK_NULL) {
return ResultVOUtils.error(500, "非此单UDI码");
}
List<IoOrderDetailResultResponse> orderDetailResultResponses = acceptOrderEntity.getOrderDetailEntities();
if (StrUtil.isNotEmpty(acceptOrderEntity.getCode()) && CollUtil.isNotEmpty(orderDetailResultResponses)) {
boolean isExit = false;
for (IoOrderDetailResultResponse orderDetailResultResponse : orderDetailResultResponses) {
if (orderDetailResultResponse.getBindRlFk().longValue() == codeEntity.getRelId().longValue() &&
StrUtil.trimToEmpty(orderDetailResultResponse.getBatchNo()).equals(StrUtil.trimToEmpty(codeEntity.getBatchNo()))) {
orderDetailResultResponse.setAcceptCount(orderDetailResultResponse.getAcceptCount() + calCountUtil.getActCount(codeEntity.getNameCode()));
if (orderDetailResultResponse.getAcceptCount() > orderDetailResultResponse.getCount()) {
return ResultVOUtils.error(500, "数量溢出!");
}
isExit = true;
break;
}
}
if (isExit) {
redisUtil.set(ConstantStatus.REDIS_BILLNO + acceptOrderEntity.getBillNo(), orderDetailResultResponses);
redisUtil.set(ConstantStatus.REDIS_BILLNO_CODES + acceptOrderEntity.getBillNo(), codeList);
acceptOrderEntity.setOrderDetailEntities(orderDetailResultResponses);
if (vailFinish(orderDetailResultResponses)) {
acceptOrderEntity.setFinishAccept(true);
return ResultVOUtils.success(acceptOrderEntity);
}
return ResultVOUtils.success(acceptOrderEntity);
}
}
return ResultVOUtils.error(500, "非此单条码!");
}
@Resource
AuthAdminService authAdminService;
@Resource
EntrustReceService entrustReceService;
//手持终端验收完成后,更新订单状态
@AuthRuleAnnotation("")
@PostMapping("/spms/inout/order/check/updateStatus")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse updateStatus(@RequestBody UpdateExportStatusRequest updateExportStatusRequest,
BindingResult bindingResult) {
AuthAdmin authAdmin = null;
if (StrUtil.isNotEmpty(updateExportStatusRequest.getWmsUserId())) {
authAdmin = authAdminService.findById(Long.parseLong(updateExportStatusRequest.getWmsUserId()));
} else
authAdmin = getUser();
IoOrderEntity orderEntity = orderService.findByBillNo(updateExportStatusRequest.getOrderId());
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
return ResultVOUtils.error(500, "单据已验收!");
}
if (updateExportStatusRequest.isEntrust() && updateExportStatusRequest.getEntrustId() != null) {
EntrustReceEntity entrustReceEntity = entrustReceService.findById(updateExportStatusRequest.getEntrustId());
if (entrustReceEntity == null) {
return ResultVOUtils.error(500, "无验收权限!");
} else {
if (orderEntity.getFromType().intValue() != ConstantStatus.FROM_CHANGE && orderEntity.getFromType().intValue() != ConstantStatus.FROM_PEACE_CHANGE) {
if (StrUtil.isNotEmpty(entrustReceEntity.getEntrustAction())) {
transferOrder(orderEntity, entrustReceEntity);
}
}
if (!entrustReceEntity.getFinishRece()) {
redisUtil.del(ConstantStatus.REDIS_BILLNO + orderEntity.getBillNo());
redisUtil.del(ConstantStatus.REDIS_BILLNO_CODES + orderEntity.getBillNo());
return ResultVOUtils.success("验收成功!");
} else {
return updateReview(authAdmin, orderEntity);
}
}
} else {
return updateReview(authAdmin, orderEntity);
}
}
@Resource
IBasicBussinessTypeService basicBussinessTypeService;
@Resource
GennerOrderUtils gennerOrderUtils;
@Resource
SystemParamConfigService systemParamConfigService;
public void transferOrder(IoOrderEntity orderEntity, EntrustReceEntity entrustReceEntity) {
List<IoCodeEntity> warehouseEntities = codeService.findByOrderId(orderEntity.getBillNo());
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(entrustReceEntity.getEntrustAction());
IoOrderEntity supplementOrder = new IoOrderEntity();
BeanUtil.copyProperties(orderEntity, supplementOrder);
//生成补单单号
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
String supplementOrderNo = orderNo;
supplementOrder.setOriginUllageSupNo(orderEntity.getBillNo());
supplementOrder.setBillNo(supplementOrderNo);
// SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("additional_auto_submit");
// if ("1".equals(systemParamConfigEntity.getParamValue())) {
// supplementOrder.setStatus(ConstantStatus.ORDER_STATUS_PROCESS); //设置状态为补录单据
// } else {
// supplementOrder.setStatus(ConstantStatus.ORDER_STATUS_ADDITIONAL); //设置状态为补录单据
// }
supplementOrder.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE); //设置导出状态为未导出
supplementOrder.setCorpOrderId(CustomUtil.getId() + "x");
//修改往来单位及当前库存号
supplementOrder.setFromCorp(null);
supplementOrder.setFromDeptCode(orderEntity.getDeptCode());
supplementOrder.setFromInvCode(orderEntity.getInvCode());
supplementOrder.setDeptCode(entrustReceEntity.getEntrustDept());
supplementOrder.setInvCode(entrustReceEntity.getEntrustInv());
supplementOrder.setFromType(ConstantStatus.FROM_REVIEW);
supplementOrder.setMainAction(bussinessTypeEntity.getMainAction());
supplementOrder.setAction(bussinessTypeEntity.getAction());
orderEntity.setBusType(bussinessTypeEntity.getBusType());
//复制码表
List<IoCodeTempEntity> supplementCodes = new ArrayList<>();
warehouseEntities.forEach(
code -> {
IoCodeTempEntity supplementCode = new IoCodeTempEntity();
BeanUtil.copyProperties(code, supplementCode);
supplementCode.setInvCode(supplementOrder.getInvCode());
supplementCode.setDeptCode(supplementOrder.getDeptCode());
supplementCode.setOrderId(supplementOrderNo);
//查询补单设置
supplementCode.setAction(bussinessTypeEntity.getSupplementOrderType());
supplementCode.setMainAction(bussinessTypeEntity.getMainAction());
supplementCode.setId(null);
supplementCodes.add(supplementCode);
}
);
//更新数据
orderService.insertOrder(supplementOrder);
orderEntity.setUllageSupNo(supplementOrder.getBillNo());
orderService.update(orderEntity);
codeTempService.insertBatch(supplementCodes);
}
public int checkCodeExit(String code, List<IoCodeEntity> codesList) {
if (StrUtil.isNotEmpty(code)) {
code = code.replace("\r\n", "");
}
if (code.endsWith("\u001D")) {
code = code.replace("\u001D", "");
}
for (IoCodeEntity checkOrderCodesBean : codesList) {
if (checkOrderCodesBean.getCode().toUpperCase(Locale.ROOT).equals(code.toUpperCase(Locale.ROOT))) {
if (checkOrderCodesBean.getStatus() == Constant.DB_CHECK_ED
&& checkOrderCodesBean.getMyCount() == checkOrderCodesBean.getScanCount()) {
return Constant.CHECK_REPEAT;
}
int curCount = checkOrderCodesBean.getScanCount() + calCountUtil.getActCount(checkOrderCodesBean.getNameCode());
if (curCount == checkOrderCodesBean.getMyCount()) {
checkOrderCodesBean.setStatus(Constant.DB_CHECK_ED);
}
checkOrderCodesBean.setScanCount(curCount);
return Constant.CHECK_EXIT;
}
}
return Constant.CHECK_NULL;
}
public IoCodeEntity isExit(List<IoCodeEntity> codeList, String code) {
if (CollUtil.isNotEmpty(codeList)) {
for (IoCodeEntity codeEntity : codeList) {
if (codeEntity.getCode().equals(code)) {
return codeEntity;
}
}
}
return null;
}
public boolean vailFinish(List<IoOrderDetailResultResponse> orderDetailResultResponses) {
if (CollUtil.isNotEmpty(orderDetailResultResponses)) {
for (IoOrderDetailResultResponse stockOrderDetailEntity : orderDetailResultResponses) {
if (stockOrderDetailEntity.getCount() != stockOrderDetailEntity.getAcceptCount()) {
return false;
}
}
return true;
}
return false;
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/stock/order/acceptClear")
public BaseResponse acceptClear(@RequestBody AcceptOrderResponse acceptOrderEntity) {
String billNo = acceptOrderEntity.getBillNo();
redisUtil.del(ConstantStatus.REDIS_BILLNO + billNo);
redisUtil.del(ConstantStatus.REDIS_BILLNO_CODES + billNo);
FilterOrderDetailResultRequest filterOrderDetailResultRequest = new FilterOrderDetailResultRequest();
filterOrderDetailResultRequest.setOrderIdFk(billNo);
List<IoOrderDetailResultResponse> orderDetailResultResponses = orderDetailResultService.filterList(filterOrderDetailResultRequest);
acceptOrderEntity.setOrderDetailEntities(orderDetailResultResponses);
return ResultVOUtils.success(acceptOrderEntity);
}
public BaseResponse updateReview(AuthAdmin authAdmin, IoOrderEntity orderEntity) {
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_AUDITED);
orderEntity.setReviewUser(authAdmin.getId() + "");
orderEntity.setUpdateTime(new Date());
orderEntity.setAuditTime(new Date());
orderService.update(orderEntity);
redisUtil.del(ConstantStatus.REDIS_BILLNO + orderEntity.getBillNo());
redisUtil.del(ConstantStatus.REDIS_BILLNO_CODES + orderEntity.getBillNo());
//验收完成->进入流程
ioCheckInoutService.checkSecond(orderEntity);
return ResultVOUtils.success("更新成功");
}
//前端第二次次验收
public BaseResponse thirdUpdateReview(AuthAdmin authAdmin, IoOrderEntity orderEntity) {
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK_REW);
orderEntity.setCheckUser(authAdmin.getId() + "");
orderEntity.setUpdateTime(new Date());
orderEntity.setCheckTime(new Date());
orderEntity.setDeliveryStatus(ConstantStatus.ORDER_DELIVERY_STATUS_ED);
orderService.update(orderEntity);
redisUtil.del(ConstantStatus.REDIS_BILLNO + orderEntity.getBillNo());
redisUtil.del(ConstantStatus.REDIS_BILLNO_CODES + orderEntity.getBillNo());
//验收完成->进入流程
ioCheckInoutService.checkThird(orderEntity);
return ResultVOUtils.success("更新成功");
}
@Resource
HeartService heartService;
@Resource
SpGetHttpClient spGetHttp;
// 新增扫码验收单,本地不存在拉去自助平台待验收单
@AuthRuleAnnotation("")
@PostMapping("/udiwms/order/reviewSpms")
public BaseResponse reviewSpms(@RequestBody ReviewSpmsRequest reviewSpmsRequest) {
String billNo = reviewSpmsRequest.getBillNo();
if (StrUtil.isEmpty(reviewSpmsRequest.getBillNo())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
AcceptOrderResponse acceptOrderEntity = new AcceptOrderResponse();
Long userId = getUserId();
String errMsg = checkReviewAuth(billNo, userId + "");
EntrustReceEntity entrustReceEntity;
if (StrUtil.isNotEmpty(errMsg)) {
if (errMsg.equals("委托验收")) {
IoOrderEntity orderEntity = orderService.findByBillNo(billNo);
entrustReceEntity = entrustReceService.findByUnique(orderEntity.getAction(), userId);
if (entrustReceEntity != null) {
acceptOrderEntity.setEntrust(true);
} else
return ResultVOUtils.error(500, "无权限验收!");
} else
return ResultVOUtils.error(500, errMsg);
}
acceptOrderEntity.setBillNo(billNo);
List<IoOrderDetailResultResponse> datas = (List<IoOrderDetailResultResponse>) redisUtil.get(ConstantStatus.REDIS_BILLNO + billNo);
IoOrderResponse orderResponse;
if (CollUtil.isNotEmpty(datas)) {
orderResponse = orderService.findGroupBillNo(billNo);
acceptOrderEntity.setOrderDetailEntities(datas);
acceptOrderEntity.setOrderEntity(orderResponse);
acceptOrderEntity.setExitAccept(true);
} else {
FilterOrderDetailResultRequest filterOrderDetailResultRequest = new FilterOrderDetailResultRequest();
filterOrderDetailResultRequest.setOrderIdFk(billNo);
List<IoOrderDetailResultResponse> orderDetailResultResponses = orderDetailResultService.filterList(filterOrderDetailResultRequest);
//本地已存在,则直接返回
if (CollUtil.isNotEmpty(orderDetailResultResponses)) {
acceptOrderEntity.setOrderDetailEntities(orderDetailResultResponses);
orderResponse = orderService.findGroupBillNo(billNo);
acceptOrderEntity.setOrderEntity(orderResponse);
acceptOrderEntity.setExitAccept(false);
} else {
//获取自助平台待审核单据,并插入到数据库
BaseResponse<SpsSyncOrderResponse> baseResponse = spGetHttp.getReviewOrder(reviewSpmsRequest, userId + "");
if (baseResponse.getCode() == 20000) {
SpsSyncOrderResponse spsSyncOrderResponse = baseResponse.getData();
List<IoOrderEntity> orderEntities = spsSyncOrderResponse.getOrderEntities();
if (CollUtil.isNotEmpty(orderEntities)) {
IoOrderEntity orderEntity;
orderEntity = orderEntities.get(0);
orderEntity.setUpdateTime(null);
orderEntity.setFromType(ConstantStatus.FROM_UDISP);
orderEntity.setReviewSp(true);
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESS);
IoOrderEntity temp = orderService.findByBillNo(orderEntity.getBillNo());
if (temp == null) {
orderEntity.setId(null);
orderService.insertOrder(orderEntity);
heartService.insetOrderDb(spsSyncOrderResponse, orderEntity);
orderEntity = orderService.findByBillNo(orderEntity.getBillNo());
addInoutService.dealProcess(orderEntity);
orderEntity = orderService.findByBillNo(orderEntity.getBillNo());
if (orderEntity.getStatus() != ConstantStatus.ORDER_STATS_ERROR && !ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
ioCheckInoutService.check(orderEntity.getBillNo());
}
}
FilterOrderDetailResultRequest tempRequest = new FilterOrderDetailResultRequest();
tempRequest.setOrderIdFk(billNo);
List<IoOrderDetailResultResponse> detailResultResponses = orderDetailResultService.filterList(tempRequest);
if (CollUtil.isNotEmpty(detailResultResponses)) {
acceptOrderEntity.setOrderDetailEntities(detailResultResponses);
acceptOrderEntity.setExitAccept(false);
orderResponse = orderService.findGroupBillNo(billNo);
acceptOrderEntity.setOrderEntity(orderResponse);
}
}
} else {
return ResultVOUtils.error(500, baseResponse.getMessage());
}
}
}
return ResultVOUtils.success(acceptOrderEntity);
}
@Resource
IoAddInoutService addInoutService;
@Resource
InvBusUserService invBusUserService;
//校验用户是否验收权限
private String checkReviewAuth(String orderId, String userId) {
IoOrderEntity orderEntity = orderService.findByBillNo(orderId);
if (orderEntity == null) {
ReviewSpmsRequest reviewSpmsRequest = new ReviewSpmsRequest();
reviewSpmsRequest.setBillNo(orderId);
BaseResponse<IoOrderEntity> response = spGetHttp.getSimpleOrder(reviewSpmsRequest, userId);
if (response.getCode() == 20000 && response.getData() != null) {
orderEntity = response.getData();
} else {
return "单据不存在!";
}
}
if (orderEntity.getStatus() != ConstantStatus.ORDER_STATUS_CHECK_REW && orderEntity.getStatus() != ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
return "单据非未验收状态,无法审核!";
}
if (!invBusUserService.exitBus(userId, orderEntity.getAction())) {
EntrustReceEntity entrustReceEntity = entrustReceService.findByUnique(orderEntity.getAction(), Long.parseLong(userId));
if (entrustReceEntity == null) {
return "无验收权限!";
} else {
return "委托验收";
}
} else {
return null;
}
}
}

@ -1,100 +0,0 @@
package com.glxp.api.controller.inout;
import com.github.pagehelper.PageInfo;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.inout.*;
import com.glxp.api.req.inout.FilterStatDataDetailRequest;
import com.glxp.api.req.inout.FilterStatDataRequest;
import com.glxp.api.service.inout.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
*
*/
@Slf4j
@RestController
public class IoStatDataController {
@Resource
private IoStatOrderService statOrderService;
@Resource
private IoStatDayService statDayService;
@Resource
private IoStatMonthService statMonthService;
@Resource
private IoStatQuarterService statQuarterService;
@Resource
private IoStatYearService statYearService;
/**
*
*
* @param statDataRequest
* @return
*/
@GetMapping("/udiwms/inout/stat/filter")
public BaseResponse filterList(FilterStatDataRequest statDataRequest) {
List<IoStatOrderEntity> list = statOrderService.filterList(statDataRequest);
PageInfo<IoStatOrderEntity> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
/**
*
*
* @param statDataDetailRequest
* @return
*/
@GetMapping("/udiwms/inout/stat/detail/day/filter")
public BaseResponse filterDayList(FilterStatDataDetailRequest statDataDetailRequest) {
List<IoStatDayEntity> list = statDayService.filterList(statDataDetailRequest);
PageInfo<IoStatDayEntity> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
/**
*
*
* @param statDataDetailRequest
* @return
*/
@GetMapping("/udiwms/inout/detail/month/filter")
public BaseResponse filterMonthList(FilterStatDataDetailRequest statDataDetailRequest) {
List<IoStatMonthEntity> list = statMonthService.filterList(statDataDetailRequest);
PageInfo<IoStatMonthEntity> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
/**
*
*
* @param statDataDetailRequest
* @return
*/
@GetMapping("/udiwms/inout/detail/quarter/filter")
public BaseResponse filterQuarterList(FilterStatDataDetailRequest statDataDetailRequest) {
List<IoStatQuarterEntity> list = statQuarterService.filterList(statDataDetailRequest);
PageInfo<IoStatQuarterEntity> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
/**
*
*
* @param statDataDetailRequest
* @return
*/
@GetMapping("/udiwms/inout/detail/year/filter")
public BaseResponse filterYearList(FilterStatDataDetailRequest statDataDetailRequest) {
List<IoStatYearEntity> list = statYearService.filterList(statDataDetailRequest);
PageInfo<IoStatYearEntity> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
}

@ -1,151 +0,0 @@
package com.glxp.api.controller.inout;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageInfo;
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.entity.basic.UdiEntity;
import com.glxp.api.entity.basic.UdiProductEntity;
import com.glxp.api.entity.inout.IoCodeRelEntity;
import com.glxp.api.req.inout.IoOrderRelRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.IoCodeRelResponse;
import com.glxp.api.service.basic.UdiProductService;
import com.glxp.api.service.inout.IoCodeRelService;
import com.glxp.api.util.udi.FilterUdiUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RestController
public class ioCodeRelController {
@Resource
IoCodeRelService ioCodeRelServicec;
@Resource
UdiProductService udiProductService;
@GetMapping("/udi/ioCode/Rel/list")
public BaseResponse list(IoOrderRelRequest ioOrderRelRequest) {
List<IoCodeRelResponse> list = ioCodeRelServicec.selectIoCodeRelList(ioOrderRelRequest);
PageInfo<IoCodeRelResponse> pageInfo;
pageInfo = new PageInfo<>(list);
PageSimpleResponse<IoCodeRelResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(list);
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("/udi/ioCode/Rel/checkUpProduct")
public BaseResponse checkUpProduct(String code) {
//判断码有没有重复
List<IoCodeRelEntity> list = ioCodeRelServicec.selectIoCodeRelByCode("", code);
if (list.size() > 0) {
return ResultVOUtils.error(999, "此码已做关联!");
}
if (StrUtil.isNotEmpty(code)) {
UdiEntity udiEntity = FilterUdiUtils.getGS1Udi(code);
if (udiEntity == null) {
return ResultVOUtils.error(500, "UDI码格式错误");
}
UdiProductEntity udiProductEntity = udiProductService.findByNameCode(udiEntity.getUdi());
if (udiProductEntity.getPackLevel() != null) {
if (Integer.valueOf(udiProductEntity.getPackLevel()) > 1) {
return ResultVOUtils.success(udiProductEntity.getBhxjcpbm());
}
}
}
return ResultVOUtils.error(999, "扫码错误!");
}
@GetMapping("/udi/ioCode/Rel/checkLowProduct")
@Log(title = "单据管理", businessType = BusinessType.INSERT)
public BaseResponse checkLowProduct(String upCode, String lowCode) {
UdiProductEntity udiProductEntity = new UdiProductEntity();
//查询上级产品信息
if (StrUtil.isNotEmpty(upCode)) {
UdiEntity udiEntity = FilterUdiUtils.getGS1Udi(upCode);
udiProductEntity = udiProductService.findByNameCode(udiEntity.getUdi());
}
//判断码有没有重复
List<IoCodeRelEntity> list = ioCodeRelServicec.selectIoCodeRelByCode(lowCode, upCode);
if (list.size() > 0) {
return ResultVOUtils.error(999, "此码已做关联!");
}
//判断条数是否超出
Long count = ioCodeRelServicec.selectIoCodeRelCount(upCode);
if (count >= udiProductEntity.getBhxjsl()) {
return ResultVOUtils.error(999, "数量超出!");
}
//查询下级产品信息
if (StrUtil.isNotEmpty(lowCode)) {
UdiEntity udiEntity = FilterUdiUtils.getGS1Udi(lowCode);
UdiProductEntity udiProductEntity1 = udiProductService.findByNameCode(udiEntity.getUdi());
if (udiProductEntity != null) {
if (udiProductEntity1.getNameCode().equals(udiProductEntity.getBhxjcpbm())) {
IoCodeRelEntity ioCodeRelEntity = new IoCodeRelEntity();
ioCodeRelEntity.setCode(lowCode);
ioCodeRelEntity.setParentCode(upCode);
ioCodeRelEntity.setNameCode(udiProductEntity1.getNameCode());
ioCodeRelEntity.setDiType(udiProductEntity1.getDiType());
ioCodeRelEntity.setLevel(udiProductEntity1.getPackLevel());
ioCodeRelEntity.setProduceDate(udiProductEntity1.getProduceDate());
ioCodeRelEntity.setExpireDate(udiProductEntity1.getExpireDate());
ioCodeRelEntity.setSerialNo(udiProductEntity1.getSerialNo());
ioCodeRelEntity.setCreateTime(new Date());
ioCodeRelEntity.setUpdateTime(new Date());
ioCodeRelEntity.setId(IdUtil.getSnowflakeNextId());
ioCodeRelServicec.insert(ioCodeRelEntity);
return ResultVOUtils.success();
} else {
return ResultVOUtils.error(999, "该条码不属于下级产品!");
}
}
}
return ResultVOUtils.error(999, "");
}
@GetMapping("/udi/ioCode/Rel/delectList")
public BaseResponse delectList(IoOrderRelRequest ioOrderRelRequest) {
List<IoCodeRelResponse> list = ioCodeRelServicec.selectIoCodeRelDetailList(ioOrderRelRequest);
PageInfo<IoCodeRelResponse> pageInfo;
pageInfo = new PageInfo<>(list);
PageSimpleResponse<IoCodeRelResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(list);
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("/udi/ioCode/Rel/del")
@Log(title = "单据管理", businessType = BusinessType.DELETE)
public BaseResponse del(String code, String parentCode) {
int count = ioCodeRelServicec.delIoCodeRel(code, parentCode);
if (count > 0) {
return ResultVOUtils.success("删除成功");
} else {
return ResultVOUtils.error(999, "删除失败");
}
}
}

@ -1,149 +0,0 @@
package com.glxp.api.controller.sync;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageInfo;
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.sync.BasicDownloadStatusEntity;
import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.req.sync.BasicDownloadRequest;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.service.sync.BasicDownloadService;
import com.glxp.api.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
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.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.List;
@Slf4j
@RestController
public class SpsSyncDownloadController {
@Resource
BasicDownloadService basicDownloadService;
@Resource
RedisUtil redisUtil;
@Resource
SpGetHttpClient spGetHttp;
@GetMapping("/spssync/download/basic/udiinfo/getStatus")
public BaseResponse getStatus(BasicDownloadRequest basicDownloadRequest) {
List<BasicDownloadStatusEntity> basicDownloadStatusEntities = basicDownloadService.filterDownloadStatus(basicDownloadRequest);
return ResultVOUtils.success(basicDownloadStatusEntities);
}
@GetMapping("/spssync/download/basic/udiinfo/filter")
public BaseResponse filterStatus(BasicDownloadRequest basicDownloadRequest) {
List<BasicDownloadStatusEntity> basicDownloadStatusEntities = basicDownloadService.filterDownloadStatus(basicDownloadRequest);
PageInfo<BasicDownloadStatusEntity> pageInfo;
pageInfo = new PageInfo<>(basicDownloadStatusEntities);
PageSimpleResponse<BasicDownloadStatusEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(basicDownloadStatusEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@PostMapping("/spssync/download/basic/udiinfo/deleteByStatus")
public BaseResponse deleteByStatus(@RequestBody DeleteRequest deleteRequest) {
boolean b = basicDownloadService.deleteById(deleteRequest.getId());
redisUtil.del(deleteRequest.getId());
if (b)
return ResultVOUtils.success("删除成功!");
else
return ResultVOUtils.error(500, "删除失败!");
}
@PostMapping("/spssync/download/basic/udiinfo/updateStatus")
public BaseResponse updateStatus(@RequestBody BasicDownloadStatusEntity basicDownloadStatusEntity) {
basicDownloadStatusEntity.setEndTime(new Date());
basicDownloadStatusEntity.setUpdateTime(new Date());
boolean b = basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
if (b)
return ResultVOUtils.success("更新成功!");
else
return ResultVOUtils.error(500, "更新成功!");
}
@GetMapping("/spssync/download/basic/connect/test")
public BaseResponse testConnect() {
return spGetHttp.testConnect();
}
@GetMapping("/sps/sync/download/info/file")
public void downloadFile(HttpServletResponse response, String id){
if (StrUtil.isBlank(id)) {
throw new RuntimeException("缺少唯一标识");
}
BasicDownloadStatusEntity info = basicDownloadService.getById(id);
if (info == null) {
throw new RuntimeException("数据不存在");
}
if (StrUtil.isBlank(info.getCacheFilePath())) {
throw new RuntimeException("文件未生成");
}
File file = new File(info.getCacheFilePath());
if (!file.exists()) {
throw new RuntimeException("文件丢失");
}
String[] split = info.getCacheFilePath().split("/");
String enFileName = URLEncoder.encode(split[split.length - 1], StandardCharsets.UTF_8);
// 设值返回文件属性,浏览器会根据属性调用下载文件方法
response.addHeader("Content-Disposition", "attachment;filename=" + enFileName);
// 前端获取文件名,需要解码
response.addHeader("downLoadName", enFileName);
// 定义输出流
ServletOutputStream outputStream = null;
FileInputStream fileInputStream = null;
try {
outputStream = response.getOutputStream();
// 定义输出类型为二进制流输出
response.setContentType("application/octet-stream");
fileInputStream = new FileInputStream(file);
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read(bytes);
// 把流写入response
outputStream.write(bytes);
// flush落盘
outputStream.flush();
// 关闭输出流
outputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}
}

@ -1,234 +0,0 @@
package com.glxp.api.controller.sync;
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.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.dao.system.SyncDataSetDao;
import com.glxp.api.entity.sync.BasicDownloadStatusEntity;
import com.glxp.api.entity.sync.BasicExportStatusEntity;
import com.glxp.api.entity.sync.BasicExportStatusTimeEntity;
import com.glxp.api.entity.system.SyncDataSetEntity;
import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.req.sync.BasicExportStatusRequest;
import com.glxp.api.req.sync.BasicExportTimeRequest;
import com.glxp.api.req.sync.ManualUploadDataReq;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.system.SyncDataSetResponse;
import com.glxp.api.service.sync.*;
import com.glxp.api.task.TaskExecutorConfig;
import com.glxp.api.util.BeanCopyUtils;
import com.glxp.api.util.DateUtil;
import com.glxp.api.util.RedisUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
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.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@Slf4j
@RestController
@RequiredArgsConstructor
public class SpsSyncExportStatusController {
@Resource
BasicExportService basicExportService;
@Resource
BasicDownloadService basicDownloadService;
@Resource
BasicExportTimeService basicExportTimeService;
@Resource
RedisUtil redisUtil;
@Resource
SpGetHttpClient spGetHttp;
@GetMapping("/spssync/basic/udiinfo/getStatus")
public BaseResponse getStatus(BasicExportStatusRequest basicExportStatusRequest) {
List<BasicExportStatusEntity> basicExportStatusEntities = basicExportService.filterExportStatus(basicExportStatusRequest);
return ResultVOUtils.success(basicExportStatusEntities);
}
@GetMapping("/spssync/basic/udiinfo/filter")
public BaseResponse filterStatus(BasicExportStatusRequest basicExportStatusRequest) {
log.info(Thread.currentThread().getName() + "--" + Thread.currentThread().getId());
List<BasicExportStatusEntity> basicExportStatusEntities = basicExportService.filterExportStatus(basicExportStatusRequest);
PageInfo<BasicExportStatusEntity> pageInfo;
pageInfo = new PageInfo<>(basicExportStatusEntities);
PageSimpleResponse<BasicExportStatusEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(basicExportStatusEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@PostMapping("/spssync/basic/udiinfo/deleteByStatus")
public BaseResponse deleteByStatus(@RequestBody DeleteRequest deleteRequest) {
if (StrUtil.isBlank(deleteRequest.getId())) {
return ResultVOUtils.error(500, "缺少唯一标识");
}
boolean b = basicExportService.deleteById(deleteRequest.getId());
redisUtil.del(deleteRequest.getId());
if (b)
return ResultVOUtils.success("删除成功!");
else
return ResultVOUtils.error(500, "删除失败!");
}
@PostMapping("/spssync/basic/udiinfo/updateStatus")
public BaseResponse updateStatus(@RequestBody BasicExportStatusEntity basicExportStatusEntity) {
basicExportStatusEntity.setEndTime(new Date());
basicExportStatusEntity.setUpdateTime(new Date());
boolean b = basicExportService.updateExportStatus(basicExportStatusEntity);
if (b)
return ResultVOUtils.success("更新成功!");
else
return ResultVOUtils.error(500, "更新成功!");
}
@GetMapping("/spssync/basic/connect/test")
public BaseResponse testConnect() {
return spGetHttp.testConnect();
}
@GetMapping("/spssync/basic/schedule/lastTime")
public BaseResponse getLastUpdateTime(BasicExportTimeRequest basicExportTimeRequest) {
List<BasicExportStatusTimeEntity> basicExportStatusEntities = basicExportTimeService.filterExportStatus(basicExportTimeRequest);
if (CollUtil.isNotEmpty(basicExportStatusEntities)) {
return ResultVOUtils.success(basicExportStatusEntities.get(0).getLastUpdateTime());
} else {
return ResultVOUtils.success("1949-01-01 00:00:00");
}
}
@PostMapping("/spssync/basic/schedule/updateLastTime")
public BaseResponse updateLastTime(@RequestBody BasicExportStatusTimeEntity basicExportStatusTimeEntity) {
boolean b = basicExportTimeService.insertExportStatus(basicExportStatusTimeEntity);
if (b)
return ResultVOUtils.success("更新成功!");
else
return ResultVOUtils.error(500, "更新失败!");
}
@AuthRuleAnnotation("")
@PostMapping("/spssync/basic/udiinfo/infoByStatus")
public void infoByStatus(HttpServletResponse response, @RequestBody DeleteRequest deleteRequest) throws IOException {
if (StrUtil.isBlank(deleteRequest.getId())) {
throw new RuntimeException("缺少唯一标识");
}
BasicExportStatusEntity info = new BasicExportStatusEntity();
if (deleteRequest.getDlType() != null && deleteRequest.getDlType() == 1) {
info = basicExportService.getById(deleteRequest.getId());
} else {
BasicDownloadStatusEntity basicDownloadStatusEntity = basicDownloadService.getById(deleteRequest.getId());
BeanUtils.copyProperties(basicDownloadStatusEntity, info);
}
if (info == null) {
throw new RuntimeException("数据不存在");
}
if (StrUtil.isBlank(info.getCacheFilePath())) {
throw new RuntimeException("文件未生成");
}
File file = new File(info.getCacheFilePath());
if (!file.exists()) {
throw new RuntimeException("文件丢失");
}
String[] split = info.getCacheFilePath().split("/");
String enFileName = URLEncoder.encode(split[split.length - 1], StandardCharsets.UTF_8);
// 设值返回文件属性,浏览器会根据属性调用下载文件方法
response.addHeader("Content-Disposition", "attachment;filename=" + enFileName);
// 前端获取文件名,需要解码
response.addHeader("downLoadName", enFileName);
// 定义输出流
ServletOutputStream outputStream = null;
FileInputStream fileInputStream = null;
try {
outputStream = response.getOutputStream();
// 定义输出类型为二进制流输出
response.setContentType("application/octet-stream");
fileInputStream = new FileInputStream(file);
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read(bytes);
// 把流写入response
outputStream.write(bytes);
// flush落盘
outputStream.flush();
// 关闭输出流
outputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (outputStream != null) {
outputStream.close();
}
if (fileInputStream != null) {
fileInputStream.close();
}
}
}
private final SyncDataSetDao syncDataSetDao;
private final HeartService heartService;
private final ThreadPoolTaskExecutor executorConfig;
/**
*
*
* @param req
* @return
*/
@AuthRuleAnnotation("")
@PostMapping("/spssync/udiinfo/uploadData")
public BaseResponse uploadData(@RequestBody ManualUploadDataReq req) {
if (req.getExportType() == null || req.getSyncTime() == null) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
SyncDataSetEntity syncDataSetEntity = syncDataSetDao.selectSet();
if (syncDataSetEntity.getSyncTime() == null) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), "缺少初始化数据");
}
CompletableFuture future = CompletableFuture.runAsync(() -> {
switch (req.getExportType()) {
case IO_ORDER:
heartService.uploadAllBusOrder(DateUtil.formatDateTime(req.getSyncTime()));
heartService.uploadAllOrder(DateUtil.formatDateTime(req.getSyncTime()));
break;
default:
heartService.pushData(syncDataSetEntity, req.getSyncTime(), req.getExportType());
}
}, executorConfig);
return ResultVOUtils.success();
}
}

@ -1,105 +0,0 @@
package com.glxp.api.controller.sync;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.constant.Constant;
import com.glxp.api.entity.system.SyncDataBustypeEntity;
import com.glxp.api.entity.system.SyncDataSetEntity;
import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.res.system.SyncDataSetResponse;
import com.glxp.api.service.sync.SyncDataBustypeService;
import com.glxp.api.service.sync.SyncDataChangeBustypeService;
import com.glxp.api.service.sync.SyncDataSetService;
import com.glxp.api.util.RedisUtil;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import org.springframework.beans.BeanUtils;
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.Date;
import java.util.List;
@RestController
public class SyncDataSetController {
@Resource
private SyncDataSetService syncDataSetService;
@Resource
private SyncDataBustypeService syncDataBustypeService;
@Resource
private SyncDataChangeBustypeService syncDataChangeBustypeService;
@Resource
private RedisUtil redisUtil;
@Resource
SpGetHttpClient spGetHttpClient;
@AuthRuleAnnotation("system/param/syncData/config")
@GetMapping("/system/param/syncData/config")
public BaseResponse list() {
Integer delaySyncTime = (Integer) redisUtil.get(Constant.DELAY_SYNC_TIME);
if (delaySyncTime != null) {
long time = redisUtil.getExpire(Constant.DELAY_SYNC_TIME);
delaySyncTime = Math.toIntExact(time) / 60;
}
SyncDataSetResponse syncDataSetResponse = syncDataSetService.selectSet();
syncDataSetResponse.setDelaySyncTime(delaySyncTime);
return ResultVOUtils.success(syncDataSetResponse);
}
@AuthRuleAnnotation("system/param/syncData/save")
@PostMapping("/system/param/syncData/save")
public BaseResponse save(@RequestBody @Valid SyncDataSetResponse syncDataSetResponse
) {
SyncDataSetEntity syncDataSetEntity = new SyncDataSetEntity();
BeanUtils.copyProperties(syncDataSetResponse, syncDataSetEntity);
syncDataSetEntity.setUpdateTime(new Date());
syncDataSetEntity.setId(1);
List<SyncDataBustypeEntity> busTypes = syncDataSetResponse.getBusTypes();
syncDataBustypeService.deleteAll(1);
if (CollUtil.isNotEmpty(busTypes)) {
syncDataBustypeService.inserts(busTypes);
}
List<SyncDataBustypeEntity> toInBusTypes = syncDataSetResponse.getToInBusTypes();
syncDataBustypeService.deleteAll(2);
if (CollUtil.isNotEmpty(toInBusTypes)) {
syncDataBustypeService.inserts(toInBusTypes);
}
if (CollUtil.isNotEmpty(syncDataSetResponse.getChangeBusTypes())) {
syncDataChangeBustypeService.deleteAll();
syncDataChangeBustypeService.inserts(syncDataSetResponse.getChangeBusTypes());
}
boolean b = syncDataSetService.insert(syncDataSetEntity);
if (syncDataSetResponse.getDelaySyncTime() != null &&
syncDataSetResponse.getDelaySyncTime() > 0) {
redisUtil.set(Constant.DELAY_SYNC_TIME, syncDataSetResponse.getDelaySyncTime(), (syncDataSetResponse.getDelaySyncTime() + 1) * 60);
redisUtil.set("SPS_SYNC_GEN_DATA", System.currentTimeMillis() + syncDataSetResponse.getDelaySyncTime() * 60 * 1000);
}
if (!b) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
//todo 请立即同步至UDI管理系统
BaseResponse<String> baseResponse = spGetHttpClient.updateSynsSet(syncDataSetResponse);
if (baseResponse.getCode() == 20000) {
return baseResponse;
} else {
return ResultVOUtils.error(500, "UDI管理系统设置成功自助平台修改失败");
}
}
}

@ -1,35 +0,0 @@
package com.glxp.api.idc.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.idc.service.ConnectService;
/**
*
*/
@RestController
public class ConnectController {
@Resource
ConnectService connectService;
@RequestMapping(value = "/spssync/common/connect")
@ResponseBody
public BaseResponse connect(HttpServletRequest request, @RequestBody Map<String, Object> params) {
return connectService.connectStatus(request,params);
}
}

@ -1,37 +0,0 @@
package com.glxp.api.idc.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.idc.service.DeleteService;
/**
*
*/
@RestController
public class DeleteController {
@Resource
DeleteService deleteService;
@RequestMapping(value = "/spssync/common/delete")
@ResponseBody
public BaseResponse delete(HttpServletRequest request, @RequestBody Map<String, Object> params) {
if(deleteService.syncDelete(params))
return ResultVOUtils.success();
return ResultVOUtils.error(9999, "失败");
}
}

@ -1,55 +0,0 @@
package com.glxp.api.idc.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.idc.service.FileService;
/**
*
*/
@RestController
public class FileController {
@Resource
FileService fileService;
@RequestMapping(value = "/spssync/file/upload")
@ResponseBody
public BaseResponse upload(HttpServletRequest request, @RequestBody Map<String, Object> params) {
return fileService.fileUpload(request, params);
}
@RequestMapping(value = "/spssync/file/download")
@ResponseBody
public BaseResponse download(HttpServletRequest request, @RequestBody Map<String, Object> params) {
return fileService.fileDownload(request, params);
}
@RequestMapping(value = "/spssync/file/downloadFile")
@ResponseBody
public BaseResponse downloadFile(HttpServletRequest request, @RequestBody Map<String, Object> params) {
return fileService.downloadFile(request, params);
}
@RequestMapping(value = "/spssync/file/uploadFile")
public BaseResponse uploadFile(HttpServletRequest request,
@RequestParam(value = "content", required = false) String content,
@RequestParam(value = "files", required = false) MultipartFile[] files) {
//
return fileService.receiveFile(request, content, files);
}
}

@ -1,209 +0,0 @@
package com.glxp.api.idc.controller;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.dao.idc.DbDao;
import com.glxp.api.idc.service.IdcService;
import com.glxp.api.idc.utils.UriUtils;
import com.glxp.api.service.system.SystemParamConfigService;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
/**
*
*/
@Slf4j
@RestController
public class IdcController {
@Resource
IdcService idcService;
@Resource
DbDao dbDao;
@Resource
UriUtils uriUtils;
/*通用上传接口*/
//@Log("中继服务数据接收,下级往上级上传")
@RequestMapping(value = "/spssync/common/upload")
public BaseResponse upload(HttpServletRequest request,
@RequestParam("content") String content,
@RequestParam(value = "files", required = false) MultipartFile[] files) {
//
return idcService.receive(request, content, files);
}
@RequestMapping(value = "/spssync/common/once")
@ResponseBody
public BaseResponse once(HttpServletRequest request,@RequestBody Map<String, Object> params) {
//
boolean isUpload = params.get("isUpload")!=null && params.get("isUpload").equals("1") ? true : false ;
return idcService.onceSync( params.get("tableName").toString(), isUpload);
}
//@Log("数据同步测试")
@RequestMapping(value = "/spssync/common/test")
public BaseResponse test(HttpServletRequest request, @RequestBody Map<String, Object> params) {
//
return idcService.send(params);
}
//@Log("数据同步任务列表拉取")
@RequestMapping(value = "/spssync/common/list")
@ResponseBody
public BaseResponse list(HttpServletRequest request, @RequestBody(required = false) Map<String, Object> params) {
return idcService.taskList(request, params);
}
//@Log("数据同步任务根据任务ID下载数据")
@RequestMapping(value = "/spssync/common/download")
@ResponseBody
public BaseResponse download(HttpServletRequest request, @RequestBody Map<String, Object> params) {
return idcService.download(request, params);
}
@RequestMapping(value = "/spssync/common/uploadStatus")
@ResponseBody
public BaseResponse uploadStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) {
return idcService.uploadStatus(request, params);
}
@RequestMapping(value = "/spssync/common/downloadStatus")
@ResponseBody
public BaseResponse downloadStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) {
return idcService.downloadStatus(request, params);
}
//@Log("数据同步任务根据任务ID,返回下载成功标记")
@RequestMapping(value = "/spssync/common/success")
@ResponseBody
public BaseResponse success(HttpServletRequest request, @RequestBody Map<String, Object> params) {
return idcService.downlaodSuccess(request, params);
}
@RequestMapping(value = "/spssync/common/downloadFile")
public void downloadFile(HttpServletResponse response,@RequestParam String fileName) throws UnsupportedEncodingException {
if (fileName != null) {
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.setContentType("application/force-download");
idcService.downloadFile(fileName, response);
}
}
@RequestMapping("/mapi/**")
public Object mapi(HttpServletRequest request, HttpServletResponse httpServletResponse) {
String uri = uriUtils.parseUri(request.getRequestURL().toString());
log.info(uri);
String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service");
if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) {
uri = uri.replace("mapi/", "");
}
String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_host");
if (StrUtil.isNotEmpty(upperServerHost)) {
uri = upperServerHost + "/" + uri;
}
log.info(uri);
if (uri.contains("getImage")) {
return redirectIamge(request, httpServletResponse, uri);
} else {
return redirect(request, uri);
}
}
private byte[] redirectIamge(HttpServletRequest request, HttpServletResponse httpServletResponse, String uri) {
RestTemplate restTemplate = new RestTemplate();
// HttpEntity<String> httpEntity = buildHeader(request);
log.info(request.getMethod());
Map<String, Object> headerParam = new HashMap<>();
Map<String, Object> bodyParam = new HashMap<String, Object>();
Enumeration pNames = request.getParameterNames();
String parm = "";
while (pNames.hasMoreElements()) {
String name = (String) pNames.nextElement();
String value = request.getParameter(name);
bodyParam.put(name, value);
parm = parm + name + "=" + value + "&";
}
uri = uri + "?" + parm.substring(0, parm.length() - 1);
HttpHeaders headers = new HttpHeaders();
Enumeration<String> enumeration = request.getHeaderNames();
while (enumeration.hasMoreElements()) {
String name = enumeration.nextElement();
String value = request.getHeader(name);
headerParam.put(name, value);
headers.add(name, value);
}
//headers.add("Content-Type", "application/json;charset=UTF-8");
HttpEntity<String> http = new HttpEntity<>(JSON.toJSONString(bodyParam), headers);
log.info(uri);
// ResponseEntity<Resource> entity = restTemplate.exchange(uri, HttpMethod.GET, httpEntity, Resource.class);
// ResponseEntity<Resource> responseEntity = restTemplate.exchange(uri,
// HttpMethod.GET, http, Resource.class, new Object[0]);
// ResponseEntity<HttpServletResponse> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, http, HttpServletResponse.class);
ResponseEntity<byte[]> rsp = restTemplate.getForEntity(uri, byte[].class);
// String targetPath = "D:\\wmslog\\splash-down.png";
// try {
// Files.write(Paths.get(targetPath), Objects.requireNonNull(rsp.getBody(),
// "未获取到下载文件"));
// } catch (IOException e) {
// e.printStackTrace();
// }
return rsp.getBody();
}
@Resource
SystemParamConfigService systemParamConfigService;
private JSONObject redirect(HttpServletRequest request, String uri) {
RestTemplate restTemplate = new RestTemplate();
HttpEntity<String> httpEntity = uriUtils.buildHeader(request);
ResponseEntity<JSONObject> responseBody = null;
if (request.getMethod().equals("POST"))
responseBody = restTemplate.postForEntity(uri, httpEntity, JSONObject.class);
else if (request.getMethod().equals("GET")) {
responseBody = restTemplate.exchange(uri, HttpMethod.GET, httpEntity, JSONObject.class);
} else if (request.getMethod().equals("PUT")) {
responseBody = restTemplate.exchange(uri, HttpMethod.PUT, httpEntity, JSONObject.class);
} else if (request.getMethod().equals("DELETE")) {
responseBody = restTemplate.exchange(uri, HttpMethod.DELETE, httpEntity, JSONObject.class);
}
JSONObject result = responseBody.getBody();
return result;
}
}

@ -1,12 +0,0 @@
package com.glxp.api.idc.service;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.glxp.api.common.res.BaseResponse;
/*连通状态服务*/
public interface ConnectService {
BaseResponse connectStatus(HttpServletRequest request,Map<String,Object> params);
}

@ -1,10 +0,0 @@
package com.glxp.api.idc.service;
import java.util.Map;
/*数据中继删除数据处理*/
public interface DeleteService {
boolean syncDelete(String tableName,String uniqueValue);
boolean syncDelete(Map<String,Object> params);
}

@ -1,52 +0,0 @@
package com.glxp.api.idc.service;
import java.io.IOException;
import java.net.URI;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.RequestCallback;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.ResponseExtractor;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import com.beust.jcommander.internal.Nullable;
import cn.hutool.core.lang.Assert;
public class DownloadRestTemplate extends RestTemplate {
public DownloadRestTemplate(ClientHttpRequestFactory requestFactory) {
super(requestFactory);
}
protected <T> T doExecute(URI url, @Nullable HttpMethod method, @Nullable RequestCallback requestCallback,
@Nullable ResponseExtractor<T> responseExtractor) throws RestClientException {
Assert.notNull(url, "URI is required");
Assert.notNull(method, "HttpMethod is required");
ClientHttpResponse response = null;
try {
ClientHttpRequest request = createRequest(url, method);
if (requestCallback != null) {
requestCallback.doWithRequest(request);
}
response = request.execute();
handleResponse(url, method, response);
return (responseExtractor != null ? responseExtractor.extractData(response) : null);
} catch (IOException ex) {
String resource = url.toString();
String query = url.getRawQuery();
resource = (query != null ? resource.substring(0, resource.indexOf('?')) : resource);
throw new ResourceAccessException("I/O error on " + method.name() +
" request for \"" + resource + "\": " + ex.getMessage(), ex);
}
/*finally {
if (response != null) {
response.close();
}
}*/
}
}

@ -1,21 +0,0 @@
package com.glxp.api.idc.service;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.multipart.MultipartFile;
import com.glxp.api.common.res.BaseResponse;
/*文件服务*/
public interface FileService {
BaseResponse upload(List<String> list);
BaseResponse download(List<String> list);
BaseResponse fileUpload(HttpServletRequest request,Map<String,Object> params);
BaseResponse fileDownload(HttpServletRequest request,Map<String,Object> params);
BaseResponse downloadFile(HttpServletRequest request,Map<String,Object> params);
BaseResponse receiveFile(HttpServletRequest request,String content,MultipartFile[] files);
}

@ -1,44 +0,0 @@
package com.glxp.api.idc.service;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;
import com.glxp.api.common.res.BaseResponse;
/*数据中继数据中心(接收)*/
public interface IdcService {
BaseResponse receive(HttpServletRequest request,
String content,MultipartFile[] files);
BaseResponse receiveJson(HttpServletRequest request,Map<String, Object> params);
BaseResponse uploadFile(HttpServletRequest request,
String content,MultipartFile[] files);
BaseResponse send(Map<String,Object> params);
BaseResponse send(String messageType,String tableName,Map<String,Object> params);
BaseResponse taskList(HttpServletRequest request,Map<String,Object> params);
BaseResponse download(HttpServletRequest request,Map<String,Object> params);
BaseResponse uploadStatus(HttpServletRequest request,Map<String,Object> params);
BaseResponse downloadStatus(HttpServletRequest request,Map<String,Object> params);
public void asyncFetchTask();
public void asyncFetchUdiTask();
BaseResponse downlaodSuccess(HttpServletRequest request,Map<String,Object> params);
void asyncUdiTask();
void asyncSpsTask();
void downloadFile(String fileName,HttpServletResponse response) ;
BaseResponse onceSync(String tableName,boolean isUpload);
boolean signleDownloadFile(String syncIp, String fileName);
boolean batchDownloadFile(String syncIp, String[] files);
}

@ -1,84 +0,0 @@
package com.glxp.api.idc.service.impl;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.dao.idc.DbDao;
import com.glxp.api.idc.service.ConnectService;
import com.glxp.api.idc.utils.IDCUtils;
/*连通检测*/
@Service
public class ConnectServiceImpl implements ConnectService {
private static final Logger logger = LoggerFactory.getLogger(IdcServiceImpl.class);
@Resource
private DbDao dbDao;
private static String NUM_STRS = "⊙①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯";
//⊙①②③④⑤⑥⑦⑧⑨⑩→⊗
@Override
public BaseResponse connectStatus(HttpServletRequest request,Map<String,Object> params) {
int level = 0;
if(params.get("level")!=null) {
level = Integer.valueOf(params.get("level").toString());
} else if(params.get("data")!=null) {
Map data = JSONObject.parseObject(JSON.toJSONString(params.get("data")), Map.class);
if(data.get("level")!=null) {
level = Integer.valueOf(data.get("level").toString());
}
}
level++;
Map<String,Object> map = new HashMap<String,Object>();
map.put("level", level);
Map<String,Object> config = new HashMap<>();
try
{
if(level==0) {
config = dbDao.get("select syncIp as paramValue from sync_data_set limit 1");
} else {
config = dbDao.get("select * from system_param_config where paramKey='upper_server_ip'");
}
} catch (Exception ex) {
}
String msg = "UDI管理系统";
for(int i=1;i<level;i++) {
msg+="→中继服务"+NUM_STRS.substring(i,i+1)+"正常";
}
if(config!=null&&config.get("paramValue")!=null) {
logger.info("next host:"+config.get("paramValue"));
String result = IDCUtils.post(config.get("paramValue") + "/spssync/common/connect", map);
logger.info("result:"+result);
if (!StringUtils.isEmpty(result)&&IDCUtils.isJson(result)) {
BaseResponse object = JSON.parseObject(result, BaseResponse.class);
if(object.getCode()!=20000) {
map.replace("level", level +1);
msg+="→中继服务"+NUM_STRS.substring(level+1,level+2)+"正常";
map.put("msg", msg);
return ResultVOUtils.success(map);
}
return object;
} else {
msg+="→自助平台运行服务连接异常";
map.put("failLevel", level+1);
}
} else {
msg+="自助平台运行正常";
map.put("successLevel", level);
}
map.put("msg", msg);
return ResultVOUtils.success(map);
}
}

@ -1,58 +0,0 @@
package com.glxp.api.idc.service.impl;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson2.JSON;
import com.glxp.api.dao.idc.DbDao;
import com.glxp.api.idc.service.DeleteService;
import com.glxp.api.util.CustomUtil;
@Service
public class DeleteServiceImpl implements DeleteService {
private static final Logger logger = LoggerFactory.getLogger(DeleteServiceImpl.class);
@Resource
private JdbcTemplate jdbcTemplate;
@Resource
private DbDao dbDao;
@Override
public boolean syncDelete(String tableName,String uniqueValue) {
Map<String,Object> map = new HashMap<>();
map.put("tableName", tableName);
map.put("uniqueValue", uniqueValue);
return syncDelete(map);
}
@Override
public boolean syncDelete(Map<String,Object> params) {
createTable();
String sql = "insert into idc_delete (id,tableName,updateTime,uniqueValue) values ('"+CustomUtil.getId()+"','"+params.get("tableName").toString().toLowerCase()+"',now(),'"+JSON.toJSONString(params.get("uniqueValue"))+"')";
if(dbDao.save(sql)>0)
return true;
return false;
}
private void createTable() {
try {
jdbcTemplate.execute("create table idc_delete (id varchar(36),tableName varchar(100),uniqueValue varchar(600),updateTime datetime,PRIMARY KEY (id))");
} catch (Exception e) {
}
try {
jdbcTemplate.execute("create index i_idc_delete_table_name on idc_delete (tableName asc)");
} catch (Exception e) {
}
}
}

@ -1,303 +0,0 @@
package com.glxp.api.idc.service.impl;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.tools.ant.util.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.dao.idc.DbDao;
import com.glxp.api.idc.service.FileService;
import com.glxp.api.idc.service.IdcService;
import com.glxp.api.idc.utils.IDCUtils;
import com.glxp.api.util.FileUtils;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
/*文件服务*/
@Service
public class FileServiceImpl implements FileService {
private static final Logger logger = LoggerFactory.getLogger(FileServiceImpl.class);
@Value("${file_path}")
private String filePath;
@Value("${API_KEY}")
private String apiKey;
@Value("${API_SECRET}")
private String apiSecret;
@Resource
private DbDao dbDao;
@Resource
private IdcService idcService;
private String imagePath = "register/file/image2/";
String pdfPath = "pdf/template/";
@Override
public BaseResponse upload(List<String> list) {
return fileToUpload(list);
}
@Override
public BaseResponse download(List<String> list) {
return fileToDownload(list);
}
@Override
public BaseResponse fileUpload(HttpServletRequest request, Map<String, Object> params) {
List<String> list = new ArrayList<>();
String[] strs = params.get("fileName").toString().split(",");
for (String str : strs) {
list.add(str);
}
return fileToUpload(list);
}
private BaseResponse fileToUpload(List<String> list) {
String host = "";
try {
Map<String, Object> map = dbDao.get("select * from sync_data_set limit 1");
if (map != null && map.get("syncIp") != null)
host = map.get("syncIp").toString();
} catch (Exception ex) {
}
if (StringUtils.isEmpty(host)) {
try {
Map<String, Object> config = dbDao.get("select paramValue from system_param_config where paramKey='upper_server_ip'");
if (config != null && config.get("paramValue") != null)
host = config.get("paramValue").toString();
} catch (Exception ex) {
}
}
if (StringUtils.isEmpty(host))
return ResultVOUtils.error(9999, "上传地址未配置,请至同步设置中进行设置");
if (list != null) {
ArrayList<String> files = new ArrayList<>();
boolean isExists = true;
List<String> noExitsList = new ArrayList<>();
for (String strs : list) {
if (!StringUtils.isEmpty(strs) && FileUtils.isFileExist(strs)) {
files.add(strs);
} else {
isExists = false;
noExitsList.add(strs);
}
}
if (!isExists)
return ResultVOUtils.error(9999, "以下文件不存在:\n" + JSON.toJSONString(noExitsList));
String result = relayFile(files, host);
if (IDCUtils.isJson(result)) {
BaseResponse baseResponse = JSON.parseObject(result, BaseResponse.class);
return baseResponse;
}
}
return ResultVOUtils.error(9999, "失败");
}
@Override
public BaseResponse fileDownload(HttpServletRequest request, Map<String, Object> params) {
List<String> list = new ArrayList<>();
String[] strs = params.get("fileName").toString().split(",");
for (String str : strs) {
list.add(str);
}
return fileToDownload(list);
}
private BaseResponse fileToDownload(List<String> list) {
Map<String, Object> params = new HashMap<String, Object>();
String fileName = "";
for (String str : list) {
fileName += fileName.length() > 0 ? "," + str : str;
}
params.put("fileName", fileName);
Map<String, Object> map = dbDao.get("select * from sync_data_set limit 1");
if (map != null && map.get("syncIp") != null) {
String result = IDCUtils.post(map.get("syncIp").toString() + "/spssync/file/downloadFile", params);
boolean success = false;
if (IDCUtils.isJson(result)) {
JSONObject object = JSON.parseObject(result);
if (object.getInteger("code") == 20000) {
String[] files = params.get("fileName").toString().split(",");
success = true;
for (String str : files) {
if (!idcService.signleDownloadFile(map.get("syncIp").toString(), str))
success = false;
}
}
}
if (!success)
return ResultVOUtils.error(9999, "失败");
} else {
return ResultVOUtils.error(9999, "中继服务地址未配置,请至同步设置中进行配置");
}
return ResultVOUtils.success(null);
}
@Override
public BaseResponse receiveFile(HttpServletRequest request, String content, MultipartFile[] files) {
boolean isRelay = false;
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/";
String host = "";
try {
Map<String, Object> config = dbDao.get("select paramValue from system_param_config where paramKey='upper_server_ip'");
if (config != null && config.get("paramValue") != null) {
isRelay = true;
host = config.get("paramValue").toString();
}
} catch (Exception ex) {
ex.printStackTrace();
}
ArrayList<String> saveFiles = new ArrayList<>();
if (files != null) {
if (!FileUtils.makeDirectory(filePath + filePathSlash + imagePath))
IDCUtils.createDirectory(filePath + filePathSlash + imagePath);
try {
for (MultipartFile file : files) {
String flodPath;
if (file.getName().contains(".jrxml") || file.getName().contains(".jasper")) {
flodPath = pdfPath;
} else {
flodPath = imagePath;
}
String imageName = filePath + filePathSlash + flodPath + file.getOriginalFilename();
saveFiles.add(imageName);
IDCUtils.writeFile(file.getBytes(), filePath + filePathSlash + flodPath, file.getOriginalFilename());
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (isRelay) {
String result = relayFile(saveFiles, host);
logger.info(result);
if (IDCUtils.isJson(result) && !result.contains("<html")) {
BaseResponse baseResponse = JSON.parseObject(result, BaseResponse.class);
return baseResponse;
} else {
return ResultVOUtils.error(9999, "上传失败");
}
}
return ResultVOUtils.success(null);
}
/*转发图片*/
private String relayFile(ArrayList<String> files, String ip) {
String host = ip;
String result = "";
if (!StringUtils.isEmpty(host)) {
host += "/spssync/file/uploadFile";
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)//设置连接超时时间
.readTimeout(30, TimeUnit.SECONDS)//设置读取超时时间
.build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM);
String fileType = "application/octet-stream";
if (files != null && files.size() > 0) {
for (int i = 0; i < files.size(); i++) {
if (!StringUtils.isEmpty(files.get(i))) {
File file = new File(files.get(i));
String fileName = files.get(i);
fileName = fileName.substring(fileName.lastIndexOf("/"));
builder.addFormDataPart("files", fileName,
RequestBody.create(MediaType.parse(fileType), file));
}
}
}
RequestBody body = builder.build();
Request req = new Request.Builder()
.url(host)
.method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("format", "json")
.addHeader("apiKey", apiKey)
.addHeader("secretKey", apiSecret)
.addHeader("timestamp", DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"))
.addHeader("Access-Control-Allow-Headers", "Authorization, Origin, X-Requested-With, Content-Type, Accept")
.build();
try {
Response response = client.newCall(req).execute();
result = response.body().string();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
logger.debug("未配置中继服务地址");
}
return result;
}
@Override
public BaseResponse downloadFile(HttpServletRequest request, Map<String, Object> params) {
String host = "";
try {
Map<String, Object> config = dbDao.get("select paramValue from system_param_config where paramKey='upper_server_ip'");
if (config != null && config.get("paramValue") != null)
host = config.get("paramValue").toString();
} catch (Exception ex) {
}
if (!StringUtils.isEmpty(host)) {
String result = IDCUtils.post(host + "/spssync/file/downloadFile", params);
JSONObject object = JSON.parseObject(result);
boolean success = false;
if (object.getInteger("code") == 20000) {
String[] files = params.get("fileName").toString().split(",");
success = true;
for (String str : files) {
if (!idcService.signleDownloadFile(host, str))
success = false;
}
}
if (!success)
ResultVOUtils.error(9999, "失败");
}
return ResultVOUtils.success(null);
}
}

@ -1,400 +0,0 @@
package com.glxp.api.idc.utils;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.glxp.api.util.DateUtil;
/**
* @author chenqf
*/
public class DBAUtils {
private static final Logger logger = LoggerFactory.getLogger(DBAUtils.class);
private static final String keywords = ",limit,offset,sort,order,isLike,menuId,menuCode,page,isAuto,pageNo,pageSize,pageNum,sqlOrder,join,";
/*解析where条件*/
public static String parseWhere(String sql,Map<String,Object> columns,Map<String,Object> params,String dataWhere) {
return parseWhere(sql,columns,params,dataWhere,false);
}
public static String parseWhere(String sql,Map<String,Object> columns,Map<String,Object> params,String dataWhere,boolean isSimpleWhere) {
String where="";
boolean isAnd0 = false;
boolean isLike = params!=null&&params.get("isLike")!=null&&params.get("isLike").toString().equals("true") ? true : false;
if(sql.contains("sqlWhere")||!sql.contains("<if")) {
where = convertWhere(columns,params,dataWhere,sql);
if(!sql.contains("<if")&&!StringUtils.isEmpty(where)) {
sql+=sql.toLowerCase().contains(" where ") ? " and "+where : " where " +where;
}
}
int n=0;
if(sql.contains("<if")) {
int s1 = sql.indexOf("<if");
if(isSimpleWhere&&s1>0) {
for(int i=s1-1;i>-1;i--) {
if(!sql.substring(i,i+1).equals(" ")&&!sql.substring(i,i+1).equals("\n")) {
isAnd0 = true;
}
}
}
if(!StringUtils.isEmpty(dataWhere)) {
if(sql.contains("sqlWhere")) {
if(params.get("sqlWhere")!=null&&!StringUtils.isEmpty(params.get("sqlWhere").toString())) {
String temp = params.get("sqlWhere").toString();
params.replace("sqlWhere", "("+temp+") and ("+dataWhere+")");
} else {
params.put("sqlWhere", dataWhere);
}
}
}
while(sql.contains("<if")) {
int a = sql.indexOf("<if");
int b = sql.indexOf(">",a+1);
int h = sql.indexOf("isLike",a+1);
int j = sql.indexOf("!=",a+1);
if(h>a&&h<b) {
sql = j>1&&j<b ? sql.substring(0,a)+"[!=isLike]"+sql.substring(b+1) : sql.substring(0,a)+"[==isLike]"+sql.substring(b+1);
n=0;
continue;
}
int c = sql.indexOf("</if>");
String str = sql.substring(b+1,c);
int e1 = str.indexOf("#{");
int e2 = str.indexOf("}",e1 +1);
if(e1<0) {
e1 = str.indexOf("${");
}
String key =str.substring(e1 +2,e2).trim();
Object obj = params.get(key);
String value = obj!=null ? obj.toString() : "";
if(key.equals("sqlWhere")) {
if(StringUtils.isEmpty(value))
value = where;
}
if(!StringUtils.isEmpty(value)) {
str = str.length()>e2+1 ? str.substring(0,e1)+"'"+value+"'"+str.substring(e2+1) : str.substring(0,e1)+"'"+value+"'";
if(!isAnd0&&n==0) {
if(str.length()>3) {
if(str.trim().substring(0, 4).toLowerCase().equals("and ")) {
str = str.substring(str.toLowerCase().indexOf("and ")+3);
}
if(str.trim().substring(0, 3).toLowerCase().equals("or ")) {
str = str.substring(str.toLowerCase().indexOf("or ")+2);
}
}
}
n++;
} else {
str = "";
}
sql = sql.length()>c+5 ? sql.substring(0,a) +str+sql.substring(c+5) : sql.substring(0,a) +str;
}
}
if(sql.contains("<where>")) {
sql = n>0 ? sql.replaceAll("<where>", " where ") : sql.replaceAll("<where>", "");
if(!StringUtils.isEmpty(dataWhere)&&!sql.contains("sqlWhere")) {
sql = n>0 ? sql.replaceAll("</where>", " and ("+dataWhere+")") : sql.replaceAll("</where>", " ("+dataWhere+")");
} else {
sql = sql.replaceAll("</where>", "");
}
}
if(sql.contains("=isLike")) {
int a1,a2,b1,b2;
a1 = sql.indexOf("[==isLike]");
a2 = sql.indexOf("</if>",a1+1);
if(a1>0&&a2>0) {
if(isLike) {
sql = sql.length()>a2+5 ? sql.substring(0,a1)+sql.substring(a1 +10, a2) +sql.substring(a2+5) : sql.substring(0,a1)+sql.substring(a1 +10, a2);
} else {
sql = sql.length()>a2+5 ? sql.substring(0,a1)+sql.substring(a2+5) : sql.substring(0,a1);
}
}
b1 = sql.indexOf("[!=isLike]");
b2 = sql.indexOf("</if>",b1 +1);
if(b1>0&&b2>0) {
if(!isLike) {
sql = sql.length()>b2+5 ? sql.substring(0,b1)+sql.substring(b1 +10, b2) +sql.substring(b2+5) : sql.substring(0,b1)+sql.substring(b1 +10, b2);
} else {
sql = sql.length()>b2+5 ? sql.substring(0,b1)+sql.substring(b2+5) : sql.substring(0,b1);
}
}
}
sql =parseParams(sql,columns,params);
return sql;
}
public static String parseParams(String sql,Map<String,Object> columns,Map<String,Object> params) {
String[] iStr={"#{","${"};
for(int k=0;k<2;k++) {
while(sql.contains(iStr[k])) {
int a1 = sql.indexOf(iStr[k]);
int a2 = sql.indexOf("}",a1 +1);
String key = sql.substring(a1+2,a2);
Object obj = params.get(key);
String value = obj!=null ? obj.toString() : "";
String dataType = "0";
if(columns!=null) {
Map<String,Object> map = (Map<String, Object>) columns.get(key);
dataType = map!=null&&map.get("dataType")!=null ? map.get("dataType").toString() : "0";
}
sql = sql.substring(0,a1)+(dataType.equals("0") ? "'" : "")+value+(dataType.equals("0") ? "'" : "")+sql.substring(a2 +1);
}
}
return sql;
}
/*生成where条件*/
public static String convertWhere(Map<String,Object> colums,Map<String,Object> params,String dataWhere) {
String where=convertWhere(colums,params,dataWhere,"");
return where;
}
public static String convertWhere(Map<String,Object> colums,Map<String,Object> params,String dataWhere,String sql) {
String where="";
String value ="";
boolean isLike = false;
boolean isKey = false;
if(params!=null&&params.get("isLike")!=null&&params.get("isLike").toString().equals("true"))
isLike = true;
if(colums!=null) {
Iterator keys = colums.keySet().iterator();
isKey = keys.hasNext();
}
for(String key : params.keySet()){
Object obj = params.get(key);
value = "";
if(obj!=null)
value = obj.toString();
if(!StringUtils.isEmpty(value)&&!keywords.contains(","+key+",")&&(StringUtils.isEmpty(sql)||(!StringUtils.isEmpty(sql)&&!sql.contains("{"+key+"}")))) {
if(key.equals("sqlWhere")||key.equals("join")) {
where+=(!StringUtils.isEmpty(where) ? " and " : "") +" "+value;
} else {
String[] cns = key.split(",");
String wh = "";
for (String cn:cns) {
String columnName = cn;//StringUtils.propertyToField(cn);
if(colums!=null&&isKey&&colums.get(cn)==null) {
logger.error("列名"+columnName+"不存在,属性"+cn+"错误.");
} else {
if(!StringUtils.isEmpty(wh))
wh+=" or ";
if(isLike) {
wh+="instr("+columnName+",'"+value+"')>0";
} else {
wh+=columnName+"='"+value+"'";
}
}
}
where+=!StringUtils.isEmpty(wh) ? (!StringUtils.isEmpty(where) ? " and " : "") + "("+wh+")" : "";
}
}
}
if(!StringUtils.isEmpty(dataWhere)) {
if(!StringUtils.isEmpty(where)) {
where = "("+where+") and ("+dataWhere+")";
} else {
where = dataWhere;
}
}
if(!StringUtils.isEmpty(where))
where = "("+where+")";
return where;
}
/*生成insert语句*/
public static String parseInsert(Map<String,Object> params,Map<String,Object> columns) {
String ins="";
String vas="";
String sql="";
for(String key : columns.keySet()){
String value = "";
if(params.get(key)!=null)
value = params.get(key).toString();
Map<String,Object> map = (Map<String, Object>) columns.get(key);
String dataType = map.get("dataType").toString();
String extra = map.get("extra")!=null&&map.get("extra").toString().toLowerCase().contains("auto") ? "A" : "N";
if(map.get("columnKey").toString().equals("PRI")&&extra.equals("N")) {
if(StringUtils.isEmpty(value)) {
}
}
value = DBAUtils.escape(value);
if(!StringUtils.isEmpty(value)) {
if(!StringUtils.isEmpty(ins))
ins+=",";
ins+=map.get("columnName").toString();
if(!StringUtils.isEmpty(vas))
vas+=",";
if(StringUtils.isEmpty(value)) {
vas+="null";
} else {
if(dataType.equals("C")) {
vas+="'"+value+"'";
} else if (dataType.equals("N")) {
vas+=value;
} else {
String str = "";
Date date = new Date();
if(StringUtils.isNumeric(value)) {
date = new Date(Long.valueOf(value));
str = DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss");
} else {
str = DateUtil.formatDate(IDCUtils.parseDate(value),"yyyy-MM-dd HH:mm:ss");
}
vas+="cast('"+str+"' as datetime)";
}
}
}
}
if(!StringUtils.isEmpty(ins)&&!StringUtils.isEmpty(vas)) {
sql = "("+ins+") values ("+vas+")";
}
return sql;
}
public static String convertColumnType(String dataType,String dbType,String width) {
String columnType = dataType.toLowerCase();
if(dbType.contains("oracle.")) {
columnType = columnType.contains("varchar") ? width.contains("(") ? ("varchar2" +width) : ("varchar2(" +width+")") :
columnType.contains("char") ? width.contains("(") ? ("char" +width) : ("char(" +width+")") :
columnType.contains("date")||columnType.contains("time") ? "date" :
columnType.contains("int")||columnType.contains("num")||columnType.contains("dec") ? width.contains("(") ? ("number"+width+"") : ("number("+width+")") : "";
} else {
columnType = columnType.contains("varchar") ? width.contains("(") ? ("varchar" +width) : ("varchar(" +width+")") :
columnType.contains("char") ? width.contains("(") ? ("char" +width) : ("char(" +width+")") :
columnType.contains("date")||columnType.contains("time") ? "datetime" :
columnType.contains("int")||columnType.contains("num")||columnType.contains("dec") ? width !=null && width.contains(",") ? width.contains("(") ? ("decimal"+width+"") : ("decimal("+width+")") : "int" : "";
}
return columnType;
}
private static String aliasNameChars = "_hijklmnopqrstuvwxyzabcdefg9876543210";
private static String realNamechars = "abcdefghijklmnopqrstuvwxyz_0123456789";
/*表名简单转义*/
public static String tableAliasName(String tableName) {
String tname="2d";
for(int i=0;i<tableName.length();i++) {
int idx = realNamechars.indexOf(tableName.substring(i,i+1).toLowerCase());
if(idx>-1) {
tname+=aliasNameChars.substring(idx,idx+1);
} else {
tname+=tableName.substring(i,i+1).toLowerCase();
}
}
return tname;
}
/*获取实际表名*/
public static String tableRealName(String tableName) {
String tname="";
String result = "";
tableName = tableName.replaceAll("202c", ",");
String[] tabs = tableName.split(",");
for(int n=0;n<tabs.length;n++) {
String t = tabs[n];
tname="";
if(!StringUtils.isEmpty(t)) {
if(!StringUtils.isEmpty(result))
result +=",";
if (t.length()>2&&t.substring(0, 2).toLowerCase().equals("2d")) {
t = t.substring(2);
for(int i=0;i<t.length();i++) {
int idx = aliasNameChars.indexOf(t.substring(i,i+1).toLowerCase());
if(idx>-1) {
tname+=realNamechars.substring(idx,idx+1);
} else {
tname+=t.substring(i,i+1);
}
}
} else {
tname = t;
}
result+=tname;
}
}
return result;
}
public static String tableJoinWhere(String tableName,Map<String,Object> columns) {
String result = "";
if(tableName.contains(",")) {
String[] tabs = tableName.split(",");
String mTname = ((Map)columns.get("id")).get("tableName").toString();
//String sTname = ((Map)columns.get(StringUtils.uncapitalize(StringUtils.columnToJava(mTname,"false"))+"Id")).get("tableName").toString();
//result = mTname+".id="+sTname+"."+mTname+"_id";
}
return result;
}
/*从update语句解析select*/
public static String updateSqlToSelectSql(String sql,Map<String,Object> map) {
String aSql = sql.toLowerCase();
String result = "";
if(map==null)
map = new HashMap<String,Object>();
if(aSql.contains("update ")) {
int uIdx = aSql.indexOf("update ");
int sIdx = aSql.indexOf(" set ");
String tName = aSql.substring(uIdx+7,sIdx);
int wIdx = aSql.indexOf(" where ");
String where = aSql.substring(wIdx+7);
if(where.contains("=")) {
result = "select * from "+tName+" where ";
String[] tWh = where.split(" and ");
for(int i=0;i<tWh.length;i++) {
if(tWh[i].contains("=")) {
if(!tWh[i].substring(0, tWh[i].indexOf("=")).toLowerCase().trim().equals("data_version")) {
result+= tWh[i];
map.put("businessId", tWh[i].substring(tWh[i].indexOf("=")+1).replaceAll("'", ""));
break;
}
}
}
}
map.put("tableName", tName);
}
return result;
}
public static String escape(String str) {
String value = str;
if(value!=null&&value.contains("'")) {
value = value.replaceAll("'", "CCCBBBAAA12345ZZZYYYXXX");
value = value.replaceAll("CCCBBBAAA12345ZZZYYYXXX", "''");
}
return value;
}
}

@ -1,177 +0,0 @@
package com.glxp.api.idc.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
/**
* @author chenqf
*/
public class IDCUtils {
private static final Logger logger = LoggerFactory.getLogger(IDCUtils.class);
private static String aliasNameChars = "_hijklmnopqrstuvwxyzabcdefg9876543210";
private static String realNamechars = "abcdefghijklmnopqrstuvwxyz_0123456789";
private final static String MONTH_EN = "JanFebMarAprMayJunJulAugSepOctNovDec";
//判断是否json字符串
public static boolean isJson(String json) {
if(json!=null&&json.contains("{")&&json.contains("}")&&json.contains("\""))
return true;
return false;
}
public static Date parseDate(String str) {
return parseDate(str,"yyyy-MM-dd HH:mm:ss");
}
public static Date parseDate(String str,String fmt) {
String dateStr=str.replace("?", " ");
SimpleDateFormat df = new SimpleDateFormat(fmt);
if(str!=null&&!str.contains("-")&&str.length()>7&&StringUtils.isNumeric(str.substring(0, 4))&&
Long.valueOf(str.substring(0,4))>1899&&Long.valueOf(str.substring(0,4))<2199&&
StringUtils.isNumeric(str.substring(4, 6))&&StringUtils.isNumeric(str.substring(6, 8))&&
(!str.contains(" ")||(str.contains(" ")&&str.indexOf(" ")>7))) {
dateStr = str.substring(0,4)+"-"+str.substring(4,6)+"-"+str.substring(6,8);
dateStr+=" ";
if(str.contains(" ")) {
if(str.length()>9) {
dateStr+= str.substring(9,11);
if(str.length()>11) {
dateStr+=":"+str.substring(11,13);
if(str.length()>13) {
dateStr+=":"+str.substring(13,15);
}
} else {
dateStr+=":00:00";
}
} else {
dateStr+="00:00:00";
}
} else {
if(str.length()>8) {
dateStr+= str.substring(8,10);
if(str.length()>10) {
dateStr+=":"+str.substring(10,12);
if(str.length()>13) {
dateStr+=":"+str.substring(12,14);
} if(str.length()>12) {
dateStr+=":"+str.substring(12,13)+"0";
}
} else {
dateStr+=":00:00";
}
} else {
dateStr+="00:00:00";
}
}
} else if(str!=null&&str.contains("CST")) {
//Wed Feb 16 15:35:31 CST 2022
int index = str.indexOf("CST");
int month = (MONTH_EN.indexOf(str.substring(index -16,index -13))+3)/3;
dateStr = str.substring(index+4)+"-";
if(month<10)
dateStr+="0";
dateStr+= month+"-"+str.substring(index -12,index -10)+" "+str.substring(index -9,index -1);
} else if(str!=null&&str.contains("GMT")) {
int index = str.indexOf("GMT");
int month = (MONTH_EN.indexOf(str.substring(index -16,index -13))+3)/3;
if(str.contains("GMT+")) {
dateStr = str.substring(index+10)+"-";
} else {
dateStr = str.substring(index+4)+"-";
}
if(month<10)
dateStr+="0";
dateStr+= month+"-"+str.substring(index -12,index -10)+" "+str.substring(index -9,index -1);
} else if (str!=null&&str.equals("-30609820800000")) {
dateStr="1000-01-01 00:01:01";
} else if (str!=null&&str.length()==4&&StringUtils.isNumeric(str)&&Integer.valueOf(str)>999) {
dateStr=str+"-01-01 00:01:01";
} else if (str!=null&&str.length()==6&&StringUtils.isNumeric(str)) {
dateStr=str.substring(0, 4)+"-"+str.substring(4)+"-01 00:01:01";
} else if(str!=null&&StringUtils.isNumeric(str)&&str.length()>8&&(Long.valueOf(str.substring(0,4))<1899||Long.valueOf(str.substring(0,4))>2200)) {
dateStr=df.format(new Date(Long.valueOf(str)));
}
dateStr = dateStr.replace("T", " ");
Date date = null;
try {
date = df.parse(dateStr);
} catch (ParseException e) {
logger.error(e.getMessage());
}
return date;
}
public static void createDirectory(String directory) {
String dir = directory;
String path ="";
String[] breakChar ={"\\","/"};
for(String bk:breakChar) {
while(dir.indexOf(bk)>-1) {
path+=dir.substring(0,dir.indexOf(bk))+"\\";
File file = new File(path);
if (!(new File(path)).exists()) {
(new File(path)).mkdir();
}
if (dir.length()>dir.indexOf(bk)) {
dir = dir.substring(dir.indexOf(bk) +1);
} else {
dir = "";
}
}
}
}
public static String post(String url, Map<String, Object> params) {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
if (params != null)
body = RequestBody.create(mediaType, JSON.toJSONString(params));
Request request = new Request.Builder()
.url(url)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
String result = "";
try {
Response response = client.newCall(request).execute();
result = response.body().string();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
public static void writeFile(byte[] file, String filePath, String fileName) throws Exception {
File targetFile = new File(filePath);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
FileOutputStream out = new FileOutputStream(filePath + fileName);
out.write(file);
out.flush();
out.close();
}
}

@ -1,50 +0,0 @@
package com.glxp.api.idc.utils;
/**
* @author chenqf
*/
public class TableUtils {
/*同步表,格式:同步设置表列名/同步设置表列名(子表时设置,主表不设置)/主表唯一列(多列逗号分隔)/主表关联列/子表关联列/数据库实际表/时间列/图片或文件列/数据条件/说明*/
private static final String[] SYNC_TABLES = {
"typeThird//thr_bustype_origin/id///updateTime///第三方单据类型",
"basicThirdCorp//thr_corp/id///updateTime///第三方往来单位",
"//thr_dept/id///updateTime///第三方部门",
"//thr_inv_products/id///updateTime///第三方库存",
"basicThirdInv//thr_inv_warehouse/id//////第三方仓库",
"basicThirdBusOrder//thr_order/id///updateTime///第三方业务单据",
"/basicThirdBusOrder/thr_order_detail/orderIdFk/id/orderIdFk/updateTime///第三方单据详情",
"basicThirdProducts//thr_products/id///updateTime///第三方产品信息",
"basicType//basic_hosp_type/id///updateTime///物资字典分类",
"basicDept//auth_dept/id///updateTime///部门信息",
"basicInv//auth_warehouse/id///updateTime///仓库信息",
"typeBus//basic_bustype_change/id///updateTime///业务单据类型",
"typeScan//basic_bussiness_type/id///updateTime///扫码单据类型"
};
/**
* "entrustAction//basic_entrust_accept/id///updateTime///委托验收",
* "basicProducts//basic_udirel/id///updateTime///耗材字典",
* "/basicProducts/basic_products/id/uuid/uuid////耗材字典信息详情",
* "basicCorp//basic_corp/id///updateTime///往来单位",
* "//company_product_relevance/id///updateTime///供应商关联信息",
* <p>
* "//sup_cert_set/id///updateTime///供应商资质证书设置",
* "companyCert//sup_company/customerId///updateTime///配送企业",
* "manufacturerCert//sup_manufacturer/id///updateTime///生产企业",
* "productCert//sup_product/id///updateTime///产品资质信息",
* "/companyCert/sup_cert/id/customerId/customerId/updateTime/filePath/type=1/配送企业资质证书信息",
* "/manufacturerCert/sup_cert/id/manufacturerId/manufacturerIdFk/updateTime/filePath/type=2/生产企业资质证书信息",
* "/productCert/sup_cert/id/productId/productIdFk/updateTime/filePath/type=3/产品资质证书信息",
* "//udicompany/id///updateTime///国际库医疗器械注册人信息",
*/
//"dbDiProducts//productinfo/id///updateTime///DI产品信息",
//"basicInv/////////仓库字典",
//"typeBus/////////业务单据类型",
//"typeScan/////////扫码单据类型",
public static String[] syncTables() {
return SYNC_TABLES;
}
}

@ -1,79 +0,0 @@
package com.glxp.api.idc.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import cn.hutool.core.io.IoUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class UriUtils {
public String parseUri(String url) {
String uri = url;
int a1 = uri.indexOf("://");
int a2 = 0;
if (a1 > 0) {
a2 = uri.indexOf("/", a1 + 4);
if (a2 > 0) {
uri = uri.substring(a2 + 1);
}
}
return uri;
}
public HttpEntity<String> buildHeader(HttpServletRequest request) {
log.info(request.getMethod());
String bodyContent = "";
Map<String, Object> headerParam = new HashMap<>();
if (request.getMethod().equals(HttpMethod.GET)) {
Map<String, Object> bodyParam = new HashMap<String, Object>();
Enumeration pNames = request.getParameterNames();
while (pNames.hasMoreElements()) {
String name = (String) pNames.nextElement();
String value = request.getParameter(name);
bodyParam.put(name, value);
}
bodyContent = JSON.toJSONString(bodyParam);
} else {
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
bodyContent = IoUtil.read(reader);
log.info(bodyContent);
} catch (IOException e) {
e.printStackTrace();
}
}
HttpHeaders headers = new HttpHeaders();
Enumeration<String> enumeration = request.getHeaderNames();
while (enumeration.hasMoreElements()) {
String name = enumeration.nextElement();
String value = request.getHeader(name);
headerParam.put(name, value);
headers.add(name, value);
}
//headers.add("Content-Type", "application/json;charset=UTF-8");
HttpEntity<String> http = new HttpEntity<>(bodyContent, headers);
return http;
}
}

@ -1,55 +0,0 @@
package com.glxp.api.task;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.idc.service.IdcService;
import com.glxp.api.req.system.ScheduledRequest;
//
//@Component
//@EnableScheduling
public class AsyncFetchUdiTask implements SchedulingConfigurer {
final Logger logger = LoggerFactory.getLogger(AsyncFetchUdiTask.class);
@Resource
private ScheduledDao scheduledDao;
@Resource
private IdcService idcService;
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
scheduledTaskRegistrar.addTriggerTask(() -> process(),
triggerContext -> {
ScheduledRequest scheduledRequest = new ScheduledRequest();
scheduledRequest.setCronName("syncFetch");
logger.info("syncFetch----------------");
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
String cron = scheduledEntity!=null ? scheduledEntity.getCron() : "0 0/3 * * * ?";
if (cron.isEmpty()) {
logger.error("cron is null");
}
logger.info("syncFetch----------------"+cron);
return new CronTrigger(cron).nextExecutionTime(triggerContext);
});
}
private void process() {
logger.info("syncFetch----process------------");
idcService.asyncFetchUdiTask();
}
}

@ -1,54 +0,0 @@
package com.glxp.api.task;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.idc.service.IdcService;
import com.glxp.api.req.system.ScheduledRequest;
//
//@Component
//@EnableScheduling
public class AsyncUdiTask implements SchedulingConfigurer {
final Logger logger = LoggerFactory.getLogger(AsyncUdiTask.class);
@Resource
private ScheduledDao scheduledDao;
@Resource
private IdcService idcService;
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
scheduledTaskRegistrar.addTriggerTask(() -> process(),
triggerContext -> {
ScheduledRequest scheduledRequest = new ScheduledRequest();
scheduledRequest.setCronName("syncIdcUdi");
logger.info("syncIdcUdi----------------");
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
String cron = scheduledEntity != null ? scheduledEntity.getCron() : "0 0/1 * * * ?";
if (cron.isEmpty()) {
logger.error("cron is null");
}
logger.info("syncIdcUdi----------------");
return new CronTrigger(cron).nextExecutionTime(triggerContext);
});
}
private void process() {
logger.info("syncIdcUdi----process------------");
idcService.asyncUdiTask();
}
}

@ -1,139 +0,0 @@
package com.glxp.api.task;
import com.glxp.api.constant.BasicExportTypeEnum;
import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.dao.system.SyncDataSetDao;
import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.entity.system.SyncDataSetEntity;
import com.glxp.api.req.system.ScheduledRequest;
import com.glxp.api.service.sync.HeartService;
import com.glxp.api.util.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Arrays;
@Component
@EnableScheduling
public class SyncHeartTask implements SchedulingConfigurer {
final Logger logger = LoggerFactory.getLogger(SyncHeartTask.class);
@Resource
protected ScheduledDao scheduledDao;
@Resource
RedisUtil redisUtil;
@Resource
HeartService heartService;
@Resource
private SyncDataSetDao syncDataSetDao;
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
scheduledTaskRegistrar.addTriggerTask(() -> process(),
triggerContext -> {
ScheduledRequest scheduledRequest = new ScheduledRequest();
scheduledRequest.setCronName("heartTask");
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
String cron = scheduledEntity.getCron();
if (cron.isEmpty()) {
logger.error("cron is null");
}
return new CronTrigger(cron).nextExecutionTime(triggerContext);
});
}
private void process() {
logger.info("数据同步心跳");
//查询数据同步设置
SyncDataSetEntity syncDataSetEntity = syncDataSetDao.selectSet();
if (syncDataSetEntity.isDownstreamEnable()) {
//定时上传最近更新基础数据至上游轮询时间
long timeInterval1 = syncDataSetEntity.getSyncTime() * 6 * 1000L;
long curTime1 = System.currentTimeMillis();
Long lastTime1 = (Long) redisUtil.get("SPS_SYNC_UPLOAD_DATA");
if (lastTime1 == null) {
lastTime1 = System.currentTimeMillis();
redisUtil.set("SPS_SYNC_UPLOAD_DATA", lastTime1);
}
try {
if (curTime1 - lastTime1 > timeInterval1) {
// heartService.uploadAllBus(null);
// heartService.uploadAllUserData(null);
// heartService.uploadScheduleList();
// heartService.uploadThrData(null);
// heartService.uploadThrProducts(null);
// heartService.uploadSysSetting(null);
Arrays.stream(BasicExportTypeEnum.values()).forEach(i -> {
heartService.pushData(syncDataSetEntity, null, i);
});
redisUtil.set("SPS_SYNC_UPLOAD_DATA", curTime1);
}
} catch (Exception e) {
e.printStackTrace();
}
//定时上传最近更新单据数据至上游轮询时间
long timeInterval2 = syncDataSetEntity.getOrderSyncTime() * 6 * 1000L;
long curTime2 = System.currentTimeMillis();
Long lastTime2 = (Long) redisUtil.get("SPS_SYNC_UPLOAD_ORDER");
if (lastTime2 == null) {
lastTime2 = System.currentTimeMillis();
redisUtil.set("SPS_SYNC_UPLOAD_ORDER", lastTime2);
}
try {
if (curTime2 - lastTime2 > timeInterval2) {
heartService.uploadAllOrder(null);
heartService.uploadAllBusOrder(null);
redisUtil.set("SPS_SYNC_UPLOAD_ORDER", curTime2);
}
} catch (Exception e) {
e.printStackTrace();
}
//定时下载上游最近更新数据轮询时间
long timeInterval = syncDataSetEntity.getSyncDownloadTime() * 6 * 1000;
long curTime = System.currentTimeMillis();
Long lastTime = (Long) redisUtil.get("SPS_SYNC_DOWNLOAD_DATA");
if (lastTime == null) {
lastTime = System.currentTimeMillis();
redisUtil.set("SPS_SYNC_DOWNLOAD_DATA", lastTime);
}
if (curTime - lastTime > timeInterval) {
try {
heartService.dlAllOrder();
} catch (Exception e) {
e.printStackTrace();
}
try {
heartService.dlAllDiProducts();
} catch (Exception e) {
e.printStackTrace();
}
Arrays.stream(BasicExportTypeEnum.values()).forEach(i -> {
heartService.pullData(i);
});
// heartService.pullBasicData();
// heartService.pullOtherData();
redisUtil.set("SPS_SYNC_DOWNLOAD_DATA", curTime);
}
}
}
}
Loading…
Cancel
Save