|
|
@@ -248,34 +248,34 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
|
|
|
private void createContractNo(TOrderNew t) {
|
|
|
//根据订单部门或许合同编号前缀
|
|
|
- Map<String, Object> mp;
|
|
|
- mp=organizationManagementMapper.getDepMaxNo(t.getOrderDep());
|
|
|
+ OrganizationManagement dep=organizationManagementMapper.selectByPrimaryKey(t.getOrderDep());
|
|
|
+ if (dep==null||StringUtils.isBlank(dep.getAbbreviation())) {
|
|
|
+ throw new BusinessException(new Error( "该部门缩写不存在","该部门缩写不存在"));
|
|
|
+ }
|
|
|
+ //根据前缀查询最大编号
|
|
|
+ String max=organizationManagementMapper.getMaxAbbreviation(dep.getAbbreviation());
|
|
|
//获取日期年份
|
|
|
Calendar c=Calendar.getInstance();
|
|
|
int y=c.getWeekYear();
|
|
|
- String s=null;
|
|
|
- if(mp!=null)s=(String) mp.get("maxNo");
|
|
|
- if (mp==null) {
|
|
|
- throw new BusinessException(new Error( "该部门缩写不存在","该部门缩写不存在"));
|
|
|
- }
|
|
|
+
|
|
|
String sno=null;
|
|
|
- if (StringUtils.isBlank(s)||s.length()<13) {
|
|
|
- String cn=""+mp.get("abbreviation")+"-"+y+"0001";
|
|
|
- cn=iterationNo(cn,mp.get("abbreviation"),y,1);
|
|
|
+ if (StringUtils.isBlank(max)||max.length()<13) {
|
|
|
+ String cn=""+dep.getAbbreviation()+"-"+y+"0001";
|
|
|
+ cn=iterationNo(cn,dep.getAbbreviation(),y,1);
|
|
|
t.setContractNo(cn);
|
|
|
}else {
|
|
|
- int ty=Integer.parseInt(s.substring(s.indexOf("-")+1, s.length()-4));
|
|
|
- int no=Integer.parseInt(s.substring(s.length()-4, s.length()));
|
|
|
+ int ty=Integer.parseInt(max.substring(max.indexOf("-")+1, max.length()-4));
|
|
|
+ int no=Integer.parseInt(max.substring(max.length()-4, max.length()));
|
|
|
no++;
|
|
|
//得出字符串
|
|
|
- sno = countNo(mp.get("abbreviation"), sno, ty, no);
|
|
|
+ sno = countNo(dep.getAbbreviation(), sno, ty, no);
|
|
|
//迭代得出最后编码
|
|
|
- sno=iterationNo(sno,mp.get("abbreviation"),ty,no);
|
|
|
+ sno=iterationNo(sno,dep.getAbbreviation(),ty,no);
|
|
|
//年份小于等于则获取最大值加1,大于则获取最新年份
|
|
|
if (y<=ty) {
|
|
|
t.setContractNo(sno);
|
|
|
}else {
|
|
|
- t.setContractNo(""+mp.get("abbreviation")+"-"+y+"0001");
|
|
|
+ t.setContractNo(""+dep.getAbbreviation()+"-"+y+"0001");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -296,9 +296,9 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
private String countNo(Object object, String sno, int ty, int no) {
|
|
|
if (no>0&&no<10) {
|
|
|
sno=object+"-"+ty+"000"+no;
|
|
|
- }else if (no>10&&no<100) {
|
|
|
+ }else if (no>9&&no<100) {
|
|
|
sno=object+"-"+ty+"00"+no;
|
|
|
- } else if (no>100&&no<1000) {
|
|
|
+ } else if (no>99&&no<1000) {
|
|
|
sno=object+"-"+ty+"0"+no;
|
|
|
} else if(no>1000){
|
|
|
sno=object+"-"+ty+no;
|