123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- 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<ApplyPaymentSettle, ApplyPaymentSettleExample> {
- //文件mapper
- @Autowired
- private ApplyPaymentSettleMapper modelMapper;
- @Autowired
- private ApplyPaymentSettleExtendMapper ApplyPaymentSettleExtendMapper;
- /**
- * 分页查询
- *
- * @return
- */
- public PageInfo<ApplyPaymentSettle> list(Tablepar tablepar, ApplyPaymentSettle model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<ApplyPaymentSettle> list = null;//modelMapper.selectByExample(getCondition(model,dt));
- PageInfo<ApplyPaymentSettle> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- public Object listAll(ApplyPaymentSettle model, DateTrans dt) {
- List<ApplyPaymentSettle> list = null;//modelMapper.selectByExample(getCondition(model,dt));
- return list;
- }
- @Override
- public int deleteByPrimaryKey(String ids) {
- List<String> 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<ApplyPaymentSettle> 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<String, Object> getUserInfoByUserId(String userId) {
- Map<String, Object> 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;
- }
- }
|