|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(new PageInfo<>(result)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public  PageData<SalaryStatisticsListVO> salaryStatistic(PageWrap<QuerySalaryStatisticDTO> pageWrap) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您无权限进行该操作!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //只能查看当前根组织的数据 | 
|---|
|  |  |  | pageWrap.getModel().setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | List<SalaryStatisticsListVO> result = workorderRecordExtMapper.salaryStatistic(pageWrap.getModel()); | 
|---|
|  |  |  | if(result!=null){ | 
|---|
|  |  |  | List<DepartmentExtListVO> allDepartList = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_DEPART_LIST_KEY+user.getCompany().getId(),ArrayList.class); | 
|---|
|  |  |  | for(SalaryStatisticsListVO model : result){ | 
|---|
|  |  |  | //查询生产人员姓名 | 
|---|
|  |  |  | //                model.setUserName(initProUser(user,model.getUserId(),allDepartList)); | 
|---|
|  |  |  | model.setUserInfo(initProUser(user,model.getUserId(),allDepartList)); | 
|---|
|  |  |  | model.setJijianSalary(model.getJijianSalary().divide(new BigDecimal("100"),2,BigDecimal.ROUND_HALF_UP)); | 
|---|
|  |  |  | model.setJishiSalary(model.getJishiSalary().divide(new BigDecimal("100"),2,BigDecimal.ROUND_HALF_UP)); | 
|---|
|  |  |  | model.setTotalSalary(model.getTotalSalary().divide(new BigDecimal("100"),2,BigDecimal.ROUND_HALF_UP)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(new PageInfo<>(result)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public  PageData<UserSalaryListVO> userSalaryPage(PageWrap<QueryUserSalaryListDTO> pageWrap) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您无权限进行该操作!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //只能查看当前根组织的数据 | 
|---|
|  |  |  | pageWrap.getModel().setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | pageWrap.getModel().setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //数据权限 | 
|---|
|  |  |  | //        List<Integer> dataPermission = user.getDepartPermissionList(); | 
|---|
|  |  |  | List<UserSalaryListVO> result = workorderRecordExtMapper.userSalaryPage(pageWrap.getModel()); | 
|---|
|  |  |  | if(result!=null){ | 
|---|
|  |  |  | List<DepartmentExtListVO> allDepartList = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_DEPART_LIST_KEY+user.getCompany().getId(),ArrayList.class); | 
|---|
|  |  |  | for(UserSalaryListVO model : result){ | 
|---|
|  |  |  | //查询生产人员姓名 | 
|---|
|  |  |  | model.setUserInfo(initProUser(user,model.getUserId(),allDepartList)); | 
|---|
|  |  |  | if(Constants.formatBigdecimal4Float(model.getNum()).compareTo(new BigDecimal(0))>0){ | 
|---|
|  |  |  | model.setRate(Constants.formatBigdecimal4Float(model.getQualifiedNum()).divide(model.getNum(),4).multiply(new BigDecimal(100))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(new PageInfo<>(result)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void initProUser(LoginUserInfo user, WorkorderRecordExtListVO data, List<DepartmentExtListVO> allDepartList) { | 
|---|
|  |  |  | if(data.getCreateUser() ==null){ | 
|---|
|  |  |  | 
|---|
|  |  |  | String dName =d==null?"":StringUtils.defaultString(d.getName(),""); | 
|---|
|  |  |  | data.setProcedureName(comp.getName()+"-"+dName); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private UserBaseInfoVO initProUser(LoginUserInfo user, Integer userId, List<DepartmentExtListVO> allDepartList) { | 
|---|
|  |  |  | if(userId ==null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CompanyUser query=new CompanyUser(); | 
|---|
|  |  |  | query.setUserId(userId); | 
|---|
|  |  |  | query.setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | query.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | CompanyUser comp= companyUserExtMapper.selectOne(new QueryWrapper<>(query).last(" limit 1")); | 
|---|
|  |  |  | if(comp!=null){ | 
|---|
|  |  |  | UserBaseInfoVO userinfo = new UserBaseInfoVO(); | 
|---|
|  |  |  | DepartmentExtListVO d = departmentExtService.getModelById(user.getCompany().getId(),comp.getDepartmentId(),allDepartList); | 
|---|
|  |  |  | String dName =d==null?"":StringUtils.defaultString(d.getName(),""); | 
|---|
|  |  |  | userinfo.setNameAndDepart (comp.getName()+"-"+dName); | 
|---|
|  |  |  | userinfo.setDepartId(d.getId()); | 
|---|
|  |  |  | userinfo.setUserId(userId); | 
|---|
|  |  |  | userinfo.setUserName(comp.getName()); | 
|---|
|  |  |  | userinfo.setDepartName(d.getName()); | 
|---|
|  |  |  | return  userinfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<WorkorderRecordExtListVO> findAll(QueryWorkorderRecordExtDTO pageWrap) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.create) | 
|---|
|  |  |  | && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.material) | 
|---|
|  |  |  | && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.producing) | 
|---|
|  |  |  | && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.check) | 
|---|
|  |  |  | && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.done)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该工单状态已流转,不能进行该操作!"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.create) | 
|---|
|  |  |  | && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.material) | 
|---|
|  |  |  | && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.producing) | 
|---|
|  |  |  | && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.check) | 
|---|
|  |  |  | && !Constants.equalsInteger(model.getWorkorderStatus(),Constants.WORKORDER_STATUS.done)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该工单状态已流转,不能进行该操作!"); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(tModel.getDoneType(),Constants.ZERO)){ | 
|---|
|  |  |  | //如果不良,累计工单的不良产出 | 
|---|
|  |  |  | mp.setUnqualifiedNum(Constants.formatIntegerNum(mp.getUnqualifiedNum())+(Constants.formatBigdecimal(tModel.getNum()).intValue())); | 
|---|
|  |  |  | //                    mp.setUnqualifiedNum(mp.getUnqualifiedNum().add(tModel.getNum())); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //如果是合格,累计工单的合格数量 | 
|---|
|  |  |  | mp.setQualifiedNum(Constants.formatIntegerNum(mp.getQualifiedNum())+(Constants.formatBigdecimal(tModel.getNum()).intValue())); | 
|---|
|  |  |  | //                    mp.setUnqualifiedNum(mp.getQualifiedNum().add(tModel.getNum())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //检查篮筐是否被作为产出篮筐,如果是,则需要判断该篮筐是否投料余额为0 | 
|---|
|  |  |  | Appliances curUpdateModel = getApplianceFromList(tModel.getAppliancesId(),updateApplianceList); | 
|---|
|  |  |  | 
|---|
|  |  |  | order.setStatus(Constants.WORKORDER_STATUS.material); | 
|---|
|  |  |  | }else if(status ==Constants.WORKORDER_HISTORY_STATUS.done){ | 
|---|
|  |  |  | order.setStatus(Constants.WORKORDER_STATUS.done); | 
|---|
|  |  |  | }else if(status ==Constants.WORKORDER_HISTORY_STATUS.produce){ | 
|---|
|  |  |  | //投料操作 | 
|---|
|  |  |  | if(Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create) | 
|---|
|  |  |  | ||Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material)){ | 
|---|
|  |  |  | //如果是已创建或者已备料状态的工单,修改其状态为【生产中】 | 
|---|
|  |  |  | order.setStatus(Constants.WORKORDER_STATUS.producing); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workorderExtMapper.updateById(order); | 
|---|
|  |  |  | workorderHistoryExtMapper.insertBatch(whList); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create) | 
|---|
|  |  |  | && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material) | 
|---|
|  |  |  | && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.producing) | 
|---|
|  |  |  | && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.check) | 
|---|
|  |  |  | && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.done)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该工单状态已流转,不能进行该操作!"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void exportUserSalary(PageWrap<QueryUserSalaryListDTO> pageWrap, HttpServletResponse response) { | 
|---|
|  |  |  | List<UserSalaryListVO> result=this.userSalaryPage(pageWrap).getRecords(); | 
|---|
|  |  |  | for(UserSalaryListVO model : result) { | 
|---|
|  |  |  | if(model.getUserInfo()!=null){ | 
|---|
|  |  |  | model.setUserName(model.getUserInfo().getUserName()); | 
|---|
|  |  |  | model.setDepartName(model.getUserInfo().getDepartName()); | 
|---|
|  |  |  | model.setNum(Constants.formatBigdecimalFloat(model.getNum(),2)); | 
|---|
|  |  |  | model.setQualifiedNum(Constants.formatBigdecimalFloat(model.getQualifiedNum(),2)); | 
|---|
|  |  |  | model.setUnQualifiedNum(Constants.formatBigdecimalFloat(model.getUnQualifiedNum(),2)); | 
|---|
|  |  |  | model.setRate(Constants.formatBigdecimalFloat(model.getRate(),2)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ExcelExporter.build(UserSalaryListVO.class).export(result, "员工绩效明细"+System.currentTimeMillis(), response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void exportSalaryStatistics(PageWrap<QuerySalaryStatisticDTO> pageWrap, HttpServletResponse response){ | 
|---|
|  |  |  | List<SalaryStatisticsListVO> result=this.salaryStatistic(pageWrap).getRecords(); | 
|---|
|  |  |  | for(SalaryStatisticsListVO model : result) { | 
|---|
|  |  |  | if(model.getUserInfo()!=null){ | 
|---|
|  |  |  | model.setUserName(model.getUserInfo().getUserName()); | 
|---|
|  |  |  | model.setDepartName(model.getUserInfo().getDepartName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ExcelExporter.build(SalaryStatisticsListVO.class).export(result, "工资报表"+System.currentTimeMillis(), response); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void exportExcel(PageWrap<QueryWorkorderRecordExtDTO> pageWrap, HttpServletResponse response) { | 
|---|
|  |  |  | List<WorkorderRecordExtListVO> result=this.findPage(pageWrap).getRecords(); | 
|---|
|  |  |  | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | 
|---|