Browse Source

卷其它出入库记录 2022年12月27日 sxm

master
[li_she] 4 years ago
parent
commit
41ca967d8d
  1. 13
      src/main/java/com/gaotao/modules/finishedProduct/service/TransdetailService.java
  2. 5
      src/main/java/com/gaotao/modules/finishedProduct/service/TransheaderService.java
  3. 8
      src/main/java/com/gaotao/modules/finishedProduct/service/impl/CRollinfoServiceImpl.java
  4. 17
      src/main/java/com/gaotao/modules/finishedProduct/service/impl/TransdetailServiceImpl.java
  5. 77
      src/main/java/com/gaotao/modules/finishedProduct/service/impl/TransheaderServiceImpl.java

13
src/main/java/com/gaotao/modules/finishedProduct/service/TransdetailService.java

@ -1,9 +1,18 @@
package com.gaotao.modules.finishedProduct.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gaotao.modules.finishedProduct.entity.Transdetail;
import com.gaotao.modules.finishedProduct.entity.Transdetailsub;
import java.util.List;
public interface TransdetailService extends IService<Transdetail> {
/**
* @author: sxm
* @description: 批量保存
* @param [transdetailList]
* @return: void
* @date: 2022/12/27 16:39
*/
void saveList(List<Transdetail> transdetailList);
}

5
src/main/java/com/gaotao/modules/finishedProduct/service/TransheaderService.java

@ -1,8 +1,11 @@
package com.gaotao.modules.finishedProduct.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gaotao.modules.finishedProduct.entity.CRollinfoEntity;
import com.gaotao.modules.finishedProduct.entity.Transheader;
import java.util.List;
public interface TransheaderService extends IService<Transheader> {
/*
@ -13,4 +16,6 @@ public interface TransheaderService extends IService<Transheader> {
* @return [java.lang.String]
**/
Transheader getTransHeader(String pickingNo);
void saveTransInfo(List<CRollinfoEntity> list,String transType);
}

8
src/main/java/com/gaotao/modules/finishedProduct/service/impl/CRollinfoServiceImpl.java

@ -507,17 +507,25 @@ public class CRollinfoServiceImpl extends ServiceImpl<CRollinfoDao, CRollinfoEnt
//添加到卷集合
cRollinfoList.add(cRollinfoEntity);
}
transheaderService.saveTransInfo(cRollinfoList,"OI");
this.saveBatch(cRollinfoList);
return cRollinfoList;
}
@Override
@Transactional
public void batchRollUpdateStatus(List<CRollinfoEntity> cRollinfoList) {
if (CollectionUtils.isEmpty(cRollinfoList)) return;
transheaderService.saveTransInfo(cRollinfoList,"OC");
// 修改卷状态
cRollinfoList.forEach(rollInfo -> {
lambdaUpdate().set(CRollinfoEntity::getStatus, rollInfo.getStatus())
.set(CRollinfoEntity::getStatusDb, rollInfo.getStatusDb())
.set(StringUtils.isNotEmpty(rollInfo.getSynchronizedflag()), CRollinfoEntity::getSynchronizedflag, rollInfo.getSynchronizedflag())
.set(CRollinfoEntity::getNeedsynchronizeflag,"N")
.eq(StringUtils.isNotEmpty(rollInfo.getSite()), CRollinfoEntity::getSite, rollInfo.getSite())
.eq(CRollinfoEntity::getRollno, rollInfo.getRollno())
.update();

17
src/main/java/com/gaotao/modules/finishedProduct/service/impl/TransdetailServiceImpl.java

@ -4,8 +4,25 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaotao.modules.finishedProduct.dao.TransdetailDao;
import com.gaotao.modules.finishedProduct.entity.Transdetail;
import com.gaotao.modules.finishedProduct.service.TransdetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List;
@Service
@Slf4j
public class TransdetailServiceImpl extends ServiceImpl<TransdetailDao, Transdetail> implements TransdetailService {
@Override
public void saveList(List<Transdetail> transDetailList) {
try{
this.saveBatch(transDetailList,1000);
}catch (UncategorizedSQLException e){
log.info("批量插入,卷信息");
} catch (Exception e){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
}
}

77
src/main/java/com/gaotao/modules/finishedProduct/service/impl/TransheaderServiceImpl.java

@ -1,17 +1,35 @@
package com.gaotao.modules.finishedProduct.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaotao.common.utils.RandomUtil;
import com.gaotao.modules.finishedProduct.dao.TransheaderDao;
import com.gaotao.modules.finishedProduct.entity.CRollinfoEntity;
import com.gaotao.modules.finishedProduct.entity.Transdetail;
import com.gaotao.modules.finishedProduct.entity.Transdetailsub;
import com.gaotao.modules.finishedProduct.entity.Transheader;
import com.gaotao.modules.finishedProduct.service.TransdetailService;
import com.gaotao.modules.finishedProduct.service.TransdetailsubService;
import com.gaotao.modules.finishedProduct.service.TransheaderService;
import com.gaotao.modules.sys.entity.SysUserEntity;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class TransheaderServiceImpl extends ServiceImpl<TransheaderDao, Transheader> implements TransheaderService {
@Autowired
private TransdetailService transdetailService;
@Autowired
private TransdetailsubService transdetailsubService;
@Override
public Transheader getTransHeader(String pickingNo) {
SysUserEntity user = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
@ -20,4 +38,63 @@ public class TransheaderServiceImpl extends ServiceImpl<TransheaderDao, Transhea
.eq(Transheader::getSite,user.getSite())
.one();
}
@Override
@Transactional
public void saveTransInfo(List<CRollinfoEntity> cRollinfoList,String tranType) {
SysUserEntity user = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
// transheader
String transHeaderNo = RandomUtil.getOrderNoByAtomic(user.getSite(), tranType);
Transheader herder = new Transheader();
herder.setTransno(transHeaderNo);
herder.setSite(user.getSite());
herder.setTranstypeDb("OI");
herder.setUserid(user.getUsername());
herder.setUsername(user.getUserDisplay());
herder.setTransdate(Calendar.getInstance().getTime());
herder.setStatus("已录入");
String remark = "";
switch (tranType){
case "OI":
remark = "其它入库";
break;
case "OC":
remark = "其它出库";
break;
}
herder.setRemark(remark);
this.save(herder);
// transDetail
Map<String, List<CRollinfoEntity>> partGroup = cRollinfoList.stream().collect(Collectors.groupingBy((CRollinfoEntity::getPartno)));
List<Transdetail> transdetailList = new ArrayList<>();
for (String partNo : partGroup.keySet() ){
double itemNo = 1.0;
Double sumQty = partGroup.get(partNo).stream().collect(Collectors.summingDouble((CRollinfoEntity::getRollqty)));
Transdetail transdetail = new Transdetail();
transdetail.setTransno(herder.getTransno());
transdetail.setSite(user.getSite());
transdetail.setPartno(partNo);
transdetail.setItemno(itemNo++);
transdetail.setTransqty(sumQty);
transdetail.setBatchno("*");
transdetailList.add(transdetail);
}
transdetailService.saveBatch(transdetailList,1000);
// transDetailSub
List<Transdetailsub> transdetailsubs = new ArrayList<>();
for (int i = 0; i < cRollinfoList.size(); i++) {
CRollinfoEntity cRollinfoEntity = cRollinfoList.get(i);
Transdetailsub sub = new Transdetailsub();
sub.setSite(cRollinfoEntity.getSite());
sub.setSubqty(cRollinfoEntity.getRollqty());
sub.setOrderref1(cRollinfoEntity.getOrderref1() != null ? cRollinfoEntity.getOrderref1() : "");
sub.setOrderref3(cRollinfoEntity.getOrderref2() != null ? cRollinfoEntity.getOrderref2() : "");
sub.setItemno(1.0 + i);
sub.setTransno(herder.getTransno());
sub.setSubno(cRollinfoEntity.getRollno());
sub.setDirection("-");
transdetailsubs.add(sub);
}
transdetailsubService.saveBatch(transdetailsubs,1000);
}
}
Loading…
Cancel
Save