|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.yxt.anrui.as.biz.asbusrepairinventorybill; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
@ -10,14 +11,19 @@ import com.yxt.anrui.as.api.asbusrepairinventorybill.*; |
|
|
|
import com.yxt.anrui.as.api.asbusrepairinventorybilldetail.AsBusrepairInventorybillDetail; |
|
|
|
import com.yxt.anrui.as.api.asbusrepairinventorybilldetail.AsBusrepairInventorybillDetailSDto; |
|
|
|
import com.yxt.anrui.as.api.asbusrepairinventorybilldetail.SitemsVo; |
|
|
|
import com.yxt.anrui.as.api.asbusreservebill.AsBusreserveBillVo; |
|
|
|
import com.yxt.anrui.as.api.enums.AsBillTypeEnum; |
|
|
|
import com.yxt.anrui.as.api.utils.AsRule; |
|
|
|
import com.yxt.anrui.as.api.utils.domain.AsBillNo; |
|
|
|
import com.yxt.anrui.as.biz.asbusrepairbill.AsBusrepairBillService; |
|
|
|
import com.yxt.anrui.as.biz.asbusrepairinventorybilldetail.AsBusrepairInventorybillDetailService; |
|
|
|
import com.yxt.anrui.as.feign.portal.privilege.PrivilegeQuery; |
|
|
|
import com.yxt.anrui.as.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.anrui.as.feign.portal.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.anrui.as.feign.portal.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.as.feign.portal.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.as.feign.wms.wmsInventory.WmsInventoryFeign; |
|
|
|
import com.yxt.anrui.as.feign.wms.wmsInventory.WmsUpdateCountQuery; |
|
|
|
import com.yxt.anrui.as.feign.wms.wmsinventorybill.WmsInventoryBillDetailDto; |
|
|
|
import com.yxt.anrui.as.feign.wms.wmsinventorybill.WmsInventoryBillDto; |
|
|
|
import com.yxt.anrui.as.feign.wms.wmsinventorybill.WmsInventoryBillFeign; |
|
|
@ -27,6 +33,7 @@ import com.yxt.common.base.utils.StringUtils; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import javassist.Loader; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
@ -56,7 +63,10 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
|
private AsBusrepairBillService asBusrepairBillService; |
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private WmsInventoryFeign wmsInventoryFeign; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
/** |
|
|
|
* 维修出/退库分页列表 |
|
|
|
* |
|
|
@ -67,32 +77,71 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
|
AsBusrepairInventorybillQuery query = pagerQuery.getParams(); |
|
|
|
QueryWrapper<AsBusrepairInventorybill> qw = new QueryWrapper<>(); |
|
|
|
if (query != null) { |
|
|
|
if (StringUtils.isNotBlank(query.getMenuUrl())) { |
|
|
|
PrivilegeQuery privilegeQuery = new PrivilegeQuery(); |
|
|
|
privilegeQuery.setOrgPath(query.getOrgPath()); |
|
|
|
privilegeQuery.setMenuUrl(query.getMenuUrl()); |
|
|
|
privilegeQuery.setUserSid(query.getUserSid()); |
|
|
|
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); |
|
|
|
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { |
|
|
|
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
|
|
|
|
String orgSidPath = query.getOrgPath(); |
|
|
|
orgSidPath = orgSidPath + "/"; |
|
|
|
int i1 = orgSidPath.indexOf("/"); |
|
|
|
int i2 = orgSidPath.indexOf("/", i1 + 1); |
|
|
|
int i3 = orgSidPath.indexOf("/", i2 + 1); |
|
|
|
int i4 = orgSidPath.indexOf("/", i3 + 1); |
|
|
|
String orgLevelKey = defaultIdReltBean.getData(); |
|
|
|
if ("1".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i1); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i2); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i3); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("4".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i4); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("5".equals(orgLevelKey)) { |
|
|
|
qw.eq("a.createBySid", query.getUserSid()); |
|
|
|
} else { |
|
|
|
PagerVo<AsBusrepairInventorybillVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} else { |
|
|
|
PagerVo<AsBusrepairInventorybillVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getUserSid())) { |
|
|
|
qw.eq("createBySid", query.getUserSid()); |
|
|
|
qw.eq("a.createBySid", query.getUserSid()); |
|
|
|
} |
|
|
|
//单据编号
|
|
|
|
if (StringUtils.isNotBlank(query.getBillNo())) { |
|
|
|
qw.like("billNo", query.getBillNo()); |
|
|
|
qw.like("a.billNo", query.getBillNo()); |
|
|
|
} |
|
|
|
//单据日期开始时间-单据日期结束时间
|
|
|
|
qw.apply(StringUtils.isNotBlank(query.getCreateTimeStart()), "date_format (createTime,'%Y-%m-%d') >= date_format('" + query.getCreateTimeStart() + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(query.getCreateTimeEnd()), "date_format (createTime,'%Y-%m-%d') <= date_format('" + query.getCreateTimeEnd() + "','%Y-%m-%d')" |
|
|
|
qw.apply(StringUtils.isNotBlank(query.getCreateTimeStart()), "date_format (a.createTime,'%Y-%m-%d') >= date_format('" + query.getCreateTimeStart() + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(query.getCreateTimeEnd()), "date_format (a.createTime,'%Y-%m-%d') <= date_format('" + query.getCreateTimeEnd() + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
//维修工单编号
|
|
|
|
if (StringUtils.isNotBlank(query.getSourceBillNo())) { |
|
|
|
qw.like("sourceBillNo", query.getSourceBillNo()); |
|
|
|
qw.like("b.billNo", query.getSourceBillNo()); |
|
|
|
} |
|
|
|
//业务类型
|
|
|
|
if (StringUtils.isNotBlank(query.getBusTypeValue())) { |
|
|
|
qw.like("busTypeValue", query.getBusTypeValue()); |
|
|
|
qw.like("a.busTypeValue", query.getBusTypeValue()); |
|
|
|
} |
|
|
|
//操作人
|
|
|
|
if (StringUtils.isNotBlank(query.getCreateByName())) { |
|
|
|
qw.like("createByName", query.getCreateByName()); |
|
|
|
qw.like("a.createByName", query.getCreateByName()); |
|
|
|
} |
|
|
|
//经办人
|
|
|
|
if (StringUtils.isNotBlank(query.getWarehouseManager())) { |
|
|
|
qw.like("warehouseManager", query.getWarehouseManager()); |
|
|
|
qw.like("a.warehouseManager", query.getWarehouseManager()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -197,6 +246,12 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
|
return rb.success().setData(sid); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean newQuitBill(AsBusrepairInventorybillDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String sid = saveBill(dto, "1"); |
|
|
|
return rb.success().setData(sid); |
|
|
|
} |
|
|
|
|
|
|
|
public String saveBill(AsBusrepairInventorybillDto dto, String busTypeKey) { |
|
|
|
AsBusrepairInventorybill entity = new AsBusrepairInventorybill(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
@ -220,7 +275,20 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
|
if (StringUtils.isNotBlank(sDto.getOutboundCount())) { |
|
|
|
detail.setCurrentCount(new BigDecimal(sDto.getOutboundCount())); |
|
|
|
} |
|
|
|
detail.setBillSid(entity.getSid()); |
|
|
|
asBusrepairInventorybillDetailService.insert(detail); |
|
|
|
|
|
|
|
WmsUpdateCountQuery countQuery = new WmsUpdateCountQuery(); |
|
|
|
countQuery.setSid(sDto.getInventorySid()); |
|
|
|
countQuery.setCount(new BigDecimal(sDto.getCount())); |
|
|
|
if (busTypeKey.equals("0")) { |
|
|
|
//维修出库
|
|
|
|
countQuery.setAddOrReduce(1); |
|
|
|
} else if (busTypeKey.equals("1")) { |
|
|
|
//维修退库
|
|
|
|
countQuery.setAddOrReduce(0); |
|
|
|
} |
|
|
|
wmsInventoryFeign.updateInventoryCount(countQuery); |
|
|
|
} |
|
|
|
} |
|
|
|
return entity.getSid(); |
|
|
@ -228,15 +296,73 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
|
|
|
|
|
public ResultBean<InventoryBillDetailsVo> details(String sid) { |
|
|
|
ResultBean<InventoryBillDetailsVo> rb = ResultBean.fireFail(); |
|
|
|
AsBusrepairInventorybill asBusrepairInventorybill = fetchBySid(sid); |
|
|
|
InventoryBillDetailsVo inventoryBillDetailsVo = new InventoryBillDetailsVo(); |
|
|
|
BeanUtil.copyProperties(asBusrepairInventorybill, inventoryBillDetailsVo, "sid"); |
|
|
|
List<SitemsVo> sitemVoList = asBusrepairBillService.selectSitemList(asBusrepairInventorybill.getSourceBillSid()); |
|
|
|
sitemVoList.removeAll(Collections.singleton(null)); |
|
|
|
if (!sitemVoList.isEmpty()) { |
|
|
|
inventoryBillDetailsVo.setSitemVoList(sitemVoList); |
|
|
|
InventoryBillDetailsVo vo = new InventoryBillDetailsVo(); |
|
|
|
AsBusrepairInventorybill entity = fetchBySid(sid); |
|
|
|
if (null != entity) { |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
String sourceBillSid = entity.getSourceBillSid(); |
|
|
|
vo.setCreateTime(DateUtil.formatDate(entity.getCreateTime())); |
|
|
|
AsBusrepairBillDetailsVo data = asBusrepairBillService.fetchDetailsBySid(sourceBillSid).getData(); |
|
|
|
if (null != data) { |
|
|
|
if (StringUtils.isNotBlank(data.getBillNo())) { |
|
|
|
vo.setSourceBillNo(data.getBillNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getWaitorName())) { |
|
|
|
vo.setWaitorName(data.getWaitorName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getCreateDate())) { |
|
|
|
vo.setBillDate(data.getCreateDate()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getBillType())) { |
|
|
|
vo.setBillType(data.getBillType()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getSubject())) { |
|
|
|
vo.setSubject(data.getSubject()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getCustomerName())) { |
|
|
|
vo.setCustomerName(data.getCustomerName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getVehMark())) { |
|
|
|
vo.setVehMark(data.getVehMark()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getVinNo())) { |
|
|
|
vo.setVinNo(data.getVinNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getCustomerOrg())) { |
|
|
|
vo.setCustomerOrg(data.getCustomerOrg()); |
|
|
|
} |
|
|
|
List<SitemVo> sitemVos = data.getSitemVos(); |
|
|
|
List<SitemsVo> sitemsVos = new ArrayList<>(); |
|
|
|
if (!sitemVos.isEmpty()) { |
|
|
|
for (SitemVo sitemVo : sitemVos) { |
|
|
|
SitemsVo sitemsVo = new SitemsVo(); |
|
|
|
BeanUtil.copyProperties(sitemVo, sitemsVo); |
|
|
|
List<String> staffNameList = sitemVo.getStaffNameList(); |
|
|
|
StringBuffer sb = new StringBuffer(); |
|
|
|
if (!staffNameList.isEmpty()) { |
|
|
|
for (String name : staffNameList) { |
|
|
|
sb.append(name).append(","); |
|
|
|
} |
|
|
|
sb.delete(sb.length() - 1, sb.length()); |
|
|
|
sitemsVo.setRepairerName(sb.toString()); |
|
|
|
} |
|
|
|
sitemsVos.add(sitemsVo); |
|
|
|
} |
|
|
|
vo.setSitemVoList(sitemsVos); |
|
|
|
} |
|
|
|
List<AsBusrepairInventorybillDetailSDto> list = new ArrayList<>(); |
|
|
|
List<AsBusrepairInventorybillDetail> goodsDetails = asBusrepairInventorybillDetailService.selectByMainSid(sid); |
|
|
|
if (!goodsDetails.isEmpty()) { |
|
|
|
for (AsBusrepairInventorybillDetail goodsDetail : goodsDetails) { |
|
|
|
AsBusrepairInventorybillDetailSDto goodsDetailsVo = new AsBusrepairInventorybillDetailSDto(); |
|
|
|
BeanUtil.copyProperties(goodsDetail, goodsDetailsVo); |
|
|
|
list.add(goodsDetailsVo); |
|
|
|
} |
|
|
|
vo.setDetailList(list); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(inventoryBillDetailsVo); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<AsBusrepairInventoryBillInit> init(String sid) { |
|
|
@ -255,14 +381,7 @@ public class AsBusrepairInventorybillService extends MybatisBaseService<AsBusrep |
|
|
|
vo.setBillDate(data.getCreateDate()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getBillType())) { |
|
|
|
String billType = data.getBillType(); |
|
|
|
if (billType.equals("0")) { |
|
|
|
vo.setBillType("正常工单"); |
|
|
|
} else if (billType.equals("1")) { |
|
|
|
vo.setBillType("保险理赔"); |
|
|
|
} else if (billType.equals("2")) { |
|
|
|
vo.setBillType("协议单位"); |
|
|
|
} |
|
|
|
vo.setBillType(data.getBillType()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getSubject())) { |
|
|
|
vo.setSubject(data.getSubject()); |
|
|
|