| | |
| | | import com.ld.igds.inout.InoutConstant; |
| | | import com.ld.igds.inout.dto.InoutData; |
| | | import com.ld.igds.inout.dto.InoutParam; |
| | | import com.ld.igds.inout.dto.InoutCheckData; |
| | | import com.ld.igds.inout.dto.InoutCheckParam; |
| | | import com.ld.igds.inout.mapper.InoutCheckMapper; |
| | | import com.ld.igds.inout.mapper.InoutRecordMapper; |
| | | import com.ld.igds.inout.service.InoutService; |
| | | import com.ld.igds.io.constant.OrderRespEnum; |
| | |
| | | |
| | | @Resource |
| | | private InoutRecordMapper inoutMapper; |
| | | @Resource |
| | | private InoutCheckMapper inoutCheckMapper; |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | @Resource |
| | |
| | | |
| | | @Override |
| | | public String insertData(InoutData data) { |
| | | try { |
| | | data.setUpdateTime(new Date()); |
| | | |
| | | if (StringUtils.isEmpty(data.getCompanyId())) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (null == data.getDeptId()) { |
| | | data.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | // 获取当前仓库的实际库存 |
| | | if (StringUtils.isNotEmpty(data.getDepotId())) { |
| | | if (null == data.getFoodYear() || null == data.getFoodType()) { |
| | | Depot depot = commonService.getCacheDepot(data.getCompanyId(), data.getDepotId()); |
| | | if (null == data.getFoodYear()) { |
| | | data.setFoodYear(depot.getFoodYear()); |
| | | } |
| | | if (null == data.getFoodType()) { |
| | | data.setFoodType(depot.getFoodType()); |
| | | String id = this.createId(data.getRegisterTime(), data.getCompanyId()); |
| | | if (StringUtils.isEmpty(data.getId())) { |
| | | if (InoutConstant.TYPE_IN.equals(data.getType())) { |
| | | data.setId("R_" + id); |
| | | } else if (InoutConstant.TYPE_OUT.equals(data.getType())) { |
| | | data.setId("C_" + id); |
| | | } else if (Constant.LOSS_OVER_OVER.equals(data.getType())) { |
| | | data.setId("R_" + id); |
| | | } else if (Constant.LOSS_OVER_LOSS.equals(data.getType())) { |
| | | data.setId("C_" + id); |
| | | } else { |
| | | data.setId("M_" + id); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (null == data.getRegisterTime()) { |
| | | data.setRegisterTime(new Date()); |
| | | } |
| | | |
| | | String id = this.createId(data.getRegisterTime(), data.getCompanyId()); |
| | | |
| | | if (StringUtils.isEmpty(data.getId())) { |
| | | if (InoutConstant.TYPE_IN.equals(data.getType())) { |
| | | data.setId("R_" + id); |
| | | } else if (InoutConstant.TYPE_OUT.equals(data.getType())) { |
| | | data.setId("C_" + id); |
| | | } else if (Constant.LOSS_OVER_OVER.equals(data.getType())) { |
| | | data.setId("R_" + id); |
| | | } else if (Constant.LOSS_OVER_LOSS.equals(data.getType())) { |
| | | data.setId("C_" + id); |
| | | } else { |
| | | data.setId("M_" + id); |
| | | if (StringUtils.isEmpty(data.getCheckId())) { |
| | | data.setCheckId(id); |
| | | } |
| | | } |
| | | if (StringUtils.isEmpty(data.getCheckId())) { |
| | | data.setCheckId(id); |
| | | } |
| | | if (null == data.getDeptId()) { |
| | | data.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | if (null == data.getUserName()) { |
| | | data.setUserName(""); |
| | | } |
| | | |
| | | inoutMapper.insertData(data); |
| | | if (null == data.getUserName()) { |
| | | data.setUserName(""); |
| | | } |
| | | |
| | | // 如果不是手动补录的数据,添加到缓存中 |
| | | if (!InoutConstant.RECORD_STATUS_ADD.equals(data.getRecordStatus())) { |
| | | inoutMapper.insertData(data); |
| | | |
| | | this.addInoutCache(data); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("------------出入库执行保存出错---{}", e); |
| | | return "后台异常:" + e.getMessage(); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | |
| | | |
| | | List<InoutData> records = inoutMapper.pageRecordData(page, param); |
| | | //判断入库重量是否为空,为空则赋值结算重量 |
| | | if(records != null){ |
| | | if (records != null) { |
| | | for (InoutData record : records) { |
| | | if(record.getRecordWeight() == null || record.getRecordWeight() == 0.0){ |
| | | if (record.getRecordWeight() == null || record.getRecordWeight() == 0.0) { |
| | | record.setRecordWeight(record.getSettleWeight()); |
| | | } |
| | | } |
| | |
| | | // 获取上一车的流水数据 |
| | | InoutData inoutData = this.getLastRecord(data.getCompanyId(), data.getDepotId()); |
| | | |
| | | // 设置流水的库存 |
| | | if (InoutConstant.TYPE_IN.equals(inoutData.getType())) { |
| | | data.setCurStorage(inoutData.getCurStorage() |
| | | + inoutData.getSettleWeight()); |
| | | } else if (InoutConstant.TYPE_OUT.equals(inoutData.getType())) { |
| | | data.setCurStorage(inoutData.getCurStorage() |
| | | - inoutData.getSettleWeight()); |
| | | } |
| | | // // 设置流水的库存 |
| | | // if (InoutConstant.TYPE_IN.equals(inoutData.getType())) { |
| | | // data.setCurStorage(inoutData.getCurStorage() |
| | | // + inoutData.getSettleWeight()); |
| | | // } else if (InoutConstant.TYPE_OUT.equals(inoutData.getType())) { |
| | | // data.setCurStorage(inoutData.getCurStorage() |
| | | // - inoutData.getSettleWeight()); |
| | | // } |
| | | |
| | | // 添加补单数据 |
| | | this.insertData(data); |
| | |
| | | return result.getNumValue1(); |
| | | } |
| | | |
| | | @Override |
| | | public int checkExist(InoutParam param) { |
| | | return inoutMapper.checkExist(param); |
| | | } |
| | | |
| | | /** |
| | | * 未完成流程存入缓存 |
| | | * |
| | |
| | | public String buildInoutKey(String deptId, String key, String type, String bizId) { |
| | | return Constant.APP_NAME + ":" + deptId + ":" + key + ":" + type + ":" + bizId; |
| | | } |
| | | |
| | | @Override |
| | | public Page<InoutCheckData> pageSampleData(InoutCheckParam param) { |
| | | |
| | | //设置起始和截止时间 |
| | | if (null != param.getStart()) { |
| | | param.setStart(DateUtil.getCurZero(param.getStart())); |
| | | } |
| | | if (null != param.getEnd()) { |
| | | param.setEnd(DateUtil.getNextZero(param.getEnd())); |
| | | } |
| | | |
| | | // 设置车牌和检验单据的模糊查询 |
| | | if (StringUtils.isNotEmpty(param.getPlateNum())) { |
| | | param.setPlateNum("%" + param.getPlateNum() + "%"); |
| | | } |
| | | if (StringUtils.isNotEmpty(param.getCheckId())) { |
| | | param.setCheckId("%" + param.getCheckId() + "%"); |
| | | } |
| | | |
| | | Page<InoutCheckData> page = new Page<>(param.getPage(), param.getLimit()); |
| | | page.setSearchCount(true); |
| | | |
| | | List<InoutCheckData> records = inoutCheckMapper.pageSampleData(page, param); |
| | | page.setRecords(records); |
| | | |
| | | return page; |
| | | } |
| | | |
| | | @Override |
| | | public String updateSampleData(InoutData data) { |
| | | if (StringUtils.isEmpty(data.getCompanyId())) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(data.getDeptId())) { |
| | | data.setCompanyId(ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | int num = inoutCheckMapper.updateSampleData(data); |
| | | return null; |
| | | } |
| | | |
| | | } |