From 782b6e58c80d2cb2b44647c048b5f1b7d1aac5ab Mon Sep 17 00:00:00 2001 From: chengqf <584883665@139.com> Date: Fri, 12 May 2023 16:46:57 +0800 Subject: [PATCH] delete --- .../controller/inout/IoCodeController.java | 84 - .../inout/IoCodeLostController.java | 125 -- .../inout/IoCodeTempController.java | 1169 ------------- .../controller/inout/IoOrderController.java | 736 -------- .../inout/IoOrderDetailBizController.java | 668 -------- .../inout/IoOrderDetailCodeController.java | 64 - .../inout/IoOrderDetailResultController.java | 139 -- .../inout/IoOrderInvoiceController.java | 59 - .../inout/IoOrderReviewController.java | 573 ------- .../inout/IoStatDataController.java | 100 -- .../controller/inout/ioCodeRelController.java | 151 -- .../sync/SpsSyncDownloadController.java | 149 -- .../sync/SpsSyncExportStatusController.java | 234 --- .../sync/SyncDataSetController.java | 105 -- .../api/idc/controller/ConnectController.java | 35 - .../api/idc/controller/DeleteController.java | 37 - .../api/idc/controller/FileController.java | 55 - .../api/idc/controller/IdcController.java | 209 --- .../glxp/api/idc/service/ConnectService.java | 12 - .../glxp/api/idc/service/DeleteService.java | 10 - .../api/idc/service/DownloadRestTemplate.java | 52 - .../com/glxp/api/idc/service/FileService.java | 21 - .../com/glxp/api/idc/service/IdcService.java | 44 - .../idc/service/impl/ConnectServiceImpl.java | 84 - .../idc/service/impl/DeleteServiceImpl.java | 58 - .../api/idc/service/impl/FileServiceImpl.java | 303 ---- .../api/idc/service/impl/IdcServiceImpl.java | 1478 ----------------- .../java/com/glxp/api/idc/utils/DBAUtils.java | 400 ----- .../java/com/glxp/api/idc/utils/IDCUtils.java | 177 -- .../com/glxp/api/idc/utils/TableUtils.java | 50 - .../java/com/glxp/api/idc/utils/UriUtils.java | 79 - .../com/glxp/api/task/AsyncFetchUdiTask.java | 55 - .../java/com/glxp/api/task/AsyncUdiTask.java | 54 - .../java/com/glxp/api/task/SyncHeartTask.java | 139 -- 34 files changed, 7708 deletions(-) delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoCodeController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoCodeLostController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoCodeTempController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoOrderController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoOrderDetailBizController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoOrderDetailCodeController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoOrderInvoiceController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoOrderReviewController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/IoStatDataController.java delete mode 100644 src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java delete mode 100644 src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java delete mode 100644 src/main/java/com/glxp/api/controller/sync/SpsSyncExportStatusController.java delete mode 100644 src/main/java/com/glxp/api/controller/sync/SyncDataSetController.java delete mode 100644 src/main/java/com/glxp/api/idc/controller/ConnectController.java delete mode 100644 src/main/java/com/glxp/api/idc/controller/DeleteController.java delete mode 100644 src/main/java/com/glxp/api/idc/controller/FileController.java delete mode 100644 src/main/java/com/glxp/api/idc/controller/IdcController.java delete mode 100644 src/main/java/com/glxp/api/idc/service/ConnectService.java delete mode 100644 src/main/java/com/glxp/api/idc/service/DeleteService.java delete mode 100644 src/main/java/com/glxp/api/idc/service/DownloadRestTemplate.java delete mode 100644 src/main/java/com/glxp/api/idc/service/FileService.java delete mode 100644 src/main/java/com/glxp/api/idc/service/IdcService.java delete mode 100644 src/main/java/com/glxp/api/idc/service/impl/ConnectServiceImpl.java delete mode 100644 src/main/java/com/glxp/api/idc/service/impl/DeleteServiceImpl.java delete mode 100644 src/main/java/com/glxp/api/idc/service/impl/FileServiceImpl.java delete mode 100644 src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java delete mode 100644 src/main/java/com/glxp/api/idc/utils/DBAUtils.java delete mode 100644 src/main/java/com/glxp/api/idc/utils/IDCUtils.java delete mode 100644 src/main/java/com/glxp/api/idc/utils/TableUtils.java delete mode 100644 src/main/java/com/glxp/api/idc/utils/UriUtils.java delete mode 100644 src/main/java/com/glxp/api/task/AsyncFetchUdiTask.java delete mode 100644 src/main/java/com/glxp/api/task/AsyncUdiTask.java delete mode 100644 src/main/java/com/glxp/api/task/SyncHeartTask.java diff --git a/src/main/java/com/glxp/api/controller/inout/IoCodeController.java b/src/main/java/com/glxp/api/controller/inout/IoCodeController.java deleted file mode 100644 index 0d66f9f..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoCodeController.java +++ /dev/null @@ -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 list = ioCodeService.filterList(filterCodeRequest); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.page(pageInfo); - } - - /** - * 根据单据号查询正式码表数据 - * - * @return - */ - @GetMapping("/udiwms/inout/code/findByOrderId") - public BaseResponse findAllByOrderId(FilterCodeRequest filterCodeRequest) { - List list = ioCodeService.filterList(filterCodeRequest); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.success(pageInfo); - } - - - /** - * 单据复核,获取单据对应条码 - */ - @AuthRuleAnnotation("") - @GetMapping("spms/inout/dlcode/findByOrderId") - public BaseResponse downloadCodesByOrderId(String orderId) { - - - List codeEntityList = ioCodeService.findByOrderId(orderId); - PageInfo pageInfo; - pageInfo = new PageInfo<>(codeEntityList); - PageSimpleResponse 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 list = ioCodeService.getCodeListForEdit(filterCodeRequest); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.page(pageInfo); - } - -} diff --git a/src/main/java/com/glxp/api/controller/inout/IoCodeLostController.java b/src/main/java/com/glxp/api/controller/inout/IoCodeLostController.java deleted file mode 100644 index fd2e55d..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoCodeLostController.java +++ /dev/null @@ -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 list = codeLostService.selectLost(ioCodeLostEntity); - PageInfo pageInfo; - pageInfo = new PageInfo<>(list); - PageSimpleResponse 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); - - } -} diff --git a/src/main/java/com/glxp/api/controller/inout/IoCodeTempController.java b/src/main/java/com/glxp/api/controller/inout/IoCodeTempController.java deleted file mode 100644 index 91f0402..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoCodeTempController.java +++ /dev/null @@ -1,1169 +0,0 @@ -package com.glxp.api.controller.inout; - -import cn.hutool.Hutool; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.UUID; -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.constant.ConstantType; -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.BasicBussinessTypeEntity; -import com.glxp.api.entity.basic.BasicCorpEntity; -import com.glxp.api.entity.basic.UdiEntity; -import com.glxp.api.entity.basic.UdiProductEntity; -import com.glxp.api.entity.inout.*; -import com.glxp.api.entity.inv.InvPreInProductDetailEntity; -import com.glxp.api.entity.inv.InvPreProductDetailEntity; -import com.glxp.api.entity.inv.InvPreinDetailEntity; -import com.glxp.api.entity.system.SystemParamConfigEntity; -import com.glxp.api.req.basic.CompanyProductRelevanceRequest; -import com.glxp.api.req.inout.AddEnterCodeRequest; -import com.glxp.api.req.inout.AddOrderRequest; -import com.glxp.api.req.inout.FilterCodeRequest; -import com.glxp.api.req.inout.PostOrderRequest; -import com.glxp.api.res.PageSimpleResponse; -import com.glxp.api.res.basic.UdiRelevanceResponse; -import com.glxp.api.res.basic.UdiRlSupResponse; -import com.glxp.api.res.inout.AddCodeResult; -import com.glxp.api.res.inout.IoCodeTempResponse; -import com.glxp.api.service.auth.InvWarehouseService; -import com.glxp.api.service.basic.*; -import com.glxp.api.service.inout.*; -import com.glxp.api.service.inv.*; -import com.glxp.api.service.purchase.SupProductService; -import com.glxp.api.service.system.SystemParamConfigService; -import com.glxp.api.util.*; -import com.glxp.api.util.udi.FilterUdiUtils; -import com.glxp.api.util.udi.UdiCalCountUtil; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.BeanUtils; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Locale; - -@RestController -public class IoCodeTempController extends BaseController { - - @Resource - private IoCodeTempService codeTempService; - @Resource - private IoOrderService orderService; - @Resource - private IBasicBussinessTypeService basicBussinessTypeService; - @Resource - IoAddInoutService transInoutService; - @Resource - private SystemParamConfigService systemParamConfigService; - @Resource - UdiRelevanceService udiRelevanceService; - @Resource - UdiProductService udiProductService; - @Resource - BasicCorpService basicUnitMaintainService; - @Resource - GennerOrderUtils gennerOrderUtils; - @Resource - UdiCalCountUtil udiCalCountUtil; - @Resource - UdiRlSupService udiRlSupService; - @Resource - InvWarehouseService invWarehouseService; - @Resource - IoCheckInoutService ioCheckInoutService; - @Resource - InvPreinProductDetailService invPreinProductDetailService; - @Resource - InvProductDetailService invProductDetailService; - @Resource - IoCodeLostService codeLostService; - @Resource - IoOrderDetailBizService orderDetailBizService; - @Resource - IoCodeService codeService; - @Resource - InvPreProductDetailService invPreProductDetailService; - - //手持端扫码单据上传调用接口 - @AuthRuleAnnotation("") - @PostMapping("warehouse/inout/postOrders") - @Log(title = "单据管理", businessType = BusinessType.INSERT) - public BaseResponse postOrders(@RequestBody PostOrderRequest postOrderRequest, BindingResult bindingResult) { - - if (bindingResult.hasErrors()) { - return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); - } - - Long userId = getUserId(); - try { - PostOrderRequest inPostOrder = new PostOrderRequest(); - List inPostOrders = new ArrayList<>(); - PostOrderRequest outPostOrder = new PostOrderRequest(); - List outPostOrders = new ArrayList<>(); - - List postOrders = postOrderRequest.getPostOrders(); - if (postOrders != null && postOrders.size() > 0) { - for (PostOrderRequest.PostOrder postOrder : postOrders) { - BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(postOrder.getOrderBean().getType()); - if (bussinessTypeEntity.isOutToSpms()) { - outPostOrders.add(postOrder); - } else { - inPostOrders.add(postOrder); - } - } - } - - BeanUtils.copyProperties(postOrderRequest, inPostOrder); - BeanUtils.copyProperties(postOrderRequest, outPostOrder); - inPostOrder.setPostOrders(inPostOrders); - outPostOrder.setPostOrders(outPostOrders); - - - if (CollUtil.isNotEmpty(inPostOrders)) { - inPostOrder.setCustomerId(getCustomerId()); - inPostOrder.setUserId(userId); - transInoutService.creatOrderByPda(inPostOrder); - } - - - } catch (Exception e) { - return ResultVOUtils.error(ResultEnum.NOT_NETWORK); - } - - return ResultVOUtils.success("上传成功,等待后台处理"); - } - - - //前端扫码完整性校验 - @AuthRuleAnnotation("") - @PostMapping("warehouse/inout/enterCode") - public BaseResponse addEndterCode(@RequestBody AddEnterCodeRequest addEnterCodeRequest) { - - if (StrUtil.isEmpty(addEnterCodeRequest.getCode())) { - return ResultVOUtils.error(500, "条码不能为空!"); - } - String code = ""; - String originCode = addEnterCodeRequest.getOriginCode(); - if (originCode == null) - originCode = ""; - code = originCode + addEnterCodeRequest.getCode(); - String newCode = addEnterCodeRequest.getCode(); - //重复判断 - if (StrUtil.isNotEmpty(addEnterCodeRequest.getOriginCode())) { - String tempOriginCode = addEnterCodeRequest.getOriginCode(); - if (tempOriginCode.endsWith("\u001D")) { - tempOriginCode = tempOriginCode.replace("\u001D", ""); - } - UdiEntity originUdiEntity = FilterUdiUtils.getUdi(tempOriginCode); - if (StrUtil.isNotEmpty(newCode)) { - if (newCode.startsWith("10")) { - if (StrUtil.isNotEmpty(originUdiEntity.getBatchNo())) { - BaseResponse baseResponse = ResultVOUtils.error(501, "批次号重复添加"); - baseResponse.setData(originCode); - return baseResponse; - } else { - String msg = checkNewCode(originUdiEntity, newCode); - if (msg != null) { - BaseResponse baseResponse = ResultVOUtils.error(501, msg); - baseResponse.setData(originCode); - return baseResponse; - } - } - } else if (newCode.startsWith("17")) { - if (StrUtil.isNotEmpty(originUdiEntity.getExpireDate())) { - BaseResponse baseResponse = ResultVOUtils.error(501, "失效日期重复添加"); - baseResponse.setData(originCode); - return baseResponse; - } else { - String msg = checkNewCode(originUdiEntity, newCode); - if (msg != null) { - BaseResponse baseResponse = ResultVOUtils.error(501, msg); - baseResponse.setData(originCode); - return baseResponse; - } - } - } else if (newCode.startsWith("11")) { - if (StrUtil.isNotEmpty(originUdiEntity.getProduceDate())) { - BaseResponse baseResponse = ResultVOUtils.error(501, "生产日期重复添加"); - baseResponse.setData(originCode); - return baseResponse; - } else { - String msg = checkNewCode(originUdiEntity, newCode); - if (msg != null) { - BaseResponse baseResponse = ResultVOUtils.error(501, msg); - baseResponse.setData(originCode); - return baseResponse; - } - } - } else if (newCode.startsWith("21")) { - if (StrUtil.isNotEmpty(originUdiEntity.getSerialNo())) { - BaseResponse baseResponse = ResultVOUtils.error(501, "序列号重复添加"); - baseResponse.setData(originCode); - return baseResponse; - } else { - String msg = checkNewCode(originUdiEntity, newCode); - if (msg != null) { - BaseResponse baseResponse = ResultVOUtils.error(501, msg); - baseResponse.setData(originCode); - return baseResponse; - } - } - } else { - BaseResponse baseResponse = ResultVOUtils.error(501, "格式错误"); - baseResponse.setData(originCode); - return baseResponse; - } - } - } - - UdiEntity udiEntity = FilterUdiUtils.getUdi(code); - if (udiEntity == null) { - String sptmtodi = systemParamConfigService.selectValueByParamKey(Constant.SPTM_TO_DI); - if (sptmtodi.equals("1")) { - if (code.length() == 13) { - UdiProductEntity udiProductEntity = udiProductService.findBySptm(code); - if (udiProductEntity != null) { - BaseResponse baseResponse = ResultVOUtils.error(508, "UDI码格式错误"); - baseResponse.setData(udiProductEntity); - return baseResponse; - } - } - } - BaseResponse baseResponse = ResultVOUtils.error(501, "UDI码格式错误"); - baseResponse.setData(originCode); - return baseResponse; - } - - if (StrUtil.isNotEmpty(udiEntity.getBatchNo())) { - if (code.endsWith("10" + udiEntity.getBatchNo())) { - code = code + "\u001D"; - } - } - - UdiRelevanceResponse checkUdi = udiRelevanceService.selectByNameCode(udiEntity.getUdi()); - if (checkUdi == null) { - return ResultVOUtils.error(500, "耗材字典不存在此产品!"); - } - boolean checkSuccess = true; - String lostMsg = ""; - //校验条码完整性 - if ("是".equals(checkUdi.getScbssfbhph()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { - checkSuccess = false; - lostMsg = lostMsg + ",批次号"; - } - if ("是".equals(checkUdi.getScbssfbhscrq()) && StrUtil.isEmpty(udiEntity.getProduceDate())) { - checkSuccess = false; - lostMsg = lostMsg + ",生产日期"; - } - - if ("是".equals(checkUdi.getScbssfbhsxrq()) && StrUtil.isEmpty(udiEntity.getExpireDate())) { - checkSuccess = false; - lostMsg = lostMsg + ",失效日期"; - } - if (("是".equals(checkUdi.getScbssfbhxlh()) && StrUtil.isEmpty(udiEntity.getSerialNo())) - ) { - checkSuccess = false; - lostMsg = lostMsg + ",序列号"; - } - if (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && udiEntity.getSerialNo().length() > 20) { - return ResultVOUtils.error(504, "序列号超出20位!"); - } - if (StrUtil.isNotEmpty(udiEntity.getBatchNo()) && udiEntity.getBatchNo().length() > 20) { - return ResultVOUtils.error(504, "批次号超出20位!"); - } - if (StrUtil.isEmpty(udiEntity.getSerialNo()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { - checkSuccess = false; - } - if (checkSuccess) { - if (code.endsWith("\u001D")) { - code = code.substring(0, code.length() - "\u001D".length()); - } - return ResultVOUtils.success(code); - } else { - if (newCode.startsWith("21") || (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && newCode.contains("21" + udiEntity.getSerialNo()))) { - if (StrUtil.isEmpty(lostMsg)) { - lostMsg = ","; - } - BaseResponse baseResponse = ResultVOUtils.error(503, "条码完整性错误,缺少" + lostMsg.substring(1) + "是否继续添加?"); - baseResponse.setData(code); - return baseResponse; - } - } - BaseResponse baseResponse = ResultVOUtils.error(502, "校验未完成"); - baseResponse.setData(code); - return baseResponse; - } - - - public String checkNewCode(UdiEntity originEnity, String newCode) { - UdiEntity newEntity = FilterUdiUtils.getUdi(originEnity.getUdi() + newCode); - if (newEntity == null || originEnity == null) { - return null; - } - if (StrUtil.isNotEmpty(originEnity.getBatchNo()) && StrUtil.isNotEmpty(newEntity.getBatchNo())) { - return "批次号重复添加!"; - } - if (StrUtil.isNotEmpty(originEnity.getProduceDate()) && StrUtil.isNotEmpty(newEntity.getProduceDate())) { - return "生产日期重复添加!"; - } - if (StrUtil.isNotEmpty(originEnity.getExpireDate()) && StrUtil.isNotEmpty(newEntity.getExpireDate())) { - return "失效日期重复添加!"; - } - if (StrUtil.isNotEmpty(originEnity.getSerialNo()) && StrUtil.isNotEmpty(newEntity.getSerialNo())) { - return "序列号重复添加!"; - } - return null; - } - - //前端扫码提交 - @AuthRuleAnnotation("") - @PostMapping("warehouse/inout/addOrderWeb") - @Log(title = "单据管理", businessType = BusinessType.INSERT) - public BaseResponse addOrderWeb(@RequestBody AddOrderRequest addOrderRequest, BindingResult bindingResult) { - - if (bindingResult.hasErrors()) { - return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); - } - AddCodeResult addCodeResult = new AddCodeResult(); - BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(addOrderRequest.getAction()); - InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(addOrderRequest.getInvCode()); - String code = addOrderRequest.getCode(); - if (StringUtils.isBlank(code)) return ResultVOUtils.error(ResultEnum.DATA_ERROR); - UdiEntity udiEntity = FilterUdiUtils.getUdi(code); - if (udiEntity == null) - return ResultVOUtils.error(500, "无效条码!"); - - if (StrUtil.isNotEmpty(addOrderRequest.getBatchNo())) { - udiEntity.setBatchNo(addOrderRequest.getBatchNo()); - } - if (StrUtil.isNotEmpty(addOrderRequest.getProduceDate())) { - udiEntity.setProduceDate(addOrderRequest.getProduceDate()); - } - if (StrUtil.isNotEmpty(addOrderRequest.getExpireDate())) { - udiEntity.setExpireDate(addOrderRequest.getExpireDate()); - } - if (StrUtil.isNotEmpty(addOrderRequest.getSerialNo())) { - udiEntity.setSerialNo(addOrderRequest.getSerialNo()); - } - - - if (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && udiEntity.getSerialNo().length() > 20) { - return ResultVOUtils.error(500, "无效条码!序列号超出最大范围"); - } - - if (StrUtil.isNotEmpty(udiEntity.getBatchNo()) && udiEntity.getBatchNo().length() > 20) { - return ResultVOUtils.error(500, "无效条码!批次号超出最大范围"); - } - - - //批次号校验 - //判断此产品是否开启允许无批次号 - UdiProductEntity udiInfoEntity = udiProductService.findByNameCode(udiEntity.getUdi()); - if (udiInfoEntity == null) { - return ResultVOUtils.error(500, "耗材字典不存在此产品!"); - } - if (!udiInfoEntity.getAllowNoBatch()) { - if (StrUtil.isEmpty(udiEntity.getSerialNo()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { - return ResultVOUtils.error(500, "序列号与批次号不能同时为空!"); - } - } - - String orderId = addOrderRequest.getBillNo(); - - //三期校验 - if (bussinessTypeEntity.isCodeFillCheck()) { - - BaseResponse checkOriginCodeRes = checkOriginCode(udiEntity); - if (checkOriginCodeRes != null) { - IoCodeLostEntity codeLostEntity = codeLostService.findByCode(code); - if (codeLostEntity == null) { - if (StrUtil.isNotEmpty(orderId)) { - List ioCodeEnttities = codeTempService.findByOrderId(orderId); - IoCodeTempEntity ioCodeEnttity = isExitLocal(code, ioCodeEnttities); - if (ioCodeEnttity == null) { - return checkOriginCodeRes; - } - } else - return checkOriginCodeRes; - } else { - udiEntity.setBatchNo(codeLostEntity.getBatchNo()); - udiEntity.setExpireDate(codeLostEntity.getExpireDate()); - udiEntity.setProduceDate(codeLostEntity.getProduceDate()); - } - - if (StrUtil.isNotEmpty(orderId)) { - List ioCodeEnttities = codeTempService.findByOrderId(orderId); - IoCodeTempEntity ioCodeEnttity = isExitLocal(code, ioCodeEnttities); - if (ioCodeEnttity == null) { - return checkOriginCodeRes; - } - } else - return checkOriginCodeRes; - } - } - - - //过期提醒: -// SystemParamConfigEntity expireParamConfigEntity = systemParamConfigService.selectByParamKey("expire_date_tip"); - - if (bussinessTypeEntity.getCheckVailDate() == 1 && !addOrderRequest.isIgnoreExpire()) { - if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) { - String expireDate = "20" + udiEntity.getExpireDate(); - long expireTime = DateUtil.parseDateExpire(expireDate); - if (expireTime - System.currentTimeMillis() < 0) { - return ResultVOUtils.error(504, "当前产品已过期,是否确定继续添加?"); - } - } - } - if (bussinessTypeEntity.getCheckExpire() == 2) { - if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) { - String expireDate = "20" + udiEntity.getExpireDate(); - long expireTime = DateUtil.parseDateExpire(expireDate); - if (expireTime - System.currentTimeMillis() < 0) { - return ResultVOUtils.error(604, "当前产品已过期,无法添加?"); - } - } - } - - - UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(udiEntity.getUdi()); - //近效期提醒 -// SystemParamConfigEntity recentParamConfigEntity = systemParamConfigService.selectByParamKey("recent_date_tip"); - long recent = 0; - if (udiRelevanceResponse.getRecentDateTime() != null) - recent = udiRelevanceResponse.getRecentDateTime().longValue(); - if (bussinessTypeEntity.getCheckVailDate() == 1 && recent > 0 && !addOrderRequest.isIgnoreRecentExpire()) { - if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) { - String expireDate = "20" + udiEntity.getExpireDate(); - long expireTime = DateUtil.parseDateExpire(expireDate); - long recentTieme = Math.abs(recent * 24 * 60 * 60 * 1000); - long resultTime = expireTime - System.currentTimeMillis(); - - if (resultTime > 0) { - long time = resultTime / (24 * 60 * 60 * 1000); - if (resultTime < recentTieme) { - return ResultVOUtils.error(505, "当前产品临近过期,距过期还剩" + time + "天,是否确定继续添加?"); - } - } - } - } - - if (bussinessTypeEntity.getCheckVailDate() == 2 && recent > 0) { - if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) { - String expireDate = "20" + udiEntity.getExpireDate(); - long expireTime = DateUtil.parseDateExpire(expireDate); - long recentTieme = Math.abs(recent * 24 * 60 * 60 * 1000); - long resultTime = expireTime - System.currentTimeMillis(); - - if (resultTime > 0) { - long time = resultTime / (24 * 60 * 60 * 1000); - if (resultTime < recentTieme) { - return ResultVOUtils.error(605, "当前产品临近过期,距过期还剩" + time + "天,无法添加!"); - } - } - } - } - - - //校验预验收是否已存在 - if (bussinessTypeEntity.getActionType() == ConstantStatus.ACTION_TYPE_PREIN) { - if (StrUtil.isNotEmpty(udiEntity.getSerialNo())) { - int count = invPreinProductDetailService.findCountByCode(code); - if (count > 0) { - return ResultVOUtils.error(500, "预验收库存已存在此UDI码,请检查后重试!"); - } - } - } - - //校验预验收库存是否已存在 - if (bussinessTypeEntity.isScanPreIn()) { - if (bussinessTypeEntity.getBackPreinType() == 1 && bussinessTypeEntity.isPreInBack()) {//按单出库&& bussinessTypeEntity.isPreInBack() - String orderIds = addOrderRequest.getCheckPreInOrders(); - if (StrUtil.isNotEmpty(orderIds)) { - String[] orderIdArray = orderIds.split(","); - List orderList = CollUtil.toList(orderIdArray); - int count = codeService.findByOrderIdsCount(orderList, code); - if (count <= 0) { - return ResultVOUtils.error(500, "非预验收单产品或预验收库存数量不足!"); - } - if (StrUtil.isNotEmpty(orderId)) {//非首次添加 - if (StrUtil.isEmpty(udiEntity.getSerialNo())) {//该单据已有该产品 - //无序列号,则可能存在多个预验收入库单 - IoCodeTempEntity codeTempEntity = codeTempService.findByUnique(orderId, code); - if (codeTempEntity != null) { - if (count < (codeTempEntity.getMyCount() + 1)) { - return ResultVOUtils.error(500, "超出预验收库存数量"); - } - } - } else { - if (count < 1) { - return ResultVOUtils.error(500, "预验收库存数量不足"); - } - } - } - - } else { - return ResultVOUtils.error(500, "未选择预验收入库单,请先选择预验收入库单!"); - } - - } else if (bussinessTypeEntity.getBackPreinType() == 2) { //按货位出库 - if (StrUtil.isEmpty(addOrderRequest.getCheckPreInSpaceCode())) - return ResultVOUtils.error(500, "" + - "请选择预验收货位!"); - int preInCount = invPreinProductDetailService.findCountBySpaceCode(addOrderRequest.getCheckPreInSpaceCode(), code); - InvPreInProductDetailEntity invPreinDetailEntity = invPreinProductDetailService.findUseOneByCode(code); - if (preInCount <= 0) { - return ResultVOUtils.error(500, "预验收库存数量不足!"); - } else { - if (StrUtil.isNotEmpty(invPreinDetailEntity.getBatchNo()) && StrUtil.isNotEmpty(udiEntity.getBatchNo()) - && !invPreinDetailEntity.getBatchNo().equals(udiEntity.getBatchNo())) { - return ResultVOUtils.error(500, "当前批次号与预验收录入批次号不匹配!"); - } - if (StrUtil.isNotEmpty(orderId)) {//非首次添加 - if (StrUtil.isEmpty(udiEntity.getSerialNo())) {//该单据已有该产品 - //无序列号,则可能存在多个预验收入库单 - IoCodeTempEntity codeTempEntity = codeTempService.findByUnique(orderId, code); - if (codeTempEntity != null) { - if (preInCount < (codeTempEntity.getMyCount() + 1)) { - return ResultVOUtils.error(500, "超出预验收库存数量"); - } - } - } else { - if (preInCount < 1) { - return ResultVOUtils.error(500, "预验收库存数量不足"); - } - } - } - } - } - - /** - * else { //按库存出库 - * int preInCount = invPreinProductDetailService.findCountByCode(code); - * InvPreInProductDetailEntity invPreinDetailEntity = invPreinProductDetailService.findUseOneByCode(code); - * if (preInCount <= 0) { - * return ResultVOUtils.error(500, "预验收库存数量不足!"); - * } else { - * if (StrUtil.isNotEmpty(invPreinDetailEntity.getBatchNo()) && StrUtil.isNotEmpty(udiEntity.getBatchNo()) - * && !invPreinDetailEntity.getBatchNo().equals(udiEntity.getBatchNo())) { - * return ResultVOUtils.error(500, "当前批次号与预验收录入批次号不匹配!"); - * } - * if (StrUtil.isNotEmpty(orderId)) {//非首次添加 - * if (StrUtil.isEmpty(udiEntity.getSerialNo())) {//该单据已有该产品 - * //无序列号,则可能存在多个预验收入库单 - * IoCodeTempEntity codeTempEntity = codeTempService.findByUnique(orderId, code); - * if (codeTempEntity != null) { - * if (preInCount < (codeTempEntity.getMyCount() + 1)) { - * return ResultVOUtils.error(500, "超出预验收库存数量"); - * } - * } - * } else { - * if (preInCount < 1) { - * return ResultVOUtils.error(500, "预验收库存数量不足"); - * } - * } - * } - * } - * } - */ - - - } - // 是否检验寄售库存 - if (bussinessTypeEntity.isAdvancePreIn()) { - int preInCount = invPreProductDetailService.findCountByCode(code); - InvPreProductDetailEntity invPreinDetailEntity = invPreProductDetailService.findUseOneByCode(code); - if (preInCount <= 0) { - return ResultVOUtils.error(500, "寄售库存数量不足!"); - } else { - if (StrUtil.isNotEmpty(invPreinDetailEntity.getBatchNo()) && StrUtil.isNotEmpty(udiEntity.getBatchNo()) - && !invPreinDetailEntity.getBatchNo().equals(udiEntity.getBatchNo())) { - return ResultVOUtils.error(500, "当前批次号与预验收录入批次号不匹配!"); - } - if (StrUtil.isNotEmpty(orderId)) {//非首次添加 - if (StrUtil.isEmpty(udiEntity.getSerialNo())) {//该单据已有该产品 - //无序列号,则可能存在多个预验收入库单 - IoCodeTempEntity codeTempEntity = codeTempService.findByUnique(orderId, code); - if (codeTempEntity != null) { - if (preInCount < (codeTempEntity.getMyCount() + 1)) { - return ResultVOUtils.error(500, "超出寄售存数量"); - } - } - } else { - if (preInCount < 1) { - return ResultVOUtils.error(500, "寄售库存数量不足"); - } - } - } - } - } - - - if (addOrderRequest.getFromCorp() == null) { - BasicCorpEntity basicCorpEntity = basicUnitMaintainService.selectByName(addOrderRequest.getFromCorp()); - if (basicCorpEntity == null && bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INPUT && bussinessTypeEntity.isGenUnit()) { - basicCorpEntity = new BasicCorpEntity(); - basicCorpEntity.setErpId(CustomUtil.getUnitId()); - addOrderRequest.setFromCorp((basicCorpEntity.getErpId())); - basicCorpEntity.setCorpType(ConstantStatus.CORP_SICK); - basicCorpEntity.setOutType(ConstantStatus.CORP_SICK_SICK); - basicCorpEntity.setName(addOrderRequest.getFromCorp()); - addOrderRequest.setFromCorp(basicCorpEntity.getName()); - basicCorpEntity.setId(IdUtil.getSnowflakeNextId()); - basicUnitMaintainService.insert(basicCorpEntity); - } - } - - //先生成扫码单据 - IoOrderEntity orderEntity = orderService.findByBillNo(orderId); - if (StringUtils.isBlank(orderId) || orderEntity == null) { - String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd")); - orderId = orderNo; - } - - List codeEnttitys = codeTempService.findByOrderId(orderId); - IoCodeTempEntity exitLocalEntity = null; - IoCodeTempEntity genDetaiEntity = new IoCodeTempEntity(); - List udiRelevanceResponses = null; - if (codeEnttitys.size() > 0) { - exitLocalEntity = isExitLocal(code, codeEnttitys); - if (exitLocalEntity != null) { - if (StrUtil.isEmpty(exitLocalEntity.getSupId()) || exitLocalEntity.getRelId() == null) { - return ResultVOUtils.error(500, "当前UDI码已存在,且存在异常未处理!"); - } - udiRelevanceResponses = udiRelevanceService.selectGroupByNameCode(exitLocalEntity.getNameCode(), null); - - BeanUtils.copyProperties(exitLocalEntity, genDetaiEntity); - genDetaiEntity.setCount(1); - genDetaiEntity.setReCount(udiCalCountUtil.getActCount(udiRelevanceResponses.get(0))); - - exitLocalEntity.setCount(exitLocalEntity.getMyCount() + 1); - exitLocalEntity.setReCount(exitLocalEntity.getMyCount() * udiCalCountUtil.getActCount(udiRelevanceResponses.get(0))); - - BaseResponse invRes = checkInv(bussinessTypeEntity, exitLocalEntity); - if (invRes != null) { - return invRes; - } - - if (StringUtils.isBlank(exitLocalEntity.getSerialNo())) { - if (addOrderRequest.getOrderType() == ConstantStatus.ORDER_TYPE_NORMAL && bussinessTypeEntity.isCheckEnable()) { - String errMsg = ioCheckInoutService.checkCode(genDetaiEntity); - if (errMsg != null) { - return ResultVOUtils.error(500, errMsg); - } else - codeTempService.updateById(exitLocalEntity); - } else if (addOrderRequest.getOrderType() == ConstantStatus.ORDER_TYPE_WAIT && bussinessTypeEntity.isCheckEnable()) { - String errMsg = ioCheckInoutService.checkNoPiCode(genDetaiEntity); - if (errMsg != null) { - return ResultVOUtils.error(500, errMsg); - } else - codeTempService.updateById(exitLocalEntity); - } else { - codeTempService.updateById(exitLocalEntity); - } - - } else { - return ResultVOUtils.error(ResultEnum.DATA_REPEAT); - } - } - } - - if (exitLocalEntity == null) { - IoCodeTempEntity codeEnttity = new IoCodeTempEntity(); - codeEnttity.setCode(code); - codeEnttity.setOrderId(orderId); - codeEnttity.setCorpOrderId(addOrderRequest.getCorpOrderId()); - codeEnttity.setCreateTime(new Date()); - codeEnttity.setUpdateTime(new Date()); - codeEnttity.setMainAction(bussinessTypeEntity.getMainAction()); - codeEnttity.setAction(bussinessTypeEntity.getAction()); - codeEnttity.setNameCode(udiEntity.getUdi()); - codeEnttity.setBatchNo(udiEntity.getBatchNo()); - codeEnttity.setProduceDate(udiEntity.getProduceDate()); - codeEnttity.setExpireDate(udiEntity.getExpireDate()); - codeEnttity.setSerialNo(udiEntity.getSerialNo()); - codeEnttity.setDeptCode(invWarehouseEntity.getParentId()); - codeEnttity.setInvCode(addOrderRequest.getInvCode()); - codeEnttity.setCount(1); - String unitFk = null; - if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT) { - unitFk = addOrderRequest.getFromCorp(); - } else if (StrUtil.isNotEmpty(addOrderRequest.getSelectSupId())) { - unitFk = addOrderRequest.getSelectSupId(); - } - //产品是否可以以使用单元入库 - udiRelevanceResponses = udiRelevanceService.selectGroupByNameCode(codeEnttity.getNameCode(), false); - if (udiRelevanceResponses.size() >= 1) { -// UdiRelevanceResponse udiRelevanceResponse = udiRelevanceResponses.get(0); - if (udiRelevanceResponse == null) { - return ResultVOUtils.error(500, "该产品信息未维护!"); - } else if (!udiRelevanceResponse.getUseDy() && udiRelevanceResponse.getDiType() == ConstantStatus.DITYPE_SYDY) { - return ResultVOUtils.error(500, "该产品不允许以使用单元入库!"); - } - - if (bussinessTypeEntity.isVailDispatch() && !udiRelevanceResponse.isDispatch()) { - return ResultVOUtils.error(500, "该产品不可配送,请联系院方!"); - } - - if (bussinessTypeEntity.getVailGroupBuy() == 1 && !udiRelevanceResponse.isGroupBuy()) { //只采集集采产品 - return ResultVOUtils.error(500, bussinessTypeEntity.getName() + "单只允许录入集采产品!"); - } - - if (bussinessTypeEntity.getVailGroupBuy() == 2 && udiRelevanceResponse.isGroupBuy()) { //只采集非集采产品 - return ResultVOUtils.error(500, bussinessTypeEntity.getName() + "单只允许录入非集采产品!"); - } - - //计算实际数量 - codeEnttity.setReCount(codeEnttity.getMyCount() * udiCalCountUtil.getActCount(udiRelevanceResponse)); - } else if (udiRelevanceResponses.size() == 0) { - if (unitFk == null) - return ResultVOUtils.error(500, "耗材字典不存在此产品!"); - else - return ResultVOUtils.error(500, "当前供应商不存在此配送产品!"); - } - - //校验供应商是否配送此产品 - BaseResponse corpResponse = checkCorp(codeEnttity, bussinessTypeEntity, unitFk); - if (corpResponse != null) { - return corpResponse; - } - - IoOrderEntity isExit = orderService.findByBillNo(orderId); - if (isExit == null) { - orderEntity = new IoOrderEntity(); - orderEntity.setBillNo(orderId); - orderEntity.setCorpOrderId(addOrderRequest.getCorpOrderId()); - orderEntity.setMainAction(bussinessTypeEntity.getMainAction()); - orderEntity.setAction(bussinessTypeEntity.getAction()); - orderEntity.setFromCorp(addOrderRequest.getFromCorp()); - if (StrUtil.isNotEmpty(addOrderRequest.getFromInvCode())) { - InvWarehouseEntity invWarehouseEntity1 = invWarehouseService.findByInvSubByCode(addOrderRequest.getFromInvCode()); - orderEntity.setFromDeptCode(invWarehouseEntity1.getParentId()); - } - orderEntity.setFromInvCode(addOrderRequest.getFromInvCode()); - orderEntity.setFromType(ConstantStatus.FROM_WEBNEW); - orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE); - orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT); - AuthAdmin authAdmin = getUser(); - 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.setCheckPreInOrders(addOrderRequest.getCheckPreInOrders()); - orderEntity.setInvCode(addOrderRequest.getInvCode()); - orderEntity.setOrderType(addOrderRequest.getOrderType()); - orderEntity.setBusType(bussinessTypeEntity.getBusType()); - orderService.insertOrder(orderEntity); - } - - - if (addOrderRequest.getOrderType() == ConstantStatus.ORDER_TYPE_NORMAL && bussinessTypeEntity.isCheckEnable() && bussinessTypeEntity.getCheckWebNew() != 0) { - - boolean isBillExit = orderDetailBizService.isExit(orderEntity.getBillNo()); - if (!isBillExit) { - orderService.deleteByBillNo(orderEntity.getBillNo()); - return ResultVOUtils.error(500, "请先录入业务详情"); - } - } - - - BaseResponse baseResponse = checkRelId(codeEnttity, unitFk); - if (baseResponse != null) { - deleteEmptyBillNo(orderEntity); - } - - //判断证书是否过期 -// if (codeEnttity.getRelId() != null && bussinessTypeEntity.isCheckCertExpire()) { -// -// SupProductEntity supProductEntity = supProductService.findByRelIdFk(codeEnttity.getRelId() + ""); -// if(supProductEntity!=null){ -// -// } -// if (DateUtil.) -// } - - BaseResponse invRes = checkInv(bussinessTypeEntity, codeEnttity); - if (invRes != null) { - deleteEmptyBillNo(orderEntity); - return invRes; - } - genDetaiEntity = codeEnttity; - if (baseResponse == null) { - baseResponse = checkSupId(bussinessTypeEntity, codeEnttity, unitFk); - if (baseResponse != null) - return baseResponse; - } else { - if (baseResponse.getCode() == 501) { - return baseResponse; - } else if (baseResponse.getCode() == 502) { - return baseResponse; - } - checkSupId(bussinessTypeEntity, codeEnttity, unitFk); - return baseResponse; - } - - //是否边扫边校验 - if (addOrderRequest.getOrderType() == ConstantStatus.ORDER_TYPE_NORMAL && bussinessTypeEntity.isCheckEnable()) { - String errMsg = ioCheckInoutService.checkCode(codeEnttity); - if (errMsg != null) { - return ResultVOUtils.error(500, errMsg); - } else - codeTempService.insert(codeEnttity); - } else if (addOrderRequest.getOrderType() == ConstantStatus.ORDER_TYPE_WAIT && bussinessTypeEntity.isCheckEnable()) { - String errMsg = ioCheckInoutService.checkNoPiCode(codeEnttity); - if (errMsg != null) { - return ResultVOUtils.error(500, errMsg); - } else - codeTempService.insert(codeEnttity); - } else { - codeTempService.insert(codeEnttity); - } - } - addCodeResult.setOrderId(orderId); - transInoutService.genOrderDetailCode(orderEntity, genDetaiEntity); - return ResultVOUtils.success(addCodeResult); - } - - //校验条码完整性 - public BaseResponse checkOriginCode(UdiEntity udiEntity) { - //校验条码的完整性 - String errMsg = ""; - UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(udiEntity.getUdi()); - if (udiRelevanceResponse == null) { - return ResultVOUtils.error(501, "耗材字典不存在此产品!"); - } - if (StrUtil.isEmpty(udiEntity.getBatchNo()) && !udiRelevanceResponse.getAllowNoBatch()) { - errMsg = errMsg + ",批次号"; - } - if (StrUtil.isEmpty(udiEntity.getProduceDate()) && !udiRelevanceResponse.getAllowNoProduct()) { - errMsg = errMsg + ",生产日期"; - } - if (StrUtil.isEmpty(udiEntity.getExpireDate()) && !udiRelevanceResponse.getAllowNoExpire()) { - errMsg = errMsg + ",失效日期"; - } - - if (StrUtil.isNotEmpty(errMsg)) { - BaseResponse baseResponse = ResultVOUtils.error(507, "产品三期缺失请补齐" + errMsg.substring(1) + ""); - baseResponse.setData(udiEntity); - return baseResponse; - } - return null; - } - - //校验供应商是否配送此产品 - public BaseResponse checkCorp(IoCodeTempEntity codeEnttity, BasicBussinessTypeEntity bussinessTypeEntity, String unitFk) { - CompanyProductRelevanceRequest companyProductRelevanceRequest = new CompanyProductRelevanceRequest(); - UdiEntity udiEntity = FilterUdiUtils.getUdi(codeEnttity.getCode()); - companyProductRelevanceRequest.setNameCode(udiEntity.getUdi()); - if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT) { - companyProductRelevanceRequest.setUnitFk(unitFk); - List datas = udiRlSupService.filterUdiGp(companyProductRelevanceRequest); - if (datas.size() <= 0) { - return ResultVOUtils.error(500, "当前供应商不存在此配送产品!"); - } - } else { - List datas = udiRlSupService.filterUdiGp(companyProductRelevanceRequest); - if (datas.size() <= 0) { - return ResultVOUtils.error(500, "此产品无指定供应商,请检查后添加!"); - } - } - return null; - } - - //校验产品ID唯一性 - public BaseResponse checkRelId(IoCodeTempEntity codeEnttity, String unitFk) { - - List udiRelevanceEntities = udiRelevanceService.selectAllByNameCode(codeEnttity.getNameCode(), unitFk); - if (udiRelevanceEntities != null && udiRelevanceEntities.size() > 1 && codeEnttity.getRelId() == null) {//同一个DI绑定多个产品西信息 - codeEnttity.setRelId(null); - codeEnttity.setStatus(ConstantStatus.ORDER_DETAIL_DI_MUTI); - codeTempService.insert(codeEnttity); - codeEnttity = codeTempService.findByUnique(codeEnttity.getOrderId(), codeEnttity.getCode()); - BaseResponse baseResponse = ResultVOUtils.error(502, "DI绑定多个产品ID,请指定对应产品"); - baseResponse.setData(codeEnttity); - return baseResponse; - } else if (udiRelevanceEntities == null || udiRelevanceEntities.size() == 0) {//未找到产品信息,一般不会出现 - codeEnttity.setRelId(null); - codeEnttity.setStatus(2); - return ResultVOUtils.error(501, "耗材字典不存在此产品!"); - } else { - codeEnttity.setStatus(0); - if (codeEnttity.getRelId() == null) - codeEnttity.setRelId(udiRelevanceEntities.get(0).getId()); - } - - return null; - } - - //校验供应商唯一性 - public BaseResponse checkSupId(BasicBussinessTypeEntity bussinessTypeEntity, IoCodeTempEntity codeEnttity, String unitFk) { - String originSupId = unitFk; -// if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT) { -// if (unitFk != null) -// originSupId = unitFk; -// } - if (originSupId != null) { - codeEnttity.setSupId(originSupId); - } else { - - IoCodeEntity ioCodeEntity = new IoCodeEntity(); - BeanUtils.copyProperties(codeEnttity, ioCodeEntity); - String supId = transInoutService.checkInvExitSup(ioCodeEntity); - if (supId == null) { - supId = transInoutService.checkExitSup(codeEnttity.getRelId()); - } - if (supId == null) { - codeEnttity.setSupId(null); - BaseResponse baseResponse = ResultVOUtils.error(503, "该产品未绑定供应商,请指定对应的供应商"); - baseResponse.setData(codeEnttity); - return baseResponse; - } else if ("MUTI".equals(supId)) { - codeEnttity.setSupId(null); - BaseResponse baseResponse = ResultVOUtils.error(503, "该产品绑定多个供应商,请指定对应的供应商"); - baseResponse.setData(codeEnttity); - return baseResponse; - } else { - codeEnttity.setSupId(supId); - } - } - codeTempService.updateById(codeEnttity); - return null; - } - - //判断本单是否存在 - public IoCodeTempEntity isExitLocal(String code, List codeEnttityList) { - - UdiEntity udiEntity = FilterUdiUtils.getUdi(code); - for (int i = 0; i < codeEnttityList.size(); i++) { - IoCodeTempEntity drugCodeSelectEntity = codeEnttityList.get(i); - if (codeEnttityList.get(i).getCode().equals(code)) { - return drugCodeSelectEntity; - } -// UdiEntity originUdiEntity = FilterUdiUtils.getUdi(drugCodeSelectEntity.getCode()); - if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getNameCode()).equals(StrUtil.emptyIfNull(udiEntity.getUdi()))) { - continue; - } - if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getBatchNo()).toUpperCase(Locale.ROOT).equals(StrUtil.emptyIfNull(udiEntity.getBatchNo()).toUpperCase(Locale.ROOT))) { - continue; - } - if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getProduceDate()).equals(StrUtil.emptyIfNull(udiEntity.getProduceDate()))) { - continue; - } - if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getExpireDate()).equals(StrUtil.emptyIfNull(udiEntity.getExpireDate()))) { - continue; - } - if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getSerialNo()).equals(StrUtil.emptyIfNull(udiEntity.getSerialNo()))) { - continue; - } - return drugCodeSelectEntity; - } - return null; - } - - public BaseResponse checkInv(BasicBussinessTypeEntity bussinessTypeEntity, IoCodeTempEntity codeTempEntity) { - if (bussinessTypeEntity.isVailInv() && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { - if (bussinessTypeEntity.getActionType() == ConstantStatus.ACTION_TYPE_ADVANCE) { -// int count = invPreProductDetailService.vailStockCount(code); //todo 寄售 -// if (count < 0) { -// return ResultVOUtils.error(500, "当前库存不足,不允许0库存出库"); -// } - } else { - int count = invProductDetailService.vailStockCount(codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getSupId(), codeTempEntity.getDeptCode(), codeTempEntity.getInvCode(), null); - if (count <= 0) { - return ResultVOUtils.error(500, "当前库存不足,不允许0库存出库"); - } else { - //查询此单据已扫描的条码数量 - if (codeTempEntity.getMyReCount() > count) { - return ResultVOUtils.error(500, "当前库存不足,不允许0库存出库"); - } - } - } - } - - return null; - } - - - @AuthRuleAnnotation("") - @GetMapping("admin/warehouse/inout/findErrorByOrderId") - public BaseResponse findErrorByOrderId(FilterCodeRequest filterCodeRequest) { - if (StrUtil.isEmpty(filterCodeRequest.getOrderId())) { - return ResultVOUtils.error(500, "单据号不能为空!"); - } - - List list = codeTempService.findCodeList(filterCodeRequest); - PageInfo pageInfo = new PageInfo<>(list); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageInfo.getTotal()); - pageSimpleResponse.setList(pageInfo.getList()); - return ResultVOUtils.success(pageSimpleResponse); - } - - @AuthRuleAnnotation("") - @PostMapping("/udiwms/addCode/updateBindSup") - @Log(title = "单据管理", businessType = BusinessType.UPDATE) - public BaseResponse updateBindSup(@RequestBody IoCodeTempEntity codeSaveRequest, BindingResult bindingResult) { - - if (bindingResult.hasErrors()) { - return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); - } - - - //更新供应商 - IoCodeTempEntity codeTempEntity = codeTempService.selectById(codeSaveRequest.getId()); - if (StrUtil.isNotEmpty(codeSaveRequest.getMySupId())) { - codeTempEntity.setSupId(codeSaveRequest.getMySupId()); - codeTempService.updateById(codeSaveRequest); - } - if (StrUtil.isNotEmpty(codeSaveRequest.getSupId())) { - codeTempEntity.setSupId(codeSaveRequest.getSupId()); - codeTempService.updateById(codeSaveRequest); - } - - //更新耗材字典 - if (codeSaveRequest.getRelId() != null) { - - BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(codeTempEntity.getAction()); - BaseResponse baseResponse = checkSupId(bussinessTypeEntity, codeTempEntity, codeTempEntity.getSupId()); - if (baseResponse != null) - return baseResponse; - - codeTempEntity.setRelId(codeSaveRequest.getRelId()); - int reCount = udiCalCountUtil.getActCount(codeTempEntity); - codeTempEntity.setReCount(reCount); - } - IoOrderEntity orderEntity = orderService.findByBillNo(codeTempEntity.getOrderId()); - BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction()); - //todo 可能会出问题 - if (orderEntity.getOrderType() == ConstantStatus.ORDER_TYPE_NORMAL && bussinessTypeEntity.isCheckEnable() && bussinessTypeEntity.getCheckWebNew() == 1) { - String errMsg = ioCheckInoutService.checkCode(codeTempEntity); - if (errMsg != null) { - return ResultVOUtils.error(500, errMsg); - } else - codeTempService.updateById(codeTempEntity); - } else { - codeTempService.updateById(codeTempEntity); - } - - ioAddInoutService.genOrderDetailCode(orderEntity, codeTempEntity); - - return ResultVOUtils.success("绑定成功"); - } - - @Resource - IoAddInoutService ioAddInoutService; - @Resource - IoOrderDetailCodeService ioOrderDetailCodeService; - - @AuthRuleAnnotation("") - @GetMapping("warehouse/inout/deleteCodesTempById") - @Log(title = "单据管理", businessType = BusinessType.DELETE) - public BaseResponse deleteCodesTempById(@RequestParam("id") Integer id) { - - IoCodeTempEntity codeTempEntity = codeTempService.selectById(id); - if (codeTempEntity == null) { - return ResultVOUtils.error(506, "UDI码异常,未录入!"); - } - IoOrderEntity orderEntity = orderService.findByBillNo(codeTempEntity.getOrderId()); - if (codeTempEntity.getMyCount() > 1) { - codeTempEntity.setCount(codeTempEntity.getMyCount() - 1); - codeTempEntity.setReCount(codeTempEntity.getMyReCount() - udiCalCountUtil.getActCount(codeTempEntity.getNameCode())); - codeTempService.updateById(codeTempEntity); - } else { - codeTempService.deleteById(id); - } - - //更新扫码详情 - IoOrderDetailCodeEntity orderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(orderEntity.getBillNo(), codeTempEntity.getRelId(), codeTempEntity.getBatchNo()); - if (orderDetailCodeEntity != null) { - //扫码数量-1 - int orderCount = IntUtil.value(orderDetailCodeEntity.getCount()); - int orderReCount = IntUtil.value(orderDetailCodeEntity.getReCount()); - if (orderCount > 1) { - orderDetailCodeEntity.setCount(orderCount - 1); - orderDetailCodeEntity.setReCount(orderReCount - udiCalCountUtil.getActCount(codeTempEntity.getNameCode())); - ioOrderDetailCodeService.update(orderDetailCodeEntity); - } else { - ioOrderDetailCodeService.deleteById(orderDetailCodeEntity.getId()); - } - } - - - boolean r1 = orderDetailBizService.isExit(orderEntity.getBillNo()); - boolean r2 = ioOrderDetailCodeService.isExit(orderEntity.getBillNo()); - if (!r1 && !r2) { - orderService.deleteByBillNo(orderDetailCodeEntity.getOrderIdFk()); - } - - orderEntity.setUpdateUser(getUserId() + ""); - orderEntity.setUpdateTime(new Date()); - orderService.update(orderEntity); - return ResultVOUtils.success("删除成功!"); - } - - - public void deleteEmptyBillNo(IoOrderEntity orderEntity) { - boolean r1 = orderDetailBizService.isExit(orderEntity.getBillNo()); - boolean r2 = ioOrderDetailCodeService.isExit(orderEntity.getBillNo()); - if (!r1 && !r2) { - orderService.deleteByBillNo(orderEntity.getBillNo()); - } - } - - - @AuthRuleAnnotation("") - @PostMapping("warehouse/inout/saveTempCode") - @Log(title = "单据管理", businessType = BusinessType.UPDATE) - public BaseResponse saveCode(@RequestBody IoCodeTempEntity codeTempEntity) { - if (codeTempEntity.getCount() == null) - codeTempEntity.setCount(1); - - 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())) { - List codeTempEntityList = codeTempService.findByOrderId(codeTempEntity.getOrderId()); - for (IoCodeTempEntity object : codeTempEntityList) { - if (object.getId() != codeTempEntity.getId() && object.getCode().equals(codeTempEntity.getCode()) && StrUtil.nullToEmpty(object.getCode()).equals(codeTempEntity.getSerialNo())) { - return ResultVOUtils.error(500, "条码重复!"); - } - } - } - if (codeTempEntity.getMyCount() <= 0) { - return ResultVOUtils.error(500, "数量不能小于0"); - } - codeTempEntity.setReCount(codeTempEntity.getMyCount() * udiCalCountUtil.getActCount(codeTempEntity.getNameCode())); - int b = codeTempService.updateById(codeTempEntity); - if (b > 0) - return ResultVOUtils.success("修改成功"); - else return ResultVOUtils.error(500, "修改失败!"); - } - - -} diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderController.java deleted file mode 100644 index cb69eb4..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderController.java +++ /dev/null @@ -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 list = orderService.filterList(filterOrderRequest); - PageInfo 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 list = orderService.getfilterList(filterOrderRequest); - for (IoOrderResponse ioOrderResponse : list) { - if(ioOrderResponse.getCheckStatus() == null){ - ioOrderResponse.setCheckStatus(0+""); - } - FilterOrderDetailCodeRequest filterOrderDetailCodeRequest = new FilterOrderDetailCodeRequest(); - filterOrderDetailCodeRequest.setOrderIdFk(ioOrderResponse.getBillNo()); - List 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 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 list = orderService.filterList(filterOrderRequest); - PageInfo 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 list = orderService.filterList(filterOrderRequest); - PageInfo 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 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 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 orderDetailBizEntities = orderDetailBizService.findByOrderId(addOrderRequest.getBillNo()); - List 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 orderDetailBizEntities = orderDetailBizService.findByOrderId(addOrderRequest.getBillNo()); - List 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 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 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 orderResponses = orderService.filterList(filterOrderRequest); - List 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 orderDetailBizEntities = orderDetailBizService.filterList(filterOrderDetailBizRequest); - pdaBusOrderResponse.setOrderDetailBizResponses(orderDetailBizEntities); - erpOrderResponses.add(pdaBusOrderResponse); - } - } - PageInfo pageInfo; - pageInfo = new PageInfo<>(orderResponses); - PageSimpleResponse 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 entrustReceEntities; - List 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 orderEntityList = orderService.filterList(filterOrderRequest); - PageInfo pageInfo; - pageInfo = new PageInfo<>(orderEntityList); - PageSimpleResponse 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 list = orderService.filterOrderTrace(billNo); - List 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 list = orderService.filterUploadOrderList(uploadOrderRequest); - PageInfo 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 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 supplementCodes = new ArrayList<>(); - - List 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(); - } - -} diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailBizController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderDetailBizController.java deleted file mode 100644 index 88be98c..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailBizController.java +++ /dev/null @@ -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 orderEntityList = orderDetailBizService.checkOrderList(orderId); - PageSimpleResponse 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 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 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 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 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 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 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 list = orderDetailBizService.filterList(orderDetailBizRequest); - List orderDetailCodeEntities = orderDetailCodeService.findByOrderId(orderDetailBizRequest.getOrderIdFk()); - ioCheckInoutService.bizOrderCheck2(list, orderDetailCodeEntities); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.page(pageInfo); - } - -// @GetMapping("/udiwms/inout/bizDetail/filterListInv") -// public BaseResponse filterListInv(FilterOrderDetailBizRequest orderDetailBizRequest) { -// List list = orderDetailBizService.getfilterList(orderDetailBizRequest); -// List orderDetailCodeEntities = orderDetailCodeService.findByOrderId(orderDetailBizRequest.getOrderIdFk()); -// ioCheckInoutService.bizOrderCheck2(list, orderDetailCodeEntities); -// PageInfo pageInfo = new PageInfo<>(list); -// return ResultVOUtils.page(pageInfo); -// } - - @GetMapping("/udiwms/inout/bizDetail/filterListInvoice") - public BaseResponse filterListInvoice(FilterOrderDetailBizRequest orderDetailBizRequest) { - List list = orderDetailBizService.filterListInv(orderDetailBizRequest); - PageInfo 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 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 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 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 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 pageInfo = new PageInfo<>(ioOrderDetailCodeResponses); - return ResultVOUtils.page(pageInfo); - } - -} - diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailCodeController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderDetailCodeController.java deleted file mode 100644 index c29c2b3..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailCodeController.java +++ /dev/null @@ -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 orderEntityList = ioOrderDetailCodeService.checkOrderList(orderId); - - List list = ioOrderDetailCodeService.getDetailCodeResponse(orderEntityList); - PageSimpleResponse 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 list = ioOrderDetailCodeService.filterList(detailCodeRequest); - List orderDetailBizEntities = orderDetailBizService.findByOrderId(detailCodeRequest.getOrderIdFk()); - ioCheckInoutService.codeOrderCheck2(list, orderDetailBizEntities); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.page(pageInfo); - } - - -} diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java deleted file mode 100644 index 8328cff..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailResultController.java +++ /dev/null @@ -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 list = orderDetailResultService.filterList(orderDetailResultRequest); - PageInfo 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 actions = orderService.setActions(filterOrderRequest); - if (CollUtil.isEmpty(actions)) { - return ResultVOUtils.success(""); - } - orderDetailResultRequest.setActions(actions); - List 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 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 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 orderDetailBizEntities = orderDetailBizService.findByOrderId(orderDetailResultRequest.getOrderIdFk()); - List 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 orderDetailBizEntities = orderDetailBizService.findByOrderId(orderDetailResultRequest.getOrderIdFk()); - checkInoutService.bizNoPiCheck(orderDetailBizEntities, orderEntity); - return ResultVOUtils.success(orderDetailBizEntities); - } - - -} diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderInvoiceController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderInvoiceController.java deleted file mode 100644 index 4df72ef..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderInvoiceController.java +++ /dev/null @@ -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 orderInvoiceEntities = BeanUtil.toBean(baseResponse.getData(),List.class); - if (CollUtil.isNotEmpty(orderInvoiceEntities)) { - List 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; - - - } -} diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderReviewController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderReviewController.java deleted file mode 100644 index e0c5052..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderReviewController.java +++ /dev/null @@ -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 datas = (List) 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 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 datas = (List) 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 codeList; - List codeEntityList = (List) 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 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 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 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 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 codeList, String code) { - if (CollUtil.isNotEmpty(codeList)) { - for (IoCodeEntity codeEntity : codeList) { - if (codeEntity.getCode().equals(code)) { - return codeEntity; - } - } - } - return null; - } - - - public boolean vailFinish(List 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 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 datas = (List) 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 orderDetailResultResponses = orderDetailResultService.filterList(filterOrderDetailResultRequest); - //本地已存在,则直接返回 - if (CollUtil.isNotEmpty(orderDetailResultResponses)) { - acceptOrderEntity.setOrderDetailEntities(orderDetailResultResponses); - orderResponse = orderService.findGroupBillNo(billNo); - acceptOrderEntity.setOrderEntity(orderResponse); - acceptOrderEntity.setExitAccept(false); - } else { - //获取自助平台待审核单据,并插入到数据库 - BaseResponse baseResponse = spGetHttp.getReviewOrder(reviewSpmsRequest, userId + ""); - if (baseResponse.getCode() == 20000) { - SpsSyncOrderResponse spsSyncOrderResponse = baseResponse.getData(); - List 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 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 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; - } - - - } - -} diff --git a/src/main/java/com/glxp/api/controller/inout/IoStatDataController.java b/src/main/java/com/glxp/api/controller/inout/IoStatDataController.java deleted file mode 100644 index 0c613d1..0000000 --- a/src/main/java/com/glxp/api/controller/inout/IoStatDataController.java +++ /dev/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 list = statOrderService.filterList(statDataRequest); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.page(pageInfo); - } - - /** - * 查询日汇总数据列表 - * - * @param statDataDetailRequest - * @return - */ - @GetMapping("/udiwms/inout/stat/detail/day/filter") - public BaseResponse filterDayList(FilterStatDataDetailRequest statDataDetailRequest) { - List list = statDayService.filterList(statDataDetailRequest); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.page(pageInfo); - } - - /** - * 查询月汇总数据列表 - * - * @param statDataDetailRequest - * @return - */ - @GetMapping("/udiwms/inout/detail/month/filter") - public BaseResponse filterMonthList(FilterStatDataDetailRequest statDataDetailRequest) { - List list = statMonthService.filterList(statDataDetailRequest); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.page(pageInfo); - } - - /** - * 查询季度汇总数据列表 - * - * @param statDataDetailRequest - * @return - */ - @GetMapping("/udiwms/inout/detail/quarter/filter") - public BaseResponse filterQuarterList(FilterStatDataDetailRequest statDataDetailRequest) { - List list = statQuarterService.filterList(statDataDetailRequest); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.page(pageInfo); - } - - /** - * 查询月汇总数据列表 - * - * @param statDataDetailRequest - * @return - */ - @GetMapping("/udiwms/inout/detail/year/filter") - public BaseResponse filterYearList(FilterStatDataDetailRequest statDataDetailRequest) { - List list = statYearService.filterList(statDataDetailRequest); - PageInfo pageInfo = new PageInfo<>(list); - return ResultVOUtils.page(pageInfo); - } - -} diff --git a/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java b/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java deleted file mode 100644 index fedc25c..0000000 --- a/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java +++ /dev/null @@ -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 list = ioCodeRelServicec.selectIoCodeRelList(ioOrderRelRequest); - PageInfo pageInfo; - pageInfo = new PageInfo<>(list); - PageSimpleResponse 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 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 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 list = ioCodeRelServicec.selectIoCodeRelDetailList(ioOrderRelRequest); - PageInfo pageInfo; - pageInfo = new PageInfo<>(list); - PageSimpleResponse 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, "删除失败"); - } - - } - - -} diff --git a/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java b/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java deleted file mode 100644 index 1e8c176..0000000 --- a/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java +++ /dev/null @@ -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 basicDownloadStatusEntities = basicDownloadService.filterDownloadStatus(basicDownloadRequest); - return ResultVOUtils.success(basicDownloadStatusEntities); - } - - @GetMapping("/spssync/download/basic/udiinfo/filter") - public BaseResponse filterStatus(BasicDownloadRequest basicDownloadRequest) { - List basicDownloadStatusEntities = basicDownloadService.filterDownloadStatus(basicDownloadRequest); - PageInfo pageInfo; - pageInfo = new PageInfo<>(basicDownloadStatusEntities); - PageSimpleResponse 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); - } - } - } - } - -} diff --git a/src/main/java/com/glxp/api/controller/sync/SpsSyncExportStatusController.java b/src/main/java/com/glxp/api/controller/sync/SpsSyncExportStatusController.java deleted file mode 100644 index 8611fcd..0000000 --- a/src/main/java/com/glxp/api/controller/sync/SpsSyncExportStatusController.java +++ /dev/null @@ -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 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 basicExportStatusEntities = basicExportService.filterExportStatus(basicExportStatusRequest); - PageInfo pageInfo; - pageInfo = new PageInfo<>(basicExportStatusEntities); - PageSimpleResponse 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 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(); - } - - -} diff --git a/src/main/java/com/glxp/api/controller/sync/SyncDataSetController.java b/src/main/java/com/glxp/api/controller/sync/SyncDataSetController.java deleted file mode 100644 index dbf15d4..0000000 --- a/src/main/java/com/glxp/api/controller/sync/SyncDataSetController.java +++ /dev/null @@ -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 busTypes = syncDataSetResponse.getBusTypes(); - syncDataBustypeService.deleteAll(1); - if (CollUtil.isNotEmpty(busTypes)) { - syncDataBustypeService.inserts(busTypes); - } - - List 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 baseResponse = spGetHttpClient.updateSynsSet(syncDataSetResponse); - if (baseResponse.getCode() == 20000) { - return baseResponse; - } else { - return ResultVOUtils.error(500, "UDI管理系统设置成功,自助平台修改失败"); - } - - } -} diff --git a/src/main/java/com/glxp/api/idc/controller/ConnectController.java b/src/main/java/com/glxp/api/idc/controller/ConnectController.java deleted file mode 100644 index 434eb64..0000000 --- a/src/main/java/com/glxp/api/idc/controller/ConnectController.java +++ /dev/null @@ -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 params) { - - return connectService.connectStatus(request,params); - } - -} diff --git a/src/main/java/com/glxp/api/idc/controller/DeleteController.java b/src/main/java/com/glxp/api/idc/controller/DeleteController.java deleted file mode 100644 index 913487f..0000000 --- a/src/main/java/com/glxp/api/idc/controller/DeleteController.java +++ /dev/null @@ -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 params) { - if(deleteService.syncDelete(params)) - return ResultVOUtils.success(); - return ResultVOUtils.error(9999, "失败"); - } - -} diff --git a/src/main/java/com/glxp/api/idc/controller/FileController.java b/src/main/java/com/glxp/api/idc/controller/FileController.java deleted file mode 100644 index 69c4fd6..0000000 --- a/src/main/java/com/glxp/api/idc/controller/FileController.java +++ /dev/null @@ -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 params) { - return fileService.fileUpload(request, params); - } - - @RequestMapping(value = "/spssync/file/download") - @ResponseBody - public BaseResponse download(HttpServletRequest request, @RequestBody Map params) { - return fileService.fileDownload(request, params); - } - - @RequestMapping(value = "/spssync/file/downloadFile") - @ResponseBody - public BaseResponse downloadFile(HttpServletRequest request, @RequestBody Map 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); - } - - -} diff --git a/src/main/java/com/glxp/api/idc/controller/IdcController.java b/src/main/java/com/glxp/api/idc/controller/IdcController.java deleted file mode 100644 index ae07bdb..0000000 --- a/src/main/java/com/glxp/api/idc/controller/IdcController.java +++ /dev/null @@ -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 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 params) { - // - return idcService.send(params); - } - - //@Log("数据同步任务列表拉取") - @RequestMapping(value = "/spssync/common/list") - @ResponseBody - public BaseResponse list(HttpServletRequest request, @RequestBody(required = false) Map params) { - return idcService.taskList(request, params); - } - - //@Log("数据同步任务根据任务ID下载数据") - @RequestMapping(value = "/spssync/common/download") - @ResponseBody - public BaseResponse download(HttpServletRequest request, @RequestBody Map params) { - return idcService.download(request, params); - } - @RequestMapping(value = "/spssync/common/uploadStatus") - @ResponseBody - public BaseResponse uploadStatus(HttpServletRequest request, @RequestBody Map params) { - return idcService.uploadStatus(request, params); - } - - @RequestMapping(value = "/spssync/common/downloadStatus") - @ResponseBody - public BaseResponse downloadStatus(HttpServletRequest request, @RequestBody Map params) { - return idcService.downloadStatus(request, params); - } - //@Log("数据同步任务根据任务ID,返回下载成功标记") - @RequestMapping(value = "/spssync/common/success") - @ResponseBody - public BaseResponse success(HttpServletRequest request, @RequestBody Map 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 httpEntity = buildHeader(request); - log.info(request.getMethod()); - Map headerParam = new HashMap<>(); - Map bodyParam = new HashMap(); - 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 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 http = new HttpEntity<>(JSON.toJSONString(bodyParam), headers); - - - log.info(uri); -// ResponseEntity entity = restTemplate.exchange(uri, HttpMethod.GET, httpEntity, Resource.class); -// ResponseEntity responseEntity = restTemplate.exchange(uri, -// HttpMethod.GET, http, Resource.class, new Object[0]); -// ResponseEntity responseEntity = restTemplate.exchange(uri, HttpMethod.GET, http, HttpServletResponse.class); - - ResponseEntity 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 httpEntity = uriUtils.buildHeader(request); - - ResponseEntity 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; - } - - -} diff --git a/src/main/java/com/glxp/api/idc/service/ConnectService.java b/src/main/java/com/glxp/api/idc/service/ConnectService.java deleted file mode 100644 index 0b6f402..0000000 --- a/src/main/java/com/glxp/api/idc/service/ConnectService.java +++ /dev/null @@ -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 params); -} diff --git a/src/main/java/com/glxp/api/idc/service/DeleteService.java b/src/main/java/com/glxp/api/idc/service/DeleteService.java deleted file mode 100644 index d8cfa87..0000000 --- a/src/main/java/com/glxp/api/idc/service/DeleteService.java +++ /dev/null @@ -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 params); -} diff --git a/src/main/java/com/glxp/api/idc/service/DownloadRestTemplate.java b/src/main/java/com/glxp/api/idc/service/DownloadRestTemplate.java deleted file mode 100644 index 205d08b..0000000 --- a/src/main/java/com/glxp/api/idc/service/DownloadRestTemplate.java +++ /dev/null @@ -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 doExecute(URI url, @Nullable HttpMethod method, @Nullable RequestCallback requestCallback, - @Nullable ResponseExtractor 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(); - } - }*/ - } -} diff --git a/src/main/java/com/glxp/api/idc/service/FileService.java b/src/main/java/com/glxp/api/idc/service/FileService.java deleted file mode 100644 index a0e7115..0000000 --- a/src/main/java/com/glxp/api/idc/service/FileService.java +++ /dev/null @@ -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 list); - BaseResponse download(List list); - BaseResponse fileUpload(HttpServletRequest request,Map params); - BaseResponse fileDownload(HttpServletRequest request,Map params); - BaseResponse downloadFile(HttpServletRequest request,Map params); - BaseResponse receiveFile(HttpServletRequest request,String content,MultipartFile[] files); -} diff --git a/src/main/java/com/glxp/api/idc/service/IdcService.java b/src/main/java/com/glxp/api/idc/service/IdcService.java deleted file mode 100644 index d135a90..0000000 --- a/src/main/java/com/glxp/api/idc/service/IdcService.java +++ /dev/null @@ -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 params); - BaseResponse uploadFile(HttpServletRequest request, - String content,MultipartFile[] files); - BaseResponse send(Map params); - BaseResponse send(String messageType,String tableName,Map params); - - BaseResponse taskList(HttpServletRequest request,Map params); - - BaseResponse download(HttpServletRequest request,Map params); - BaseResponse uploadStatus(HttpServletRequest request,Map params); - BaseResponse downloadStatus(HttpServletRequest request,Map params); - public void asyncFetchTask(); - public void asyncFetchUdiTask(); - - BaseResponse downlaodSuccess(HttpServletRequest request,Map 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); -} diff --git a/src/main/java/com/glxp/api/idc/service/impl/ConnectServiceImpl.java b/src/main/java/com/glxp/api/idc/service/impl/ConnectServiceImpl.java deleted file mode 100644 index f83aad1..0000000 --- a/src/main/java/com/glxp/api/idc/service/impl/ConnectServiceImpl.java +++ /dev/null @@ -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 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 map = new HashMap(); - map.put("level", level); - Map 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 map = new HashMap<>(); - map.put("tableName", tableName); - map.put("uniqueValue", uniqueValue); - return syncDelete(map); - } - @Override - public boolean syncDelete(Map 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) { - - } - } -} \ No newline at end of file diff --git a/src/main/java/com/glxp/api/idc/service/impl/FileServiceImpl.java b/src/main/java/com/glxp/api/idc/service/impl/FileServiceImpl.java deleted file mode 100644 index 064542d..0000000 --- a/src/main/java/com/glxp/api/idc/service/impl/FileServiceImpl.java +++ /dev/null @@ -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 list) { - return fileToUpload(list); - } - - @Override - public BaseResponse download(List list) { - return fileToDownload(list); - } - - @Override - public BaseResponse fileUpload(HttpServletRequest request, Map params) { - List list = new ArrayList<>(); - String[] strs = params.get("fileName").toString().split(","); - for (String str : strs) { - list.add(str); - } - return fileToUpload(list); - } - - private BaseResponse fileToUpload(List list) { - String host = ""; - try { - Map 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 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 files = new ArrayList<>(); - boolean isExists = true; - List 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 params) { - List list = new ArrayList<>(); - String[] strs = params.get("fileName").toString().split(","); - for (String str : strs) { - list.add(str); - } - return fileToDownload(list); - } - - - private BaseResponse fileToDownload(List list) { - Map params = new HashMap(); - String fileName = ""; - for (String str : list) { - fileName += fileName.length() > 0 ? "," + str : str; - } - params.put("fileName", fileName); - Map 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 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 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(" 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 params) { - String host = ""; - try { - Map 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); - } - -} diff --git a/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java b/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java deleted file mode 100644 index 80854e1..0000000 --- a/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java +++ /dev/null @@ -1,1478 +0,0 @@ -package com.glxp.api.idc.service.impl; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.text.WordUtils; -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.jdbc.core.JdbcTemplate; -import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.support.CronSequenceGenerator; -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.dao.schedule.ScheduledDao; -import com.glxp.api.entity.system.ScheduledEntity; -import com.glxp.api.entity.system.SystemParamConfigEntity; -import com.glxp.api.idc.service.IdcService; -import com.glxp.api.idc.utils.DBAUtils; -import com.glxp.api.idc.utils.IDCUtils; -import com.glxp.api.idc.utils.TableUtils; -import com.glxp.api.req.system.ScheduledRequest; -import com.glxp.api.service.system.SystemParamConfigService; -import com.glxp.api.util.CustomUtil; -import com.glxp.api.util.DateUtil; -import com.glxp.api.util.FileUtils; - -import lombok.extern.slf4j.Slf4j; -import okhttp3.MediaType; -import okhttp3.MultipartBody; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; - -/*数据中继数据中心(接收)*/ -@Slf4j -@Service -public class IdcServiceImpl implements IdcService { - private static final Logger logger = LoggerFactory.getLogger(IdcServiceImpl.class); - @Value("${file_path}") - private String filePath; - @Value("${back_file_path}") - private String backFilePath; - - @Value("${API_KEY}") - private String apiKey; - @Value("${API_SECRET}") - private String apiSecret; - - - private int orderNum = 0; - - @Resource - private SystemParamConfigService systemParamConfigService; - - @Resource - private JdbcTemplate jdbcTemplate; - - @Resource - private DbDao dbDao; - - @Resource - private ScheduledDao scheduledDao; - - private String imagePath = "register/file/image2/"; - /*获取拉取任务列表*/ - @Override - public BaseResponse taskList(HttpServletRequest request, Map params) { - Map map = new HashMap(); - map.put("sql", "select id as taskId from basic_export_status where receiveStatus='0'"); - List> list = dbDao.list(map); - return ResultVOUtils.success(list); - } - - - /*下载任务*/ - @Override - public BaseResponse download(HttpServletRequest request, Map params) { - return statusFile(params, "basic_export_status"); - } - - @Override - public BaseResponse uploadStatus(HttpServletRequest request, Map params) { - return statusFile(params, "basic_upload_status"); - } - - @Override - public BaseResponse downloadStatus(HttpServletRequest request, Map params) { - return statusFile(params, "basic_download_status"); - } - - private BaseResponse statusFile(Map params, String tableName) { - String id = ""; - if (params.containsKey("taskId") && params.get("taskId") != null) { - id = params.get("taskId").toString(); - } else { - id = params.get("id").toString(); - } - - Map map = map = dbDao.get("select * from " + tableName + " where id='" + id + "'"); - - if (map == null) - return ResultVOUtils.error(9000, "下载任务不存在" + tableName); - if (!(map.get("cacheFilePath") != null && FileUtils.isFileExist(map.get("cacheFilePath").toString()))) - return ResultVOUtils.error(9000, "下载文件不存在-" + tableName); - String json = FileUtils.readFileAll(map.get("cacheFilePath").toString()); - - JSONObject object = JSON.parseObject(json); - if (object == null) - return ResultVOUtils.error(9000, "任务下载失败"); - if (object != null && object.getInteger("code") != null) { - BaseResponse response = JSON.parseObject(json, BaseResponse.class); - return response; - } - - return ResultVOUtils.success(object); - } - - - /*UDI系统上传自助平台*/ - @Override - public void asyncUdiTask() { - logger.info("UDI管理系统同步任务开始--------"); - asyncDataTask(true); - } - - /*自助平台生成任务,不上传*/ - @Override - public void asyncSpsTask() { - logger.info("自助平台同步任务开始--------"); - asyncDataTask(false); - } - - /*UDI系统拉取前一级中继服务或自助平台数据*/ - @Async - @Override - public void asyncFetchUdiTask() { - fetchTask(false); - } - - /*中继服务拉取任务*/ - @Async - @Override - public void asyncFetchTask() { - initTable(); - Map map = dbDao.get("select * from idc_var where code='system_type'"); - if (map == null) { - dbDao.save("insert into idc_var (code,content) values ('system_type','IDC')"); - } - fetchTask(true); - } - - - /*任务拉取,isIdc 是否中继服务*/ - private void fetchTask(boolean isIdc) { - - String host = getNextHost(); - if (!isIdc) { - Map map = dbDao.get("select * from sync_data_set limit 1"); - if (map != null && map.get("syncIp") != null) - host = map.get("syncIp").toString(); - } - if (!StringUtils.isEmpty(host)) { - String result = IDCUtils.post(host + "/spssync/common/list", null); - if (IDCUtils.isJson(result)) { - JSONObject json = JSON.parseObject(result); - if (json != null && json.getInteger("code") == 20000 && json.getString("data") != null) { - List list = JSON.parseArray(json.getString("data"), Map.class); - if (list != null) { - for (Map map : list) { - Map params = new HashMap(); - params.put("taskId", map.get("taskId")); - fetchData(host, params); - } - } - } - } - //拉取失败文件 - fetchFailFile(host); - } - } - - - private void fetchFailFile(String host) { - Map map = new HashMap(); - map.put("sql", "select * from idc_file where createTime> list = dbDao.list(map); - for(int i=0;i map = dbDao.get("select * from sync_data_set limit 1"); - if (map != null && map.get("downstreamEnable") != null && map.get("downstreamEnable").toString().equals("1")) { - if (isUpload) { - if (!(map.get("syncIp") != null && !StringUtils.isEmpty(map.get("syncIp").toString()))) { - logger.error("中继服务地址未配置"); - return; - } - /*未发送重新发送*/ - asyncFailTask(map.get("syncIp").toString()); - } - - String[] syncTables = TableUtils.syncTables(); - for (int i = 0; i < syncTables.length; i++) { - String[] tnames = syncTables[i].split("/"); - boolean sync = (StringUtils.isEmpty(tnames[0])&&StringUtils.isEmpty(tnames[1])) || - (!StringUtils.isEmpty(tnames[0]) && map != null && map.get(tnames[0]) != null && map.get(tnames[0]).toString().equals("1")); - saveIdcLog("---", "", map.get(tnames[0]) + syncTables[i], 0, 0); - if (sync) { - String syncIp = map.get("syncIp") != null ? map.get("syncIp").toString() : ""; - syncData(syncTables[i], isUpload, syncIp); - asyncDelete(syncTables[i], isUpload, syncIp); - } - } - } - } - - - /*上传失败重新上传*/ - private void asyncFailTask(String host) { - try - { - String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/"; - String sql = "select * from basic_export_status where status='1' and receiveStatus='0' where updateTime map = new HashMap(); - map.put("sql", sql); - List> list = dbDao.list(map); - ArrayList files = new ArrayList<>(); - for(int i=0;i dataList = JSONObject.parseArray(JSON.toJSONString(object.get("data")), Map.class); - for (int m = 0; m < dataList.size(); m++) { - if(object.get("filePathColumn")!=null&&!StringUtils.isEmpty(object.get("filePathColumn").toString())&& - dataList.get(m).get(object.get("filePathColumn").toString()) !=null ) { - String fileNames = dataList.get(m).get(object.get("filePathColumn").toString()).toString(); - String[] str = fileNames.split(","); - for (int r = 0; r < str.length; r++) { - if (!StringUtils.isEmpty(str[r]) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + str[r])) - files.add(filePath + filePathSlash + imagePath + str[r]); - } - } - for(int k=0;k<30;k++) { - if(dataList.get(k).get("tableName"+k) == null) - break; - if(dataList.get(k).get("data"+k)!=null && dataList.get(k).get("filePathColumn"+k)!=null) { - List childList = JSONObject.parseArray(JSON.toJSONString(dataList.get(i).get("data"+k)), Map.class); - for(int x =0 ;x reUpload->success", 0, 0); - } else { - saveIdcLog(object.getString("messageType"), list.get(i).get("id").toString(), object.getString("tableName") + ">reUpload->fail", 0, 0); - } - } else { - saveIdcLog(object.getString("messageType"), list.get(i).get("id").toString(), object.getString("tableName") + ">reUpload->fail", 0, 0); - } - } - } catch (Exception ex) { - - } - } - - /*数据删除同步*/ - private void asyncDelete(String tname,boolean isUpload,String syncIp) { - String[] tnames = tname.split("/"); - String lastUpdateTime = getUpdateTime(tnames[2] + "." + tnames[0]+"."+tnames[1]+".delete"); - Date nowUpdateTime = new Date(); - String where = "tableName='"+tnames[2].toLowerCase()+"' and updateTime between cast('"+lastUpdateTime+"' as datetime) "+ - " and cast('"+DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss")+"' as datetime)"; - Map count = new HashMap(); - count.put("sql", "select count(*) from idc_delete where "+where); - int total = dbDao.count(count); - int limit = 50; - if (total > 0) { - boolean success = true; - for (int i = 0; i < Math.ceil(total / limit) + 1; i++) { - Date startTime = new Date(); - Map map = new HashMap(); - map.put("sql", "select * from idc_delete"); - map.put("sqlWhere", where); - map.put("limit", limit); - map.put("page", i * limit); - List> list = dbDao.list(map); - if(list!=null&&map.size()>0) { - List> data = new ArrayList<>(); - for(int k=0;i0 ? ","+key : key; - } - obj.put("uniqueColumn", uniqueColumn); - obj.put("operateMode", "D"); - data.add(obj); - } - Map msg = new HashMap(); - msg.put("messageId", CustomUtil.getId()); - msg.put("messageType", tnames[9]+"(删除)"); - msg.put("apiCode", "common"); - msg.put("tableName", DBAUtils.tableAliasName(tnames[2])); - msg.put("sendTime", new Date()); - msg.put("version", "1.0"); - msg.put("total", data.size()); - msg.put("data", data); - if (isUpload) { - String result = ""; - try { - result = relay("", JSON.toJSONString(msg), null, syncIp); - } catch (Exception ex) { - - } - if (IDCUtils.isJson(result)) { - JSONObject json = JSON.parseObject(result); - if (json.getInteger("code") == 20000) { - saveIdcLog(tnames[9], "", tnames[2] + ">success(delete)", i * limit, total); - } else { - success = false; - - saveIdcLog(tnames[9], "", tnames[2] + ">" + result, i * limit, total); - } - } else { - success = false; - saveIdcLog(tnames[9], "", syncIp + ":" + tnames[2] + ">fail:上传地址未连通", i * limit, total); - } - - } else { - saveIdcLog(tnames[9], "", tnames[2] + ">success(delete)", i * limit, total); - } - syncAddTaskStatus(msg, isUpload ? 1 : 0, true, startTime, isUpload,success); - } - } - } - } - - /*单独表调用,tableName可只传表名,如传完整参数按SYNCS_TABLES格式*/ - @Override - public BaseResponse onceSync(String tableName, boolean isUpload) { - String tnames = tableName.contains("/") ? tableName : "//" + tableName + "///////"; - String[] ts = tnames.split("/"); - String ip = ""; - Map map = dbDao.get("select * from sync_data_set limit 1"); - if (isUpload) { - if (!(map.get("syncIp") != null && !StringUtils.isEmpty(map.get("syncIp").toString()))) { - logger.error("中继服务地址未配置"); - return ResultVOUtils.error(9999, "中继服务地址未配置"); - } - ip = map.get("syncIp").toString(); - } - if (!StringUtils.isEmpty(ts[0])) { - if (!(map != null && map.get(ts[0]) != null && map.get(ts[0]).equals("1"))) - return ResultVOUtils.error(9999, "当前不允许生成"); - } - if (syncData(tnames, isUpload, ip)) - return ResultVOUtils.success(); - return ResultVOUtils.error(9999, "系统错误"); - } - - private boolean syncData(String t, boolean isUpload, String syncIp) { - boolean sync = true; - boolean result = false; - try { - String[] tnames = t.split("/"); - - String lastUpdateTime = getUpdateTime(tnames[2] + "." + tnames[0]+"."+tnames[1]); - Date nowUpdateTime = new Date(); -// if (!StringUtils.isEmpty(tnames[0])) { - - List> keyList = dbDao.listKeyMysql(tnames[2]); - String keyColumn = keyList != null && keyList.size() > 0 ? keyList.get(0).get("columnName").toString() : "id"; - Map map = new HashMap(); - String sqlWhere = ""; - String updateTimeColumn = tnames[6]; - if (StringUtils.isEmpty(updateTimeColumn)) { - Map tMap = dbDao.get("select column_name columnName from information_schema.columns where column_name='updateTime' and lower(table_name) = lower('" + tnames[0] + "') and table_schema = (select database()) limit 1"); - updateTimeColumn = tMap != null ? "updateTime" : ""; - } - - - if (!StringUtils.isEmpty(updateTimeColumn)) { - sqlWhere += " " + updateTimeColumn + " between cast('" + lastUpdateTime + "' as datetime) and cast('"+DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss")+"' as datetime)"; - //sqlWhere += " and not exists (select fkId from idc_record where type='" + tnames[2] + "' and fkId=" + tnames[2] + "." + keyColumn + " and createTime>date_sub(now(),interval 15 MINUTE))"; - } else { - sqlWhere = "not exists (select fkId from idc_record where type='" + tnames[2] + "' and fkId=" + tnames[2] + "." + keyColumn + ")"; - map.put("isEnd", "1"); - } - map.put("sqlWhere", sqlWhere); - - map.put("tableKey", tnames[0]); - map.put("tableName", tnames[2]); - map.put("uniqueColumn", tnames[3]); - map.put("masterLinkColumn", tnames[4]); - map.put("subLinkColumn", tnames[5]); - map.put("filePathColumn", tnames[7]); - map.put("dataWhere", tnames[8]); - map.put("messageType", tnames[9]); - map.put("messageName", tnames[9]); - ScheduledRequest scheduledRequest = new ScheduledRequest(); - scheduledRequest.setCronName("sync" + WordUtils.capitalizeFully(tnames[2], new char[]{'_'}).replace("_", "")); - ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest); - String cron = scheduledEntity != null ? scheduledEntity.getCron() : ""; - - if (!StringUtils.isEmpty(cron)) { - CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(cron); - Date nextTimePoint = cronSequenceGenerator.next(DateUtil.parseDate(lastUpdateTime)); - sync = nextTimePoint.before(nowUpdateTime); - } - if (sync) { - result = syncMasterData(map, isUpload, syncIp); - if (result) { - setUpdateTime(tnames[2] + "." + tnames[0]+"."+tnames[1], DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss")); - } - } - //} - } catch (Exception ex) { - - } - return result; - } - - - private String fetchData(String host, Map params) { - OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - MediaType mediaType = MediaType.parse("application/json"); - RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(params)); - Request request = new Request.Builder() - .url(host + "/spssync/common/download") - .method("POST", body) - .addHeader("Content-Type", "application/json") - .build(); - String result = ""; - MultipartFile[] files = {}; - Date startTime = new Date(); - try { - boolean success = true; - Response response = client.newCall(request).execute(); - result = response.body().string(); - JSONObject json = JSONObject.parseObject(result); - - if (isLastLevel()) { - if (json.get("code") != null && json.getInteger("code") == 20000) { - success = analyMiddle(host, json.getJSONObject("data"), files, false, true); - if (!success) - logger.info("fetchData-->解析失败"); - } else { - success = false; - } - syncAddTaskStatus(json.getJSONObject("data"), 3, true, startTime, true,success); - } else { - if (json.get("code") != null && json.get("data") != null) { - //logger.info("res1-->"+JSON.toJSONString(json)); - syncAddTaskStatus(json.getJSONObject("data"), 0, true, startTime, true,success); - analyMiddle(host, json.getJSONObject("data"), files, false, false); - } - } - - if (success) { - String ret = IDCUtils.post(host + "/spssync/common/success", params); - - } - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - logger.error("fetchData-->" + e.getMessage()); - } - return result; - } - - - public BaseResponse downlaodSuccess(HttpServletRequest request, Map params) { - String sql = "update basic_export_status set receiveStatus='1',endTime=now() where id='" + params.get("taskId") + "'"; - dbDao.update(sql); - return ResultVOUtils.success(); - } - - - @Override - public BaseResponse receiveJson(HttpServletRequest request, Map params) { - - return ResultVOUtils.success(); - } - - @Override - public BaseResponse uploadFile(HttpServletRequest request, - String content, MultipartFile[] files) { - return ResultVOUtils.success(); - } - - /****/ - @Override - public BaseResponse receive(HttpServletRequest request, - String content, MultipartFile[] files) { - /*授权检查,后续完善*/ - String apiKey = request.getHeader("apiKey"); - String secretKey = request.getHeader("secretKey"); - /*******/ - JSONObject json = JSONObject.parseObject(content); - String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/"; - String backFileSlash = backFilePath.substring(backFilePath.length() - 1).equals("/") ? "" : "/"; - String datePath = DateUtil.formatDate(new Date(), "yyyy-MM-dd"); - String fileName = filePath + filePathSlash + datePath + "/" + json.getString("messageType") + "-" + json.getString("messageId") + ".udi"; - String backFileName = backFilePath + backFileSlash + datePath + "/" + json.getString("messageType") + "-" + json.getString("messageId") + ".udi"; - if (!FileUtils.makeDirectory(filePath + filePathSlash + datePath)) - IDCUtils.createDirectory(filePath + filePathSlash + datePath + "/"); - if (!FileUtils.makeDirectory(backFilePath + backFileSlash + datePath)) - IDCUtils.createDirectory(filePath + backFileSlash + datePath + "/"); - if(!FileUtils.makeDirectory(filePath + filePathSlash + imagePath)) - IDCUtils.createDirectory(filePath + filePathSlash + imagePath); - FileUtils.SaveFileAs(content, fileName); - FileUtils.SaveFileAs(content, backFileName); - ArrayList saveFiles = new ArrayList<>(); - Date startTime = new Date(); - if (files != null) { - - int n = 0; - try { - for (MultipartFile file : files) { - String imageName = filePath + filePathSlash + imagePath + file.getOriginalFilename(); - saveFiles.add(imageName); - - writeFile(file.getBytes(), filePath + filePathSlash + imagePath, file.getOriginalFilename()); - writeFile(file.getBytes(), backFilePath + backFileSlash + datePath + imagePath, file.getOriginalFilename()); - n++; - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - /*解析入库*/ - boolean success = false; - if (isLastLevel()) { - success = analyMiddle("", json, files, true, true); - syncAddTaskStatus(json, 3, true, startTime, true,success); - if (!success) { - - return ResultVOUtils.error(9000, "解析失败"); - } - } else { - //需要转发 - if (isRelay()) { - String host = getNextHost(); - String result = relay(request.getHeader("reqNo"), content, saveFiles, host); - if (IDCUtils.isJson(result)) { - syncAddTaskStatus(json, 2, true, startTime, true,true); - BaseResponse object = JSON.parseObject(result, BaseResponse.class); - return object; - } else { - syncAddTaskStatus(json, 2, true, startTime, false,false); - return ResultVOUtils.error(9000, "转发失败"); - } - - } - } - return ResultVOUtils.success(); - } - - - /*数据同步,从数据库获取数据下发或上传下级中继服务*/ - @Override - public BaseResponse send(Map params) { - - return send(params.get("messageType").toString(), params.get("tableName").toString(), params); - - - } - - @Override - public BaseResponse send(String messageType, String tableName, Map params) { - - return ResultVOUtils.error(9999, ""); - } - - - @Override - public void downloadFile(String fileName, HttpServletResponse response) { - OutputStream os; - String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : fileName.substring(0, 1).equals("/") ? "" : "/"; - String sourceFileName = filePath +filePathSlash+imagePath +fileName; - try { - if (FileUtils.isFileExist(sourceFileName)) { - byte[] bytes = FileUtils.readFileByBytes(sourceFileName); - os = response.getOutputStream(); - os.write(bytes); - os.flush(); - os.close(); - } else { - logger.error("file not exists:"+sourceFileName); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - private void saveUploadStatus(Map params) { - Map map = new HashMap(); - map.putAll(params); - - Map columns = getColumn("basic_upload_status"); - String sql = "replace basic_upload_status " + DBAUtils.parseInsert(map, columns); - - dbDao.save(sql); - } - - private void saveExportStatus(Map params) { - Map map = new HashMap(); - map.putAll(params); - Map columns = getColumn("basic_export_status"); - String sql = "replace basic_export_status " + DBAUtils.parseInsert(map, columns); - - dbDao.save(sql); - } - - private void saveDownloadStatus(Map params) { - Map map = new HashMap(); - map.putAll(params); - - Map columns = getColumn("basic_download_status"); - String sql = "replace basic_download_status " + DBAUtils.parseInsert(map, columns); - - dbDao.save(sql); - } - - private void saveIdcLog(String messageType, String taskId, String content, int offset, int total) { - Map map = new HashMap(); - map.put("id", CustomUtil.getId()); - map.put("taskId", taskId); - map.put("orderNum", orderNum); - map.put("type", messageType); - map.put("createTime", new Date()); - map.put("content", content); - map.put("offset", offset); - map.put("total", total); - Map columns = getColumn("idc_log"); - String sql = "insert into idc_log " + DBAUtils.parseInsert(map, columns); - - dbDao.save(sql); - } - - - private boolean syncMasterData(Map params, boolean isUpload, String syncIp) { - boolean success = false; - String tableName = params.get("tableName").toString(); - String tableKey = params.get("tableKey").toString(); - String[] childs = new String[30]; - int childNum = -1; - /*子表*/ - String[] syncTables = TableUtils.syncTables(); - if (!StringUtils.isEmpty(tableKey)) { - for (String str : syncTables) { - if (str.contains("/" + tableKey + "/")) { - childNum++; - childs[childNum] = str; - } - } - } - Map table = dbDao.getMysql(tableName); - if (!(table != null && table.get("tableName") != null)) - return false; - String sql = "select count(*) from " + tableName; - Map column = getColumn(tableName); - - Map whereParams = new HashMap(); - whereParams.put("sqlWhere", params.get("sqlWhere")); - - String dataWhere = params.get("dataWhere")!=null ? params.get("dataWhere").toString() : ""; - Map map = new HashMap(); - String where = DBAUtils.convertWhere(column, whereParams, dataWhere); - sql += !StringUtils.isEmpty(where) ? " where " + where : ""; - map.put("sql", sql); - int total = dbDao.count(map); - - String isEnd = params.get("isEnd") != null ? params.get("isEnd").toString() : "0"; - int limit = 50; - ArrayList files = new ArrayList<>(); - - String filePathColumn = params.get("filePathColumn") != null ? params.get("filePathColumn").toString() : ""; - orderNum++; - String messageType = params.get("messageType").toString(); - saveIdcLog(messageType, "", tableName + ">" + where, 0, total); - String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/"; - - if (total > 0) { - success = true; - - whereParams.put("page", 0); - whereParams.put("limit", limit); - - List> keyList = dbDao.listKeyMysql(tableName); - String keyColumn = keyList != null && keyList.size() > 0 ? keyList.get(0).get("columnName").toString() : "id"; - for (int i = 0; i < Math.ceil(total / limit) + 1; i++) { - whereParams.replace("page", i * limit); - whereParams.replace("limit", limit); - Date startTime = new Date(); - Map data = getData(messageType, tableName, params, whereParams); - String recordSql = ""; - orderNum++; - saveIdcLog(messageType, "", tableName + ">" + where, i * limit, total); - if (data.get("data") != null) { - - List list = JSONObject.parseArray(JSON.toJSONString(data.get("data")), Map.class); - if (list != null && list.size() > 0) { - for (int m = 0; m < list.size(); m++) { - - if (!StringUtils.isEmpty(filePathColumn) && list.get(m).get(filePathColumn) != null) { - String fileNames = list.get(m).get(filePathColumn).toString(); - String[] str = fileNames.split(","); - for (int r = 0; r < str.length; r++) { - if (!StringUtils.isEmpty(str[r]) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + str[r])) - files.add(filePath + filePathSlash + imagePath + str[r]); - } - } - recordSql += !StringUtils.isEmpty(recordSql) ? "," : ""; - recordSql += "('" + UUID.randomUUID().toString().replaceAll("-", "") + "','" + tableName + "','" + list.get(m).get(keyColumn) + "','" + isEnd + "',now())"; - - if (childNum > -1) { - for (int z = 0; z < childNum + 1; z++) { - String[] chidTnames = childs[z].split("/"); - if (!StringUtils.isEmpty(chidTnames[4]) && !StringUtils.isEmpty(chidTnames[5])) { - String keyValue = list.get(m).get(chidTnames[4]).toString(); - Map childMap = new HashMap<>(); - childMap.put(chidTnames[5], keyValue); - List> childList = getList(chidTnames[2], childMap); - list.get(m).put("tableName" + z, chidTnames[2]); - list.get(m).put("filePathColumn" + z, chidTnames[7]); - list.get(m).put("data" + z, childList); - if (!StringUtils.isEmpty(chidTnames[7]) && childList.size() > 0) { - for (int x = 0; x < childList.size(); x++) { - if (childList.get(i).get(chidTnames[7]) != null) { - String[] str = childList.get(i).get(chidTnames[7]).toString().split(","); - for (int s = 0; s < str.length; s++) { - if (!StringUtils.isEmpty(str[s]) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + str[s])) - files.add(filePath + filePathSlash + imagePath + str[s]); - } - } - } - } - } - } - } - } - data.replace("data", list); - orderNum++; - - if (isUpload) { - String result = ""; - try { - result = relay("", JSON.toJSONString(data), files, syncIp); - } catch (Exception ex) { - - } - if (IDCUtils.isJson(result)) { - JSONObject json = JSON.parseObject(result); - if (json.getInteger("code") == 20000) { - if (!StringUtils.isEmpty(recordSql)) { - dbDao.save("insert into idc_record (id,type,fkId,isEnd,createTime) values " + recordSql); - } - saveIdcLog(messageType, "", tableName + ">success", i * limit, total); - } else { - success = false; - - saveIdcLog(messageType, "", tableName + ">" + result, i * limit, total); - } - } else { - success = false; - saveIdcLog(messageType, "", syncIp + ":" + tableName + ">fail:上传地址未连通", i * limit, total); - } - - } else { - if (!StringUtils.isEmpty(recordSql)) { - dbDao.save("insert into idc_record (id,type,fkId,isEnd,createTime) values " + recordSql); - } - saveIdcLog(messageType, "", tableName + ">success", i * limit, total); - } - syncAddTaskStatus(data, isUpload ? 1 : 0, true, startTime, isUpload,success); - } - } - } - - } - - return success; - } - - /*增加同步任务状态*/ - private void syncAddTaskStatus(Map json, int scheduleType, boolean success, Date startTime, - boolean isEnd,boolean isReceive) { - try { - String content = JSON.toJSONString(json); - String datePath = DateUtil.formatDate(new Date(), "yyyy-MM-dd"); - String fileName = filePath + datePath + "/" + json.get("messageType") + "-" + json.get("messageId") + ".udi"; - String backFileName = backFilePath + datePath + "/" + json.get("messageType") + "-" + json.get("messageId") + ".udi"; - if (!FileUtils.makeDirectory(filePath + datePath)) - IDCUtils.createDirectory(filePath + datePath + "/"); - if (!FileUtils.makeDirectory(backFilePath + datePath)) - IDCUtils.createDirectory(filePath + datePath + "/"); - - FileUtils.SaveFileAs(content, fileName); - FileUtils.SaveFileAs(content, backFileName); - - //type,transportType,superiorService,subordinateService,cacheFilePath - Map map = new HashMap<>(); - map.put("type", json.get("messageType")); - map.put("id", json.get("messageId")); - if (json.get("messageId") == null) - map.put("id", CustomUtil.getId()); - map.put("transportType", scheduleType == 0 ? "1" : "2"); - map.put("scheduleType", scheduleType); - map.put("taskId", json.get("messageId")); - map.put("cacheFilePath", fileName); - map.put("status", success ? "1" : "0"); - map.put("receiveStatus", isReceive ? "1" : "0"); - map.put("startTime", startTime != null ? startTime : new Date()); - if(isReceive) - map.put("endTime", new Date()); - map.put("updateTime", new Date()); - map.put("remark", json.get("messageType") + ": " + json.get("total") + "条"); - if (isEnd) - map.put("endTime", new Date()); - if (scheduleType == 2) { - saveUploadStatus(map); - } else if (scheduleType == 3) { - saveDownloadStatus(map); - } else { - saveExportStatus(map); - } - } catch (Exception ex) { - logger.error(ex.getMessage()); - } - - } - - private boolean analyMiddle(String host, JSONObject jsonObject, MultipartFile[] files, boolean isUpload, - boolean isToDB) { - if (jsonObject.get("data") != null) { - String tableName = ""; - String uniqueColumn = ""; - String filePathColumn = ""; - Object object = jsonObject.get("data"); - List> list = new ArrayList<>(); - if (object instanceof List) { - list = jsonObject.getObject("data", List.class); - tableName = jsonObject.getString("tableName"); - uniqueColumn = jsonObject.getString("uniqueColumn"); - filePathColumn = jsonObject.getString("filePathColumn"); - } else { - JSONObject obj = jsonObject.getJSONObject("data"); - list = obj.getObject("data", List.class); - tableName = obj.getString("tableName"); - uniqueColumn = obj.getString("uniqueColumn"); - filePathColumn = obj.getString("filePathColumn"); - } - if (!StringUtils.isEmpty(tableName)) { - if (isToDB) { - return analyToDB(host, tableName, uniqueColumn, filePathColumn, list, isUpload); - } else { - //logger.info("files-->"+tableName); - return analyToFile(host, filePathColumn, list); - } - } else { - logger.error("数据格式错误:无数据标记"); - } - //图片处理 - } - return false; - } - - private boolean analyToFile(String host, String filePathColumn, List> list) { - - if (list != null && list.size() > 0) { - String[] files = new String[list.size()]; - //logger.info("filePathColumn-->"+filePathColumn); - for (int i = 0; i < list.size(); i++) { - if (!StringUtils.isEmpty(filePathColumn)) { - files[i] = list.get(i).get(filePathColumn) != null ? list.get(i).get(filePathColumn).toString() : ""; - logger.info("file-->"+files[i]); - } - for (int z = 0; z < 30; z++) { - if (list.get(i).get("data" + z) != null) { - if (list.get(i).get("filePathColumn" + z) != null) { - List> childList = (List>) list.get(i).get("data" + z); - analyToFile(host, list.get(i).get("filePathColumn" + z).toString(), childList); - } - } else { - break; - } - } - } - - batchDownloadFile(host, files); - } - return true; - } - /*解析到数据库*/ - - /*按表名解析数据到数据库,子表暂未处理*/ - private boolean analyToDB(String host, String tableName, String uniqueColumn, String - filePathColumn, List> list, boolean isUpload) { - - - String tName = DBAUtils.tableRealName(tableName); - String sql = "replace " + tName + "("; - String del = "delete from " + tName + " where "; - String upd = "update " + tName + " set "; - String[] keyColumn = new String[30]; - String[] keyDataType = new String[30]; - List> columnList = dbDao.listColumnsMysql(tName); - Map column = getColumn(tName); - boolean result = false; - int key = 0; - int col = 0; - for (int i = 0; i < columnList.size(); i++) { - if (col > 0) - sql += ","; - columnList.get(i).put("attrName", columnList.get(i).get("columnName")); - sql += "`"+columnList.get(i).get("columnName").toString()+"`"; - col++; - if (uniqueColumn != null && columnList.get(i).get("columnKey") != null && ("," + uniqueColumn + ",").contains("," + columnList.get(i).get("columnName") + ",")) { - keyColumn[key] = columnList.get(i).get("columnName").toString(); - keyDataType[key] = columnList.get(i).get("dataType").toString().contains("char") ? "C" : columnList.get(i).get("dataType").toString().contains("date") ? "D" : "N"; - key++; - } else { - if (columnList.get(i).get("columnKey") != null && !StringUtils.isEmpty(columnList.get(i).get("columnKey").toString()) && - ("PRI".contains(columnList.get(i).get("columnKey").toString()))) { - keyColumn[key] = columnList.get(i).get("columnName").toString(); - keyDataType[key] = columnList.get(i).get("dataType").toString().contains("char") ? "C" : columnList.get(i).get("dataType").toString().contains("date") ? "D" : "N"; - key++; - } - } - } - sql += ") values "; - - if (list != null && list.size() > 0) { - int n = 0; - int d = 0; - String[] files = new String[list.size()]; - for (int i = 0; i < list.size(); i++) { - String operateMode = list.get(i).get("operateMode") != null ? list.get(i).get("operateMode").toString() : "A"; - String updateWhere = ""; - String updateSet = ""; - if (!StringUtils.isEmpty(filePathColumn)) { - files[i] = list.get(i).get(filePathColumn) != null ? list.get(i).get(filePathColumn).toString() : ""; - } - - if ("A,D,U".contains(operateMode)) { - if(operateMode.equals("D")&&list.get(i).get("uniqueColumn")!=null) { - String[] ucs = list.get(i).get("uniqueColumn").toString().split(","); - for(String str:ucs) { - Map map = (Map) column.get(str); - String dataType = map.get("dataType").toString(); - updateWhere += !StringUtils.isEmpty(updateWhere) ? " and " : " "; - updateWhere += str +" = "+(dataType.equals("C") ? "'" : "") + list.get(i).get(str) + (dataType.equals("C") ? "'" : ""); - } - } else { - for (int z = 0; z < keyColumn.length; z++) { - if (list.get(i).get(keyColumn[z]) != null && !StringUtils.isEmpty(list.get(i).get(keyColumn[z]).toString())) { - updateWhere += !StringUtils.isEmpty(updateWhere) ? " and " : " "; - String value = list.get(i).get(keyColumn[z]) != null ? list.get(i).get(keyColumn[z]).toString() : ""; - value = keyDataType[z].equals("D") ? "cast('" + DateUtil.formatDate(IDCUtils.parseDate(value), "yyyy-MM-dd HH:mm:ss") + "' as datetime)" : value; - updateWhere += keyColumn[z] + " = " + (keyDataType[z].equals("C") ? "'" : "") + value + (keyDataType[z].equals("C") ? "'" : ""); - } - } - } - if ("A,D".contains(operateMode) && !StringUtils.isEmpty(updateWhere)) - dbDao.delete(del + updateWhere); - } - - /*A 新增 U 更新*/ - if ("A,U".contains(operateMode)) { - sql += n > 0 ? "," : ""; - sql += "("; - int m = 0; - int h = 0; - for (int k = 0; k < columnList.size(); k++) { - String attrName = columnList.get(k).get("attrName"); - String value = list.get(i).get(attrName) != null ? list.get(i).get(attrName).toString() : ""; - value = DBAUtils.escape(value); - String dataType = columnList.get(k).get("dataType").toLowerCase().contains("char") || columnList.get(k).get("dataType").toLowerCase().contains("text") ? - "C" : columnList.get(k).get("dataType").toLowerCase().contains("date") ? "D" : "N"; - - sql += m > 0 ? "," : ""; - boolean ups = list.get(i).containsKey(attrName) ? true : false; - updateSet += ups && h > 0 ? "," : ""; - updateSet += ups ? columnList.get(k).get("columnName") + "=" : ""; - if (StringUtils.isEmpty(value)) { - sql += "null"; - updateSet += ups ? "null" : ""; - } else { - if (dataType.equals("C")) { - sql += "'" + value + "'"; - updateSet += ups ? "'" + value + "'" : ""; - } else if (dataType.equals("N")) { - sql += value; - updateSet += ups ? value : ""; - } else { - Date date = new Date(); - date = StringUtils.isNumeric(value) ? new Date(Long.valueOf(value)) : IDCUtils.parseDate(value); - String str = DateUtils.format(date, "yyyy-MM-dd HH:mm:ss"); - sql += "cast('" + str + "' as datetime)"; - updateSet += ups ? "cast('" + str + "' as datetime)" : ""; - } - } - m++; - if (operateMode.equals("U") && !StringUtils.isEmpty(updateSet) && !StringUtils.isEmpty(updateWhere)) - dbDao.update(upd + updateSet + " where " + updateWhere); - h += ups ? 1 : 0; - } - - sql += ")"; - n++; - } - - for (int m = 0; m < 30; m++) { - if (list.get(i).get("tableName" + m) != null && list.get(i).get("data" + m) != null) { - Object obj = list.get(i).get("data" + m); - List> chList = new ArrayList>(); - for (Object o : (List) obj) { - chList.add((Map) o); - } - analyToDB(host, list.get(i).get("tableName" + m).toString(), "", "", chList, isUpload); - } else { - break; - } - } - - } - if (n > 0) { - result = (dbDao.save(sql) > 0); - if (!result) - logger.error(tableName + "-->fetchSave Fail"); - } - batchDownloadFile(host, files); - } - return result; - } - - - /*转发下级或上级中继服务*/ - private String relay(String reqNo, String content, ArrayList files, String ip) { - String host = ip; - String result = ""; - if (StringUtils.isEmpty(reqNo)) - reqNo = UUID.randomUUID().toString(); - if (!StringUtils.isEmpty(host)) { - host += "/spssync/common/upload"; - 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)); - builder.addFormDataPart("files", files.get(i), - RequestBody.create(MediaType.parse(fileType), file)); - } - } - } - builder.addFormDataPart("content", content); - 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("reqNo", reqNo) - .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(); - log.info("result--->" + result); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } else { - log.debug("未配置中继服务地址"); - } - return result; - } - - /*下载文件*/ - public boolean batchDownloadFile(String syncIp, String[] files) { - boolean success = true; - for (String fileName : files) { - if (!StringUtils.isEmpty(fileName)) { - String[] str = fileName.split(","); - for (int i = 0; i < str.length; i++) { - if (!StringUtils.isEmpty(str[i])) { - //logger.info("downloadFile-->"+str[i]); - if (!signleDownloadFile(syncIp, str[i])) - success = false; - } - } - } - } - return success; - } - -// @Override -// public boolean signleDownloadFile(String syncIp, String fileName) { -// String filePathSlash = fileName.substring(filePath.length() - 1).equals("/") ? "" : "/"; -// if(!FileUtils.makeDirectory(filePath + filePathSlash + imagePath)) -// IDCUtils.createDirectory(filePath + filePathSlash + imagePath); -// OkHttpClient client = new OkHttpClient().newBuilder() -// .build(); -// ; -// MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); -// -// RequestBody body = RequestBody.create(mediaType, "fileName=" + fileName); -// -// Request request = new Request.Builder() -// .url(syncIp + "/spssync/common/downloadFile") -// .post(body) -// .addHeader("Content-Type", "application/x-www-form-urlencoded") -// .build(); -// int total = 0; -// try { -// Response result = client.newCall(request).execute(); -// String msg = result!=null ? result.message().length()>200 ? result.message().substring(0,200) : result.message() : ""; -// -// if (result!=null&&result.isSuccessful()&&MediaType.parse("application/force-download").equals(result.body().contentType())) { -// try (InputStream inputStream = result.body().byteStream()) { -// -// -// FileOutputStream outputStream = new FileOutputStream(filePath + filePathSlash + imagePath+fileName); -// -// byte b[] = new byte[1024]; -// -// int len = 0; -// while ((len = inputStream.read(b)) != -1) { -// total += len; -// outputStream.write(b, 0, len); -// -// } -// -// outputStream.flush(); -// outputStream.close(); -// if(!(total>0)) { -// new File(filePath + filePathSlash + imagePath+fileName).delete(); -// executeSql("delete from idc_file where filePath='"+fileName+"'"); -// } -// -// } catch (Exception e) { -// -// -// } -// } -// if(!(total>0)) { -// String sql = "replace idc_file (filePath,createTime,msg) values ('"+fileName+"',now(),'"+msg+"')"; -// executeSql(sql); -// } -// -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// return (total>0); -// } - @Override - public boolean signleDownloadFile(String syncIp, String fileFullName) { - OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - ; - MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); - - RequestBody body = RequestBody.create(mediaType, "fileName=" + fileFullName); - - Request request = new Request.Builder() - .url(syncIp + "/spssync/common/downloadFile") - .post(body) - .addHeader("Content-Type", "application/x-www-form-urlencoded") - .build(); - int total = 0; - try { - Response result = client.newCall(request).execute(); - String msg = result!=null ? result.message().length()>200 ? result.message().substring(0,200) : result.message() : ""; - - if (result!=null&&result.isSuccessful()&&MediaType.parse("application/force-download").equals(result.body().contentType())) { - try (InputStream inputStream = result.body().byteStream()) { - - String path = fileFullName.substring(0,fileFullName.lastIndexOf("/")); - if(!FileUtils.makeDirectory(path)) - IDCUtils.createDirectory(path); - - - FileOutputStream outputStream = new FileOutputStream(fileFullName); - - byte b[] = new byte[1024]; - - int len = 0; - while ((len = inputStream.read(b)) != -1) { - total += len; - outputStream.write(b, 0, len); - - } - - outputStream.flush(); - outputStream.close(); - if(!(total>0)) { - new File(fileFullName).delete(); - executeSql("delete from idc_file where filePath='"+fileFullName+"'"); - } - - } catch (Exception e) { - - - } - } - if(!(total>0)) { - String sql = "replace idc_file (filePath,createTime,msg) values ('"+fileFullName+"',now(),'"+msg+"')"; - executeSql(sql); - } - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return (total>0); - } - - /*获取转发服务地址,当前值允许单向,只使用参数upper_server_ip*/ - private String getNextHost() { - SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("upper_server_ip"); - String host = systemParamConfigEntity != null ? systemParamConfigEntity.getParamValue() : ""; - host = !StringUtils.isEmpty(host) && host.substring(host.length() - 1).equals("/") ? host.substring(0, host.length() - 1) : host; - return host; - } - - /*判断是否需要解析入库,中继服务只转发*/ - private boolean isLastLevel() { - Map map = dbDao.get("select * from idc_var where code='system_type'"); - return !(map != null && map.get("content") != null && map.get("content").toString().equals("IDC")); - } - - /*是否需要转发*/ - private boolean isRelay() { - String relayHost = getNextHost(); - return StringUtils.isEmpty(relayHost) ? false : true; - } - - - private List> getList(String tableName, Map params) { - String sql = "select " + tableName + ".*,'A' as operateMode from " + tableName; - Map column = getColumn(tableName); - - String where = DBAUtils.convertWhere(column, params, ""); - sql += !StringUtils.isEmpty(where) ? " where " + where : ""; - Map map = new HashMap(); - map.putAll(params); - map.put("sql", sql); - List> list = dbDao.list(map); - return list; - } - - /*由表名获取数据*/ - private Map getData(String messageType, String - tableName, Map params, Map whereParams) { - List> list = getList(tableName, whereParams); - Map map = new HashMap(); - map.put("messageId", CustomUtil.getId()); - map.put("messageType", messageType); - map.put("apiCode", "common"); - map.put("tableName", DBAUtils.tableAliasName(tableName)); - map.put("uniqueColumn", params.get("uniqueColumn")); - map.put("filePathColumn", params.get("filePathColumn")); - map.put("sendTime", new Date()); - map.put("version", "1.0"); - map.put("level", 0); - map.put("total", list.size()); - map.put("data", list); - return map; - } - - - private SystemParamConfigEntity getSystemParamConfig(String paramKey, String paramName, String - defaultValue, String paramExplain) { - SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey(paramKey); - if (systemParamConfigEntity == null || (systemParamConfigEntity != null && StringUtils.isEmpty(systemParamConfigEntity.getParamKey()))) { - systemParamConfigEntity = new SystemParamConfigEntity(); - systemParamConfigEntity.setParamKey(paramKey); - systemParamConfigEntity.setParamName(paramName); - systemParamConfigEntity.setParentId(0); - systemParamConfigEntity.setParamValue(defaultValue); - systemParamConfigEntity.setParamExplain(paramExplain); - systemParamConfigEntity.setParamStatus(1); - systemParamConfigEntity.setParamType(0); - systemParamConfigService.insert(systemParamConfigEntity); - } - return systemParamConfigEntity; - } - - - - - /*把列数据转Map*/ - private Map getColumn(String tableName) { - Map map = new HashMap(); - List> columnList = new ArrayList>(); - String columnKey = ""; - String[] tnames = tableName.split(","); - for (String tname : tnames) { - columnList = dbDao.listColumnsMysql(tname); - if (columnList != null && columnList.size() > 0) { - for (int i = 0; i < columnList.size(); i++) { - Map column = new HashMap(); - String dataType = columnList.get(i).get("dataType").toLowerCase().contains("char") || columnList.get(i).get("dataType").toLowerCase().contains("text") ? - "C" : columnList.get(i).get("dataType").toLowerCase().contains("date") ? "D" : "N"; - ; - String attrName = columnList.get(i).get("columnName").toString(); - if (map.get(attrName) == null) { - column.put("tableName", tname); - column.put("dataType", dataType); - column.put("columnName", columnList.get(i).get("columnName")); - if (columnList.get(i).get("columnKey") != null) { - column.put("columnKey", columnList.get(i).get("columnKey")); - } else { - column.put("columnKey", "N"); - } - if (map.get(attrName) != null) { - map.put(tname.toLowerCase() + "." + attrName, column); - } else { - map.put(attrName, column); - } - } - } - } - } - return map; - } - - - private String getUpdateTime(String id) { - String updateTime = ""; - Map map = dbDao.get("select * from idc_status where id='" + id + "'"); - if (map != null && map.get("id") != null) { - updateTime = DateUtil.formatDate(IDCUtils.parseDate(map.get("statusTime").toString()), "yyyy-MM-dd HH:mm:ss"); - } else { - //国家库数据 - if (id.equals("productinfo")) { - - } - updateTime = "2000-01-01 00:00:00"; - String sql = "insert into idc_status (id,statusTime) values ('" + id + "',cast('" + updateTime + "' as datetime))"; - dbDao.save(sql); - } - return updateTime; - } - - private String setUpdateTime(String id, String updateTime) { - String sql = ""; - Map map = dbDao.get("select * from idc_status where id='" + id + "'"); - if (map != null && map.get("id") != null) { - sql = "update idc_status set statusTime=cast('" + updateTime + "' as datetime) where id='" + id + "'"; - dbDao.update(sql); - } else { - sql = "insert into idc_status (id,statusTime) values ('" + id + "',cast('" + updateTime + "' as datetime))"; - dbDao.save(sql); - } - return updateTime; - } - - private void initTable() { - alterTable("idc_var", "create table idc_var (code varchar(60),content varchar(200),PRIMARY KEY (code))"); - alterTable("idc_status", "create table idc_status (id varchar(100),statusTime datetime,PRIMARY KEY (id))"); - alterTable("idc_record", "create table idc_record (id varchar(36),type varchar(60),fkId varchar(36),isEnd char(1),createTime datetime,primary key (id),INDEX i_idc_record_fk_id (fkId),INDEX i_idc_record_create_time (createTime))"); - alterTable("idc_log", "create table idc_log (id varchar(36),orderNum int,taskId varchar(60),type varchar(60),content varchar(2000),offset int,total int,createTime datetime,PRIMARY KEY (id))"); - alterTable("idc_file", "create table idc_file (filePath varchar(255),createTime datetime,PRIMARY KEY (filePath))"); - dbDao.delete("delete from idc_record where createTime map = dbDao.getMysql(tableName); - if (!(map != null && map.get("tableName") != null)) { - executeSql(sql); - } - - } - - - private void executeSql(String sql) { - try { - jdbcTemplate.execute(sql); - - } catch (Exception e) { - - } - } - private 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(); - } - -} diff --git a/src/main/java/com/glxp/api/idc/utils/DBAUtils.java b/src/main/java/com/glxp/api/idc/utils/DBAUtils.java deleted file mode 100644 index 872902f..0000000 --- a/src/main/java/com/glxp/api/idc/utils/DBAUtils.java +++ /dev/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 columns,Map params,String dataWhere) { - return parseWhere(sql,columns,params,dataWhere,false); - } - public static String parseWhere(String sql,Map columns,Map params,String dataWhere,boolean isSimpleWhere) { - String where=""; - boolean isAnd0 = false; - boolean isLike = params!=null&¶ms.get("isLike")!=null&¶ms.get("isLike").toString().equals("true") ? true : false; - - if(sql.contains("sqlWhere")||!sql.contains("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("",a+1); - int h = sql.indexOf("isLike",a+1); - int j = sql.indexOf("!=",a+1); - if(h>a&&h1&&j"); - 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("")) { - sql = n>0 ? sql.replaceAll("", " where ") : sql.replaceAll("", ""); - if(!StringUtils.isEmpty(dataWhere)&&!sql.contains("sqlWhere")) { - sql = n>0 ? sql.replaceAll("", " and ("+dataWhere+")") : sql.replaceAll("", " ("+dataWhere+")"); - } else { - sql = sql.replaceAll("", ""); - } - } - if(sql.contains("=isLike")) { - int a1,a2,b1,b2; - a1 = sql.indexOf("[==isLike]"); - a2 = sql.indexOf("",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("",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 columns,Map 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 map = (Map) 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 colums,Map params,String dataWhere) { - String where=convertWhere(colums,params,dataWhere,""); - return where; - } - public static String convertWhere(Map colums,Map params,String dataWhere,String sql) { - String where=""; - String value =""; - boolean isLike = false; - boolean isKey = false; - if(params!=null&¶ms.get("isLike")!=null&¶ms.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 params,Map 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 map = (Map) 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-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;n2&&t.substring(0, 2).toLowerCase().equals("2d")) { - t = t.substring(2); - for(int i=0;i-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 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 map) { - String aSql = sql.toLowerCase(); - String result = ""; - if(map==null) - map = new HashMap(); - 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;i7&&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 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(); - } -} diff --git a/src/main/java/com/glxp/api/idc/utils/TableUtils.java b/src/main/java/com/glxp/api/idc/utils/TableUtils.java deleted file mode 100644 index 98838e2..0000000 --- a/src/main/java/com/glxp/api/idc/utils/TableUtils.java +++ /dev/null @@ -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///供应商关联信息", - *

- * "//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; - } -} diff --git a/src/main/java/com/glxp/api/idc/utils/UriUtils.java b/src/main/java/com/glxp/api/idc/utils/UriUtils.java deleted file mode 100644 index 1478eb2..0000000 --- a/src/main/java/com/glxp/api/idc/utils/UriUtils.java +++ /dev/null @@ -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 buildHeader(HttpServletRequest request) { - - log.info(request.getMethod()); - String bodyContent = ""; - Map headerParam = new HashMap<>(); - if (request.getMethod().equals(HttpMethod.GET)) { - Map bodyParam = new HashMap(); - 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 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 http = new HttpEntity<>(bodyContent, headers); - return http; - } - - -} diff --git a/src/main/java/com/glxp/api/task/AsyncFetchUdiTask.java b/src/main/java/com/glxp/api/task/AsyncFetchUdiTask.java deleted file mode 100644 index ec0dfd4..0000000 --- a/src/main/java/com/glxp/api/task/AsyncFetchUdiTask.java +++ /dev/null @@ -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(); - } - -} diff --git a/src/main/java/com/glxp/api/task/AsyncUdiTask.java b/src/main/java/com/glxp/api/task/AsyncUdiTask.java deleted file mode 100644 index c00ae31..0000000 --- a/src/main/java/com/glxp/api/task/AsyncUdiTask.java +++ /dev/null @@ -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(); - } - -} diff --git a/src/main/java/com/glxp/api/task/SyncHeartTask.java b/src/main/java/com/glxp/api/task/SyncHeartTask.java deleted file mode 100644 index 3c28896..0000000 --- a/src/main/java/com/glxp/api/task/SyncHeartTask.java +++ /dev/null @@ -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); - } - - } - - } - - -}