@ -16,20 +16,32 @@ import jnpf.base.vo.DownloadVO;
import jnpf.base.vo.PageListVO ;
import jnpf.base.vo.PaginationVO ;
import jnpf.config.ConfigValueUtil ;
import jnpf.contractfile.entity.ContractFileEntity ;
import jnpf.contractfile.service.ContractFileService ;
import jnpf.exception.DataException ;
import jnpf.materialvo.entity.MaterialEntity ;
import jnpf.materialvo.service.MaterialService ;
import jnpf.mobilePort.utils.FileCopy ;
import jnpf.payment.model.payment.PaymentListVO ;
import jnpf.payment.service.PaymentService ;
import jnpf.poundlist.entity.PoundlistEntity ;
import jnpf.poundlist.service.PoundlistService ;
import jnpf.purchaseback.entity.PurchasebackEntity ;
import jnpf.purchaseback.entity.PurchaseorderEntity ;
import jnpf.purchaseback.service.PurchasebackService ;
import jnpf.purchaseback.service.PurchaseorderService ;
import jnpf.purchaseorder.entity.* ;
import jnpf.purchaseorder.model.purchaseorder.* ;
import jnpf.purchaseorder.service.* ;
import jnpf.reservoirarea.entity.ReservoirareaEntity ;
import jnpf.reservoirarea.service.ReservoirareaService ;
import jnpf.util.* ;
import jnpf.util.enums.FileTypeEnum ;
import jnpf.util.file.UploadUtil ;
import jnpf.warehouse.service.WareHouseService ;
import lombok.Cleanup ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.poi.hssf.usermodel.HSSFWorkbook ;
import org.apache.poi.ss.usermodel.Workbook ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -71,10 +83,12 @@ public class PurchaseorderController {
@Autowired
private UserProvider userProvider ;
@Autowired
private PaymentService paymentService ;
@Autowired
private PurchaseorderitemService purchaseorderitemService ;
@Autowired
private PurchasebackService purchasebackService ;
@Autowired
private Purchaseorder_item0Service purchaseorder_item0Service ;
@Autowired
@ -91,7 +105,16 @@ public class PurchaseorderController {
private InvoicesitemService invoicesitemService ;
@Autowired
private PurchaseorderService purchaseorderService ;
@Autowired
private PoundlistService poundlistService ;
@Autowired
private MaterialService materialService ;
@Autowired
private ReservoirareaService reservoirareaService ;
@Autowired
private WareHouseService wareHouseService ;
@Autowired
private ContractFileService contractFileService ;
/ * *
* 归 档
@ -106,6 +129,11 @@ public class PurchaseorderController {
if ( purchaseorder . getInvoiceAmount ( ) . equals ( purchaseorder . getAmount ( ) ) & & purchaseorder . getInvoiceAmount ( ) . equals ( purchaseorder . getPayPrice ( ) ) ) {
purchaseorder . setStatus ( "3" ) ;
purchaseorderitemService . updateById ( purchaseorder ) ;
List < PoundlistEntity > poundlistEntityList = purchaseorderitemService . getPoundList ( purchaseorder . getId ( ) ) ;
for ( PoundlistEntity poundlistEntity : poundlistEntityList ) {
poundlistEntity . setPurchaseStatus ( "3" ) ;
poundlistService . updateById ( poundlistEntity ) ;
}
return ActionResult . success ( "归档成功!" ) ;
} else {
return ActionResult . fail ( "发票金额、金额、已付款金额三者不一致!" ) ;
@ -150,20 +178,20 @@ public class PurchaseorderController {
* @param purchaseorderPagination
* @return
* /
@PostMapping ( "/getList" )
@PostMapping ( "/getList" )
public ActionResult list ( @RequestBody PurchaseorderPagination purchaseorderPagination ) throws IOException {
List < PurchaseorderitemEntity > list = purchaseorderitemService . getList ( purchaseorderPagination ) ;
//处理id字段转名称, 若无需转或者为空可删除
for ( PurchaseorderitemEntity entity : list ) {
Map < String , Object > contractNameMap = new HashMap < > ( ) ;
entity . setContractName ( generaterSwapUtil . getPopupSelectValue ( "390143765857220229" , "contract_name" , "contract_name" , entity . getContractName ( ) , contractNameMap ) ) ;
for ( PurchaseorderitemEntity entity : list ) {
Map < String , Object > contractCodeMap = new HashMap < > ( ) ;
entity . setContractName ( generaterSwapUtil . getPopupSelectValue ( "390143765857220229" , "id" , "contract_name" , entity . getContractCode ( ) , contractCodeMap ) ) ;
Map < String , Object > supplierIdMap = new HashMap < > ( ) ;
entity . setSupplierName ( generaterSwapUtil . getPopupSelectValue ( "397751667988199621" , "id" , "supplier_name" , entity . getSupplierId ( ) , supplierIdMap ) ) ;
entity . setCreatorUserName ( generaterSwapUtil . userSelectValue ( entity . getCreatorUserName ( ) ) ) ;
}
List < PurchaseorderListVO > listVO = JsonUtil . getJsonToList ( list , PurchaseorderListVO . class ) ;
for ( PurchaseorderListVO purchaseorderVO : listVO ) {
}
}
List < PurchaseorderListVO > listVO = JsonUtil . getJsonToList ( list , PurchaseorderListVO . class ) ;
for ( PurchaseorderListVO purchaseorderVO : listVO ) {
}
PageListVO vo = new PageListVO ( ) ;
vo . setList ( listVO ) ;
PaginationVO page = JsonUtil . getJsonToBean ( purchaseorderPagination , PaginationVO . class ) ;
@ -186,16 +214,24 @@ public class PurchaseorderController {
purchaseorderCrForm . setDocumentNo ( generaterSwapUtil . getBillNumber ( "cgdj" , false ) ) ;
purchaseorderCrForm . setCreatorUserName ( userInfo . getUserId ( ) ) ;
purchaseorderCrForm . setCreatorTime ( DateUtil . getNow ( ) ) ;
purchaseorderCrForm . setStatus ( "0" ) ; //待开票
purchaseorderCrForm . setSourceSystem ( "0" ) ; //人工创建
purchaseorderCrForm . setIsSettle ( "0" ) ; //未结算
purchaseorderCrForm . setIsTransfer ( "0" ) ; //未转销售
PurchaseorderitemEntity entity = JsonUtil . getJsonToBean ( purchaseorderCrForm , PurchaseorderitemEntity . class ) ;
entity . setId ( mainId ) ;
entity . setStatus ( null ) ;
purchaseorderitemService . save ( entity ) ;
List < Purchaseorder_item0Entity > Purchaseorder_item0List = JsonUtil . getJsonToList ( purchaseorderCrForm . getPurchaseorder_item0List ( ) , Purchaseorder_item0Entity . class ) ;
for ( Purchaseorder_item0Entity entitys : Purchaseorder_item0List ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPurchaseorderId ( entity . getId ( ) ) ;
purchaseorder_item0Service . save ( entitys ) ;
}
entity . setId ( mainId ) ;
purchaseorderitemService . save ( entity ) ;
List < Purchaseorder_item0Entity > Purchaseorder_item0List = JsonUtil . getJsonToList ( purchaseorderCrForm . getPurchaseorder_item0List ( ) , Purchaseorder_item0Entity . class ) ;
for ( Purchaseorder_item0Entity entitys : Purchaseorder_item0List ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPurchaseorderId ( entity . getId ( ) ) ;
purchaseorder_item0Service . save ( entitys ) ;
PoundlistEntity poundlistEntity = poundlistService . getById ( entitys . getPoundlistId ( ) ) ;
poundlistEntity . setSettlement ( entitys . getSettlement ( ) ) ;
poundlistEntity . setPurchasePrice ( entitys . getPrice ( ) ) ;
poundlistEntity . setPurchaseStatus ( "0" ) ;
poundlistService . updateById ( poundlistEntity ) ;
}
//
// List<Invoices_item0itemEntity> Invoices_item0itemList = JsonUtil.getJsonToList(purchaseorderCrForm.getInvoices_item0itemList(),Invoices_item0itemEntity.class);
// for(Invoices_item0itemEntity entitys : Invoices_item0itemList){
@ -225,15 +261,15 @@ public class PurchaseorderController {
// collectionpoService.save(entitys);
// }
return ActionResult . success ( "创建成功" ) ;
}
}
/ * *
* 模 板 下 载
*
* @return
* /
* 模 板 下 载
*
* @return
* /
@ApiOperation ( "模板下载" )
@GetMapping ( "/templateDownload" )
public ActionResult < DownloadVO > TemplateDownload ( ) {
@ -331,14 +367,14 @@ public class PurchaseorderController {
PurchaseorderPagination purchaseorderPagination = JsonUtil . getJsonToBean ( purchaseorderPaginationExportModel , PurchaseorderPagination . class ) ;
List < PurchaseorderitemEntity > list = purchaseorderitemService . getTypeList ( purchaseorderPagination , purchaseorderPaginationExportModel . getDataType ( ) ) ;
//处理id字段转名称, 若无需转或者为空可删除
for ( PurchaseorderitemEntity entity : list ) {
Map < String , Object > contractNameMap = new HashMap < > ( ) ;
for ( PurchaseorderitemEntity entity : list ) {
Map < String , Object > contractNameMap = new HashMap < > ( ) ;
entity . setContractName ( generaterSwapUtil . getPopupSelectValue ( "390143765857220229" , "contract_name" , "contract_name" , entity . getContractName ( ) , contractNameMap ) ) ;
entity . setCreatorUserName ( generaterSwapUtil . userSelectValue ( entity . getCreatorUserName ( ) ) ) ;
}
List < PurchaseorderListVO > listVO = JsonUtil . getJsonToList ( list , PurchaseorderListVO . class ) ;
for ( PurchaseorderListVO purchaseorderVO : listVO ) {
}
}
List < PurchaseorderListVO > listVO = JsonUtil . getJsonToList ( list , PurchaseorderListVO . class ) ;
for ( PurchaseorderListVO purchaseorderVO : listVO ) {
}
//转换为map输出
List < Map < String , Object > > mapList = JsonUtil . getJsonToListMap ( JsonUtil . getObjectToStringDateFormat ( listVO , "yyyy-MM-dd HH:mm:ss" ) ) ;
@ -350,84 +386,84 @@ public class PurchaseorderController {
//导出表格
public DownloadVO creatModelExcel ( String path , List < Map < String , Object > > list , String [ ] keys , UserInfo userInfo ) {
DownloadVO vo = DownloadVO . builder ( ) . build ( ) ;
List < ExcelExportEntity > entitys = new ArrayList < > ( ) ;
if ( keys . length > 0 ) {
for ( String key : keys ) {
switch ( key ) {
List < ExcelExportEntity > entitys = new ArrayList < > ( ) ;
if ( keys . length > 0 ) {
for ( String key : keys ) {
switch ( key ) {
case "documentNo" :
entitys . add ( new ExcelExportEntity ( "单据编号" , "documentNo" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "单据编号" , "documentNo" ) ) ;
break ;
case "contractName" :
entitys . add ( new ExcelExportEntity ( "合同名称" , "contractName" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "合同名称" , "contractName" ) ) ;
break ;
case "supplierName" :
entitys . add ( new ExcelExportEntity ( "供应商名称" , "supplierName" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "供应商名称" , "supplierName" ) ) ;
break ;
case "currency" :
entitys . add ( new ExcelExportEntity ( "币种" , "currency" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "币种" , "currency" ) ) ;
break ;
case "contractNo" :
entitys . add ( new ExcelExportEntity ( "对方合同号" , "contractNo" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "对方合同号" , "contractNo" ) ) ;
break ;
case "advanceAmount" :
entitys . add ( new ExcelExportEntity ( "垫资金额" , "advanceAmount" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "垫资金额" , "advanceAmount" ) ) ;
break ;
case "num" :
entitys . add ( new ExcelExportEntity ( "重量" , "num" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "重量" , "num" ) ) ;
break ;
case "amount" :
entitys . add ( new ExcelExportEntity ( "金额" , "amount" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "金额" , "amount" ) ) ;
break ;
case "notAmount" :
entitys . add ( new ExcelExportEntity ( "不含税金额" , "notAmount" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "不含税金额" , "notAmount" ) ) ;
break ;
case "remark" :
entitys . add ( new ExcelExportEntity ( "备注信息" , "remark" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "备注信息" , "remark" ) ) ;
break ;
case "creatorUserName" :
entitys . add ( new ExcelExportEntity ( "制单人" , "creatorUserName" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "制单人" , "creatorUserName" ) ) ;
break ;
case "creatorTime" :
entitys . add ( new ExcelExportEntity ( "制单时间" , "creatorTime" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "制单时间" , "creatorTime" ) ) ;
break ;
case "erpNo" :
entitys . add ( new ExcelExportEntity ( "ERP订单号" , "erpNo" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "ERP订单号" , "erpNo" ) ) ;
break ;
case "payPrice" :
entitys . add ( new ExcelExportEntity ( "已付款金额" , "payPrice" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "已付款金额" , "payPrice" ) ) ;
break ;
case "invoiceNum" :
entitys . add ( new ExcelExportEntity ( "发票数量" , "invoiceNum" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "发票数量" , "invoiceNum" ) ) ;
break ;
case "invoiceAmount" :
entitys . add ( new ExcelExportEntity ( "发票金额" , "invoiceAmount" ) ) ;
break ;
entitys . add ( new ExcelExportEntity ( "发票金额" , "invoiceAmount" ) ) ;
break ;
case "status" :
entitys . add ( new ExcelExportEntity ( "单据状态 " , "status" ) ) ;
break ;
default :
break ;
}
entitys . add ( new ExcelExportEntity ( "单据状态 " , "status" ) ) ;
break ;
default :
break ;
}
}
}
ExportParams exportParams = new ExportParams ( null , "表单信息" ) ;
exportParams . setType ( ExcelType . XSSF ) ;
try {
@Cleanup Workbook workbook = new HSSFWorkbook ( ) ;
if ( entitys . size ( ) > 0 ) {
workbook = ExcelExportUtil . exportExcel ( exportParams , entitys , list ) ;
}
String name = "表单信息" + DateUtil . dateNow ( "yyyyMMdd" ) + "_" + RandomUtil . uuId ( ) + ".xlsx" ;
@Cleanup Workbook workbook = new HSSFWorkbook ( ) ;
if ( entitys . size ( ) > 0 ) {
workbook = ExcelExportUtil . exportExcel ( exportParams , entitys , list ) ;
}
String name = "表单信息" + DateUtil . dateNow ( "yyyyMMdd" ) + "_" + RandomUtil . uuId ( ) + ".xlsx" ;
String fileName = configValueUtil . getTemporaryFilePath ( ) + name ;
@Cleanup FileOutputStream output = new FileOutputStream ( XSSEscape . escapePath ( fileName ) ) ;
workbook . write ( output ) ;
//上传文件
UploadUtil . uploadFile ( configValueUtil . getFileType ( ) , fileName , FileTypeEnum . TEMPORARY , name ) ;
String fileName = configValueUtil . getTemporaryFilePath ( ) + name ;
@Cleanup FileOutputStream output = new FileOutputStream ( XSSEscape . escapePath ( fileName ) ) ;
workbook . write ( output ) ;
//上传文件
UploadUtil . uploadFile ( configValueUtil . getFileType ( ) , fileName , FileTypeEnum . TEMPORARY , name ) ;
vo . setName ( name ) ;
vo . setUrl ( UploaderUtil . uploaderFile ( userInfo . getId ( ) + "#" + name + "#" + "Temporary" ) ) ;
vo . setName ( name ) ;
vo . setUrl ( UploaderUtil . uploaderFile ( userInfo . getId ( ) + "#" + name + "#" + "Temporary" ) ) ;
} catch ( Exception e ) {
log . error ( "信息导出Excel错误:{}" , e . getMessage ( ) ) ;
e . printStackTrace ( ) ;
@ -446,7 +482,7 @@ public class PurchaseorderController {
@Transactional
public ActionResult batchRemove ( @PathVariable ( "ids" ) String ids ) {
String [ ] idList = ids . split ( "," ) ;
int i = 0 ;
int i = 0 ;
for ( String allId : idList ) {
this . delete ( allId ) ;
i + + ;
@ -454,89 +490,131 @@ public class PurchaseorderController {
if ( i = = 0 ) {
return ActionResult . fail ( "删除失败" ) ;
}
return ActionResult . success ( "删除成功" ) ;
return ActionResult . success ( "删除成功" ) ;
}
/ * *
* 信 息
*
* @param id
* @return
* /
* 批 量 查 询 采 购 订 单 信 息
*
* @param ids
* @return
* /
@GetMapping ( "/batchQueryPurchaseorder/{ids}" )
@Transactional
public ActionResult < List < PurchaseorderitemEntity > > batchQueryPurchaseorder ( @PathVariable ( "ids" ) String ids ) {
List < PurchaseorderitemEntity > list = new ArrayList < > ( ) ;
String [ ] idList = ids . split ( "," ) ;
for ( String id : idList ) {
PurchaseorderitemEntity entity = purchaseorderitemService . getInfo ( id ) ;
List < PoundlistEntity > poundlistEntityList = purchaseorderitemService . getPoundList ( id ) ;
entity . setPoundlistEntityList ( poundlistEntityList ) ;
if ( entity ! = null & & StringUtils . isNotEmpty ( entity . getContractCode ( ) ) ) {
ContractFileEntity contractFileEntity = contractFileService . getById ( entity . getContractCode ( ) ) ;
if ( contractFileEntity ! = null & & StringUtils . isNotEmpty ( contractFileEntity . getContractName ( ) ) ) {
entity . setContractNo ( contractFileEntity . getContractCode ( ) ) ;
}
}
list . add ( entity ) ;
}
return ActionResult . success ( list ) ;
}
/ * *
* 信 息
*
* @param id
* @return
* /
@GetMapping ( "/{id}" )
public ActionResult < PurchaseorderInfoVO > info ( @PathVariable ( "id" ) String id ) {
PurchaseorderitemEntity entity = purchaseorderitemService . getInfo ( id ) ;
PurchaseorderInfoVO vo = JsonUtil . getJsonToBean ( entity , PurchaseorderInfoVO . class ) ;
vo . setCreatorUserName ( generaterSwapUtil . userSelectValue ( vo . getCreatorUserName ( ) ) ) ;
vo . setCreatorUserName ( generaterSwapUtil . userSelectValue ( vo . getCreatorUserName ( ) ) ) ;
if ( vo . getCreatorTime ( ) ! = null ) {
vo . setCreatorTime ( vo . getCreatorTime ( ) ) ;
}
//子表
List < Purchaseorder_item0Entity > Purchaseorder_item0List = purchaseorderitemService . GetPurchaseorder_item0List ( id ) ;
for ( Purchaseorder_item0Entity purchaseorder_item0Entity : Purchaseorder_item0List ) {
}
vo . setPurchaseorder_item0List ( JsonUtil . getJsonToList ( Purchaseorder_item0List , Purchaseorder_item0Model . class ) ) ;
QueryWrapper < InvoicesitemEntity > invoicesitemWrapper = new QueryWrapper < > ( ) ;
invoicesitemWrapper . lambda ( ) . eq ( InvoicesitemEntity : : getPurchaseorderId , id ) ;
List < InvoicesitemEntity > invoicesitemList = invoicesitemService . list ( invoicesitemWrapper ) ;
List < Invoices_item0itemEntity > Invoices_item0itemList = new ArrayList < > ( ) ;
for ( InvoicesitemEntity invoicesitemEntity : invoicesitemList ) {
//子表
List < Purchaseorder_item0Entity > Purchaseorder_item0List = purchaseorderitemService . GetPurchaseorder_item0List ( id ) ;
for ( Purchaseorder_item0Entity purchaseorder_item0Entity : Purchaseorder_item0List ) {
if ( StringUtils . isNotEmpty ( purchaseorder_item0Entity . getMaterialId ( ) ) ) {
MaterialEntity materialEntity = materialService . getById ( purchaseorder_item0Entity . getMaterialId ( ) ) ;
if ( materialEntity ! = null & & StringUtils . isNotEmpty ( materialEntity . getInArea ( ) ) ) {
purchaseorder_item0Entity . setReservoirareaId ( materialEntity . getInArea ( ) ) ;
ReservoirareaEntity reservoirareaEntity = reservoirareaService . getById ( materialEntity . getInArea ( ) ) ;
if ( reservoirareaEntity ! = null & & StringUtils . isNotEmpty ( reservoirareaEntity . getWarehouseId ( ) ) ) {
purchaseorder_item0Entity . setWarehouseId ( reservoirareaEntity . getWarehouseId ( ) ) ;
}
}
}
}
vo . setPurchaseorder_item0List ( JsonUtil . getJsonToList ( Purchaseorder_item0List , Purchaseorder_item0Model . class ) ) ;
QueryWrapper < InvoicesitemEntity > invoicesitemWrapper = new QueryWrapper < > ( ) ;
invoicesitemWrapper . lambda ( ) . eq ( InvoicesitemEntity : : getPurchaseorderId , id ) ;
List < InvoicesitemEntity > invoicesitemList = invoicesitemService . list ( invoicesitemWrapper ) ;
List < Invoices_item0itemEntity > Invoices_item0itemList = new ArrayList < > ( ) ;
for ( InvoicesitemEntity invoicesitemEntity : invoicesitemList ) {
List < Invoices_item0itemEntity > invoices_item0itemList = purchaseorderitemService . GetInvoices_item0itemList ( invoicesitemEntity . getId ( ) ) ;
Invoices_item0itemList . addAll ( invoices_item0itemList ) ;
}
for ( Invoices_item0itemEntity invoices_item0itemEntity : Invoices_item0itemList ) {
}
vo . setInvoices_item0itemList ( JsonUtil . getJsonToList ( Invoices_item0itemList , Invoices_item0itemModel . class ) ) ;
QueryWrapper < PaymentdocpoEntity > PaymentdocpoWrapper = new QueryWrapper < > ( ) ;
PaymentdocpoWrapper . lambda ( ) . eq ( PaymentdocpoEntity : : getPurchaseOrderNo , entity . getDocumentNo ( ) ) ;
List < PaymentdocpoEntity > paymentdocList = paymentdocpoService . list ( PaymentdocpoWrapper ) ;
List < P aymentitemEntity> PaymentitemList = new ArrayList < > ( ) ;
for ( PaymentdocpoEntity paymentdocpoEntity : paymentdocList ) {
List < PaymentitemEntity > paymentitemlist = purchaseorderitemService . GetPaymentitemList ( paymentdocpoE ntity. getDocumentNo ( ) ) ;
PaymentitemList . addAll ( paymentitemlist ) ;
for ( Invoices_item0itemEntity invoices_item0itemEntity : Invoices_item0itemList ) {
}
vo . setInvoices_item0itemList ( JsonUtil . getJsonToList ( Invoices_item0itemList , Invoices_item0itemModel . class ) ) ;
List < PaymentListVO > paymentList = paymentService . queryByPurchaseorderId ( id ) ;
vo. setPaymentList ( paymentList ) ;
QueryWrapper< PurchasebackEntity > purchasebackWrapper = new QueryWrapper < > ( ) ;
purchasebackWrapper. lambda ( ) . eq ( PurchasebackEntity : : getPurchaseOrderId , id ) ;
List < P urchasebackEntity> PurchasebackList = purchasebackService . list ( purchasebackWrapper ) ;
vo . setPurchasebackList ( PurchasebackList ) ;
List < CollectionpoEntity > CollectionitemList = purchaseorderitemService . GetCollectionitemList ( e ntity. getDocumentNo ( ) ) ;
for ( CollectionpoEntity collectionpoEntity : CollectionitemList ) {
}
for ( PaymentitemEntity paymentitemEntity : PaymentitemList ) {
}
vo . setPaymentList ( JsonUtil . getJsonToList ( PaymentitemList , PaymentListVO . class ) ) ;
List < PurchasebackitemEntity > PurchasebackitemList = purchaseorderitemService . GetPurchasebackitemList ( id ) ;
for ( PurchasebackitemEntity purchasebackitemEntity : PurchasebackitemList ) {
}
vo . setPurchasebackList ( JsonUtil . getJsonToList ( PurchasebackitemList , PurchasebackEntity . class ) ) ;
List < CollectionpoEntity > CollectionitemList = purchaseorderitemService . GetCollectionitemList ( entity . getDocumentNo ( ) ) ;
for ( CollectionpoEntity collectionpoEntity : CollectionitemList ) {
}
vo . setCollectionitemList ( JsonUtil . getJsonToList ( CollectionitemList , CollectionitemModel . class ) ) ;
//副表
vo . setCollectionitemList ( JsonUtil . getJsonToList ( CollectionitemList , CollectionitemModel . class ) ) ;
//副表
return ActionResult . success ( vo ) ;
}
/ * *
* 表 单 信 息 ( 详 情 页 )
*
* @param id
* @return
* /
* 归 档
*
* @param id
* @return
* /
@GetMapping ( "guidang/{id}" )
public ActionResult < PurchaseorderInfoVO > guidang ( @PathVariable ( "id" ) String id ) {
PurchaseorderitemEntity entity = purchaseorderitemService . getInfo ( id ) ;
entity . setStatus ( "3" ) ;
purchaseorderitemService . updateById ( entity ) ;
return ActionResult . success ( "归档成功" ) ;
}
/ * *
* 表 单 信 息 ( 详 情 页 )
*
* @param id
* @return
* /
@GetMapping ( "/detail/{id}" )
public ActionResult < PurchaseorderInfoVO > detailInfo ( @PathVariable ( "id" ) String id ) throws IOException {
PurchaseorderitemEntity entity = purchaseorderitemService . getInfo ( id ) ;
PurchaseorderInfoVO vo = JsonUtil . getJsonToBean ( entity , PurchaseorderInfoVO . class ) ;
//子表数据转换
List < Purchaseorder_item0Entity > jg_purchaseorder_item0List = purchaseorderitemService . GetPurchaseorder_item0List ( id ) ;
List < Purchaseorder_item0Model > jg_purchaseorder_item0ModelList = JsonUtil . getJsonToList ( jg_purchaseorder_item0List , Purchaseorder_item0Model . class ) ;
for ( Purchaseorder_item0Model jg_purchaseorder_item0Model : jg_purchaseorder_item0ModelList ) {
// Map<String,Object> licenseNumMap = new HashMap<>();
// jg_purchaseorder_item0Model.setLicenseNum(generaterSwapUtil.getPopupSelectValue("389754644018016581","license_no","license_no",jg_purchaseorder_item0Model.getLicenseNum(),licenseNumMap));
//子表数据转换
List < Purchaseorder_item0Entity > jg_purchaseorder_item0List = purchaseorderitemService . GetPurchaseorder_item0List ( id ) ;
List < Purchaseorder_item0Model > jg_purchaseorder_item0ModelList = JsonUtil . getJsonToList ( jg_purchaseorder_item0List , Purchaseorder_item0Model . class ) ;
for ( Purchaseorder_item0Model jg_purchaseorder_item0Model : jg_purchaseorder_item0ModelList ) {
Map < String , Object > vehicleIdMap = new HashMap < > ( ) ;
jg_purchaseorder_item0Model . setVehicleId ( generaterSwapUtil . getPopupSelectValue ( "389754644018016581" , "vehicle_id" , "ticketno" , jg_purchaseorder_item0Model . getVehicleId ( ) , vehicleIdMap ) ) ;
Map < String , Object > materialIdMap = new HashMap < > ( ) ;
jg_purchaseorder_item0Model . setMaterialId ( generaterSwapUtil . getPopupSelectValue ( "397736371898382533" , "id" , "item_name" , jg_purchaseorder_item0Model . getMaterialId ( ) , materialIdMap ) ) ;
}
vo . setPurchaseorder_item0List ( jg_purchaseorder_item0ModelList ) ;
List < Invoices_item0itemEntity > jg_invoices_item0List = purchaseorderitemService . GetInvoices_item0itemList ( id ) ;
List < Invoices_item0itemModel > jg_invoices_item0ModelList = JsonUtil . getJsonToList ( jg_invoices_item0List , Invoices_item0itemModel . class ) ;
for ( Invoices_item0itemModel jg_invoices_item0Model : jg_invoices_item0ModelList ) {
}
vo . setPurchaseorder_item0List ( jg_purchaseorder_item0ModelList ) ;
// List<Invoices_item0itemEntity> jg_invoices_item0List = purchaseorderitemService.GetInvoices_item0itemList(id);
// List<Invoices_item0itemModel> jg_invoices_item0ModelList = JsonUtil.getJsonToList(jg_invoices_item0List,Invoices_item0itemModel.class);
// for(Invoices_item0itemModel jg_invoices_item0Model : jg_invoices_item0ModelList){
// }
// vo.setInvoices_item0itemList(jg_invoices_item0ModelList);
vo . setInvoices_item0itemList ( jg_invoices_item0ModelList ) ;
QueryWrapper < InvoicesitemEntity > invoicesitemWrapper = new QueryWrapper < > ( ) ;
invoicesitemWrapper . lambda ( ) . eq ( InvoicesitemEntity : : getPurchaseorderId , id ) ;
@ -550,121 +628,111 @@ public class PurchaseorderController {
}
vo . setInvoices_item0itemList ( JsonUtil . getJsonToList ( Invoices_item0itemList , Invoices_item0itemModel . class ) ) ;
// List<PaymentitemEntity> jg_paymentList = purchaseorderitemService.GetPaymentitemList(id);
// List<PaymentitemModel> jg_paymentModelList = JsonUtil.getJsonToList(jg_paymentList,PaymentitemModel.class);
// for(PaymentitemModel jg_paymentModel : jg_paymentModelList){
// }
// vo.setPaymentitemList(jg_paymentModelList);
QueryWrapper < PaymentdocpoEntity > PaymentdocpoWrapper = new QueryWrapper < > ( ) ;
PaymentdocpoWrapper . lambda ( ) . eq ( PaymentdocpoEntity : : getPurchaseOrderNo , entity . getDocumentNo ( ) ) ;
List < PaymentdocpoEntity > paymentdocList = paymentdocpoService . list ( PaymentdocpoWrapper ) ;
List < PaymentitemEntity > PaymentitemList = new ArrayList < > ( ) ;
for ( PaymentdocpoEntity paymentdocpoEntity : paymentdocList ) {
List < PaymentitemEntity > paymentitemlist = purchaseorderitemService . GetPaymentitemList ( paymentdocpoEntity . getDocumentNo ( ) ) ;
PaymentitemList . addAll ( paymentitemlist ) ;
}
for ( PaymentitemEntity paymentitemEntity : PaymentitemList ) {
}
vo . setPaymentList ( JsonUtil . getJsonToList ( PaymentitemList , PaymentListVO . class ) ) ;
List < PurchasebackitemEntity > jg_purchasebackList = purchaseorderitemService . GetPurchasebackitemList ( id ) ;
List < PurchasebackEntity > jg_purchasebackModelList = JsonUtil . getJsonToList ( jg_purchasebackList , PurchasebackEntity . class ) ;
for ( PurchasebackEntity jg_purchasebackModel : jg_purchasebackModelList ) {
List < PaymentListVO > paymentList = paymentService . queryByPurchaseorderId ( id ) ;
vo . setPaymentList ( paymentList ) ;
QueryWrapper < PurchasebackEntity > purchasebackWrapper = new QueryWrapper < > ( ) ;
purchasebackWrapper . lambda ( ) . eq ( PurchasebackEntity : : getPurchaseOrderId , id ) ;
List < PurchasebackEntity > PurchasebackList = purchasebackService . list ( purchasebackWrapper ) ;
vo . setPurchasebackList ( PurchasebackList ) ;
List < CollectionpoEntity > jg_collectionList = purchaseorderitemService . GetCollectionitemList ( id ) ;
List < CollectionitemModel > jg_collectionModelList = JsonUtil . getJsonToList ( jg_collectionList , CollectionitemModel . class ) ;
for ( CollectionitemModel jg_collectionModel : jg_collectionModelList ) {
}
vo . setPurchasebackList ( jg_purchasebackModelList ) ;
// List<CollectionpoEntity> jg_collectionList = purchaseorderitemService.GetCollectionitemList(id);
// List<CollectionitemModel> jg_collectionModelList = JsonUtil.getJsonToList(jg_collectionList,CollectionitemModel.class);
// for(CollectionitemModel jg_collectionModel : jg_collectionModelList){
// }
// vo.setCollectionitemList(jg_collectionModelList);
vo . setCollectionitemList ( jg_collectionModelList ) ;
List < CollectionpoEntity > CollectionitemList = purchaseorderitemService . GetCollectionitemList ( entity . getDocumentNo ( ) ) ;
for ( CollectionpoEntity collectionpoEntity : CollectionitemList ) {
}
vo . setCollectionitemList ( JsonUtil . getJsonToList ( CollectionitemList , CollectionitemModel . class ) ) ;
//附表数据转换
//附表数据转换
//添加到详情表单对象中
Map < String , Object > contractNameMap = new HashMap < > ( ) ;
// vo.setContractName(generaterSwapUtil.getPopupSelectValue("390143765857220229","contract_name","contract_name",vo.getContractName(),contractNameMap));
vo . setCreatorUserName ( generaterSwapUtil . userSelectValue ( vo . getCreatorUserName ( ) ) ) ;
Map < String , Object > contractCodeMap = new HashMap < > ( ) ;
vo . setContractCode ( generaterSwapUtil . getPopupSelectValue ( "390143765857220229" , "id" , "contract_name" , vo . getContractCode ( ) , contractCodeMap ) ) ;
Map < String , Object > supplierIdMap = new HashMap < > ( ) ;
vo . setSupplierId ( generaterSwapUtil . getPopupSelectValue ( "397751667988199621" , "id" , "supplier_name" , vo . getSupplierId ( ) , supplierIdMap ) ) ;
vo . setCreatorUserName ( generaterSwapUtil . userSelectValue ( vo . getCreatorUserName ( ) ) ) ;
return ActionResult . success ( vo ) ;
}
}
/ * *
* 更 新
*
* @param id
* @return
* /
@PutMapping ( "/{id}" )
@Transactional
public ActionResult update ( @PathVariable ( "id" ) String id , @RequestBody @Valid PurchaseorderUpForm purchaseorderUpForm ) throws DataException {
UserInfo userInfo = userProvider . get ( ) ;
PurchaseorderitemEntity entity = purchaseorderitemService . getInfo ( id ) ;
if ( ! entity . getStatus ( ) . equals ( "0" ) ) {
String info = "" ;
switch ( entity . getStatus ( ) ) {
case "1" :
info = "开票中" ;
break ;
case "2" :
info = "付款中" ;
break ;
case "3" :
info = "归档" ;
break ;
}
return ActionResult . fail ( "已" + info + ",无法编辑!" ) ;
}
if ( entity ! = null ) {
PurchaseorderitemEntity subentity = JsonUtil . getJsonToBean ( purchaseorderUpForm , PurchaseorderitemEntity . class ) ;
subentity . setCreatorUserName ( entity . getCreatorUserName ( ) ) ;
subentity . setCreatorTime ( entity . getCreatorTime ( ) ) ;
purchaseorderitemService . update ( id , subentity ) ;
QueryWrapper < Purchaseorder_item0Entity > Purchaseorder_item0queryWrapper = new QueryWrapper < > ( ) ;
Purchaseorder_item0queryWrapper . lambda ( ) . eq ( Purchaseorder_item0Entity : : getPurchaseorderId , entity . getId ( ) ) ;
purchaseorder_item0Service . remove ( Purchaseorder_item0queryWrapper ) ;
List < Purchaseorder_item0Entity > Purchaseorder_item0List = JsonUtil . getJsonToList ( purchaseorderUpForm . getPurchaseorder_item0List ( ) , Purchaseorder_item0Entity . class ) ;
for ( Purchaseorder_item0Entity entitys : Purchaseorder_item0List ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPurchaseorderId ( entity . getId ( ) ) ;
purchaseorder_item0Service . save ( entitys ) ;
}
QueryWrapper < Invoices_item0itemEntity > Invoices_item0itemqueryWrapper = new QueryWrapper < > ( ) ;
Invoices_item0itemqueryWrapper . lambda ( ) . eq ( Invoices_item0itemEntity : : getPurchaseorderId , entity . getId ( ) ) ;
invoices_item0itemService . remove ( Invoices_item0itemqueryWrapper ) ;
List < Invoices_item0itemEntity > Invoices_item0itemList = JsonUtil . getJsonToList ( purchaseorderUpForm . getInvoices_item0itemList ( ) , Invoices_item0itemEntity . class ) ;
for ( Invoices_item0itemEntity entitys : Invoices_item0itemList ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPurchaseorderId ( entity . getId ( ) ) ;
invoices_item0itemService . save ( entitys ) ;
}
QueryWrapper < PaymentdocpoEntity > PaymentdocpoWrapper = new QueryWrapper < > ( ) ;
PaymentdocpoWrapper . lambda ( ) . eq ( PaymentdocpoEntity : : getPurchaseOrderNo , entity . getDocumentNo ( ) ) ;
List < PaymentdocpoEntity > paymentdocList = paymentdocpoService . list ( PaymentdocpoWrapper ) ;
for ( PaymentdocpoEntity paymentdocpoEntity : paymentdocList ) {
QueryWrapper < PaymentitemEntity > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . lambda ( ) . eq ( PaymentitemEntity : : getPaymentno , paymentdocpoEntity . getDocumentNo ( ) ) ;
paymentitemService . remove ( queryWrapper ) ;
}
List < PaymentitemEntity > PaymentitemList = JsonUtil . getJsonToList ( purchaseorderUpForm . getPaymentList ( ) , PaymentitemEntity . class ) ;
for ( PaymentitemEntity entitys : PaymentitemList ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPaymentno ( entitys . getPaymentno ( ) ) ;
paymentitemService . save ( entitys ) ;
}
/ * *
* 更 新
*
* @param id
* @return
* /
@PutMapping ( "/{id}" )
@Transactional
public ActionResult update ( @PathVariable ( "id" ) String id , @RequestBody @Valid PurchaseorderUpForm purchaseorderUpForm ) throws DataException {
UserInfo userInfo = userProvider . get ( ) ;
PurchaseorderitemEntity entity = purchaseorderitemService . getInfo ( id ) ;
if ( ! entity . getStatus ( ) . equals ( "0" ) ) {
String info = "" ;
switch ( entity . getStatus ( ) ) {
case "1" :
info = "开票中" ;
break ;
case "2" :
info = "付款中" ;
break ;
case "3" :
info = "归档" ;
break ;
}
return ActionResult . fail ( "已" + info + ",无法编辑!" ) ;
}
if ( entity ! = null ) {
PurchaseorderitemEntity subentity = JsonUtil . getJsonToBean ( purchaseorderUpForm , PurchaseorderitemEntity . class ) ;
subentity . setCreatorUserName ( entity . getCreatorUserName ( ) ) ;
subentity . setCreatorTime ( entity . getCreatorTime ( ) ) ;
purchaseorderitemService . update ( id , subentity ) ;
QueryWrapper < Purchaseorder_item0Entity > Purchaseorder_item0queryWrapper = new QueryWrapper < > ( ) ;
Purchaseorder_item0queryWrapper . lambda ( ) . eq ( Purchaseorder_item0Entity : : getPurchaseorderId , entity . getId ( ) ) ;
purchaseorder_item0Service . remove ( Purchaseorder_item0queryWrapper ) ;
List < Purchaseorder_item0Entity > Purchaseorder_item0List = JsonUtil . getJsonToList ( purchaseorderUpForm . getPurchaseorder_item0List ( ) , Purchaseorder_item0Entity . class ) ;
for ( Purchaseorder_item0Entity entitys : Purchaseorder_item0List ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPurchaseorderId ( entity . getId ( ) ) ;
purchaseorder_item0Service . save ( entitys ) ;
PoundlistEntity poundlistEntity = poundlistService . getById ( entitys . getPoundlistId ( ) ) ;
poundlistEntity . setSettlement ( entitys . getSettlement ( ) ) ;
poundlistEntity . setPurchasePrice ( entitys . getPrice ( ) ) ;
poundlistService . updateById ( poundlistEntity ) ;
}
QueryWrapper < Invoices_item0itemEntity > Invoices_item0itemqueryWrapper = new QueryWrapper < > ( ) ;
Invoices_item0itemqueryWrapper . lambda ( ) . eq ( Invoices_item0itemEntity : : getPurchaseorderId , entity . getId ( ) ) ;
invoices_item0itemService . remove ( Invoices_item0itemqueryWrapper ) ;
List < Invoices_item0itemEntity > Invoices_item0itemList = JsonUtil . getJsonToList ( purchaseorderUpForm . getInvoices_item0itemList ( ) , Invoices_item0itemEntity . class ) ;
for ( Invoices_item0itemEntity entitys : Invoices_item0itemList ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPurchaseorderId ( entity . getId ( ) ) ;
invoices_item0itemService . save ( entitys ) ;
}
QueryWrapper < PaymentdocpoEntity > PaymentdocpoWrapper = new QueryWrapper < > ( ) ;
PaymentdocpoWrapper . lambda ( ) . eq ( PaymentdocpoEntity : : getPurchaseOrderNo , entity . getDocumentNo ( ) ) ;
List < PaymentdocpoEntity > paymentdocList = paymentdocpoService . list ( PaymentdocpoWrapper ) ;
for ( PaymentdocpoEntity paymentdocpoEntity : paymentdocList ) {
QueryWrapper < PaymentitemEntity > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . lambda ( ) . eq ( PaymentitemEntity : : getPaymentno , paymentdocpoEntity . getDocumentNo ( ) ) ;
paymentitemService . remove ( queryWrapper ) ;
}
/ * List < PaymentitemEntity > PaymentitemList = JsonUtil . getJsonToList ( purchaseorderUpForm . getPaymentitemList ( ) , PaymentitemEntity . class ) ;
for ( PaymentitemEntity entitys : PaymentitemList ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPaymentno ( entitys . getPaymentno ( ) ) ;
paymentitemService . save ( entitys ) ;
} * /
// QueryWrapper<PaymentitemEntity> PaymentitemqueryWrapper = new QueryWrapper<>();
// PaymentitemqueryWrapper.lambda().eq(PaymentitemEntity::getDocumentno, entity.getDocumentNo());
// paymentitemService.remove(PaymentitemqueryWrapper);
@ -675,41 +743,41 @@ public class PurchaseorderController {
// entitys.setDocumentno(entity.getDocumentNo());
// paymentitemService.save(entitys);
// }
QueryWrapper < PurchasebackitemEntity > PurchasebackitemqueryWrapper = new QueryWrapper < > ( ) ;
PurchasebackitemqueryWrapper . lambda ( ) . eq ( PurchasebackitemEntity : : getPurchaseOrderId , entity . getId ( ) ) ;
purchasebackitemService . remove ( PurchasebackitemqueryWrapper ) ;
List < PurchasebackitemEntity > PurchasebackitemList = JsonUtil . getJsonToList ( purchaseorderUpForm . getPurchaseback List( ) , PurchasebackitemEntity . class ) ;
for ( PurchasebackitemEntity entitys : PurchasebackitemList ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPurchaseOrderId ( entity . getId ( ) ) ;
purchasebackitemService . save ( entitys ) ;
}
QueryWrapper < CollectionpoEntity > CollectionitemqueryWrapper = new QueryWrapper < > ( ) ;
CollectionitemqueryWrapper . lambda ( ) . eq ( CollectionpoEntity : : getSalesOrderNo , entity . getDocumentNo ( ) ) ;
collectionpoService . remove ( CollectionitemqueryWrapper ) ;
List < CollectionpoEntity > CollectionitemList = JsonUtil . getJsonToList ( purchaseorderUpForm . getCollectionitemList ( ) , CollectionpoEntity . class ) ;
for ( CollectionpoEntity entitys : CollectionitemList ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setSalesOrderNo ( entity . getDocumentNo ( ) ) ;
collectionpoService . save ( entitys ) ;
}
return ActionResult . success ( "更新成功" ) ;
} else {
return ActionResult . fail ( "更新失败,数据不存在" ) ;
}
}
/ * *
* 删 除
*
* @param id
* @return
* /
/ * QueryWrapper < PurchasebackitemEntity > PurchasebackitemqueryWrapper = new QueryWrapper < > ( ) ;
PurchasebackitemqueryWrapper . lambda ( ) . eq ( PurchasebackitemEntity : : getPurchaseOrderId , entity . getId ( ) ) ;
purchasebackitemService . remove ( PurchasebackitemqueryWrapper ) ;
List < PurchasebackitemEntity > PurchasebackitemList = JsonUtil . getJsonToList ( purchaseorderUpForm . getPurchaseback item List( ) , PurchasebackitemEntity . class ) ;
for ( PurchasebackitemEntity entitys : PurchasebackitemList ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPurchaseOrderId ( entity . getId ( ) ) ;
purchasebackitemService . save ( entitys ) ;
}
QueryWrapper < CollectionpoEntity > CollectionitemqueryWrapper = new QueryWrapper < > ( ) ;
CollectionitemqueryWrapper . lambda ( ) . eq ( CollectionpoEntity : : getSalesOrderNo , entity . getDocumentNo ( ) ) ;
collectionpoService . remove ( CollectionitemqueryWrapper ) ;
List < CollectionpoEntity > CollectionitemList = JsonUtil . getJsonToList ( purchaseorderUpForm . getCollectionitemList ( ) , CollectionpoEntity . class ) ;
for ( CollectionpoEntity entitys : CollectionitemList ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setSalesOrderNo ( entity . getDocumentNo ( ) ) ;
collectionpoService . save ( entitys ) ;
} * /
return ActionResult . success ( "更新成功" ) ;
} else {
return ActionResult . fail ( "更新失败,数据不存在" ) ;
}
}
/ * *
* 删 除
*
* @param id
* @return
* /
@DeleteMapping ( "/{id}" )
@Transactional
public ActionResult delete ( @PathVariable ( "id" ) String id ) {