合同管理接口开发
This commit is contained in:
		
							parent
							
								
									bc3f972a45
								
							
						
					
					
						commit
						0347e19cce
					
				| 
						 | 
				
			
			@ -68,4 +68,7 @@ public class MaterialConstants {
 | 
			
		|||
    /** 文件类型:退租检修图片类型 */
 | 
			
		||||
    public static final Integer LEASE_REPAIR_RECORD_TABLE_NAME = 19;
 | 
			
		||||
 | 
			
		||||
    /** 文件类型:合同照片 */
 | 
			
		||||
    public static final Integer APPENDICES_OF_CONTRACT = 20;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,66 @@
 | 
			
		|||
package com.bonus.material.contract.controller;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.convert.Convert;
 | 
			
		||||
import com.bonus.common.biz.config.ListPagingUtil;
 | 
			
		||||
import com.bonus.common.core.web.controller.BaseController;
 | 
			
		||||
import com.bonus.common.core.web.domain.AjaxResult;
 | 
			
		||||
import com.bonus.material.contract.domain.BmContract;
 | 
			
		||||
import com.bonus.material.contract.service.BmContractService;
 | 
			
		||||
import com.bonus.material.device.domain.vo.DevInfoVo;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/13 - 9:14
 | 
			
		||||
 */
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/contract")
 | 
			
		||||
@Api(value = "合同管理", tags = "合同管理")
 | 
			
		||||
public class BmContractController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private BmContractService bmContractService;
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "合同列表")
 | 
			
		||||
    @GetMapping("/list")
 | 
			
		||||
    public AjaxResult list(BmContract bmContract) {
 | 
			
		||||
        List<BmContract> list = bmContractService.list(bmContract);
 | 
			
		||||
        return AjaxResult.success(list);
 | 
			
		||||
    }
 | 
			
		||||
    @ApiOperation(value = "合同新增")
 | 
			
		||||
    @PostMapping("/add")
 | 
			
		||||
    public AjaxResult add(@RequestBody BmContract bmContract) {
 | 
			
		||||
        Integer i = bmContractService.add(bmContract);
 | 
			
		||||
        if (i > 0){
 | 
			
		||||
            return AjaxResult.success("新增成功");
 | 
			
		||||
        }else {
 | 
			
		||||
            return AjaxResult.error("新增失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    @ApiOperation(value = "合同修改")
 | 
			
		||||
    @PostMapping("/edit")
 | 
			
		||||
    public AjaxResult edit(@RequestBody BmContract bmContract) {
 | 
			
		||||
        Integer i = bmContractService.edit(bmContract);
 | 
			
		||||
        if (i > 0){
 | 
			
		||||
            return AjaxResult.success("修改成功");
 | 
			
		||||
        }else {
 | 
			
		||||
            return AjaxResult.error("修改失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    @ApiOperation(value = "合同修改")
 | 
			
		||||
    @PostMapping("/del")
 | 
			
		||||
    public AjaxResult del(@RequestBody BmContract bmContract) {
 | 
			
		||||
        Integer i = bmContractService.del(bmContract);
 | 
			
		||||
        if (i > 0){
 | 
			
		||||
            return AjaxResult.success("删除成功");
 | 
			
		||||
        }else {
 | 
			
		||||
            return AjaxResult.error("删除失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
package com.bonus.material.contract.domain;
 | 
			
		||||
 | 
			
		||||
import com.bonus.common.biz.domain.BmFileInfo;
 | 
			
		||||
import com.fasterxml.jackson.annotation.JsonFormat;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/13 - 9:17
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
public class BmContract {
 | 
			
		||||
    @ApiModelProperty(value = "id")
 | 
			
		||||
    private Integer id;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "合同编号")
 | 
			
		||||
    private String contractCode;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "合同名称")
 | 
			
		||||
    private String contractName;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "状态(0:禁止 1启用)")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "创建时间")
 | 
			
		||||
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
 | 
			
		||||
    private Date createTime;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "修改时间")
 | 
			
		||||
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
 | 
			
		||||
    private Date updateTime;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "用户id")
 | 
			
		||||
    private Long ownerId;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "用户所属公司")
 | 
			
		||||
    private Long ownerCom;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "文件附件")
 | 
			
		||||
    private List<BmFileInfo> bmFileInfoList;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
package com.bonus.material.contract.mapper;
 | 
			
		||||
 | 
			
		||||
import com.bonus.material.contract.domain.BmContract;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/13 - 9:24
 | 
			
		||||
 */
 | 
			
		||||
public interface BmContractMapper {
 | 
			
		||||
 | 
			
		||||
    List<BmContract> list(BmContract bmContract);
 | 
			
		||||
 | 
			
		||||
    Integer add(BmContract bmContract);
 | 
			
		||||
 | 
			
		||||
    Integer edit(BmContract bmContract);
 | 
			
		||||
 | 
			
		||||
    Integer del(BmContract bmContract);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
package com.bonus.material.contract.service;
 | 
			
		||||
 | 
			
		||||
import com.bonus.material.contract.domain.BmContract;
 | 
			
		||||
import com.bonus.material.device.domain.vo.DevInfoVo;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/13 - 9:16
 | 
			
		||||
 */
 | 
			
		||||
public interface BmContractService {
 | 
			
		||||
 | 
			
		||||
    List<BmContract> list(BmContract bmContract);
 | 
			
		||||
 | 
			
		||||
    Integer add(BmContract bmContract);
 | 
			
		||||
 | 
			
		||||
    Integer edit(BmContract bmContract);
 | 
			
		||||
 | 
			
		||||
    Integer del(BmContract bmContract);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,86 @@
 | 
			
		|||
package com.bonus.material.contract.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.bonus.common.biz.constant.MaterialConstants;
 | 
			
		||||
import com.bonus.common.biz.domain.BmFileInfo;
 | 
			
		||||
import com.bonus.common.security.utils.SecurityUtils;
 | 
			
		||||
import com.bonus.material.contract.domain.BmContract;
 | 
			
		||||
import com.bonus.material.contract.mapper.BmContractMapper;
 | 
			
		||||
import com.bonus.material.contract.service.BmContractService;
 | 
			
		||||
import com.bonus.material.device.mapper.BmFileInfoMapper;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author:liang.chao
 | 
			
		||||
 * @Date:2024/12/13 - 9:16
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class BmContractServiceImpl implements BmContractService {
 | 
			
		||||
    @Resource
 | 
			
		||||
    private BmContractMapper bmContractMapper;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private BmFileInfoMapper bmFileInfoMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<BmContract> list(BmContract bmContract) {
 | 
			
		||||
        return bmContractMapper.list(bmContract);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Integer add(BmContract bmContract) {
 | 
			
		||||
        bmContract.setOwnerId(SecurityUtils.getLoginUser().getUserid());
 | 
			
		||||
        bmContract.setOwnerCom(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
 | 
			
		||||
        bmContract.setStatus(0);
 | 
			
		||||
        Integer add = bmContractMapper.add(bmContract);
 | 
			
		||||
        if (add > 0) {
 | 
			
		||||
            if (bmContract.getBmFileInfoList().size() > 0) {
 | 
			
		||||
                for (BmFileInfo bmFileInfo : bmContract.getBmFileInfoList()) {
 | 
			
		||||
                    bmFileInfo.setModelId(Long.valueOf(bmContract.getId()));
 | 
			
		||||
                    bmFileInfo.setTaskType(MaterialConstants.APPENDICES_OF_CONTRACT);
 | 
			
		||||
                    // 合同照片附件
 | 
			
		||||
                    bmFileInfo.setFileType(0L);
 | 
			
		||||
                    bmFileInfo.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
 | 
			
		||||
                    bmFileInfoMapper.insertBmFileInfo(bmFileInfo);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return add;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Integer edit(BmContract bmContract) {
 | 
			
		||||
        bmContract.setOwnerId(SecurityUtils.getLoginUser().getUserid());
 | 
			
		||||
        bmContract.setOwnerCom(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
 | 
			
		||||
        Integer edit = bmContractMapper.edit(bmContract);
 | 
			
		||||
        if (edit > 0) {
 | 
			
		||||
            if (bmContract.getBmFileInfoList().size() > 0) {
 | 
			
		||||
                BmFileInfo fileInfo = new BmFileInfo();
 | 
			
		||||
                fileInfo.setModelId(Long.valueOf(bmContract.getId())).setTaskType(MaterialConstants.APPENDICES_OF_CONTRACT).setFileType(0L);
 | 
			
		||||
                bmFileInfoMapper.deleteBmFileInfo(fileInfo);
 | 
			
		||||
                for (BmFileInfo bmFileInfo : bmContract.getBmFileInfoList()) {
 | 
			
		||||
                    bmFileInfo.setModelId(Long.valueOf(bmContract.getId()));
 | 
			
		||||
                    bmFileInfo.setTaskType(MaterialConstants.APPENDICES_OF_CONTRACT);
 | 
			
		||||
                    // 合同照片附件
 | 
			
		||||
                    bmFileInfo.setFileType(0L);
 | 
			
		||||
                    bmFileInfo.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
 | 
			
		||||
                    bmFileInfoMapper.insertBmFileInfo(bmFileInfo);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return edit;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Integer del(BmContract bmContract) {
 | 
			
		||||
        Integer del = bmContractMapper.del(bmContract);
 | 
			
		||||
        if (del > 0) {
 | 
			
		||||
            BmFileInfo fileInfo = new BmFileInfo();
 | 
			
		||||
            fileInfo.setModelId(Long.valueOf(bmContract.getId())).setTaskType(MaterialConstants.APPENDICES_OF_CONTRACT).setFileType(0L);
 | 
			
		||||
            bmFileInfoMapper.deleteBmFileInfo(fileInfo);
 | 
			
		||||
        }
 | 
			
		||||
        return del;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -74,4 +74,6 @@ public interface BmFileInfoMapper {
 | 
			
		|||
    TypeInfo getTypeInfo(String deviceName);
 | 
			
		||||
 | 
			
		||||
    Integer deleteBmFileInfoByMaId(@Param("maId") Integer maId, @Param("fileType") Integer fileType);
 | 
			
		||||
 | 
			
		||||
    Integer deleteBmFileInfo(BmFileInfo fileInfo);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,33 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8" ?>
 | 
			
		||||
<!DOCTYPE mapper
 | 
			
		||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="com.bonus.material.contract.mapper.BmContractMapper">
 | 
			
		||||
    <insert id="add" useGeneratedKeys="true" keyProperty="id">
 | 
			
		||||
        insert into bm_contract(contract_code, contract_name, status, create_time, owner_id, owner_com)
 | 
			
		||||
        values(#{contractCode}, #{contractName}, #{status}, now(), #{ownerId}, #{ownerCom})
 | 
			
		||||
    </insert>
 | 
			
		||||
    <update id="edit">
 | 
			
		||||
        update bm_contract set
 | 
			
		||||
        contract_name = #{contractName},
 | 
			
		||||
        owner_id = #{ownerId},
 | 
			
		||||
        owner_com = #{ownerCom},
 | 
			
		||||
        update_time = now()
 | 
			
		||||
        where id = #{id}
 | 
			
		||||
    </update>
 | 
			
		||||
    <delete id="del">
 | 
			
		||||
        delete from bm_contract where id = #{id}
 | 
			
		||||
    </delete>
 | 
			
		||||
 | 
			
		||||
    <select id="list" resultType="com.bonus.material.contract.domain.BmContract">
 | 
			
		||||
        select id, contract_code as contractCode, contract_name as contractName, status, create_time as createTime, update_time as updateTime, owner_id as ownerId, owner_com as ownerCom from bm_contract
 | 
			
		||||
        <where>
 | 
			
		||||
            <if test="contractCode != null and contractCode != ''">
 | 
			
		||||
                and contract_code like concat('%', #{contractCode}, '%')
 | 
			
		||||
            </if>
 | 
			
		||||
            <if test="contractName != null and contractName != ''">
 | 
			
		||||
                and contract_name like concat('%', #{contractName}, '%')
 | 
			
		||||
            </if>
 | 
			
		||||
        </where>
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
| 
						 | 
				
			
			@ -121,4 +121,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
    <delete id="deleteBmFileInfoByMaId">
 | 
			
		||||
        delete from bm_file_info where model_id = #{maId} and task_type = 17 and file_type = #{fileType}
 | 
			
		||||
    </delete>
 | 
			
		||||
    <delete id="deleteBmFileInfo">
 | 
			
		||||
        delete from bm_file_info
 | 
			
		||||
        <where>
 | 
			
		||||
            and task_type = #{taskType}
 | 
			
		||||
            <if test="taskId != null "> and task_id = #{taskId}</if>
 | 
			
		||||
            <if test="modelId != null "> and model_id = #{modelId}</if>
 | 
			
		||||
            <if test="fileType != null "> and file_type = #{fileType}</if>
 | 
			
		||||
        </where>
 | 
			
		||||
    </delete>
 | 
			
		||||
</mapper>
 | 
			
		||||
		Loading…
	
		Reference in New Issue