对比新文件 |
| | |
| | | package com.gk.firework.Service.ServiceImpl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gk.firework.Domain.ContractUnitDetail; |
| | | import com.gk.firework.Domain.Enterprise; |
| | | import com.gk.firework.Domain.Enum.EnterpriseSafetySupervision; |
| | | import com.gk.firework.Domain.Exception.BusinessException; |
| | | import com.gk.firework.Domain.UserInfo; |
| | | import com.gk.firework.Domain.Utils.StringUtils; |
| | | import com.gk.firework.Mapper.ContractUnitDetailMapper; |
| | | import com.gk.firework.Service.ContractUnitDetailService; |
| | | import com.gk.firework.Service.EnterpriseService; |
| | | import com.gk.firework.Service.UserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | |
| | | @Service("contractUnitDetailService") |
| | | public class ContractUnitDetailServiceImpl extends ServiceImpl<ContractUnitDetailMapper, ContractUnitDetail> implements ContractUnitDetailService { |
| | | |
| | | @Autowired |
| | | ContractUnitDetailMapper contractUnitDetailMapper; |
| | | @Autowired |
| | | UserService userService; |
| | | @Autowired |
| | | EnterpriseService enterpriseService; |
| | | |
| | | @Override |
| | | public IPage selectSupplyAndPurchaseUnitPage(Page<ContractUnitDetail> page, Map filter, UserInfo userInfo) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | UserInfo user = userService.getById(userInfo.getId()); |
| | | |
| | | { |
| | | params.put("enterprisenumber", user.getCompanynumber()); |
| | | params.put("province", user.getProvince()); |
| | | params.put("city", user.getCity()); |
| | | params.put("district", user.getArea()); |
| | | params.put("street", user.getTown()); |
| | | params.put("committee", user.getCommunity()); |
| | | } |
| | | |
| | | { |
| | | params.put("unitname", filter.get("unitname")); |
| | | params.put("filterProvince", filter.get("province")); |
| | | params.put("filterCity", filter.get("city")); |
| | | params.put("filterDistrict", filter.get("district")); |
| | | params.put("filterStreet", filter.get("street")); |
| | | params.put("filterCommittee", filter.get("committee")); |
| | | } |
| | | List<ContractUnitDetail> data = contractUnitDetailMapper.selectPages(page, params); |
| | | return page.setRecords(data); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 新增购货|购货 |
| | | * @date 2021/5/26 9:58 |
| | | */ |
| | | @Override |
| | | public void addSupplyAndPurchaseUnit(ContractUnitDetail contractUnitDetail, UserInfo userInfo) { |
| | | UserInfo user = userService.getById(userInfo.getId()); |
| | | if (user.getCompanynumber() == null) { |
| | | throw new BusinessException("没有新建权限"); |
| | | } |
| | | |
| | | Enterprise enterprise = enterpriseService.getById(user.getCompanyid()); |
| | | if (EnterpriseSafetySupervision.PRODUCE.getMsg().equals(enterprise.getSafetysupervision())) { |
| | | //生产单位->供货单位 |
| | | contractUnitDetail.setType(1); |
| | | }else{ |
| | | //购买单位 |
| | | contractUnitDetail.setType(0); |
| | | } |
| | | contractUnitDetail.setCreateby(userInfo.getId()); |
| | | contractUnitDetail.setCreatebyname(userInfo.getUsername()); |
| | | contractUnitDetail.setEnterprisenumber(user.getCompanynumber()); |
| | | contractUnitDetail.setCreatetime(new Date()); |
| | | contractUnitDetail.setValidflag(true); |
| | | this.save(contractUnitDetail); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 修改购货|购货 |
| | | * @date 2021/5/26 9:58 |
| | | */ |
| | | @Override |
| | | public void modSupplyAndPurchaseUnit(ContractUnitDetail contractUnitDetail, UserInfo userInfo) { |
| | | contractUnitDetail.setUpdateby(userInfo.getId()); |
| | | contractUnitDetail.setUpdatebyname(userInfo.getUsername()); |
| | | contractUnitDetail.setUpdatetime(new Date()); |
| | | this.updateById(contractUnitDetail); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 删除购货|购货 |
| | | * @date 2021/5/26 9:58 |
| | | */ |
| | | @Override |
| | | public void delSupplyAndPurchaseUnit(Long id, UserInfo user) { |
| | | LambdaUpdateWrapper<ContractUnitDetail> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.set(ContractUnitDetail::getValidflag, false) |
| | | .eq(ContractUnitDetail::getId, id) |
| | | .eq(ContractUnitDetail::getValidflag, true); |
| | | this.update(updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void checkAdd(ContractUnitDetail contractUnitDetail) { |
| | | |
| | | if (StringUtils.isBlank(contractUnitDetail.getUnitname())) { |
| | | throw new BusinessException("单位名称不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(contractUnitDetail.getUnitaddress())) { |
| | | throw new BusinessException("单位地址不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(contractUnitDetail.getRepresentative())) { |
| | | throw new BusinessException("法定代表人不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(contractUnitDetail.getRepresentativephone())) { |
| | | throw new BusinessException("法定代表人联系电话不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(contractUnitDetail.getRepresentativeemail())) { |
| | | throw new BusinessException("法定代表人电子邮箱不能为空"); |
| | | |
| | | } |
| | | if (StringUtils.isBlank(contractUnitDetail.getBank())) { |
| | | throw new BusinessException("开户银行不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(contractUnitDetail.getLicensenumber())) { |
| | | throw new BusinessException("许可证编号不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(contractUnitDetail.getZipcode())) { |
| | | throw new BusinessException("邮政编码不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(contractUnitDetail.getAgent())) { |
| | | throw new BusinessException("委托代理人不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(contractUnitDetail.getAgentphone())) { |
| | | throw new BusinessException("委托代理人联系电话不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(contractUnitDetail.getAgentemail())) { |
| | | throw new BusinessException("委托代理人电子邮箱不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(contractUnitDetail.getAccount())) { |
| | | throw new BusinessException("账户不能为空"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |