|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WorkPlansExtMapper workPlansExtMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyExtService companyExtService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DepartmentExtService departmentExtService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RouteProcedureExtMapper routeProcedureExtMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlansExtMapper plansExtMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WorkorderRecordExtMapper workorderRecordExtMapper; | 
|---|
|  |  |  | private WStockExtMapper stockExtMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DepartmentExtService departmentExtService; | 
|---|
|  |  |  | private WorkorderRecordExtMapper workorderRecordExtMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceCheckExtService deviceCheckExtService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | return  result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public   List<StockDataModel> getStockList(Integer companyId, Integer departId){ | 
|---|
|  |  |  | DepartmentExtListVO department =   departmentExtService.getModelById(companyId,departId); | 
|---|
|  |  |  | if(department == null || Constants.equalsInteger(department.getDeleted(), Constants.ONE)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,企业或者部门信息不合法,如有疑问,请联系系统管理员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryWStockExtDTO param = new QueryWStockExtDTO(); | 
|---|
|  |  |  | param.setRootDepartId(department.getRootId()); | 
|---|
|  |  |  | param.setWmodelDepartId(departId); | 
|---|
|  |  |  | //查询统计结果 | 
|---|
|  |  |  | List<StockDataModel> result = stockExtMapper.getStatisticsStockList(param); | 
|---|
|  |  |  | return  result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public  List<DepartmentExtListVO> getDepartmentList(Integer companyId){ | 
|---|
|  |  |  | CompanyExtListVO companyExtListVO = companyExtService.getModelById(companyId); | 
|---|
|  |  |  | if(companyExtListVO == null || Constants.equalsInteger(companyExtListVO.getDeleted(), Constants.ONE)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,企业或者部门信息不合法,如有疑问,请联系系统管理员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryDepartmentExtDTO param = new QueryDepartmentExtDTO(); | 
|---|
|  |  |  | param.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | param.setCompanyId(companyId); | 
|---|
|  |  |  | param.setType(Constants.DEPART_TYPE.com); | 
|---|
|  |  |  | List<DepartmentExtListVO> result = departmentExtService.findList(param); | 
|---|
|  |  |  | return  result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Unqualified7DayModel> getUnqualified7DayData(Integer companyId, Integer departId, Integer procedureId) { | 
|---|
|  |  |  | DepartmentExtListVO department =   departmentExtService.getModelById(companyId,departId); | 
|---|
|  |  |  | if(department == null || Constants.equalsInteger(department.getDeleted(), Constants.ONE)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Unqualified7DayModel> result = new ArrayList<>(); | 
|---|
|  |  |  | Date date = DateUtil.getCurrentDate(); | 
|---|
|  |  |  | for (int i = 0; i < 7; i++) { | 
|---|
|  |  |  | Date td = DateUtil.addDaysToDate(date, 7-i); | 
|---|
|  |  |  | Date td = DateUtil.addDaysToDate(date, i-6); | 
|---|
|  |  |  | Unqualified7DayModel m = getReusltModelByDate(td,model); | 
|---|
|  |  |  | if(m == null){ | 
|---|
|  |  |  | m = new Unqualified7DayModel(); | 
|---|
|  |  |  | 
|---|
|  |  |  | List<RecordLogModel> result = workorderRecordExtMapper.getRecordLog(pageWrap.getModel()); | 
|---|
|  |  |  | if(result!=null){ | 
|---|
|  |  |  | for(RecordLogModel model : result){ | 
|---|
|  |  |  | model.setUnqualifiedNum(new BigDecimal(0)); | 
|---|
|  |  |  | model.setUnqualifiedRate(new BigDecimal(0)); | 
|---|
|  |  |  | BigDecimal doneNum = Constants.formatBigdecimal(model.getUnqualifiedNum()).add(Constants.formatBigdecimal(model.getQualifiedNum())); | 
|---|
|  |  |  | if(model.getUnqualifiedNum() !=null && doneNum.compareTo(new BigDecimal(0)) != 0){ | 
|---|
|  |  |  | //不良品率 | 
|---|
|  |  |  | 
|---|
|  |  |  | //只能查看当前根组织的数据 | 
|---|
|  |  |  | pageWrap.getModel().setRootDepartId(department.getRootId()); | 
|---|
|  |  |  | pageWrap.getModel().setComDepartId(departId); | 
|---|
|  |  |  | PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | return deviceCheckExtService.findPage(pageWrap); | 
|---|
|  |  |  | return deviceCheckExtService.getDeviceCheckPage(pageWrap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public    List<ProcedurePlansPageModel> getProcedurePlansPage(Integer companyId, Integer departId,Integer procedureId){ | 
|---|
|  |  |  | 
|---|
|  |  |  | QueryRouteProcedureExtDTO r = new QueryRouteProcedureExtDTO(); | 
|---|
|  |  |  | r.setRouteId(model.getRouteId()); | 
|---|
|  |  |  | r.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | r.setWorkPlanId(model.getId()); | 
|---|
|  |  |  | List<RouteProcedureExtListVO> list = routeProcedureExtMapper.selectStatisticsList(r); | 
|---|
|  |  |  | List<WorkPlansProcedureModel> rList = new ArrayList<>(); | 
|---|
|  |  |  | if(list != null){ | 
|---|
|  |  |  | 
|---|
|  |  |  | tt.setRate(new BigDecimal(0)); | 
|---|
|  |  |  | if(  Constants.formatBigdecimal(t.getPlanNum()).compareTo(new BigDecimal(0)) >0){ | 
|---|
|  |  |  | //完成率 | 
|---|
|  |  |  | tt.setRate(Constants.formatBigdecimal(t.getDoneNum()).divide(t.getPlanNum(),4).subtract(new BigDecimal(100))); | 
|---|
|  |  |  | tt.setRate(Constants.formatBigdecimal(t.getQualifiedNum()).divide(t.getPlanNum(),4).multiply(new BigDecimal(100))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | tt.setPlanNum(Constants.formatBigdecimal(t.getPlanNum())); | 
|---|
|  |  |  | tt.setDoneNum(Constants.formatBigdecimal(t.getQualifiedNum())); | 
|---|
|  |  |  | rList.add(tt); | 
|---|
|  |  |  | //最后一列的良品数/完工数:为当前产品最后一道工序的良品数/完工数 | 
|---|
|  |  |  | model.setNum(t.getPlanNum()); | 
|---|
|  |  |  | model.setQualifiedNum(t.getDoneNum()); | 
|---|
|  |  |  | model.setDoneNum(t.getDoneNum()); | 
|---|
|  |  |  | model.setQualifiedNum(t.getQualifiedNum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | model.setProcedureList(rList); | 
|---|
|  |  |  | 
|---|
|  |  |  | private Unqualified7DayModel getReusltModelByDate(Date td, List<Unqualified7DayModel> model ) { | 
|---|
|  |  |  | if(model !=null){ | 
|---|
|  |  |  | for(Unqualified7DayModel m : model){ | 
|---|
|  |  |  | if(StringUtils.equals(DateUtil.getShortTime(td),DateUtil.getShortTime(m.getCreateTime()))){ | 
|---|
|  |  |  | String d1 = DateUtil.getShortTime(td); | 
|---|
|  |  |  | String d2 = DateUtil.getShortTime(m.getCreateTime()); | 
|---|
|  |  |  | if(StringUtils.equals(d1,d2)){ | 
|---|
|  |  |  | return m; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|