|
|
@@ -5,6 +5,7 @@ import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -31,6 +32,7 @@ import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.dao.AdminMapper;
|
|
|
import com.goafanti.common.dao.NoticeMapper;
|
|
|
import com.goafanti.common.dao.OrganizationContactBookMapper;
|
|
|
+import com.goafanti.common.dao.OrganizationManagementMapper;
|
|
|
import com.goafanti.common.dao.TDunLogMapper;
|
|
|
import com.goafanti.common.dao.TOrderBackMapper;
|
|
|
import com.goafanti.common.dao.TOrderDunMapper;
|
|
|
@@ -98,6 +100,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
@Autowired
|
|
|
private OrganizationContactBookMapper organizationContactBookMapper;
|
|
|
@Autowired
|
|
|
+ private OrganizationManagementMapper organizationManagementMapper ;
|
|
|
+ @Autowired
|
|
|
private JDBCIdGenerator idGenerator;
|
|
|
@Autowired
|
|
|
private AdminMapper adminMapper;
|
|
|
@@ -216,7 +220,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
if (StringUtils.isBlank(t.getOrderDep())) {
|
|
|
t.setOrderDep(adminMapper.selectByPrimaryKey(TokenManager.getAdminId()).getDepartmentId());
|
|
|
}
|
|
|
- if (isSubmit==1) {//订单
|
|
|
+ if (isSubmit==1) {//订单提交
|
|
|
t.setOrderStatus(OrderNewState.QDDS.getCode());
|
|
|
t.setProcessStatus(ProcessStatus.YPYXGLY.getCode());
|
|
|
if (t2.getApproval()==ApprovalNewState.BH.getCode()){
|
|
|
@@ -224,7 +228,10 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
}
|
|
|
//生成流转
|
|
|
addOrderLog(t.getOrderNo(),OrderLogProcess.TJ.getCode());
|
|
|
-
|
|
|
+ if (StringUtils.isBlank(t2.getContractNo())) {
|
|
|
+ //没有合同编号则生成
|
|
|
+ createContractNo(t);
|
|
|
+ }
|
|
|
}
|
|
|
if (t2.getApproval()==ApprovalNewState.BH.getCode()||
|
|
|
t2.getOrderStatus()==OrderNewState.QDSHJJ.getCode()||
|
|
|
@@ -232,11 +239,72 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
t.setCreateTime(new Date());
|
|
|
tOrderBackMapper.updateByOrderNoAndBackStatus(t.getOrderNo());
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
return tOrderNewMapper.updateByPrimaryKeySelective(t);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ private void createContractNo(TOrderNew t) {
|
|
|
+ //根据订单部门或许合同编号前缀
|
|
|
+ Map<String, Object> mp;
|
|
|
+ mp=organizationManagementMapper.getDepMaxNo(t.getOrderDep());
|
|
|
+ //获取日期年份
|
|
|
+ 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) {
|
|
|
+ t.setContractNo(""+mp.get("abbreviation")+"-"+y+"0001");
|
|
|
+ }else {
|
|
|
+ int ty=Integer.parseInt(s.substring(s.indexOf("-")+1, s.length()-4));
|
|
|
+ int no=Integer.parseInt(s.substring(s.length()-4, s.length()));
|
|
|
+ no++;
|
|
|
+ //得出字符串
|
|
|
+ sno = countNo(mp.get("abbreviation"), sno, ty, no);
|
|
|
+ //迭代得出最后编码
|
|
|
+ sno=iterationNo(sno,mp.get("abbreviation"),ty,no);
|
|
|
+ //年份小于等于则获取最大值加1,大于则获取最新年份
|
|
|
+ if (y<=ty) {
|
|
|
+ t.setContractNo(sno);
|
|
|
+ }else {
|
|
|
+ t.setContractNo(""+mp.get("abbreviation")+"-"+y+"0001");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private String iterationNo(String sno ,Object mp, int ty, int no) {
|
|
|
+ if (tOrderNewMapper.checkContractNo(sno)>0) {
|
|
|
+ int i=Integer.parseInt(sno.substring(sno.indexOf("-")+2, sno.length()-4));
|
|
|
+ sno=countNo(mp, sno, ty, i);
|
|
|
+ iterationNo(sno,mp,ty,i);
|
|
|
+ }
|
|
|
+ return sno;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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) {
|
|
|
+ sno=object+"-"+ty+"00"+no;
|
|
|
+ } else if (no>100&&no<1000) {
|
|
|
+ sno=object+"-"+ty+"0"+no;
|
|
|
+ } else if(no>1000){
|
|
|
+ sno=object+"-"+ty+no;
|
|
|
+ }
|
|
|
+ return sno;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public void addOrderLog(String orderNo, Integer code) {
|
|
|
TOrderLog tl=new TOrderLog();
|
|
|
tl.setOrderNo(orderNo);
|