|  |  |  | 
|---|
|  |  |  | import doumeemes.dao.business.*; | 
|---|
|  |  |  | import doumeemes.dao.business.model.*; | 
|---|
|  |  |  | import doumeemes.dao.business.vo.SalaryParamVO; | 
|---|
|  |  |  | import doumeemes.dao.ext.MaterialExtMapper; | 
|---|
|  |  |  | import doumeemes.dao.ext.dto.SalaryParamDTO; | 
|---|
|  |  |  | import doumeemes.dao.ext.dto.SalaryParamImportDTO; | 
|---|
|  |  |  | import doumeemes.dao.ext.vo.DepartmentExtListVO; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(SalaryParam salaryParam) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DepartmentExtListVO department =departmentExtService.getModelById(principal.getCompany().getId(),salaryParam.getDepartId()); | 
|---|
|  |  |  | Integer comDepartId = departmentExtService.getComDepartId(department); | 
|---|
|  |  |  | SalaryParam insert = new SalaryParam(); | 
|---|
|  |  |  | insert.setRootDepartId(principal.getRootDepartment().getId()); | 
|---|
|  |  |  | insert.setDepartId(salaryParam.getDepartId()); | 
|---|
|  |  |  | //        insert.setDepartId(comDepartId); | 
|---|
|  |  |  | insert.setProcedureId(salaryParam.getProcedureId()); | 
|---|
|  |  |  | insert.setMaterialId(salaryParam.getMaterialId()); | 
|---|
|  |  |  | insert.setDeleted((byte) Constants.ZERO); | 
|---|
|  |  |  | insert.setType(salaryParam.getType()); | 
|---|
|  |  |  | if(findOne(insert) != null){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"同一个物料在相同工序不能重复配置哦!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | SalaryParamDTO model = pageWrap.getModel(); | 
|---|
|  |  |  | model.setRootDepartId(principal.getRootDepartment().getId()); | 
|---|
|  |  |  | //        model.setDepartId(principal.getComDepartment().getId()); | 
|---|
|  |  |  | //        model.setDepartId(principal.getCurComDepartment().getId()); | 
|---|
|  |  |  | IPage<SalaryParamVO> salaryParamVOIPage = salaryParamMapper.selectPage(page, model); | 
|---|
|  |  |  | if (!CollectionUtils.isEmpty(salaryParamVOIPage.getRecords())){ | 
|---|
|  |  |  | salaryParamVOIPage.getRecords().forEach(s->s.setSalary(s.getSalary().divide(new BigDecimal(100)))); | 
|---|
|  |  |  | 
|---|
|  |  |  | dparam.setType(Constants.DEPART_TYPE.factory); | 
|---|
|  |  |  | dparam = departmentExtService.findOne(dparam); | 
|---|
|  |  |  | if (Objects.isNull(dparam)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "导入数据内容【公司名称】有误!"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "导入数据内容【工厂组织】有误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | DepartmentExtListVO department = new DepartmentExtListVO(); | 
|---|
|  |  |  | BeanUtils.copyProperties(dparam, department); | 
|---|
|  |  |  | department.setId(dparam.getId()); | 
|---|
|  |  |  | department.setType(dparam.getType()); | 
|---|
|  |  |  | department.setParentId(dparam.getParentId()); | 
|---|
|  |  |  | department.setRootId(dparam.getRootId()); | 
|---|
|  |  |  | department.setCompanyId(dparam.getCompanyId()); | 
|---|
|  |  |  | Integer comDepartId = departmentExtService.getComDepartId(department); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | QueryWrapper<Material> materialWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | materialWrapper.lambda() | 
|---|
|  |  |  | .eq(Material::getCode,salaryParamImportDTO.getMaterialCode()) | 
|---|
|  |  |  | .eq(Material::getRootDepartId,department.getRootId()) | 
|---|
|  |  |  | .eq(Material::getRootDepartId,dparam.getRootId()) | 
|---|
|  |  |  | .eq(Material::getDeleted,Constants.ZERO) | 
|---|
|  |  |  | .last("limit 1"); | 
|---|
|  |  |  | Material material = materialMapper.selectOne(materialWrapper); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | SalaryParam salaryParam = new SalaryParam(); | 
|---|
|  |  |  | salaryParam.setRootDepartId(department.getRootId()); | 
|---|
|  |  |  | salaryParam.setDepartId(department.getId()); | 
|---|
|  |  |  | salaryParam.setDepartId(dparam.getId()); | 
|---|
|  |  |  | salaryParam.setProcedureId(procedures.getId()); | 
|---|
|  |  |  | salaryParam.setMaterialId(materialDistribute.getId()); | 
|---|
|  |  |  | salaryParam.setSalary(salaryParamImportDTO.getSalary()); | 
|---|
|  |  |  | 
|---|
|  |  |  | }).orElse(0); | 
|---|
|  |  |  | salaryParam.setUnqualified(unqualified); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer type = Optional.ofNullable(salaryParamImportDTO.getUnqualified()).map(s -> { | 
|---|
|  |  |  | Integer type = Optional.ofNullable(salaryParamImportDTO.getType()).map(s -> { | 
|---|
|  |  |  | if ("计件".equals(s)) { | 
|---|
|  |  |  | return 0; | 
|---|
|  |  |  | } else { | 
|---|