保养工单备件逻辑变更

highway
wws 1 year ago
parent 3607c4e490
commit ba8dc2e8b4

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

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

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

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

@ -176,4 +176,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY apply_time DESC ORDER BY apply_time DESC
</select> </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> </mapper>
Loading…
Cancel
Save