68cb9086 康伟

kangwei :药剂入库审核,出库、与入库完善

1 个父辈 68cc9b2c
......@@ -339,10 +339,12 @@ public class MaterialINController {
Result<MaterialINVO> result = new Result<MaterialINVO>();
try {
materialINService.auditMaterialINVO(materialINVO);
} catch (Exception e) {
log.error("审批失败",e.getMessage());
result.setResult(materialINVO);
result.setSuccess(true);
} catch (Exception e) {
log.error("审批失败",e.getMessage());
result.error500("审批失败:"+e.getMessage());
}
return result;
}
......
......@@ -17,7 +17,7 @@ public interface IMaterialINService extends IService<MaterialIN> {
* 审核药剂入库单
* @param materialINVO
*/
String auditMaterialINVO(MaterialINVO materialINVO);
String auditMaterialINVO(MaterialINVO materialINVO) throws Exception;
/***
* 列表查询到货记录列表
......
......@@ -6,20 +6,27 @@ import com.skua.core.context.BaseContextHandler;
import com.skua.core.context.SpringContextUtils;
import com.skua.modules.equipment.dto.EquipmentInDTO;
import com.skua.modules.equipment.dto.EquipmentOutDTO;
import com.skua.modules.equipment.entity.EquipmentIn;
import com.skua.modules.equipment.entity.EquipmentInChild;
import com.skua.modules.equipment.entity.EquipmentOutChild;
import com.skua.modules.equipment.service.IEquipmentInService;
import com.skua.modules.equipment.service.IEquipmentOutService;
import com.skua.modules.erp.entity.ApproveRecord;
import com.skua.modules.erp.entity.ERPPurchaseContract;
import com.skua.modules.erp.entity.MaterialIN;
import com.skua.modules.erp.mapper.ApproveRecordMapper;
import com.skua.modules.erp.mapper.ERPPurchaseContractMapper;
import com.skua.modules.erp.mapper.MaterialINMapper;
import com.skua.modules.erp.service.IERPPurchaseContractService;
import com.skua.modules.erp.service.IMaterialINService;
import com.skua.modules.erp.vo.ArrivalRecordExcelExportVO;
import com.skua.modules.erp.vo.MaterialINVO;
import com.skua.modules.guest.util.DateUtil;
import com.skua.modules.quartz.util.BaseUtil;
import com.skua.modules.supplies.entity.SuppliesWarehouse;
import com.skua.modules.supplies.service.ISuppliesWarehouseService;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.service.spi.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
......@@ -41,6 +48,8 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
@Resource
private ApproveRecordMapper recordMapper;
@Autowired
private IERPPurchaseContractService purchaseContractService;
@Autowired
private IEquipmentInService equipmentInService;
@Autowired
private IEquipmentOutService equipmentOutService;
......@@ -52,7 +61,7 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
* @param materialINVO
*/
@Transactional
public String auditMaterialINVO(MaterialINVO materialINVO){
public String auditMaterialINVO(MaterialINVO materialINVO)throws Exception {
boolean inAndOutStock = false;
String errMsg = null;
QueryWrapper<SuppliesWarehouse> queryWrapper = new QueryWrapper<SuppliesWarehouse>();
......@@ -68,32 +77,29 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
return "所属厂站["+departName+"]下没有找到仓库信息!";
}
//保存
MaterialIN materialINTemp = this.baseMapper.selectById(materialINVO.getId());
//purchasePlan.getApproveState() 审批状态 1通过2不通过
if("1".equals( materialINVO.getApproveState() )){
materialINVO.setAuditStatus( "3" );
materialINTemp.setAuditStatus( "3" );
inAndOutStock = true;
}
if("2".equals( materialINVO.getApproveState() )){
materialINVO.setAuditStatus( "2" );
materialINTemp.setAuditStatus( "2" );
}
this.baseMapper.updateById( materialINVO ) ;
//审批记录
ApproveRecord record = new ApproveRecord( "YJIN", materialINVO.getApplyUser(), materialINVO.getId(), BaseContextHandler.getUserId(), materialINVO.getApproveMessage(), materialINVO.getApproveState());
recordMapper.insert( record ) ;
// 审核通过,生成入库单据、物料单
if(inAndOutStock ){
try {
//出库
syncEquipmentOut(materialINVO);
errMsg = syncEquipmentOut(materialINTemp);
//入库
syncEquipmentIn(materialINVO,inWarehouseId);
} catch (Exception e) {
e.printStackTrace();
}
errMsg = syncEquipmentIn(materialINTemp,inWarehouseId);
}
this.baseMapper.updateById( materialINTemp ) ;
//审批记录
ApproveRecord record = new ApproveRecord( "YJIN", materialINVO.getApplyUser(), materialINVO.getId(), BaseContextHandler.getUserId(), materialINVO.getApproveMessage(), materialINVO.getApproveState());
recordMapper.insert( record ) ;
return errMsg;
}
......@@ -130,12 +136,53 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
* 出库
* @return
*/
public int syncEquipmentOut(MaterialINVO materialINVO){
public String syncEquipmentOut(MaterialIN materialINTemp)throws Exception{
String errMsg = null;
EquipmentOutDTO equipmentOutDTO = new EquipmentOutDTO();
try{
ERPPurchaseContract erpPurchaseContract = purchaseContractService.getById(materialINTemp.getPurchaseContractId());
if(erpPurchaseContract != null ){
if(StringUtils.isNotEmpty(erpPurchaseContract.getEquipmentInId())){
EquipmentIn equipmentIn = equipmentInService.getById( erpPurchaseContract.getEquipmentInId() );
equipmentOutDTO.setDepartId( equipmentIn.getDepartId() ) ;
equipmentOutDTO.setOutType("9");//
equipmentOutDTO.setRemark( materialINTemp.getRemark() );
equipmentOutDTO.setChooseTime(BaseUtil.getCurrentDate());//经办时间
equipmentOutDTO.setUseBy( BaseContextHandler.getUserId() );//使用人
equipmentOutDTO.setOutDate( BaseUtil.getCurrentDate() );
equipmentOutDTO.setInventoryUpdateTimeEnd( BaseUtil.getCurrentDate());
equipmentOutDTO.setSuppliesWarehouseId( equipmentIn.getSuppliesWarehouseId() );// this.suppliesWarehouseId = suppliesWarehouseId;//所属仓库
//this.outOrder = outOrder;
// this.recipient = recipient;//领用人
equipmentOutDTO.setRecipient( materialINTemp.getReceiver());//收货人,领用人
EquipmentOutChild equipmentOutChild = new EquipmentOutChild();
equipmentOutChild.setSparepartId(materialINTemp.getSparepartId() );//
equipmentOutChild.setOutNum( new BigDecimal( materialINTemp.getMaterialNum() ) ) ;//出库数量
equipmentOutChild.setTotalPrice( new BigDecimal( materialINTemp.getDistributTotalPrice() ) );//总价格
equipmentOutChild.setBatchNum( materialINTemp.getGoodCode() );//批次号
List<EquipmentOutChild> outChildList = new ArrayList<EquipmentOutChild>();
outChildList.add( equipmentOutChild );
equipmentOutDTO.setEquipmentOutChildList( outChildList );
// 创建出库单
equipmentOutService.saveEquipmentOut(equipmentOutDTO);
materialINTemp.setEquipmentOutId( equipmentOutDTO.getId());
}else{
throw new ServiceException("未找到统购合同的入库信息");
}
}else{
throw new ServiceException("统购合同不存在");
}
}catch(ServiceException e){
e.printStackTrace();
}
//equipmentOutService.saveEquipmentOut(equipmentOutDTO);
return 1;
return errMsg;
}
/***
......@@ -143,7 +190,8 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
* @param materialINVO
* @return
*/
public int syncEquipmentIn(MaterialINVO materialINVO,String inWarehouseId) throws Exception{
public String syncEquipmentIn(MaterialIN materialINVO,String inWarehouseId) throws Exception{
String errMsg = null;
EquipmentInDTO equipmentInDTO = new EquipmentInDTO();
// EquipmentIn equipmentIn = new EquipmentIn();
//入库类型
......@@ -160,12 +208,12 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
EquipmentInChild equipmentInChild = new EquipmentInChild();//
equipmentInChild.setSparepartId( materialINVO.getSparepartId());//物料编号
equipmentInChild.setInNum( new BigDecimal(materialINVO.getMaterialNum())); //物料数量
equipmentInChild.setBatchNum(materialINVO.getGoodCode() ) ;//批次号
equipmentInChildrenList.add( equipmentInChild ) ;
equipmentInDTO.setEquipmentInChildList( equipmentInChildrenList );
//调用接口入库
equipmentInService.saveEquipmentIn(equipmentInDTO ) ;
......@@ -175,9 +223,10 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
if(erpPurchaseContract == null ){
throw new Exception("采购合同记录不存在");
}*/
materialINVO.setEquipmentInId( equipmentInDTO.getId() ) ;//记录入库单号
materialINVO.setEquipmentInId( equipmentInDTO.getId() ) ;//记录入库编号
materialINVO.setInOrder( equipmentInDTO.getInOrder() ) ;// 入库单号
log.debug("记录入库单号{"+equipmentInDTO.getId()+"},入库单号:"+equipmentInDTO.getInOrder());
this.baseMapper.updateById(materialINVO ) ;
return 1;
return errMsg;
}
}
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.skua.core.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -42,6 +43,7 @@ public class EquipmentInChild {
*/
@Excel(name = "备品备件id", width = 15)
@ApiModelProperty(value = "备品备件id")
@Dict(dictTable = "equipment_sparepart_supplies", dicCode="id", dicText = "sparepart_name")
private String sparepartId;
/**
* 入库数量
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.skua.core.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -42,6 +43,7 @@ public class EquipmentOutChild {
*/
@Excel(name = "备品备件id", width = 15)
@ApiModelProperty(value = "备品备件id")
@Dict(dictTable = "equipment_sparepart_supplies", dicCode="id", dicText = "sparepart_name")
private String sparepartId;
/**
* 出库数量
......
......@@ -115,7 +115,7 @@ public class EquipmentInServiceImpl extends ServiceImpl<EquipmentInMapper, Equip
}*/
for (EquipmentInChild equipmentInChild : equipmentInDTO.getEquipmentInChildList()) {
equipmentInChild.setInId(inId);
taskExecutor.execute(() -> {
// taskExecutor.execute(() -> {
try {
String sparepartId = equipmentInChild.getSparepartId();
String suppliesWarehouseId = equipmentInDTO.getSuppliesWarehouseId();
......@@ -173,7 +173,7 @@ public class EquipmentInServiceImpl extends ServiceImpl<EquipmentInMapper, Equip
} finally {
countDownLatch.countDown();
}
});
// });
}
countDownLatch.await();
return 1;
......
......@@ -20,9 +20,8 @@ import com.skua.tool.util.UniqIdUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Resource;
......@@ -37,10 +36,6 @@ import java.util.concurrent.CountDownLatch;
*/
@Service
public class EquipmentOutServiceImpl extends ServiceImpl<EquipmentOutMapper, EquipmentOut> implements IEquipmentOutService {
@Autowired
@Qualifier("taskExecutor")
private ThreadPoolTaskExecutor taskExecutor;
@Resource
private EquipmentOutMapper equipmentOutMapper;
......@@ -63,6 +58,7 @@ public class EquipmentOutServiceImpl extends ServiceImpl<EquipmentOutMapper, Equ
* @param equipmentOutDTO
* @return
*/
@Transactional
public String saveEquipmentOut(EquipmentOutDTO equipmentOutDTO) throws Exception {
String errMsg = null;
if (equipmentOutDTO.getEquipmentOutChildList() == null || equipmentOutDTO.getEquipmentOutChildList().isEmpty()) {
......@@ -80,12 +76,11 @@ public class EquipmentOutServiceImpl extends ServiceImpl<EquipmentOutMapper, Equ
EquipmentOut equipmentOut = BeanExtUtils.bean2Bean(equipmentOutDTO, EquipmentOut.class);
equipmentOut.setInventoryUpdateTime(new Date());
this.baseMapper.insert(equipmentOut);
CountDownLatch countDownLatch = new CountDownLatch(equipmentOutDTO.getEquipmentOutChildList().size());
// CountDownLatch countDownLatch = new CountDownLatch(equipmentOutDTO.getEquipmentOutChildList().size());
for (EquipmentOutChild equipmentOutChild : equipmentOutDTO.getEquipmentOutChildList()) {
equipmentOutChild.setId(UniqIdUtils.getInstance().getUniqID());
equipmentOutChild.setOutId(outId);
taskExecutor.execute(() -> {
try {
// taskExecutor.execute(() -> {
String sparepartId = equipmentOutChild.getSparepartId();
String suppliesWarehouseId = equipmentOutDTO.getSuppliesWarehouseId();
......@@ -109,7 +104,8 @@ public class EquipmentOutServiceImpl extends ServiceImpl<EquipmentOutMapper, Equ
}
BigDecimal resetStorageNum = equipmentSparepart.getStorageNum().subtract(equipmentOutChild.getOutNum());
if (resetStorageNum.doubleValue() < 0) {
return;
continue;
//return;
}
Integer version = equipmentSparepart.getVersion();
String id = equipmentSparepart.getId();
......@@ -122,19 +118,9 @@ public class EquipmentOutServiceImpl extends ServiceImpl<EquipmentOutMapper, Equ
return 0;
}
});
// if (executeRes != null && executeRes == 1) {
//
// }
} catch (Exception e) {
e.printStackTrace();
//log.error("异常error: {}", e.getMessage());
} finally {
countDownLatch.countDown();
}
});
// });
}
countDownLatch.await();
// countDownLatch.await();
return errMsg ;
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!