package com.idea.oa.apply.service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.idea.oa.apply.mapper.ApplyPaymentSettleExtendMapper; import com.idea.oa.apply.mapper.ApplyPaymentSettleMapper; import com.idea.oa.apply.model.ApplyPaymentSettle; import com.idea.oa.apply.model.ApplyPaymentSettleExample; import com.idea.oa.apply.model.inout.ApplyPaymentSettleIn; import com.idea.oa.apply.util.constant.RedisToUse; import com.rockstar.common.base.BaseService; import com.rockstar.common.support.Convert; import com.rockstar.frame.model.extend.DateTrans; import com.rockstar.frame.model.extend.Tablepar; import com.rockstar.util.UUIDUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; @Service public class ApplyPaymentSettleService implements BaseService { //文件mapper @Autowired private ApplyPaymentSettleMapper modelMapper; @Autowired private ApplyPaymentSettleExtendMapper ApplyPaymentSettleExtendMapper; /** * 分页查询 * * @return */ public PageInfo list(Tablepar tablepar, ApplyPaymentSettle model, DateTrans dt) { PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize()); List list = null;//modelMapper.selectByExample(getCondition(model,dt)); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } public Object listAll(ApplyPaymentSettle model, DateTrans dt) { List list = null;//modelMapper.selectByExample(getCondition(model,dt)); return list; } @Override public int deleteByPrimaryKey(String ids) { List lista = Convert.toListStrArray(ids); ApplyPaymentSettleExample example = new ApplyPaymentSettleExample(); example.createCriteria().andIdIn(lista); return modelMapper.deleteByExample(example); } @Override public ApplyPaymentSettle selectByPrimaryKey(String id) { return modelMapper.selectByPrimaryKey(id); } @Override public int updateByPrimaryKeySelective(ApplyPaymentSettle record) { return modelMapper.updateByPrimaryKeySelective(record); } @Override public int updateByExampleSelective(ApplyPaymentSettle record, ApplyPaymentSettleExample example) { return modelMapper.updateByExampleSelective(record, example); } @Override public int updateByExample(ApplyPaymentSettle record, ApplyPaymentSettleExample example) { return modelMapper.updateByExample(record, example); } @Override public List selectByExample(ApplyPaymentSettleExample example) { return modelMapper.selectByExample(example); } @Override public long countByExample(ApplyPaymentSettleExample example) { return modelMapper.countByExample(example); } @Override public int deleteByExample(ApplyPaymentSettleExample example) { return modelMapper.deleteByExample(example); } public int insert(ApplyPaymentSettle record) { record.setId(UUIDUtils.middleUUID()); return insertWithoutId(record); } public int insertWithoutId(ApplyPaymentSettle record) { record.setCreatedAt(new Date()); return modelMapper.insert(record); } @Override public int insertSelective(ApplyPaymentSettle record) { record.setId(UUIDUtils.middleUUID()); record.setCreatedAt(new Date()); return modelMapper.insertSelective(record); } public ApplyPaymentSettleIn getInfoByFlowMainId(String flowMainId) { return ApplyPaymentSettleExtendMapper.getInfoByFlowMainId(flowMainId); } public ApplyPaymentSettleIn getInfoByFlowMainPushId(String flowMainPushId) { return ApplyPaymentSettleExtendMapper.getInfoByFlowMainPushId(flowMainPushId); } public Map getUserInfoByUserId(String userId) { Map userInfoByUserId = ApplyPaymentSettleExtendMapper.getUserInfoByUserId(userId); return userInfoByUserId; } // public static void main(String[] args) { // System.out.println(new ApplyPaymentSettleService().getMaxNum()); // } /** * 付款记录编号 : 付款领用单20240401-002 * @return */ public String getMaxNum(){ String maxnum = null; try { int c=0; while ("#".equals(RedisToUse.pmnumber)){ try { c++; Thread.sleep(100);//等待毫秒 } catch (InterruptedException e) { throw new RuntimeException(e); } if (c>=1000){ break; } } maxnum = RedisToUse.pmnumber; RedisToUse.pmnumber="#"; if (maxnum==null){ maxnum = ApplyPaymentSettleExtendMapper.selectMaxNum(); } SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String topName = "付款领用单"+sdf.format(new Date())+"-"; // 20221111-04 if (StringUtils.isEmpty(maxnum)) { maxnum = topName+"001"; }else { String substring = maxnum.substring(0, topName.length()); if (topName.equals(substring)){ maxnum= RedisToUse.addNumber(topName, maxnum); }else{ maxnum = topName+"001"; } } } finally { RedisToUse.pmnumber=maxnum; } return maxnum; } }