diff --git a/src/main/java/com/glxp/api/controller/auth/RegisterController.java b/src/main/java/com/glxp/api/controller/auth/RegisterController.java index f83f1f9e..09e178f5 100644 --- a/src/main/java/com/glxp/api/controller/auth/RegisterController.java +++ b/src/main/java/com/glxp/api/controller/auth/RegisterController.java @@ -361,6 +361,7 @@ public class RegisterController { basicUnitMaintainEntity1.setAddr(userRegisterEntity.getArea() + userRegisterEntity.getDetailAddr()); basicUnitMaintainEntity1.setContact(userRegisterEntity.getRealName()); basicUnitMaintainEntity1.setMobile(userRegisterEntity.getMobile()); + basicUnitMaintainEntity1.setUpdateTime(new Date()); basicUnitMaintainService.insertBasicUnitMaintain(basicUnitMaintainEntity1); customerId = Long.parseLong(basicUnitMaintainEntity1.getErpId()); registerCheckRequest.setCompanyId(basicUnitMaintainEntity1.getErpId()); diff --git a/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java b/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java index 199e42b9..955ae12c 100644 --- a/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java +++ b/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java @@ -31,7 +31,9 @@ import com.glxp.api.entity.thrsys.*; import com.glxp.api.req.sync.SpsSyncDataRequest; import com.glxp.api.req.sync.SyncUpLoadRequest; import com.glxp.api.res.sync.*; +import com.glxp.api.service.auth.InvWarehouseService; import com.glxp.api.service.basic.IBasicBusTypeChangeService; +import com.glxp.api.service.basic.IBasicBussinessTypeService; import com.glxp.api.service.inout.IoAddInoutService; import com.glxp.api.service.inout.IoCheckInoutService; import com.glxp.api.service.inout.IoOrderService; @@ -603,6 +605,10 @@ public class SpsSyncDownloadController { IoOrderDetailResultDao orderDetailResultDao; @Resource IoOrderInvoiceMapper orderInvoiceMapper; + @Resource + IBasicBussinessTypeService basicBussinessTypeService; + @Resource + InvWarehouseService invWarehouseService; //接收中继服务、UDI管理系统上传单据 @AuthRuleAnnotation("sps/sync/order/upload") @@ -619,101 +625,116 @@ public class SpsSyncDownloadController { basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity); StringBuffer remark = new StringBuffer(); if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities())) { - try { - List orderEntities = syncDataResponse.getOrderEntities(); - for (IoOrderEntity orderEntity : orderEntities) { - orderEntity.setUpdateTime(null); - orderEntity.setFromType(ConstantStatus.FROM_UDISP); - orderEntity.setProcessStatus(ConstantStatus.ORDER_DEAL_POST); - orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESS); - IoOrderEntity temp = orderService.findById(orderEntity.getBillNo()); - if (temp == null) { - orderEntity.setId(null); - orderDao.insert(orderEntity); - - //更新码详情 - if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) { - List warehouseEntityList = syncDataResponse.getCodeEntities(); - for (IoCodeEntity warehouseEntity : warehouseEntityList) { - if (warehouseEntity.getOrderId().equals(orderEntity.getBillNo())) { - IoCodeTempEntity codeTempEntity = new IoCodeTempEntity(); - BeanUtils.copyProperties(warehouseEntity, codeTempEntity); - codeTempEntity.setId(null); - codeMappert.insert(codeTempEntity); - } + List orderEntities = syncDataResponse.getOrderEntities(); + for (IoOrderEntity orderEntity : orderEntities) { + orderEntity.setUpdateTime(null); + orderEntity.setFromType(ConstantStatus.FROM_UDISP); + orderEntity.setProcessStatus(ConstantStatus.ORDER_DEAL_POST); + orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESS); + IoOrderEntity temp = orderService.findById(orderEntity.getBillNo()); + + + if (temp == null) { + + // 过滤使用出库单,转换成一级库出库单(条件:往来类型为客户信息,出入库类型为出库,仓库类型为入账库,是否更改库存为是 + BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction()); + if (basicBussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INPUT + && basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT) + && basicBussinessTypeEntity.isInStock() && basicBussinessTypeEntity.getActionType() == 1) { +// orderEntity.getInvCode() + InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(orderEntity.getInvCode()); + InvWarehouseEntity parentInv = invWarehouseService.findOneLevel(invWarehouseEntity.getParentCode()); + if (parentInv == null) + parentInv = invWarehouseEntity; + orderEntity.setInvCode(parentInv.getCode()); + orderEntity.setDeptCode(parentInv.getParentId()); + orderEntity.setFromCorp("科室使用出库"); + + } + + + orderEntity.setId(null); + orderDao.insert(orderEntity); + //更新码详情 + if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) { + List warehouseEntityList = syncDataResponse.getCodeEntities(); + for (IoCodeEntity warehouseEntity : warehouseEntityList) { + if (warehouseEntity.getOrderId().equals(orderEntity.getBillNo())) { + IoCodeTempEntity codeTempEntity = new IoCodeTempEntity(); + BeanUtils.copyProperties(warehouseEntity, codeTempEntity); + codeTempEntity.setId(null); + codeMappert.insert(codeTempEntity); } } + } - //更新业务详情 - if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailBizEntities())) { - List orderDetailBizEntities = syncDataResponse.getOrderDetailBizEntities(); - for (IoOrderDetailBizEntity bizEntity : orderDetailBizEntities) { - if (bizEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { - bizEntity.setId(null); - orderDetailBizDao.insert(bizEntity); - } + //更新业务详情 + if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailBizEntities())) { + List orderDetailBizEntities = syncDataResponse.getOrderDetailBizEntities(); + for (IoOrderDetailBizEntity bizEntity : orderDetailBizEntities) { + if (bizEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { + bizEntity.setId(null); + orderDetailBizDao.insert(bizEntity); } } + } - //更新码详情 - if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) { - List orderDetailCodeEntities = syncDataResponse.getOrderDetailCodeEntities(); - for (IoOrderDetailCodeEntity codeEntity : orderDetailCodeEntities) { - if (codeEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { - codeEntity.setId(null); - orderDetailCodeDao.insert(codeEntity); - } + //更新码详情 + if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) { + List orderDetailCodeEntities = syncDataResponse.getOrderDetailCodeEntities(); + for (IoOrderDetailCodeEntity codeEntity : orderDetailCodeEntities) { + if (codeEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { + codeEntity.setId(null); + orderDetailCodeDao.insert(codeEntity); } } + } - //更新结果详情 - if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailResultEntities())) { - List orderDetailResultEntities = syncDataResponse.getOrderDetailResultEntities(); - for (IoOrderDetailResultEntity detailResultEntity : orderDetailResultEntities) { - if (detailResultEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { - detailResultEntity.setId(null); - orderDetailResultDao.insert(detailResultEntity); - } + //更新结果详情 + if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailResultEntities())) { + List orderDetailResultEntities = syncDataResponse.getOrderDetailResultEntities(); + for (IoOrderDetailResultEntity detailResultEntity : orderDetailResultEntities) { + if (detailResultEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { + detailResultEntity.setId(null); + orderDetailResultDao.insert(detailResultEntity); } } + } - //更新发票信息 - if (CollUtil.isNotEmpty(syncDataResponse.getOrderInvoiceEntities())) { - List orderInvoiceEntities = syncDataResponse.getOrderInvoiceEntities(); - for (IoOrderInvoiceEntity orderInvoiceEntity : orderInvoiceEntities) { - if (orderInvoiceEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { - orderInvoiceEntity.setId(IdUtil.getSnowflakeNextId()); - orderInvoiceMapper.insert(orderInvoiceEntity); - } + //更新发票信息 + if (CollUtil.isNotEmpty(syncDataResponse.getOrderInvoiceEntities())) { + List orderInvoiceEntities = syncDataResponse.getOrderInvoiceEntities(); + for (IoOrderInvoiceEntity orderInvoiceEntity : orderInvoiceEntities) { + if (orderInvoiceEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { + orderInvoiceEntity.setId(IdUtil.getSnowflakeNextId()); + orderInvoiceMapper.insert(orderInvoiceEntity); } } + } - 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()); - } + 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()); } } - - String logs = ""; - if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities())) - logs = logs + "单据:" + syncDataResponse.getOrderEntities().size() + "条\n"; - if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailBizEntities())) - logs = logs + "业务详情:" + syncDataResponse.getOrderDetailBizEntities().size() + "条\n"; - if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) - logs = logs + "单据扫码详情:" + syncDataResponse.getOrderDetailCodeEntities().size() + "条\n"; - if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailResultEntities())) - logs = logs + "单据结果详情:" + syncDataResponse.getOrderDetailResultEntities().size() + "条\n"; - if (CollUtil.isNotEmpty(syncDataResponse.getCodeEntities())) - logs = logs + "单据条码信息:" + syncDataResponse.getCodeEntities().size() + "条\n"; - remark.append(logs); - } catch (Exception e) { - e.printStackTrace(); } + + String logs = ""; + if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities())) + logs = logs + "单据:" + syncDataResponse.getOrderEntities().size() + "条\n"; + if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailBizEntities())) + logs = logs + "业务详情:" + syncDataResponse.getOrderDetailBizEntities().size() + "条\n"; + if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) + logs = logs + "单据扫码详情:" + syncDataResponse.getOrderDetailCodeEntities().size() + "条\n"; + if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailResultEntities())) + logs = logs + "单据结果详情:" + syncDataResponse.getOrderDetailResultEntities().size() + "条\n"; + if (CollUtil.isNotEmpty(syncDataResponse.getCodeEntities())) + logs = logs + "单据条码信息:" + syncDataResponse.getCodeEntities().size() + "条\n"; + remark.append(logs); } String fileFullPath = null; try { diff --git a/src/main/java/com/glxp/api/service/auth/InvWarehouseService.java b/src/main/java/com/glxp/api/service/auth/InvWarehouseService.java index e04bf4ac..6ba052f7 100644 --- a/src/main/java/com/glxp/api/service/auth/InvWarehouseService.java +++ b/src/main/java/com/glxp/api/service/auth/InvWarehouseService.java @@ -96,4 +96,7 @@ public interface InvWarehouseService { List selectLowWarehouseAll(String pCode); + + + InvWarehouseEntity findOneLevel(String code); } diff --git a/src/main/java/com/glxp/api/service/auth/impl/InvWarehouseServiceImpl.java b/src/main/java/com/glxp/api/service/auth/impl/InvWarehouseServiceImpl.java index 5ebe8ac1..1d2270bd 100644 --- a/src/main/java/com/glxp/api/service/auth/impl/InvWarehouseServiceImpl.java +++ b/src/main/java/com/glxp/api/service/auth/impl/InvWarehouseServiceImpl.java @@ -255,4 +255,21 @@ public class InvWarehouseServiceImpl implements InvWarehouseService { public List selectLowWarehouseAll(String pCode) { return invWarehouseDao.selectLowWarehouseAll(pCode); } + + @Override + public InvWarehouseEntity findOneLevel(String code) { + int index = 1; + while (index < 6) { //仓库层级一般不会超过5级 + InvWarehouseEntity invWarehouseEntity = findByInvSubByCode(code); + if (invWarehouseEntity != null) { + if (StrUtil.isEmpty(invWarehouseEntity.getParentCode())) + return invWarehouseEntity; + else { + code = invWarehouseEntity.getParentCode(); + index++; + } + } + } + return null; + } } diff --git a/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java b/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java index b401afb3..d3b114ce 100644 --- a/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java +++ b/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java @@ -121,7 +121,8 @@ public class IoAddInoutService { basicCorpEntity.setOutType(ConstantStatus.CORP_SICK_SICK); basicCorpEntity.setName(orderEntity.getFromCorp()); basicCorpEntity.setId(IdUtil.getSnowflakeNextId()); - basicCorpService.insertBasicUnitMaintain(basicCorpEntity); + basicCorpEntity.setUpdateTime(new Date()); + basicCorpService.insert(basicCorpEntity); } orderEntity.setFromCorp(basicCorpEntity.getErpId()); diff --git a/src/main/java/com/glxp/api/util/page/ListPageRequest.java b/src/main/java/com/glxp/api/util/page/ListPageRequest.java index 75f1f39d..38ce6bd6 100644 --- a/src/main/java/com/glxp/api/util/page/ListPageRequest.java +++ b/src/main/java/com/glxp/api/util/page/ListPageRequest.java @@ -20,4 +20,7 @@ public class ListPageRequest { @Max(value = 500, message = "分页参数不能大于500") private Integer limit; + + private String orderBy; + private String sort; } diff --git a/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml b/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml index da08b1d1..6878841f 100644 --- a/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml +++ b/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml @@ -30,7 +30,18 @@ and receiveStatus = #{receiveStatus} - ORDER BY updateTime DESC + + + + order by ${orderBy} ${sort} + + + ORDER BY updateTime DESC + + + + + diff --git a/src/main/resources/schemas/schema_v2.1.sql b/src/main/resources/schemas/schema_v2.1.sql index bcc651a3..5df05c4b 100644 --- a/src/main/resources/schemas/schema_v2.1.sql +++ b/src/main/resources/schemas/schema_v2.1.sql @@ -336,6 +336,7 @@ CALL Pro_Temp_ColumnWork('thr_bustype_origin', 'id', 'bigint', 2); CALL Pro_Temp_ColumnWork('auth_user', 'id', 'bigint', 2); CALL Pro_Temp_ColumnWork('auth_user_bustype', 'id', 'bigint', 2); +CALL Pro_Temp_ColumnWork('auth_user_bustype', 'userId', 'bigint', 2); CALL Pro_Temp_ColumnWork('auth_dept', 'id', 'bigint', 2); CALL Pro_Temp_ColumnWork('auth_warehouse', 'id', 'bigint', 2); CALL Pro_Temp_ColumnWork('auth_warehouse_bustype', 'id', 'bigint', 2);