| | |
| | | package com.doumee.service.business.impl.thrid; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | |
| | | import com.doumee.core.haikang.model.param.respose.*; |
| | | import com.doumee.core.haikang.service.HKCarOpenService; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.tms.model.TMSContants; |
| | | import com.doumee.core.tms.model.request.TmsFacrotyCodeListRequest; |
| | | import com.doumee.core.tms.model.request.TmsOutQtyAndVehicleQtyRequest; |
| | | import com.doumee.core.tms.model.request.TmsSevenArrivalDetailsRequest; |
| | | import com.doumee.core.tms.model.response.*; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | |
| | | import com.doumee.dao.web.reqeust.CarsJobAndContractDTO; |
| | | import com.doumee.dao.web.response.platformReport.*; |
| | | import com.doumee.service.business.impl.PlatformJobServiceImpl; |
| | | import com.doumee.service.business.impl.VisitsServiceImpl; |
| | | import com.doumee.service.business.third.BoardService; |
| | | import com.doumee.service.business.third.TmsService; |
| | | import com.doumee.service.business.third.WmsService; |
| | | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private TmsFactoryParamMapper tmsFactoryParamMapper; |
| | | @Autowired |
| | | private PlatformWarnEventJoinMapper platformWarnEventJoinMapper; |
| | | @Autowired |
| | | private PlatformJobMapper platformJobMapper; |
| | |
| | | private RetentionMapper retentionMapper; |
| | | @Autowired |
| | | private PlatformGroupMapper platformGroupMapper; |
| | | @Autowired |
| | | private TmsService tmsService; |
| | | |
| | | @Value("${debug_model}") |
| | | private Boolean isDebug; |
| | | /** |
| | | * 获取区域树形结构数据 |
| | | * @return |
| | |
| | | .isNotNull(PlatformLog::getParam3) |
| | | .ne(PlatformLog::getParam3,Constants.ZERO+"")); |
| | | if(platformLogList!=null && platformLogList.size()>0){ |
| | | return new BigDecimal((double)(platformLogList.stream().map(m->Long.valueOf(m.getParam3())).reduce(Long.valueOf(0),Long::sum))/(double)60); |
| | | return new BigDecimal((double)(platformLogList.stream().map(m->Long.valueOf(m.getParam3())).reduce(Long.valueOf(0),Long::sum))/(double)3600); |
| | | } |
| | | } |
| | | return r; |
| | |
| | | curtotalNum += Constants.formatIntegerNum(workEfficiencyVO.getWorkNum()) ; |
| | | } |
| | | workEfficiencyVO.setTotalWorkNum(curtotalNum);//累计值 |
| | | if(System.currentTimeMillis() < curTime){ |
| | | workEfficiencyVO.setTotalWorkNum(0); |
| | | } |
| | | workEfficiencyVOList.add(workEfficiencyVO); |
| | | } |
| | | return workEfficiencyVOList; |
| | |
| | | return null; |
| | | } |
| | | } |
| | | /** |
| | | * 出库能力 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public WholeProvinceZXTVO outAbilityUseRate(){ |
| | | WholeProvinceZXTVO result = new WholeProvinceZXTVO(); |
| | | result.setCurrentNum(new BigDecimal(0)); |
| | | result.setTotalNum(new BigDecimal(0)); |
| | | result.setUseRate(new BigDecimal(0)); |
| | | result.setDetailList(new ArrayList<>()); |
| | | List<TmsFactoryParam> paramList = factoryList(); |
| | | List<WholeProvinceZxtDetailVO> list = new ArrayList<>(); |
| | | TmsOutQtyAndVehicleQtyRequest param = new TmsOutQtyAndVehicleQtyRequest(); |
| | | if(paramList!=null){ |
| | | String startDate = DateUtil.formatDate(new Date(),"yyyy-MM-dd"); |
| | | String endDate = DateUtil.formatDate(new Date(),"yyyy-MM-dd"); |
| | | if(isDebug){ |
| | | startDate = "2024-12-01"; |
| | | endDate = "2024-12-05"; |
| | | } |
| | | for(TmsFactoryParam p : paramList){ |
| | | WholeProvinceZxtDetailVO t = new WholeProvinceZxtDetailVO(); |
| | | t.setFactoryName(p.getName()); |
| | | t.setCurrentNum(new BigDecimal(0)); |
| | | t.setUseRate(new BigDecimal(0)); |
| | | t.setTotalNum(Constants.formatBigdecimal(p.getParam3()));//8小时出库能力 |
| | | if(StringUtils.isNotBlank(p.getCode())){ |
| | | param.setFacrotyCodeList(new ArrayList<>()); |
| | | param.setDateStart(startDate); |
| | | param.setDateEnd(endDate); |
| | | param.getFacrotyCodeList().add(p.getCode()); |
| | | List<TmsOutQtyAndVehicleQtyResponse> response = tmsService.getOutQtyAndVehicleQty(param);//查询出库量 |
| | | t.setCurrentNum(getCurrentOutQryByList(response)); |
| | | if(t.getTotalNum().compareTo(new BigDecimal(0)) !=0){ |
| | | t.setUseRate(t.getCurrentNum().divide(t.getTotalNum(),4,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | } |
| | | result.getDetailList().add(t); |
| | | result.setCurrentNum(result.getCurrentNum().add(t.getCurrentNum())); |
| | | result.setTotalNum(result.getTotalNum().add(t.getTotalNum())); |
| | | } |
| | | } |
| | | if(result.getTotalNum().compareTo(new BigDecimal(0)) !=0){ |
| | | result.setUseRate(result.getCurrentNum().divide(result.getTotalNum(),4,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | return result; |
| | | } |
| | | /** |
| | | * 全身出库能力 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public WholeProvinceBoardVO centerProvinceData(String factoryCode){ |
| | | WholeProvinceBoardVO data = new WholeProvinceBoardVO(); |
| | | data.setMaxAbility(new BigDecimal(0)); |
| | | data.setHoursAbility(new BigDecimal(0)); |
| | | List<TmsFactoryParam> paramList = factoryList(); |
| | | String code = null; |
| | | if(paramList!=null){ |
| | | //处理最大出库能力和8小时出库能力 |
| | | for(TmsFactoryParam param : paramList){ |
| | | if(StringUtils.isNotBlank(factoryCode)){ |
| | | if(StringUtils.equals(param.getCode(),factoryCode)){ |
| | | data.setHoursAbility(data.getHoursAbility().add(Constants.formatBigdecimal(param.getParam3()))); |
| | | data.setMaxAbility(data.getMaxAbility().add(Constants.formatBigdecimal(param.getNum2()))); |
| | | code = param.getCode(); |
| | | break; |
| | | } |
| | | }else{ |
| | | data.setHoursAbility(data.getHoursAbility().add(Constants.formatBigdecimal(param.getParam3()))); |
| | | data.setMaxAbility(data.getMaxAbility().add(Constants.formatBigdecimal(param.getNum2()))); |
| | | } |
| | | } |
| | | } |
| | | if(isDebug){ |
| | | data.setCurrentPlanNum(new BigDecimal(1220)); |
| | | data.setCurrentOrderNum(new BigDecimal(32340)); |
| | | data.setCrrentOutNum(new BigDecimal(3450)); |
| | | data.setCrrentRestNum(new BigDecimal(456450)); |
| | | } |
| | | Date date = new Date(); |
| | | TmsOutQtyAndVehicleQtyRequest param = new TmsOutQtyAndVehicleQtyRequest(); |
| | | param.setDateEnd(DateUtil.getShortTime(date)); |
| | | param.setDateStart(DateUtil.getShortTime(date)); |
| | | if(StringUtils.isNotBlank(code)){ |
| | | param.setFacrotyCodeList(new ArrayList<>()); |
| | | param.getFacrotyCodeList().add(code);//查询指定厂区 |
| | | } |
| | | List<TmsOutQtyAndVehicleQtyResponse> listSame= tmsService.getOutQtyAndVehicleQty(param);//去年同期 |
| | | if(listSame!=null ){ |
| | | for(TmsOutQtyAndVehicleQtyResponse model : listSame){ |
| | | data.setCrrentOutNum(data.getCrrentOutNum().add(Constants.formatBigdecimal(model.getTotalOutQty())));//今日出库量 |
| | | data.setCrrentOutCarNum(data.getCrrentOutCarNum()+(Constants.formatIntegerNum(model.getVehicleQty())));//今日出库车次 |
| | | } |
| | | } |
| | | return data; |
| | | |
| | | } |
| | | /** |
| | | * 出库能力李永利 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public TotalOutQtyNumVO totalOutQtyNum(int type,String code){ |
| | | TotalOutQtyNumVO data = new TotalOutQtyNumVO(); |
| | | data.setCurrentInNum(new BigDecimal(0)); |
| | | data.setLastInNum(new BigDecimal(0)); |
| | | data.setSameInNum(new BigDecimal(0)); |
| | | //---------省外---------------- |
| | | data.setCurrentOutNum(new BigDecimal(0)); |
| | | data.setLastOutNum(new BigDecimal(0)); |
| | | data.setSameOutNum(new BigDecimal(0)); |
| | | |
| | | Date sameStart = DateUtil.getBeginDayOfMonth(-1); |
| | | Date sameEnd = DateUtil.getEndDayOfMonth(-1); |
| | | Date curStart = DateUtil.getBeginDayOfMonth(0); |
| | | Date curEnd = DateUtil.getEndDayOfMonth(0); |
| | | Date lastStart = DateUtil.getBeginDayOfLastMonth(); |
| | | Date lastEnd = DateUtil.getEndDayOfLastMonth(); |
| | | if(type ==1){ |
| | | //本周 |
| | | sameStart= DateUtil.getBeginDayOfWeek(-1); |
| | | sameEnd= DateUtil.getEndDayOfWeek(-1); |
| | | curStart= DateUtil.getBeginDayOfWeek(0); |
| | | curEnd= DateUtil.getEndDayOfWeek(0); |
| | | lastStart = DateUtil.getBeginDayOfLastWeek(); |
| | | lastEnd= DateUtil.getEndDayOfLastWeek(); |
| | | }else if(type == 2){ |
| | | curStart= DateUtil.getBeginDayOfYear(0); |
| | | curEnd= DateUtil.getEndDayOfYear(0); |
| | | lastStart= DateUtil.getBeginDayOfYear(-1); |
| | | lastEnd= DateUtil.getEndDayOfYear(-1); |
| | | sameStart = null; |
| | | sameEnd =null; |
| | | } |
| | | TmsOutQtyAndVehicleQtyRequest param = new TmsOutQtyAndVehicleQtyRequest(); |
| | | if(StringUtils.isNotBlank(code)){ |
| | | param.setFacrotyCodeList(new ArrayList<>()); |
| | | param.getFacrotyCodeList().add(code); |
| | | } |
| | | if(type !=2){ |
| | | //本年的不需要查去年同周期 |
| | | param.setDateEnd(DateUtil.getShortTime(sameEnd)); |
| | | param.setDateStart(DateUtil.getShortTime(sameStart)); |
| | | List<TmsOutQtyAndVehicleQtyResponse> listSame= tmsService.getOutQtyAndVehicleQty(param);//去年同期 |
| | | if(listSame!=null ){ |
| | | for(TmsOutQtyAndVehicleQtyResponse model : listSame){ |
| | | data.setSameOutNum(data.getSameOutNum().add(Constants.formatBigdecimal(model.getOutSideProvinceOutQty()))); |
| | | data.setSameInNum(data.getSameInNum().add(Constants.formatBigdecimal(model.getInSideProvinceOutQty()))); |
| | | } |
| | | } |
| | | } |
| | | param.setDateEnd(DateUtil.getShortTime(curEnd)); |
| | | param.setDateStart(DateUtil.getShortTime(curStart)); |
| | | List<TmsOutQtyAndVehicleQtyResponse> listCur = tmsService.getOutQtyAndVehicleQty(param);//本周期 |
| | | if(listCur!=null ){ |
| | | for(TmsOutQtyAndVehicleQtyResponse model : listCur){ |
| | | data.setCurrentOutNum(data.getCurrentOutNum().add(Constants.formatBigdecimal(model.getOutSideProvinceOutQty()))); |
| | | data.setCurrentInNum(data.getCurrentInNum().add(Constants.formatBigdecimal(model.getInSideProvinceOutQty()))); |
| | | data.setTotalCarNum(data.getTotalCarNum()+Constants.formatIntegerNum(model.getVehicleQty()));//累计车次 |
| | | } |
| | | } |
| | | param.setDateEnd(DateUtil.getShortTime(lastEnd)); |
| | | param.setDateStart(DateUtil.getShortTime(lastStart)); |
| | | List<TmsOutQtyAndVehicleQtyResponse> listLast = tmsService.getOutQtyAndVehicleQty(param);//上周期 |
| | | if(listCur!=null ){ |
| | | for(TmsOutQtyAndVehicleQtyResponse model : listLast){ |
| | | data.setLastOutNum(data.getLastOutNum().add(Constants.formatBigdecimal(model.getOutSideProvinceOutQty()))); |
| | | data.setLastInNum(data.getLastInNum().add(Constants.formatBigdecimal(model.getInSideProvinceOutQty()))); |
| | | } |
| | | } |
| | | if(type == 2){//本年的 |
| | | data.setSameOutNum(data.getLastOutNum()); |
| | | data.setSameInNum(data.getLastInNum()); |
| | | } |
| | | return data; |
| | | } |
| | | /** |
| | | * 出库能力李永利 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<WholeProvinceMapVO> mapYearAndMonthOutList(String code){ |
| | | List<WholeProvinceMapVO> result = new ArrayList<>(); |
| | | TmsFacrotyCodeListRequest param = new TmsFacrotyCodeListRequest(); |
| | | if(StringUtils.isNotBlank(code)){ |
| | | param.setFacrotyCodeList(new ArrayList<>()); |
| | | param.getFacrotyCodeList().add(code); |
| | | } |
| | | List<TmsDistributionOfDeliveryLocResponse> response = tmsService.getDistributionOfDeliveryLocations(param);//查询出库量 |
| | | if(response!=null &&response.size()>0){ |
| | | for(TmsDistributionOfDeliveryLocResponse model : response){ |
| | | WholeProvinceMapVO tt = getFromProvinceResultList(model ,result); |
| | | if(tt == null){ |
| | | tt =new WholeProvinceMapVO(); |
| | | tt.setMonthNum( Constants.formatBigdecimal0Float(model.getMonthOutboundQuantity())); |
| | | tt.setYearNum( Constants.formatBigdecimal0Float(model.getYearOutboundQuantity())); |
| | | tt.setProvinceCode(model.getFromProvinceCode()); |
| | | tt.setProvinceName(model.getFromProvinceName()); |
| | | result.add(tt); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private WholeProvinceMapVO getFromProvinceResultList(TmsDistributionOfDeliveryLocResponse model, List<WholeProvinceMapVO> result) { |
| | | for(WholeProvinceMapVO t : result){ |
| | | if(StringUtils.equals(t.getProvinceCode(), model.getFromProvinceCode())){ |
| | | t.setMonthNum(Constants.formatBigdecimal(t.getMonthNum()).add(Constants.formatBigdecimal0Float(model.getMonthOutboundQuantity()))); |
| | | t.setYearNum(Constants.formatBigdecimal(t.getYearNum()).add(Constants.formatBigdecimal0Float(model.getYearOutboundQuantity()))); |
| | | return t; |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 出库能力李永利 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<TmsFactoryParam> factoryList(){ |
| | | List<TmsFactoryParam> paramList = tmsFactoryParamMapper.selectList(new QueryWrapper<TmsFactoryParam>().lambda() |
| | | .eq(TmsFactoryParam::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(TmsFactoryParam::getSortnum)); |
| | | return paramList; |
| | | } |
| | | /** |
| | | * 获取未完成订单集合 |
| | | * @return TmsBaseResponse |
| | | */ |
| | | @Override |
| | | public List<TmsOrderNoFinishListResponse> orderNoFinishList(String code){ |
| | | TmsFacrotyCodeListRequest param = new TmsFacrotyCodeListRequest(); |
| | | if(StringUtils.isNotBlank(code)){ |
| | | param.setFacrotyCodeList(new ArrayList<>()); |
| | | param.getFacrotyCodeList().add(code);//查询指定厂区 |
| | | } |
| | | List<TmsOrderNoFinishListResponse> infoList = tmsService.getNotFinishOrderList(param);//查询出库量 |
| | | return infoList; |
| | | } |
| | | /** |
| | | * 近七日到货情况 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<LastSevenDaysOrderVo> arriveGoodsList(String code){ |
| | | List<LastSevenDaysOrderVo> list = new ArrayList<>(); |
| | | TmsSevenArrivalDetailsRequest param = new TmsSevenArrivalDetailsRequest(); |
| | | if(StringUtils.isNotBlank(code)){ |
| | | param.setFacrotyCodeList(new ArrayList<>()); |
| | | param.getFacrotyCodeList().add(code);//查询指定厂区 |
| | | } |
| | | List<TmsSevenArrivalStatusAndDetailsResponse> infoList = tmsService.getSevenArrivalStatusAndDetails(param);//查询出库量 |
| | | Date date = new Date(); |
| | | for (int i = 0; i < 7; i++) { |
| | | LastSevenDaysOrderVo model = new LastSevenDaysOrderVo(); |
| | | Date td = DateUtil.addDaysToDate(date,-i); |
| | | model.setDateStr(DateUtil.getShortTime(td)); |
| | | dealGoodsListFromResponse(model,infoList); |
| | | } |
| | | return list; |
| | | } |
| | | private void dealGoodsListFromResponse( LastSevenDaysOrderVo model, List<TmsSevenArrivalStatusAndDetailsResponse> list) { |
| | | model.setIngList(new ArrayList<>()); |
| | | model.setWaitList(new ArrayList<>()); |
| | | model.setDoneList(new ArrayList<>()); |
| | | if(list ==null || list.size()==0){ |
| | | return; |
| | | } |
| | | for(TmsSevenArrivalStatusAndDetailsResponse temp : list){ |
| | | if(StringUtils.equals(temp.getNcCreateDate(),model.getDateStr())){ |
| | | if(Constants.equalsInteger(temp.getStatus(),Constants.ZERO)){ |
| | | model.getWaitList().add(temp); |
| | | }else if(Constants.equalsInteger(temp.getStatus(),Constants.ONE)){ |
| | | model.getIngList().add(temp); |
| | | }else if(Constants.equalsInteger(temp.getStatus(),Constants.TWO)){ |
| | | model.getDoneList().add(temp); |
| | | } |
| | | } |
| | | } |
| | | model.setDoneNum(model.getDoneList().size()); |
| | | model.setIngNum(model.getIngList().size()); |
| | | model.setWaitNum(model.getWaitList().size()); |
| | | } |
| | | |
| | | /** |
| | | * 出库能力李永利 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public WholeProvinceZXTVO tranportAbilityUseRate(){ |
| | | WholeProvinceZXTVO result = new WholeProvinceZXTVO(); |
| | | result.setCurrentNum(new BigDecimal(0)); |
| | | result.setTotalNum(new BigDecimal(0)); |
| | | result.setUseRate(new BigDecimal(0)); |
| | | result.setDetailList(new ArrayList<>()); |
| | | List<TmsFactoryParam> paramList =factoryList(); |
| | | if(paramList!=null){ |
| | | List<TmsTotalAndReportVehicleQtyResponse> response = tmsService.getTotalAndReportVehicleQty();//查询出库量 |
| | | for(TmsFactoryParam p : paramList){ |
| | | WholeProvinceZxtDetailVO t = new WholeProvinceZxtDetailVO(); |
| | | t.setFactoryName(p.getName()); |
| | | t.setCurrentNum(new BigDecimal(0)); |
| | | t.setTotalNum(Constants.formatBigdecimal(p.getNum1()));//总库存量 |
| | | getFromReportVehicleQtyList(p.getCode(),t,response);//处理提报运力和总运力数据 |
| | | t.setUseRate(new BigDecimal(0)); |
| | | if(t.getTotalNum().compareTo(new BigDecimal(0)) !=0){ |
| | | t.setUseRate(t.getCurrentNum().divide(t.getTotalNum(),4,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | result.getDetailList().add(t); |
| | | result.setCurrentNum(result.getCurrentNum().add(t.getCurrentNum())); |
| | | result.setTotalNum(result.getTotalNum().add(t.getTotalNum())); |
| | | } |
| | | } |
| | | if(result.getTotalNum().compareTo(new BigDecimal(0)) !=0){ |
| | | result.setUseRate(result.getCurrentNum().divide(result.getTotalNum(),4,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | return result; |
| | | } |
| | | private void getFromReportVehicleQtyList(String code,WholeProvinceZxtDetailVO t, List<TmsTotalAndReportVehicleQtyResponse> responses) { |
| | | BigDecimal current = new BigDecimal(0); |
| | | BigDecimal total= new BigDecimal(0); |
| | | if(responses!=null && responses.size()>0){ |
| | | for(TmsTotalAndReportVehicleQtyResponse model: responses){ |
| | | if(StringUtils.equals(model.getFactoryCode(),code)){ |
| | | total = total.add(Constants.formatBigdecimal(model.getTotalQty())); |
| | | current = current.add(Constants.formatBigdecimal(model.getReportQty())); |
| | | } |
| | | } |
| | | } |
| | | t.setCurrentNum(current); |
| | | t.setTotalNum(total); |
| | | } |
| | | private BigDecimal getCurrentOutQryByList(List<TmsOutQtyAndVehicleQtyResponse> response) { |
| | | BigDecimal r = new BigDecimal(0); |
| | | if(response!=null && response.size()>0){ |
| | | for(TmsOutQtyAndVehicleQtyResponse model: response){ |
| | | r = r.add(Constants.formatBigdecimal(model.getTotalOutQty())); |
| | | } |
| | | } |
| | | return r ; |
| | | } |
| | | |
| | | /** |
| | | * 仓库资源利用率 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public WholeProvinceZXTVO inventoryUseRate(){ |
| | | WholeProvinceZXTVO result = new WholeProvinceZXTVO(); |
| | | result.setCurrentNum(new BigDecimal(0)); |
| | | result.setTotalNum(new BigDecimal(0)); |
| | | result.setUseRate(new BigDecimal(0)); |
| | | result.setDetailList(new ArrayList<>()); |
| | | List<TmsFactoryParam> paramList = factoryList(); |
| | | List<TmsInventoryListResponse> responses = tmsService.getRealTimeInventory(); |
| | | if(paramList!=null){ |
| | | for(TmsFactoryParam p : paramList){ |
| | | WholeProvinceZxtDetailVO t = new WholeProvinceZxtDetailVO(); |
| | | t.setFactoryName(p.getName()); |
| | | t.setCurrentNum(new BigDecimal(0)); |
| | | t.setTotalNum(Constants.formatBigdecimal(p.getNum1()));//总库存量 |
| | | t.setCurrentNum(getFromInventoryList(p.getCode(),responses)); |
| | | t.setUseRate(new BigDecimal(0)); |
| | | if(t.getTotalNum().compareTo(new BigDecimal(0)) !=0){ |
| | | t.setUseRate(t.getCurrentNum().divide(t.getTotalNum(),4,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | result.getDetailList().add(t); |
| | | result.setCurrentNum(result.getCurrentNum().add(t.getCurrentNum())); |
| | | result.setTotalNum(result.getTotalNum().add(t.getTotalNum())); |
| | | } |
| | | } |
| | | if(result.getTotalNum().compareTo(new BigDecimal(0)) !=0){ |
| | | result.setUseRate(result.getCurrentNum().divide(result.getTotalNum(),4,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private BigDecimal getFromInventoryList(String code, List<TmsInventoryListResponse> responses) { |
| | | BigDecimal r = new BigDecimal(0); |
| | | if(responses!=null && responses.size()>0){ |
| | | for(TmsInventoryListResponse model: responses){ |
| | | if(StringUtils.equals(model.getFactoryCode(),code)){ |
| | | r = r.add(Constants.formatBigdecimal(model.getStockQty())); |
| | | } |
| | | } |
| | | } |
| | | return r ; |
| | | |
| | | } |
| | | |
| | | |
| | | } |