|
@ -44,6 +44,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Collections; |
|
|
import java.util.Collections; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
@ -259,25 +260,53 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
public String saveBill(AsBusrepairInventorybillDto dto, String busTypeKey) { |
|
|
public String saveBill(AsBusrepairInventorybillDto dto, String busTypeKey) { |
|
|
AsBusrepairInventorybill entity = new AsBusrepairInventorybill(); |
|
|
AsBusrepairInventorybill entity = new AsBusrepairInventorybill(); |
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
|
|
int isEnable = 0; |
|
|
if (busTypeKey.equals("0")) { |
|
|
if (busTypeKey.equals("0")) { |
|
|
entity.setBusTypeKey("0"); |
|
|
entity.setBusTypeKey("0"); |
|
|
entity.setBusTypeValue("维修出库"); |
|
|
entity.setBusTypeValue("维修出库"); |
|
|
String billNo = getApplyCode(dto.getCreateOrgSid(), "WXCKD"); |
|
|
String billNo = getApplyCode(dto.getCreateOrgSid(), "WXCKD"); |
|
|
entity.setBillNo(billNo); |
|
|
entity.setBillNo(billNo); |
|
|
|
|
|
isEnable = 1; |
|
|
} else if (busTypeKey.equals("1")) { |
|
|
} else if (busTypeKey.equals("1")) { |
|
|
entity.setBusTypeKey("1"); |
|
|
entity.setBusTypeKey("1"); |
|
|
entity.setBusTypeValue("维修退库"); |
|
|
entity.setBusTypeValue("维修退库"); |
|
|
String billNo = getApplyCode(dto.getCreateOrgSid(), "WXTKD"); |
|
|
String billNo = getApplyCode(dto.getCreateOrgSid(), "WXTKD"); |
|
|
entity.setBillNo(billNo); |
|
|
entity.setBillNo(billNo); |
|
|
|
|
|
isEnable = 2; |
|
|
} |
|
|
} |
|
|
baseMapper.insert(entity); |
|
|
baseMapper.insert(entity); |
|
|
List<AsBusrepairInventorybillDetailSDto> detailList = dto.getDetailList(); |
|
|
List<AsBusrepairInventorybillDetailSDto> detailList = dto.getDetailList(); |
|
|
if (!detailList.isEmpty()) { |
|
|
if (!detailList.isEmpty()) { |
|
|
for (AsBusrepairInventorybillDetailSDto sDto : detailList) { |
|
|
for (AsBusrepairInventorybillDetailSDto sDto : detailList) { |
|
|
AsBusrepairInventorybillDetail detail = new AsBusrepairInventorybillDetail(); |
|
|
AsBusrepairInventorybillDetail detail = new AsBusrepairInventorybillDetail(); |
|
|
BeanUtil.copyProperties(sDto, detail); |
|
|
BeanUtil.copyProperties(sDto, detail,"id","sid"); |
|
|
if (StringUtils.isNotBlank(sDto.getOutboundCount())) { |
|
|
// if (StringUtils.isNotBlank(sDto.getOutboundCount())) {
|
|
|
detail.setCurrentCount(new BigDecimal(sDto.getOutboundCount())); |
|
|
// detail.setCurrentCount(new BigDecimal(sDto.getOutboundCount()));
|
|
|
|
|
|
// }
|
|
|
|
|
|
if (isEnable == 1) { |
|
|
|
|
|
if (StringUtils.isNotBlank(sDto.getCount())) { |
|
|
|
|
|
detail.setCurrentCount(new BigDecimal(sDto.getCount())); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (isEnable == 2) { |
|
|
|
|
|
String sid = sDto.getSid(); |
|
|
|
|
|
AsBusrepairInventorybillDetail detailUpdate = asBusrepairInventorybillDetailService.fetchBySid(sid); |
|
|
|
|
|
BigDecimal count = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal currentCount = BigDecimal.ZERO; |
|
|
|
|
|
if (null != detailUpdate) { |
|
|
|
|
|
if (null != detailUpdate.getCurrentCount()) { |
|
|
|
|
|
currentCount = detailUpdate.getCurrentCount(); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNotBlank(sDto.getCount())) { |
|
|
|
|
|
count = new BigDecimal(sDto.getCount()); |
|
|
|
|
|
} |
|
|
|
|
|
BigDecimal subtract = currentCount.subtract(count); |
|
|
|
|
|
detailUpdate.setCurrentCount(subtract); |
|
|
|
|
|
asBusrepairInventorybillDetailService.updateById(detailUpdate); |
|
|
|
|
|
detail.setCurrentCount(subtract); |
|
|
|
|
|
if (StringUtils.isNotBlank(sDto.getReturnAmount())) { |
|
|
|
|
|
detail.setAmount(new BigDecimal(sDto.getReturnAmount())); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
detail.setBillSid(entity.getSid()); |
|
|
detail.setBillSid(entity.getSid()); |
|
|
String inventorySid = sDto.getInventorySid(); |
|
|
String inventorySid = sDto.getInventorySid(); |
|
@ -302,6 +331,7 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
if (StringUtils.isNotBlank(sDto.getPrice())) { |
|
|
if (StringUtils.isNotBlank(sDto.getPrice())) { |
|
|
detail.setGoodsDetailsPrice(new BigDecimal(sDto.getPrice())); |
|
|
detail.setGoodsDetailsPrice(new BigDecimal(sDto.getPrice())); |
|
|
} |
|
|
} |
|
|
|
|
|
detail.setIsEnable(isEnable); |
|
|
asBusrepairInventorybillDetailService.insert(detail); |
|
|
asBusrepairInventorybillDetailService.insert(detail); |
|
|
WmsUpdateCountQuery countQuery = new WmsUpdateCountQuery(); |
|
|
WmsUpdateCountQuery countQuery = new WmsUpdateCountQuery(); |
|
|
countQuery.setSid(sDto.getInventorySid()); |
|
|
countQuery.setSid(sDto.getInventorySid()); |
|
@ -399,6 +429,7 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
AsBusrepairInventoryBillInit vo = new AsBusrepairInventoryBillInit(); |
|
|
AsBusrepairInventoryBillInit vo = new AsBusrepairInventoryBillInit(); |
|
|
AsBusrepairBillDetailsVo data = asBusrepairBillService.fetchDetailsBySid(sid).getData(); |
|
|
AsBusrepairBillDetailsVo data = asBusrepairBillService.fetchDetailsBySid(sid).getData(); |
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
if (null != data) { |
|
|
if (null != data) { |
|
|
vo.setSourceBillSid(sid); |
|
|
vo.setSourceBillSid(sid); |
|
|
if (StringUtils.isNotBlank(data.getBillNo())) { |
|
|
if (StringUtils.isNotBlank(data.getBillNo())) { |
|
@ -454,19 +485,35 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
vo.setSitemVoList(sitemsVos); |
|
|
vo.setSitemVoList(sitemsVos); |
|
|
} |
|
|
} |
|
|
List<AsBusrepairInventorybillDetailSDto> list = new ArrayList<>(); |
|
|
List<AsBusrepairInventorybillDetailSDto> list = new ArrayList<>(); |
|
|
//List<AsBusrepairInventorybillDetail> goodsDetails = asBusrepairInventorybillDetailService.getGoodsDetailsByBillSid(sid);
|
|
|
List<AsBusrepairInventorybillDetailSDto> list2 = new ArrayList<>(); |
|
|
List<AsBusrepairInventorybillDetail> goodsDetails = asBusrepairInventorybillDetailService.getGoodsDetailsByBillSidForBack(sid); |
|
|
List<AsBusrepairInventorybillDetail> goodsDetails = asBusrepairInventorybillDetailService.getGoodsDetailsByBillSidForBack(sid); |
|
|
if (!goodsDetails.isEmpty()) { |
|
|
if (!goodsDetails.isEmpty()) { |
|
|
for (AsBusrepairInventorybillDetail goodsDetail : goodsDetails) { |
|
|
for (AsBusrepairInventorybillDetail goodsDetail : goodsDetails) { |
|
|
AsBusrepairInventorybillDetailSDto goodsDetailsVo = new AsBusrepairInventorybillDetailSDto(); |
|
|
AsBusrepairInventorybillDetailSDto goodsDetailsVo = new AsBusrepairInventorybillDetailSDto(); |
|
|
|
|
|
AsBusrepairInventorybillDetailSDto goodsDetailsVo2 = new AsBusrepairInventorybillDetailSDto(); |
|
|
BeanUtil.copyProperties(goodsDetail, goodsDetailsVo); |
|
|
BeanUtil.copyProperties(goodsDetail, goodsDetailsVo); |
|
|
if (null != goodsDetail.getCount()) { |
|
|
BeanUtil.copyProperties(goodsDetail, goodsDetailsVo2); |
|
|
goodsDetailsVo.setOutboundCount(goodsDetail.getCount().toString()); |
|
|
if (StringUtils.isNotBlank(goodsDetail.getOperName())) { |
|
|
|
|
|
goodsDetailsVo.setReceivePer(goodsDetail.getOperName()); |
|
|
|
|
|
goodsDetailsVo2.setReceivePer(goodsDetail.getOperName()); |
|
|
|
|
|
} |
|
|
|
|
|
if (null != goodsDetail.getReceivedTime()) { |
|
|
|
|
|
goodsDetailsVo.setReceiveTimes(sdf.format(goodsDetail.getReceivedTime())); |
|
|
|
|
|
goodsDetailsVo2.setReceiveTimes(sdf.format(goodsDetail.getReceivedTime())); |
|
|
|
|
|
} |
|
|
|
|
|
if (null != goodsDetail.getCurrentCount()) { |
|
|
|
|
|
goodsDetailsVo.setOutboundCount(goodsDetail.getCurrentCount().toString()); |
|
|
|
|
|
goodsDetailsVo2.setOutboundCount(goodsDetail.getCurrentCount().toString()); |
|
|
} |
|
|
} |
|
|
goodsDetailsVo.setCount("0"); |
|
|
goodsDetailsVo.setCount("0"); |
|
|
|
|
|
// if (null != goodsDetail.getAmount()) {
|
|
|
|
|
|
// goodsDetailsVo.setReturnAmount(goodsDetail.getAmount().toString());
|
|
|
|
|
|
// }
|
|
|
list.add(goodsDetailsVo); |
|
|
list.add(goodsDetailsVo); |
|
|
|
|
|
list2.add(goodsDetailsVo2); |
|
|
} |
|
|
} |
|
|
vo.setDetailList(list); |
|
|
vo.setDetailList(list); |
|
|
|
|
|
vo.setReceiveList(list2); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return rb.success().setData(vo); |
|
|
return rb.success().setData(vo); |
|
|