Commit 2c12ba63 by hzc

调整基础数据id的获取

parent ea41565f
...@@ -29,4 +29,6 @@ public interface IndicatorsDefAuditMapper extends BaseMapper<BaseIndDefAudit> { ...@@ -29,4 +29,6 @@ public interface IndicatorsDefAuditMapper extends BaseMapper<BaseIndDefAudit> {
* @Author hzc * @Author hzc
**/ **/
List<BaseIndDefAudit> selectByCatalogIdAndIndName(@Param("catalogId") Integer catalogId, @Param("indName") String indName); List<BaseIndDefAudit> selectByCatalogIdAndIndName(@Param("catalogId") Integer catalogId, @Param("indName") String indName);
String getMaxIndId(@Param("code")String code,@Param("length")int length);
} }
...@@ -7,6 +7,7 @@ import java.util.List; ...@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.keymobile.indicators.model.entity.indicators.IndicatorsRel; import com.keymobile.indicators.model.entity.indicators.IndicatorsRel;
import com.keymobile.indicators.model.mapper.indmapper.IndicatorsDefAuditMapper;
import com.keymobile.indicators.model.mapper.indmapper.IndicatorsRelMapper; import com.keymobile.indicators.model.mapper.indmapper.IndicatorsRelMapper;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -26,6 +27,10 @@ public class BaseIndDefService { ...@@ -26,6 +27,10 @@ public class BaseIndDefService {
private IndicatorsRelService indRelService; private IndicatorsRelService indRelService;
@Autowired @Autowired
private DriveIndDefService driveIndDefService; private DriveIndDefService driveIndDefService;
@Autowired
private IndicatorsDefAuditMapper indicatorsDefAuditMapper;
public String saveOrUpdate(BaseIndDef baseIndDef,Integer catalogId, public String saveOrUpdate(BaseIndDef baseIndDef,Integer catalogId,
String catalogIdPath,String user,String isUpdate,String code) String catalogIdPath,String user,String isUpdate,String code)
throws Exception{ throws Exception{
...@@ -144,6 +149,13 @@ public class BaseIndDefService { ...@@ -144,6 +149,13 @@ public class BaseIndDefService {
return "id的编码不能大于等于id的长度"; return "id的编码不能大于等于id的长度";
} }
String maxId = baseIndDefMapper.getMaxIndId(code+"%", length); String maxId = baseIndDefMapper.getMaxIndId(code+"%", length);
String auditId = indicatorsDefAuditMapper.getMaxIndId(code+"%", length);
if (Integer.parseInt(auditId)>Integer.parseInt(maxId)){
maxId = auditId;
}
if(StringUtils.isBlank(maxId)) { if(StringUtils.isBlank(maxId)) {
String addZero = ""; String addZero = "";
for(int i=0;i<(length-code.length()-1);i++) { for(int i=0;i<(length-code.length()-1);i++) {
...@@ -151,6 +163,8 @@ public class BaseIndDefService { ...@@ -151,6 +163,8 @@ public class BaseIndDefService {
} }
maxId = code+addZero+"1"; maxId = code+addZero+"1";
} }
return maxId; return maxId;
} }
......
...@@ -63,7 +63,6 @@ public class IndicatorsDefAuditService { ...@@ -63,7 +63,6 @@ public class IndicatorsDefAuditService {
baseIndDefAudit.setUpdateTime(date); baseIndDefAudit.setUpdateTime(date);
baseIndDefAudit.setUpdater(currentUser); baseIndDefAudit.setUpdater(currentUser);
baseIndDefAudit.setCreater(currentUser); baseIndDefAudit.setCreater(currentUser);
indicatorsDefAuditMapper.insert(baseIndDefAudit); indicatorsDefAuditMapper.insert(baseIndDefAudit);
log.info("{}提交了申请,{}",currentUser,baseIndDefAudit); log.info("{}提交了申请,{}",currentUser,baseIndDefAudit);
return Result.genOkResult(); return Result.genOkResult();
......
...@@ -34,5 +34,9 @@ ...@@ -34,5 +34,9 @@
select * from base_ind_def_audit select * from base_ind_def_audit
where status != 4 and ind_name=#{indName} and catalog_id = #{catalogId} where status != 4 and ind_name=#{indName} and catalog_id = #{catalogId}
</select> </select>
<select id="getMaxIndId" resultType="java.lang.String">
select (max(CAST(ind_id as SIGNED INTEGER))+1) as maxId
from base_ind_def
where ind_id like #{code} and LENGTH(ind_id)=#{length}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment