物资厂家;新增修改接口名称唯一性判断

This commit is contained in:
mashuai 2024-08-16 10:46:55 +08:00
parent e53e7e09d0
commit f079c81cd8
18 changed files with 122 additions and 39 deletions

View File

@ -49,6 +49,9 @@ public class BmAgreement extends BaseEntity implements Serializable {
@ApiModelProperty(value="工程id") @ApiModelProperty(value="工程id")
private Integer project; private Integer project;
@ApiModelProperty(value="往来单位id")
private Integer customer;
@ApiModelProperty(value="开始时间") @ApiModelProperty(value="开始时间")
@Excel(name = "开始日期") @Excel(name = "开始日期")
private String startTime; private String startTime;

View File

@ -63,8 +63,8 @@ public class BmAgreementController extends BaseController {
@PostMapping(value = "/add") @PostMapping(value = "/add")
@RequiresPermissions("base:agreement:add") @RequiresPermissions("base:agreement:add")
public ResultBean<Boolean> add(@RequestBody BmAgreement bmAgreement) { public ResultBean<Boolean> add(@RequestBody BmAgreement bmAgreement) {
int result = this.bmAgreementService.insertSelective(bmAgreement); this.bmAgreementService.insertSelective(bmAgreement);
return result > 0 ? ResultBean.success(true) : ResultBean.error("新增失败"); return ResultBean.success(true);
} }
/** /**

View File

@ -99,7 +99,7 @@ public class BmCustomerController extends BaseController {
public AjaxResult add(@Validated @RequestBody BmCustomer customer) { public AjaxResult add(@Validated @RequestBody BmCustomer customer) {
try { try {
// customer.setCreateBy(SecurityUtils.getUsername()); // customer.setCreateBy(SecurityUtils.getUsername());
return toAjax(customerService.insertCustomer(customer)); return customerService.insertCustomer(customer);
} catch (Exception e) { } catch (Exception e) {
log.error(e.toString(), e); log.error(e.toString(), e);
} }
@ -115,7 +115,7 @@ public class BmCustomerController extends BaseController {
public AjaxResult edit(@Validated @RequestBody BmCustomer customer) { public AjaxResult edit(@Validated @RequestBody BmCustomer customer) {
try { try {
// customer.setUpdateBy(SecurityUtils.getUsername()); // customer.setUpdateBy(SecurityUtils.getUsername());
return toAjax(customerService.updateCustomer(customer)); return customerService.updateCustomer(customer);
} catch (Exception e) { } catch (Exception e) {
log.error(e.toString(), e); log.error(e.toString(), e);
} }

View File

@ -70,8 +70,6 @@ public class BmSupplierController extends BaseController {
@RequiresPermissions("base:supplier:add") @RequiresPermissions("base:supplier:add")
@PostMapping("/add") @PostMapping("/add")
public ResultBean add(@RequestBody BmSupplier bmSupplier) { public ResultBean add(@RequestBody BmSupplier bmSupplier) {
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
bmSupplier.setCompanyId(Integer.parseInt(companyId.toString()));
return bmSupplierService.insert(bmSupplier); return bmSupplierService.insert(bmSupplier);
} }
@ -83,7 +81,7 @@ public class BmSupplierController extends BaseController {
*/ */
@ApiOperation(value = "编辑供应商管理数据") @ApiOperation(value = "编辑供应商管理数据")
@RequiresPermissions("base:supplier:edit") @RequiresPermissions("base:supplier:edit")
@PutMapping("/update") @PostMapping("/update")
public ResultBean edit(@RequestBody BmSupplier bmSupplier) { public ResultBean edit(@RequestBody BmSupplier bmSupplier) {
return bmSupplierService.update(bmSupplier); return bmSupplierService.update(bmSupplier);
} }
@ -91,14 +89,14 @@ public class BmSupplierController extends BaseController {
/** /**
* 单个或批量删除数据 * 单个或批量删除数据
* *
* @param ids 主键 * @param id 主键
* @return 删除是否成功 * @return 删除是否成功
*/ */
@ApiOperation(value = "删除供应商管理数据") @ApiOperation(value = "删除供应商管理数据")
@RequiresPermissions("base:supplier:remove") @RequiresPermissions("base:supplier:remove")
@PostMapping(value = "/{ids}") @DeleteMapping(value = "/{id}")
public ResultBean<Boolean> deleteById(@PathVariable("ids") Long[] ids) { public ResultBean<Boolean> deleteById(@PathVariable("id") Integer id) {
int result = bmSupplierService.deleteById(ids); int result = bmSupplierService.deleteById(id);
return result > 0 ? ResultBean.success(true) : ResultBean.error(0, "删除失败"); return result > 0 ? ResultBean.success(true) : ResultBean.error(0, "删除失败");
} }

View File

@ -2,6 +2,7 @@ package com.bonus.base.mapper;
import com.bonus.base.api.domain.BmAgreement; import com.bonus.base.api.domain.BmAgreement;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -62,4 +63,11 @@ public interface BmAgreementMapper {
*/ */
int updateByPrimaryKey(BmAgreement record); int updateByPrimaryKey(BmAgreement record);
/**
* 根据客户id和项目id查询协议
* @param customer
* @param project
* @return
*/
BmAgreement select(@Param(value ="customer") Integer customer, @Param(value ="project") Integer project);
} }

View File

@ -64,4 +64,10 @@ public interface BmCustomerMapper {
*/ */
List<SysDeptTree> selectDeptTree(SysDeptTree sysDept); List<SysDeptTree> selectDeptTree(SysDeptTree sysDept);
/**
* 根据名称查询
* @param name
* @return
*/
BmCustomer selectCustomerByName(String name);
} }

View File

@ -63,4 +63,11 @@ public interface BmCustomerTypeMapper {
List<BmCustomerType> selectAll(BmCustomerType bmCustomerType); List<BmCustomerType> selectAll(BmCustomerType bmCustomerType);
int updateById(@Param("updated") BmCustomerType updated, @Param("id") Integer id); int updateById(@Param("updated") BmCustomerType updated, @Param("id") Integer id);
/**
* 根据名称查询
* @param name
* @return
*/
BmCustomerType selectCustomerByName(String name);
} }

View File

@ -50,10 +50,10 @@ public interface BmSupplierMapper {
/** /**
* 通过主键删除数据 * 通过主键删除数据
* *
* @param ids 主键 * @param id 主键
* @return 影响行数 * @return 影响行数
*/ */
int deleteById(@Param("array") Long[] ids); int deleteById(Integer id);
/** /**
* 通过名称查询单条数据 * 通过名称查询单条数据

View File

@ -1,5 +1,6 @@
package com.bonus.base.service; package com.bonus.base.service;
import com.bonus.common.core.domain.ResultBean;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.bonus.base.api.domain.BmAgreement; import com.bonus.base.api.domain.BmAgreement;
@ -44,8 +45,14 @@ public class BmAgreementService{
} }
public int insertSelective(BmAgreement record) { public ResultBean insertSelective(BmAgreement record) {
return bmAgreementMapper.insertSelective(record); //根据单位和工程id去表中判断去重
BmAgreement bmAgreement = bmAgreementMapper.select(record.getCustomer(), record.getProject());
if (bmAgreement != null) {
return ResultBean.error("该租赁单位已关联该租赁工程,请修改后重新提交!");
}
int result = bmAgreementMapper.insertSelective(record);
return result > 0 ? ResultBean.success("新建成功") : ResultBean.error("新建失败");
} }
@ -54,8 +61,14 @@ public class BmAgreementService{
} }
public int updateByPrimaryKeySelective(BmAgreement record) { public ResultBean updateByPrimaryKeySelective(BmAgreement record) {
return bmAgreementMapper.updateByPrimaryKeySelective(record); //根据单位和工程id去表中判断去重
BmAgreement bmAgreement = bmAgreementMapper.select(record.getCustomer(), record.getProject());
if (bmAgreement != null && !bmAgreement.getId().equals(record.getId())) {
return ResultBean.error("该租赁单位已关联该租赁工程,请修改后重新提交!");
}
int result = bmAgreementMapper.updateByPrimaryKeySelective(record);
return result > 0 ? ResultBean.success("修改成功") : ResultBean.error("修改失败");
} }

View File

@ -1,5 +1,6 @@
package com.bonus.base.service; package com.bonus.base.service;
import com.bonus.common.core.domain.ResultBean;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -40,8 +41,14 @@ public class BmCustomerTypeService{
} }
public int insertSelective(BmCustomerType record) { public ResultBean insertSelective(BmCustomerType record) {
return bmCustomerTypeMapper.insertSelective(record); //根据名称查询去重
BmCustomerType bmCustomerType = bmCustomerTypeMapper.selectCustomerByName(record.getName());
if (bmCustomerType != null) {
return ResultBean.error("单位类型名称重复");
}
int result = bmCustomerTypeMapper.insertSelective(record);
return result > 0 ? ResultBean.success("添加成功") : ResultBean.error("添加失败");
} }
@ -50,8 +57,14 @@ public class BmCustomerTypeService{
} }
public int updateByPrimaryKeySelective(BmCustomerType record) { public ResultBean updateByPrimaryKeySelective(BmCustomerType record) {
return bmCustomerTypeMapper.updateByPrimaryKeySelective(record); //根据名称查询去重
BmCustomerType bmCustomerType = bmCustomerTypeMapper.selectCustomerByName(record.getName());
if (bmCustomerType != null && !bmCustomerType.getId().equals(record.getId())) {
return ResultBean.error("单位类型名称重复");
}
int result = bmCustomerTypeMapper.updateByPrimaryKeySelective(record);
return result > 0 ? ResultBean.success("添加成功") : ResultBean.error("添加失败");
} }

View File

@ -48,9 +48,9 @@ public interface BmSupplierService {
/** /**
* 通过主键删除数据 * 通过主键删除数据
* *
* @param ids 主键 * @param id 主键
* @return 是否成功 * @return 是否成功
*/ */
int deleteById(Long[] ids); int deleteById(Integer id);
} }

View File

@ -3,6 +3,7 @@ package com.bonus.base.service;
import com.bonus.base.api.domain.BmCustomer; import com.bonus.base.api.domain.BmCustomer;
import com.bonus.base.api.domain.SysDeptTree; import com.bonus.base.api.domain.SysDeptTree;
import com.bonus.base.api.domain.TreeSelect; import com.bonus.base.api.domain.TreeSelect;
import com.bonus.common.core.web.domain.AjaxResult;
import java.util.List; import java.util.List;
@ -35,7 +36,7 @@ public interface IBmCustomerService
* @param customer 往来单位信息 * @param customer 往来单位信息
* @return 结果 * @return 结果
*/ */
public int insertCustomer(BmCustomer customer); public AjaxResult insertCustomer(BmCustomer customer);
/** /**
* 修改往来单位 * 修改往来单位
@ -43,7 +44,7 @@ public interface IBmCustomerService
* @param customer 往来单位信息 * @param customer 往来单位信息
* @return 结果 * @return 结果
*/ */
public int updateCustomer(BmCustomer customer); public AjaxResult updateCustomer(BmCustomer customer);
/** /**
* 删除往来单位信息 * 删除往来单位信息

View File

@ -6,6 +6,7 @@ import com.bonus.base.api.domain.TreeSelect;
import com.bonus.base.mapper.BmCustomerMapper; import com.bonus.base.mapper.BmCustomerMapper;
import com.bonus.base.service.IBmCustomerService; import com.bonus.base.service.IBmCustomerService;
import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -37,13 +38,25 @@ public class BmCustomerServiceImpl implements IBmCustomerService
} }
@Override @Override
public int insertCustomer(BmCustomer customer) { public AjaxResult insertCustomer(BmCustomer customer) {
return bmCustomerMapper.insertCustomer(customer); //根据单位名称查询去重
BmCustomer bmCustomer = bmCustomerMapper.selectCustomerByName(customer.getName());
if (bmCustomer != null) {
return AjaxResult.warn("单位名称已存在");
}
int result = bmCustomerMapper.insertCustomer(customer);
return result > 0 ? AjaxResult.success("添加成功") : AjaxResult.error("添加失败");
} }
@Override @Override
public int updateCustomer(BmCustomer customer) { public AjaxResult updateCustomer(BmCustomer customer) {
return bmCustomerMapper.updateCustomer(customer); //根据单位名称查询去重
BmCustomer bmCustomer = bmCustomerMapper.selectCustomerByName(customer.getName());
if (bmCustomer != null && !bmCustomer.getId().equals(customer.getId())) {
return AjaxResult.warn("单位名称已存在");
}
int result = bmCustomerMapper.updateCustomer(customer);
return result > 0 ? AjaxResult.success("添加成功") : AjaxResult.error("添加失败");
} }
@Override @Override

View File

@ -79,11 +79,11 @@ public class BmSupplierServiceImpl implements BmSupplierService {
/** /**
* 通过主键删除数据 * 通过主键删除数据
* *
* @param ids 主键 * @param id 主键
* @return 是否成功 * @return 是否成功
*/ */
@Override @Override
public int deleteById(Long[] ids) { public int deleteById(Integer id) {
return bmSupplierDao.deleteById(ids); return bmSupplierDao.deleteById(id);
} }
} }

View File

@ -75,6 +75,15 @@
</if> </if>
order by ba.sign_date desc order by ba.sign_date desc
</select> </select>
<select id="select" resultType="com.bonus.base.api.domain.BmAgreement">
select
<include refid="Base_Column_List" />
from bm_agreement ba
left join bm_project bp on ba.project = bp.id
left join bm_customer bc on ba.customer = bc.id
where ba.customer = #{customer}
and ba.project = #{project}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--@mbg.generated--> <!--@mbg.generated-->

View File

@ -58,6 +58,14 @@
from sys_dept d from sys_dept d
where d.del_flag = '0' and d.status = '0' where d.del_flag = '0' and d.status = '0'
</select> </select>
<select id="selectCustomerByName" resultType="com.bonus.base.api.domain.BmCustomer">
select
<include refid="Base_Column_List" />
from bm_customer
left join bm_customer_type bct on bct.id = bc.type_id
left join sys_dept sd on sd.dept_id = bc.company_id
where bc.is_active = '1' and bc.name = #{name}
</select>
<delete id="deleteCustomerById" parameterType="java.lang.Integer"> <delete id="deleteCustomerById" parameterType="java.lang.Integer">
delete from bm_customer delete from bm_customer

View File

@ -103,6 +103,13 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="selectCustomerByName" resultType="com.bonus.base.api.domain.BmCustomerType">
select
<include refid="Base_Column_List"/>
from bm_customer_type
where IS_ACTIVE = '1'
and `NAME` = #{name}
</select>
<update id="updateById"> <update id="updateById">
<!--@mbg.generated--> <!--@mbg.generated-->

View File

@ -31,7 +31,7 @@
<select id="queryAllByLimit" resultMap="BmSupplierMap"> <select id="queryAllByLimit" resultMap="BmSupplierMap">
<include refid="selectMaSupplierInfoVo"/> <include refid="selectMaSupplierInfoVo"/>
where where
1 = 1 and is_active = 1 is_active = '1'
<if test="companyId != null"> <if test="companyId != null">
AND company_id = #{companyId} AND company_id = #{companyId}
</if> </if>
@ -130,10 +130,7 @@
<!--通过主键删除--> <!--通过主键删除-->
<delete id="deleteById"> <delete id="deleteById">
update bm_supplier set is_active = 0 where id in update bm_supplier set is_active = 0 where id = #{id}
<foreach item="supplierId" collection="array" open="(" separator="," close=")">
#{supplierId}
</foreach>
</delete> </delete>
</mapper> </mapper>