保养工单备件逻辑变更

highway
wws 1 year ago
parent 3607c4e490
commit ba8dc2e8b4

@ -40,7 +40,7 @@ public class EquSpareApply extends BaseEntity {
/** 数量 */
@Excel(name = "数量")
private Long spareQuantity;
private BigDecimal spareQuantity;
/** 使用组线 */
@Excel(name = "使用组线")
@ -165,11 +165,11 @@ public class EquSpareApply extends BaseEntity {
public String getSpareModel() {
return spareModel;
}
public void setSpareQuantity(Long spareQuantity) {
public void setSpareQuantity(BigDecimal spareQuantity) {
this.spareQuantity = spareQuantity;
}
public Long getSpareQuantity() {
public BigDecimal getSpareQuantity() {
return spareQuantity;
}
public void setSpareGroupLine(String spareGroupLine) {

@ -62,4 +62,10 @@ public interface EquSpareApplyMapper {
//查询维修工单对应的备件申领记录
public List<EquSpareApply> selectRepairSparePartsRecord(EquRepairWorkOrder equRepairWorkOrder);
/**
*
* @return
*/
int selectSerialNumber();
}

@ -98,7 +98,7 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService {
//更新完备品申领单后,更新库存
SparePartsLedger sparePartsLedger = new SparePartsLedger();
sparePartsLedger.setStorageId(applyList.getStorageId());
BigDecimal applyNum = new BigDecimal(applyList.getSpareQuantity());
BigDecimal applyNum = applyList.getSpareQuantity();
BigDecimal amount = applyList.getAmount();
sparePartsLedger.setAmount(amount.subtract(applyNum));
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);

@ -33,8 +33,6 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
@Autowired
private EquOrderMapper equOrderMapper;
@Autowired
private EquOrderEquSpareMapper equOrderEquSpareMapper;
@Autowired
private EquOrderStandardMapper equOrderStandardMapper;
@Autowired
private EquOrderDetailMapper equOrderDetailMapper;
@ -42,6 +40,10 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
private EquOrderPersonMapper equOrderPersonMapper;
@Autowired
private EquOrderEquMapper equOrderEquMapper;
@Autowired
private EquSpareApplyMapper equSpareApplyMapper;
@Autowired
private SparePartsLedgerMapper sparePartsLedgerMapper;
/**
*
@ -68,7 +70,7 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
}
/**
* TODO
*
*
* @param equPlan
* @return
@ -92,8 +94,10 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
String serialNum = String.format("%03d",equOrderMapper.selectSerialNumber());
equOrder.setOrderCode("F"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+serialNum);
equOrder.setPlanLoopType("");
equOrder.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
equOrder.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
if (equPlan.getPlanTimeArray() != null) {
equOrder.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
equOrder.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
}
// 设置工单状态
equOrder.setOrderStatus("0");
equOrder.setFactoryCode(factory);
@ -109,22 +113,32 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
EquPlanEqu equPlanEqu = equPlan.getEquipmentItem().get(0);
// 生成工单-备件
List<EquOrderEquSpare> spareList = new ArrayList<>();
List<EquPlanEquSpare> equSpareList = equPlanEqu.getSpareList();
if (equSpareList != null) {
// 获取流水单号
int applySerialNum = equSpareApplyMapper.selectSerialNumber();
for (EquPlanEquSpare spare : equSpareList) {
EquOrderEquSpare spareTemp = new EquOrderEquSpare();
BeanUtils.copyProperties(spare,spareTemp);
spareTemp.setId(IdUtils.fastSimpleUUID());
spareTemp.setOrderCode(equOrder.getOrderCode());
spareTemp.setFactoryCode(factory);
spareTemp.setCreateBy(SecurityContextHolder.getUserName());
spareTemp.setCreateTime(DateUtils.getNowDate());
spareTemp.setUpdateBy(SecurityContextHolder.getUserName());
spareTemp.setUpdateTime(DateUtils.getNowDate());
EquSpareApply apply = new EquSpareApply();
apply.setApplyId(IdUtils.fastSimpleUUID());
apply.setApplyCode("A"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+String.format("%03d",applySerialNum));
applySerialNum++;
apply.setSpareCode(spare.getMaterialCode());
apply.setSpareName(spare.getMaterialDesc());
apply.setSpareModel(spare.getSpareType());
apply.setSpareQuantity(spare.getApplyNum());
apply.setFactoryCode(factory);
apply.setApplyPeople(SecurityContextHolder.getUserName());
apply.setParentCode(equOrder.getOrderCode());
apply.setCreateBy(SecurityContextHolder.getUserName());
apply.setCreateTime(DateUtils.getNowDate());
apply.setSpareUseEquipment(equOrder.getEquipmentCode());
apply.setApplyTime(DateUtils.getNowDate());
// 插入备件信息
equOrderEquSpareMapper.insertEquOrderEquSpare(spareTemp);
spareList.add(spareTemp);
equSpareApplyMapper.insertEquSpareApply(apply);
// TODO 减少备件仓库中备件数量
sparePartsLedgerMapper.updateSpareNumReduce(apply);
}
}

@ -176,4 +176,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY apply_time DESC
</select>
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(apply_id)+1 AS serialNum
FROM equ_spare_apply
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time) and del_flag = '0'
</select>
</mapper>
Loading…
Cancel
Save