合同管理接口开发
This commit is contained in:
		
							parent
							
								
									76c38b8620
								
							
						
					
					
						commit
						6a0c0ba5cd
					
				| 
						 | 
				
			
			@ -1,7 +1,9 @@
 | 
			
		|||
package com.bonus.material.contract.mapper;
 | 
			
		||||
 | 
			
		||||
import com.bonus.material.contract.domain.BmContract;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -17,4 +19,6 @@ public interface BmContractMapper {
 | 
			
		|||
    Integer edit(BmContract bmContract);
 | 
			
		||||
 | 
			
		||||
    Integer del(BmContract bmContract);
 | 
			
		||||
 | 
			
		||||
    String selectTaskNumByMonth(@Param("date") Date nowDate);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,8 @@ 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.core.utils.DateUtils;
 | 
			
		||||
import com.bonus.common.core.utils.StringUtils;
 | 
			
		||||
import com.bonus.common.security.utils.SecurityUtils;
 | 
			
		||||
import com.bonus.material.contract.domain.BmContract;
 | 
			
		||||
import com.bonus.material.contract.mapper.BmContractMapper;
 | 
			
		||||
| 
						 | 
				
			
			@ -10,6 +12,8 @@ import com.bonus.material.device.mapper.BmFileInfoMapper;
 | 
			
		|||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.text.SimpleDateFormat;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +36,7 @@ public class BmContractServiceImpl implements BmContractService {
 | 
			
		|||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Integer add(BmContract bmContract) {
 | 
			
		||||
        bmContract.setContractCode(getString());
 | 
			
		||||
        bmContract.setOwnerId(SecurityUtils.getLoginUser().getUserid());
 | 
			
		||||
        bmContract.setOwnerCom(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
 | 
			
		||||
        bmContract.setStatus(0);
 | 
			
		||||
| 
						 | 
				
			
			@ -84,4 +89,23 @@ public class BmContractServiceImpl implements BmContractService {
 | 
			
		|||
        }
 | 
			
		||||
        return del;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String getString() {
 | 
			
		||||
        //根据前台传过来的数据,生成需求编号
 | 
			
		||||
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
 | 
			
		||||
        Date nowDate = DateUtils.getNowDate();
 | 
			
		||||
        String format = dateFormat.format(nowDate);
 | 
			
		||||
        String taskNum = bmContractMapper.selectTaskNumByMonth(nowDate);
 | 
			
		||||
        if (StringUtils.isNotBlank(taskNum)) {
 | 
			
		||||
            // 将字符串转换为整数
 | 
			
		||||
            int num = Integer.parseInt(taskNum);
 | 
			
		||||
            // 执行加一操作
 | 
			
		||||
            num++;
 | 
			
		||||
            // 将结果转换回字符串格式,并确保结果是4位数,不足4位则在前面补0
 | 
			
		||||
            taskNum = String.format("%04d", num);
 | 
			
		||||
        } else {
 | 
			
		||||
            taskNum = "0001";
 | 
			
		||||
        }
 | 
			
		||||
        return "HT" + format + "-" + taskNum;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,4 +31,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            </if>
 | 
			
		||||
        </where>
 | 
			
		||||
    </select>
 | 
			
		||||
    <select id="selectTaskNumByMonth" resultType="java.lang.String">
 | 
			
		||||
        SELECT SUBSTRING(contract_code, - 4) as code
 | 
			
		||||
        FROM bm_contract
 | 
			
		||||
        WHERE DATE_FORMAT(create_time, '%y%m') = DATE_FORMAT(#{date}, '%y%m')
 | 
			
		||||
        ORDER BY create_time DESC LIMIT 1
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
		Loading…
	
		Reference in New Issue