| | |
| | | import com.bstek.dorado.annotation.DataResolver; |
| | | import com.bstek.dorado.annotation.Expose; |
| | | import com.bstek.dorado.data.provider.Page; |
| | | import com.fzzy.common.constant.BizTypeEnum; |
| | | import com.fzzy.igds.constant.Constant; |
| | | import com.fzzy.igds.data.BaseResp; |
| | | import com.fzzy.igds.data.InoutData; |
| | | import com.fzzy.igds.data.InoutParam; |
| | | import com.fzzy.igds.domain.InoutNoticeIn; |
| | | import com.fzzy.igds.domain.InoutNoticeOut; |
| | | import com.fzzy.igds.domain.InoutRecord; |
| | | import com.fzzy.igds.service.DepotService; |
| | | import com.fzzy.igds.service.ExportService; |
| | | import com.fzzy.igds.service.InoutNoticeService; |
| | | import com.fzzy.igds.service.InoutRecordService; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private InoutRecordService inoutRecordService; |
| | | @Resource |
| | | private ExportService exportService; |
| | | @Resource |
| | | private InoutNoticeService noticeService; |
| | | @Resource |
| | | private DepotService depotService; |
| | | |
| | | /** |
| | | * inoutDataPR#pageInoutData |
| | |
| | | if (!Constant.PROGRESS_RECORD.equals(data.getProgress())) { |
| | | return "系统:未结束流程的数据不支持修改!"; |
| | | } |
| | | int i = inoutRecordService.updateInoutRecord(data); |
| | | |
| | | int i = inoutRecordService.checkAndUpdate(data); |
| | | if (i > 0) { |
| | | return null; |
| | | } else { |
| | |
| | | */ |
| | | @DataResolver |
| | | @Transactional |
| | | @Log(title = "出入库数据执行异常终止", businessType = BusinessType.UPDATE,bizType = BizTypeEnum.INOUT) |
| | | public String errorInoutData(InoutRecord data) { |
| | | return inoutRecordService.errorInoutData(data); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String analysisExcel(String fileName) { |
| | | return "导入功能待上线!!"; |
| | | // try { |
| | | // List<InoutRecord> inoutRecords = exportService.readExcel(fileName); |
| | | // if (null == inoutRecords || inoutRecords.isEmpty()) { |
| | | // return "导入失败,原因-->未获取到excel中文档数据!"; |
| | | // } |
| | | // |
| | | // |
| | | // for (InoutRecord inoutRecord : inoutRecords) { |
| | | // |
| | | // //TODO 判断数据是否正常数据,正常则新增,异常则忽略 |
| | | // //设置数据状态及流程 |
| | | // inoutRecord.setRecordStatus(Constant.RECORD_STATUS_ADD); |
| | | // inoutRecord.setProgress(Constant.PROGRESS_RECORD); |
| | | // |
| | | // inoutRecord.setCompleteTime(new Date()); |
| | | // |
| | | // |
| | | // inoutRecord.setRegisterTime(DateUtils.addHours(new Date(), -2)); |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // inoutRecordService.addInoutRecord(inoutRecord); |
| | | // } |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // return null; |
| | | // } catch (Exception e) { |
| | | // return "导入失败,原因-->" + e.getMessage(); |
| | | // } |
| | | public BaseResp analysisExcel(String fileName) { |
| | | |
| | | try { |
| | | List<InoutRecord> inoutRecords = exportService.readExcel(fileName); |
| | | if (null == inoutRecords || inoutRecords.isEmpty()) { |
| | | return BaseResp.error("导入失败,原因-->未获取到excel中文档数据!"); |
| | | } |
| | | |
| | | // // 读取的Excel文件数据 |
| | | // List<NoticeInData> readResult = readExcel(fileName); |
| | | // if (null == readResult) { |
| | | // return new PageResponse<String>(RespCodeEnum.CODE_1111.getCode(), |
| | | // "导入失败:没有解析到文件中数据!"); |
| | | // } |
| | | // |
| | | // // 查询到的所有供应商信息 |
| | | // InoutParam param = new InoutParam(); |
| | | // param.setTagSupplier(Constant.TR_TRUE + ""); |
| | | // List<InoutCustomer> allCustomer = inoutCommonService.listCustomer(param); |
| | | // |
| | | // //新建任务存放集合 |
| | | // List<NoticeInData> newCustomerTaskList = new ArrayList<>(); |
| | | // Map<String, NoticeInData> newMap = new HashMap<>(); |
| | | // |
| | | // //存放编码和名称不一致的信息 |
| | | // StringBuilder stringBuilder = new StringBuilder(); |
| | | // |
| | | // //用tempFlag在后面来判断解析到的客户是否在客户表中存在 |
| | | // boolean tempFlag; |
| | | // |
| | | // int max = 0; |
| | | // for (NoticeInData noticeInData : readResult) { |
| | | // //获取客户任务数据中的客户名称和编码 |
| | | // String customerName = noticeInData.getCustomerName(); |
| | | // String customerId = noticeInData.getCustomerId(); |
| | | // //判断编码是否为空,为空则给出提示,不进行操作 |
| | | // if(StringUtils.isEmpty(customerName)){ |
| | | // stringBuilder.append("客户‘").append(customerName).append("’信息不完整,不导入此条数据;\n"); |
| | | // continue; |
| | | // } |
| | | // |
| | | // tempFlag = true; |
| | | // |
| | | // for (InoutCustomer customer : allCustomer) { |
| | | // //获取供应商名称和编码 |
| | | // String name = customer.getName(); |
| | | // String id = customer.getId(); |
| | | // //判断名称是否相同 |
| | | // if(customerName.equals(name)){ |
| | | // //名称相同,则客户在表中存在 |
| | | // tempFlag = false; |
| | | // //判断编码是否相同 |
| | | // if(StringUtils.isEmpty(customerId) || !id.equals(customerId)){ |
| | | // |
| | | // noticeInData.setCustomerId(id); |
| | | // } |
| | | // noticeInData.setCompanyId(customer.getCompanyId()); |
| | | // //身份证号 |
| | | // if(StringUtils.isEmpty(noticeInData.getCardId())){ |
| | | // noticeInData.setCardId(customer.getCardId()); |
| | | // } |
| | | // //地址 |
| | | // if(StringUtils.isEmpty(noticeInData.getAddress())){ |
| | | // noticeInData.setAddress(customer.getAddress()); |
| | | // } |
| | | // //电话 |
| | | // if(StringUtils.isEmpty(noticeInData.getPhone())){ |
| | | // noticeInData.setPhone(customer.getPhone()); |
| | | // } |
| | | // //一卡通号 |
| | | // if(StringUtils.isEmpty(noticeInData.getBankNum())){ |
| | | // noticeInData.setBankNum(customer.getBankNum()); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // if(tempFlag){ |
| | | // if(max == 0){ |
| | | // max = Integer.parseInt(inoutCommonService.getMaxCustomerId(null)); |
| | | // } |
| | | // max += 1; |
| | | // noticeInData.setCustomerId(max + ""); |
| | | // } |
| | | // |
| | | // newCustomerTaskList.add(noticeInData); |
| | | // |
| | | // newMap.putIfAbsent(noticeInData.getCustomerName(), noticeInData); |
| | | // } |
| | | // |
| | | // //更新客户信息表 |
| | | // if(newMap.size() > 0){ |
| | | // for (NoticeInData noticeInData : newMap.values()) { |
| | | // int i = inoutCommonService.updateCustomer(noticeInData); |
| | | // if (i == 0) { |
| | | // //说明没有更新到客户信息,进行新增 |
| | | // InoutCustomer data = new InoutCustomer(); |
| | | // data.setId(noticeInData.getCustomerId()); |
| | | // data.setName(noticeInData.getCustomerName()); |
| | | // data.setCardId(noticeInData.getCardId()); |
| | | // data.setBankNum(noticeInData.getBankNum()); |
| | | // data.setAddress(noticeInData.getAddress()); |
| | | // data.setPhone(noticeInData.getPhone()); |
| | | // data.setTagSupplier(Constant.TR_TRUE + ""); |
| | | // customerService.saveOrUpdataData(data); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // //判断任务集合是否为空 |
| | | // if (newCustomerTaskList.isEmpty()) { |
| | | // return new PageResponse<String>(RespCodeEnum.CODE_1111.getCode(), |
| | | // "导入失败!\n" + stringBuilder.toString()); |
| | | // } else { |
| | | // //更新任务表 |
| | | // int temp = 1; |
| | | // for (NoticeInData noticeInData : newCustomerTaskList) { |
| | | // //设置客户通知单的组织编码等信息 |
| | | // noticeInData.setCompanyId(ContextUtil.getCompanyId()); |
| | | // noticeInData.setDeptId(ContextUtil.subDeptId(null)); |
| | | // noticeInData.setCreateUser(ContextUtil.getLoginUserCName()); |
| | | // if(temp < 10){ |
| | | // noticeInData.setId(ContextUtil.getTimeId() + "00" + temp); |
| | | // }else if(temp < 100){ |
| | | // noticeInData.setId(ContextUtil.getTimeId() + "0" + temp); |
| | | // }else { |
| | | // noticeInData.setId(ContextUtil.getTimeId() + temp); |
| | | // } |
| | | // |
| | | // //更新客户任务信息,如果更新失败,则进行插入操作 |
| | | // inoutCommonService.updateNoticeIn(noticeInData); |
| | | // temp += 1; |
| | | // } |
| | | // if(StringUtils.isEmpty(stringBuilder.toString())){ |
| | | // return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), "数据全部导入成功!"); |
| | | // }else { |
| | | // String message = "数据部分导入成功!\n"+ stringBuilder.toString(); |
| | | // return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), message); |
| | | // } |
| | | // |
| | | // } |
| | | //判断数据完整性 |
| | | boolean addTag = false; |
| | | int hour = 10; |
| | | int min = 10; |
| | | |
| | | for (InoutRecord inoutRecord : inoutRecords) { |
| | | //设置数据状态及流程 |
| | | inoutRecord.setRecordStatus(Constant.RECORD_STATUS_ADD); |
| | | inoutRecord.setProgress(Constant.PROGRESS_RECORD); |
| | | |
| | | //校验通知单 |
| | | String noticeId = inoutRecord.getNoticeId(); |
| | | if(StringUtils.isBlank(noticeId)){ |
| | | addTag = true; |
| | | break; |
| | | } |
| | | if(noticeId.startsWith("RK_")){ |
| | | InoutNoticeIn noticeInOne = noticeService.getNoticeInOne(noticeId); |
| | | if(null == noticeInOne){ |
| | | addTag = true; |
| | | break; |
| | | } |
| | | inoutRecord.setDeptId(noticeInOne.getDeptId()); |
| | | } |
| | | if(noticeId.startsWith("CK_")){ |
| | | InoutNoticeOut noticeOut = noticeService.getNoticeOutOne(noticeId); |
| | | if(null == noticeOut){ |
| | | addTag = true; |
| | | break; |
| | | } |
| | | inoutRecord.setDeptId(noticeOut.getDeptId()); |
| | | } |
| | | |
| | | //校验仓库 |
| | | String depotName = inoutRecord.getDepotId(); |
| | | if(StringUtils.isBlank(depotName)){ |
| | | addTag = true; |
| | | break; |
| | | } |
| | | //根据仓库名称获取仓库编码 |
| | | String depotId = depotService.getDepotId(inoutRecord.getDeptId(), depotName); |
| | | if(StringUtils.isBlank(depotId)){ |
| | | addTag = true; |
| | | break; |
| | | } |
| | | inoutRecord.setDepotId(depotId); |
| | | |
| | | //校验日期是否完整 |
| | | String plateNum = inoutRecord.getPlateNum(); |
| | | if(null == plateNum){ |
| | | addTag = true; |
| | | break; |
| | | } |
| | | inoutRecord.setPlateNum(plateNum); |
| | | |
| | | //校验日期是否完整 |
| | | Date registerTime = inoutRecord.getRegisterTime(); |
| | | if(null == registerTime){ |
| | | addTag = true; |
| | | break; |
| | | } |
| | | |
| | | //设置登记、称重、完成时间 |
| | | String time = DateFormatUtils.format(registerTime, "yyyy-MM-dd"); |
| | | if(min >= 60){ |
| | | min = 10; |
| | | hour ++; |
| | | } |
| | | time += " " + hour + ":" + min + ":00"; |
| | | inoutRecord.setRegisterTime(DateUtils.parseDate(time,"yyyy-MM-dd HH:mm:ss")); |
| | | if(Constant.TYPE_IN.equals(inoutRecord.getType())){ |
| | | inoutRecord.setFullWeightTime(DateUtils.addMinutes(inoutRecord.getRegisterTime(), 3)); |
| | | inoutRecord.setHandleEnd(DateUtils.addMinutes(inoutRecord.getRegisterTime(), 30)); |
| | | inoutRecord.setEmptyWeightTime(DateUtils.addMinutes(inoutRecord.getRegisterTime(), 50)); |
| | | } |
| | | if(Constant.TYPE_OUT.equals(inoutRecord.getType())){ |
| | | inoutRecord.setEmptyWeightTime(DateUtils.addMinutes(inoutRecord.getRegisterTime(), 3)); |
| | | inoutRecord.setHandleEnd(DateUtils.addMinutes(inoutRecord.getRegisterTime(), 30)); |
| | | inoutRecord.setFullWeightTime(DateUtils.addMinutes(inoutRecord.getRegisterTime(), 50)); |
| | | } |
| | | inoutRecord.setCompleteTime(DateUtils.addHours(inoutRecord.getRegisterTime(), 1)); |
| | | |
| | | inoutRecord.setCompanyId(ContextUtil.getCompanyId()); |
| | | min ++; |
| | | } |
| | | |
| | | if(addTag){ |
| | | return BaseResp.error("导入失败,原因-->数据校验失败,请核查数据<日期、类型、车牌、通知单、仓库、品种等信息>!!!"); |
| | | } |
| | | |
| | | //新增数据 |
| | | String msg = inoutRecordService.addInoutRecordList(inoutRecords); |
| | | |
| | | if(null == msg){ |
| | | return BaseResp.success("导入成功,共计导入" + inoutRecords.size() + "条数据!" ); |
| | | }else { |
| | | return BaseResp.error(msg); |
| | | } |
| | | } catch (Exception e) { |
| | | return BaseResp.error("导入失败,原因-->" + e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | } |