库存组织和库存组织详情前后端

product
chuang 2 years ago
parent 78d8fcc073
commit b2a03493ad

@ -0,0 +1,200 @@
package jnpf.inventoryOrd.controller;
import io.swagger.annotations.Api;
import jnpf.base.ActionResult;
import jnpf.base.UserInfo;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.exception.DataException;
import jnpf.inventoryOrd.entity.InventoryOrgEntity;
import jnpf.inventoryOrd.model.inventoryorg.*;
import jnpf.inventoryOrd.service.InventoryOrgService;
import jnpf.util.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Slf4j
@RestController
@Api(tags = "库存组织" , value = "example")
@RequestMapping("/api/example/InventoryOrg")
public class InventoryOrgController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private InventoryOrgService inventoryOrgService;
/**
*
*
* @param inventoryOrgPagination
* @return
*/
@PostMapping("/getList")
public ActionResult list(@RequestBody InventoryOrgPagination inventoryOrgPagination)throws IOException{
List<InventoryOrgEntity> list= inventoryOrgService.getList(inventoryOrgPagination);
//处理id字段转名称若无需转或者为空可删除
for(InventoryOrgEntity entity:list){
entity.setCompanyId(generaterSwapUtil.getDynName("394016341591396805" ,"F_FullName" ,"F_Id","" ,entity.getCompanyId()));
entity.setLastModifyUserName(generaterSwapUtil.userSelectValue(entity.getLastModifyUserName()));
entity.setCreatorUserName(generaterSwapUtil.userSelectValue(entity.getCreatorUserName()));
}
List<InventoryOrgListVO> listVO=JsonUtil.getJsonToList(list,InventoryOrgListVO.class);
for(InventoryOrgListVO inventoryOrgVO:listVO){
}
PageListVO vo=new PageListVO();
vo.setList(listVO);
PaginationVO page=JsonUtil.getJsonToBean(inventoryOrgPagination,PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
*
*
* @param inventoryOrgCrForm
* @return
*/
@PostMapping
@Transactional
public ActionResult create(@RequestBody @Valid InventoryOrgCrForm inventoryOrgCrForm) throws DataException {
String mainId =RandomUtil.uuId();
UserInfo userInfo=userProvider.get();
inventoryOrgCrForm.setCreatorUserName(userInfo.getUserId());
inventoryOrgCrForm.setCreatorTime(DateUtil.getNow());
InventoryOrgEntity entity = JsonUtil.getJsonToBean(inventoryOrgCrForm, InventoryOrgEntity.class);
entity.setId(mainId);
inventoryOrgService.save(entity);
return ActionResult.success("创建成功");
}
/**
*
*
* @param id
* @return
*/
@GetMapping("/{id}")
public ActionResult<InventoryOrgInfoVO> info(@PathVariable("id") String id){
InventoryOrgEntity entity= inventoryOrgService.getInfo(id);
InventoryOrgInfoVO vo=JsonUtil.getJsonToBean(entity, InventoryOrgInfoVO.class);
vo.setLastModifyUserName(generaterSwapUtil.userSelectValue(vo.getLastModifyUserName()));
if(vo.getLastModifyTime()!=null){
vo.setLastModifyTime(vo.getLastModifyTime());
}
vo.setCreatorUserName(generaterSwapUtil.userSelectValue(vo.getCreatorUserName()));
if(vo.getCreatorTime()!=null){
vo.setCreatorTime(vo.getCreatorTime());
}
//子表
//副表
return ActionResult.success(vo);
}
/**
* ()
*
* @param id
* @return
*/
@GetMapping("/detail/{id}")
public ActionResult<InventoryOrgInfoVO> detailInfo(@PathVariable("id") String id){
InventoryOrgEntity entity= inventoryOrgService.getInfo(id);
InventoryOrgInfoVO vo=JsonUtil.getJsonToBean(entity, InventoryOrgInfoVO.class);
//子表数据转换
//附表数据转换
//添加到详情表单对象中
vo.setCompanyId(generaterSwapUtil.getDynName("394016341591396805" ,"F_FullName" ,"F_Id","" ,vo.getCompanyId()));
vo.setLastModifyUserName(generaterSwapUtil.userSelectValue(vo.getLastModifyUserName()));
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 InventoryOrgUpForm inventoryOrgUpForm) throws DataException {
UserInfo userInfo=userProvider.get();
InventoryOrgEntity entity= inventoryOrgService.getInfo(id);
if(entity!=null){
inventoryOrgUpForm.setLastModifyUserName(userInfo.getUserId());
inventoryOrgUpForm.setLastModifyTime(DateUtil.getNow());
InventoryOrgEntity subentity=JsonUtil.getJsonToBean(inventoryOrgUpForm, InventoryOrgEntity.class);
subentity.setCreatorUserName(entity.getCreatorUserName());
subentity.setCreatorTime(entity.getCreatorTime());
inventoryOrgService.update(id, subentity);
return ActionResult.success("更新成功");
}else{
return ActionResult.fail("更新失败,数据不存在");
}
}
/**
*
*
* @param id
* @return
*/
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id){
InventoryOrgEntity entity= inventoryOrgService.getInfo(id);
if(entity!=null){
inventoryOrgService.delete(entity);
}
return ActionResult.success("删除成功");
}
}

@ -0,0 +1,73 @@
package jnpf.inventoryOrd.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
@TableName("jg_inventory_org")
public class InventoryOrgEntity {
@TableId("ID")
private String id;
@TableField("INVENTORY_ORG_NAME")
private String inventoryOrgName;
@TableField("INVENTORY_ORG_CODE")
private String inventoryOrgCode;
@TableField("CREATOR_USER_ID")
private String creatorUserId;
@TableField("CREATOR_USER_NAME")
private String creatorUserName;
@TableField("CREATOR_TIME")
private Date creatorTime;
@TableField("LAST_MODIFY_USER_ID")
private String lastModifyUserId;
@TableField("LAST_MODIFY_USER_NAME")
private String lastModifyUserName;
@TableField("LAST_MODIFY_TIME")
private Date lastModifyTime;
@TableField("DELETE_USER_ID")
private String deleteUserId;
@TableField("DELETE_USER_NAME")
private String deleteUserName;
@TableField("DELETE_TIME")
private Date deleteTime;
@TableField("DELETE_MARK")
private String deleteMark;
@TableField("ORGNIZE_ID")
private String orgnizeId;
@TableField("DEPARTMENT_ID")
private String departmentId;
@TableField("COMPANY_ID")
private String companyId;
}

@ -0,0 +1,17 @@
package jnpf.inventoryOrd.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.inventoryOrd.entity.InventoryOrgEntity;
/**
*
*
* V3.2.0
* LINKAGE-BOOT
* LINKAGE-BOOT
* 2023-02-11
*/
public interface InventoryOrgMapper extends BaseMapper<InventoryOrgEntity> {
}

@ -0,0 +1,52 @@
package jnpf.inventoryOrd.model.inventoryorg;
import lombok.Data;
import java.util.List;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgCrForm {
/** 编码 **/
@JsonProperty("inventoryOrgCode")
private String inventoryOrgCode;
/** 名称 **/
@JsonProperty("inventoryOrgName")
private String inventoryOrgName;
/** 所属组织 **/
@JsonProperty("companyId")
private String companyId;
/** 修改人名称 **/
@JsonProperty("lastModifyUserName")
private String lastModifyUserName;
/** 修改时间 **/
@JsonProperty("lastModifyTime")
private String lastModifyTime;
/** 创建人名称 **/
@JsonProperty("creatorUserName")
private String creatorUserName;
/** 创建时间 **/
@JsonProperty("creatorTime")
private String creatorTime;
}

@ -0,0 +1,56 @@
package jnpf.inventoryOrd.model.inventoryorg;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgInfoVO{
/** 主键 **/
@JsonProperty("id")
private String id;
/** 编码 **/
@JsonProperty("inventoryOrgCode")
private String inventoryOrgCode;
/** 名称 **/
@JsonProperty("inventoryOrgName")
private String inventoryOrgName;
/** 所属组织 **/
@JsonProperty("companyId")
private String companyId;
/** 修改人名称 **/
@JsonProperty("lastModifyUserName")
private String lastModifyUserName;
/** 修改时间 **/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonProperty("lastModifyTime")
private Date lastModifyTime;
/** 创建人名称 **/
@JsonProperty("creatorUserName")
private String creatorUserName;
/** 创建时间 **/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonProperty("creatorTime")
private Date creatorTime;
}

@ -0,0 +1,27 @@
package jnpf.inventoryOrd.model.inventoryorg;
import lombok.Data;
import java.util.Date;
import jnpf.base.Pagination;
import java.util.List;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgListQuery extends Pagination {
/** 编码 */
private String inventoryOrgCode;
/** 名称 */
private String inventoryOrgName;
/**
* id
*/
private String menuId;
}

@ -0,0 +1,64 @@
package jnpf.inventoryOrd.model.inventoryorg;
import lombok.Data;
import java.sql.Time;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgListVO{
/** 主键 */
private String id;
/** 编码 **/
@JsonProperty("inventoryOrgCode")
private String inventoryOrgCode;
/** 名称 **/
@JsonProperty("inventoryOrgName")
private String inventoryOrgName;
/** 所属组织 **/
@JsonProperty("companyId")
private String companyId;
/** 修改人名称 **/
@JsonProperty("lastModifyUserName")
private String lastModifyUserName;
/** 修改时间 **/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonProperty("lastModifyTime")
private Date lastModifyTime;
/** 创建人名称 **/
@JsonProperty("creatorUserName")
private String creatorUserName;
/** 创建时间 **/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonProperty("creatorTime")
private Date creatorTime;
}

@ -0,0 +1,28 @@
package jnpf.inventoryOrd.model.inventoryorg;
import lombok.Data;
import jnpf.base.Pagination;
import java.util.List;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgPagination extends Pagination {
/** 编码 */
private String inventoryOrgCode;
/** 名称 */
private String inventoryOrgName;
/**
* id
*/
private String menuId;
}

@ -0,0 +1,29 @@
package jnpf.inventoryOrd.model.inventoryorg;
import lombok.Data;
import jnpf.base.Pagination;
import java.util.*;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgPaginationExportModel extends Pagination {
private String selectKey;
private String json;
private String dataType;
/** 编码 */
private String inventoryOrgCode;
/** 名称 */
private String inventoryOrgName;
}

@ -0,0 +1,61 @@
package jnpf.inventoryOrd.model.inventoryorg;
import lombok.Data;
import java.util.List;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgUpForm{
/** 主键 */
private String id;
/** 编码 **/
@JsonProperty("inventoryOrgCode")
private String inventoryOrgCode;
/** 名称 **/
@JsonProperty("inventoryOrgName")
private String inventoryOrgName;
/** 所属组织 **/
@JsonProperty("companyId")
private String companyId;
/** 修改人名称 **/
@JsonProperty("lastModifyUserName")
private String lastModifyUserName;
/** 修改时间 **/
@JsonProperty("lastModifyTime")
private String lastModifyTime;
/** 创建人名称 **/
@JsonProperty("creatorUserName")
private String creatorUserName;
/** 创建时间 **/
@JsonProperty("creatorTime")
private String creatorTime;
}

@ -0,0 +1,35 @@
package jnpf.inventoryOrd.service;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.inventoryOrd.entity.InventoryOrgEntity;
import jnpf.inventoryOrd.model.inventoryorg.InventoryOrgPagination;
import java.util.List;
/**
*
*
* V3.2.0
* LINKAGE-BOOT
* LINKAGE-BOOT
* 2023-02-11
*/
public interface InventoryOrgService extends IService<InventoryOrgEntity> {
List<InventoryOrgEntity> getList(InventoryOrgPagination inventoryOrgPagination);
List<InventoryOrgEntity> getTypeList(InventoryOrgPagination inventoryOrgPagination,String dataType);
InventoryOrgEntity getInfo(String id);
void delete(InventoryOrgEntity entity);
void create(InventoryOrgEntity entity);
boolean update( String id, InventoryOrgEntity entity);
// 子表方法
//列表子表数据方法
}

@ -0,0 +1,222 @@
package jnpf.inventoryOrd.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.inventoryOrd.entity.InventoryOrgEntity;
import jnpf.inventoryOrd.mapper.InventoryOrgMapper;
import jnpf.inventoryOrd.model.inventoryorg.InventoryOrgPagination;
import jnpf.inventoryOrd.service.InventoryOrgService;
import jnpf.permission.model.authorize.AuthorizeConditionModel;
import jnpf.permission.service.AuthorizeService;
import jnpf.util.ServletUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* V3.2.0
* LINKAGE-BOOT
* LINKAGE-BOOT
* 2023-02-11
*/
@Service
public class InventoryOrgServiceImpl extends ServiceImpl<InventoryOrgMapper, InventoryOrgEntity> implements InventoryOrgService {
@Autowired
private UserProvider userProvider;
@Autowired
private AuthorizeService authorizeService;
@Override
public List<InventoryOrgEntity> getList(InventoryOrgPagination inventoryOrgPagination){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
int total=0;
int inventoryOrgNum =0;
QueryWrapper<InventoryOrgEntity> inventoryOrgQueryWrapper=new QueryWrapper<>();
boolean pcPermission = false;
boolean appPermission = false;
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
if(isPc && pcPermission){
if (!userProvider.get().getIsAdministrator()){
Object inventoryOrgObj=authorizeService.getCondition(new AuthorizeConditionModel(inventoryOrgQueryWrapper,inventoryOrgPagination.getMenuId(),"inventoryOrg"));
if (ObjectUtil.isEmpty(inventoryOrgObj)){
return new ArrayList<>();
} else {
inventoryOrgQueryWrapper = (QueryWrapper<InventoryOrgEntity>)inventoryOrgObj;
inventoryOrgNum++;
}
}
}
if(!isPc && appPermission){
if (!userProvider.get().getIsAdministrator()){
Object inventoryOrgObj=authorizeService.getCondition(new AuthorizeConditionModel(inventoryOrgQueryWrapper,inventoryOrgPagination.getMenuId(),"inventoryOrg"));
if (ObjectUtil.isEmpty(inventoryOrgObj)){
return new ArrayList<>();
} else {
inventoryOrgQueryWrapper = (QueryWrapper<InventoryOrgEntity>)inventoryOrgObj;
inventoryOrgNum++;
}
}
}
if(StringUtil.isNotEmpty(inventoryOrgPagination.getInventoryOrgCode())){
inventoryOrgNum++;
inventoryOrgQueryWrapper.lambda().like(InventoryOrgEntity::getInventoryOrgCode,inventoryOrgPagination.getInventoryOrgCode());
}
if(StringUtil.isNotEmpty(inventoryOrgPagination.getInventoryOrgName())){
inventoryOrgNum++;
inventoryOrgQueryWrapper.lambda().like(InventoryOrgEntity::getInventoryOrgName,inventoryOrgPagination.getInventoryOrgName());
}
if(AllIdList.size()>0){
inventoryOrgQueryWrapper.lambda().in(InventoryOrgEntity::getId, AllIdList);
}
//排序
if(StringUtil.isEmpty(inventoryOrgPagination.getSidx())){
inventoryOrgQueryWrapper.lambda().orderByDesc(InventoryOrgEntity::getCreatorTime);
}else{
try {
String sidx = inventoryOrgPagination.getSidx();
InventoryOrgEntity inventoryOrgEntity = new InventoryOrgEntity();
Field declaredField = inventoryOrgEntity.getClass().getDeclaredField(sidx);
declaredField.setAccessible(true);
String value = declaredField.getAnnotation(TableField.class).value();
inventoryOrgQueryWrapper="asc".equals(inventoryOrgPagination.getSort().toLowerCase())?inventoryOrgQueryWrapper.orderByAsc(value):inventoryOrgQueryWrapper.orderByDesc(value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
if((total>0 && AllIdList.size()>0) || total==0){
Page<InventoryOrgEntity> page=new Page<>(inventoryOrgPagination.getCurrentPage(), inventoryOrgPagination.getPageSize());
IPage<InventoryOrgEntity> userIPage=this.page(page, inventoryOrgQueryWrapper);
return inventoryOrgPagination.setData(userIPage.getRecords(),userIPage.getTotal());
}else{
List<InventoryOrgEntity> list = new ArrayList();
return inventoryOrgPagination.setData(list, list.size());
}
}
@Override
public List<InventoryOrgEntity> getTypeList(InventoryOrgPagination inventoryOrgPagination,String dataType){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
int total=0;
int inventoryOrgNum =0;
QueryWrapper<InventoryOrgEntity> inventoryOrgQueryWrapper=new QueryWrapper<>();
boolean pcPermission = false;
boolean appPermission = false;
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
if(isPc && pcPermission){
if (!userProvider.get().getIsAdministrator()){
Object inventoryOrgObj=authorizeService.getCondition(new AuthorizeConditionModel(inventoryOrgQueryWrapper,inventoryOrgPagination.getMenuId(),"inventoryOrg"));
if (ObjectUtil.isEmpty(inventoryOrgObj)){
return new ArrayList<>();
} else {
inventoryOrgQueryWrapper = (QueryWrapper<InventoryOrgEntity>)inventoryOrgObj;
inventoryOrgNum++;
}
}
}
if(!isPc && appPermission){
if (!userProvider.get().getIsAdministrator()){
Object inventoryOrgObj=authorizeService.getCondition(new AuthorizeConditionModel(inventoryOrgQueryWrapper,inventoryOrgPagination.getMenuId(),"inventoryOrg"));
if (ObjectUtil.isEmpty(inventoryOrgObj)){
return new ArrayList<>();
} else {
inventoryOrgQueryWrapper = (QueryWrapper<InventoryOrgEntity>)inventoryOrgObj;
inventoryOrgNum++;
}
}
}
if(StringUtil.isNotEmpty(inventoryOrgPagination.getInventoryOrgCode())){
inventoryOrgNum++;
inventoryOrgQueryWrapper.lambda().like(InventoryOrgEntity::getInventoryOrgCode,inventoryOrgPagination.getInventoryOrgCode());
}
if(StringUtil.isNotEmpty(inventoryOrgPagination.getInventoryOrgName())){
inventoryOrgNum++;
inventoryOrgQueryWrapper.lambda().like(InventoryOrgEntity::getInventoryOrgName,inventoryOrgPagination.getInventoryOrgName());
}
if(AllIdList.size()>0){
inventoryOrgQueryWrapper.lambda().in(InventoryOrgEntity::getId, AllIdList);
}
//排序
if(StringUtil.isEmpty(inventoryOrgPagination.getSidx())){
inventoryOrgQueryWrapper.lambda().orderByDesc(InventoryOrgEntity::getCreatorTime);
}else{
try {
String sidx = inventoryOrgPagination.getSidx();
InventoryOrgEntity inventoryOrgEntity = new InventoryOrgEntity();
Field declaredField = inventoryOrgEntity.getClass().getDeclaredField(sidx);
declaredField.setAccessible(true);
String value = declaredField.getAnnotation(TableField.class).value();
inventoryOrgQueryWrapper="asc".equals(inventoryOrgPagination.getSort().toLowerCase())?inventoryOrgQueryWrapper.orderByAsc(value):inventoryOrgQueryWrapper.orderByDesc(value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
if("0".equals(dataType)){
if((total>0 && AllIdList.size()>0) || total==0){
Page<InventoryOrgEntity> page=new Page<>(inventoryOrgPagination.getCurrentPage(), inventoryOrgPagination.getPageSize());
IPage<InventoryOrgEntity> userIPage=this.page(page, inventoryOrgQueryWrapper);
return inventoryOrgPagination.setData(userIPage.getRecords(),userIPage.getTotal());
}else{
List<InventoryOrgEntity> list = new ArrayList();
return inventoryOrgPagination.setData(list, list.size());
}
}else{
return this.list(inventoryOrgQueryWrapper);
}
}
@Override
public InventoryOrgEntity getInfo(String id){
QueryWrapper<InventoryOrgEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(InventoryOrgEntity::getId,id);
return this.getOne(queryWrapper);
}
@Override
public void create(InventoryOrgEntity entity){
this.save(entity);
}
@Override
public boolean update(String id, InventoryOrgEntity entity){
entity.setId(id);
return this.updateById(entity);
}
@Override
public void delete(InventoryOrgEntity entity){
if(entity!=null){
this.removeById(entity.getId());
}
}
//子表方法
//列表子表数据方法
}

@ -0,0 +1,328 @@
package jnpf.inventoryOrdDetail.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jnpf.base.ActionResult;
import jnpf.base.UserInfo;
import jnpf.base.vo.DownloadVO;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.config.ConfigValueUtil;
import jnpf.exception.DataException;
import jnpf.inventoryOrdDetail.entity.InventoryOrgDetailEntity;
import jnpf.inventoryOrdDetail.model.inventoryorgdetail.*;
import jnpf.inventoryOrdDetail.service.InventoryOrgDetailService;
import jnpf.util.*;
import jnpf.util.enums.FileTypeEnum;
import jnpf.util.file.UploadUtil;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Slf4j
@RestController
@Api(tags = "库存组织详细" , value = "example")
@RequestMapping("/api/example/InventoryOrgDetail")
public class InventoryOrgDetailController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private ConfigValueUtil configValueUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private InventoryOrgDetailService inventoryOrgDetailService;
/**
*
*
* @param inventoryOrgDetailPagination
* @return
*/
@PostMapping("/getList")
public ActionResult list(@RequestBody InventoryOrgDetailPagination inventoryOrgDetailPagination)throws IOException{
List<InventoryOrgDetailEntity> list= inventoryOrgDetailService.getList(inventoryOrgDetailPagination);
//处理id字段转名称若无需转或者为空可删除
for(InventoryOrgDetailEntity entity:list){
Map<String,Object> inventoryIdMap = new HashMap<>();
entity.setInventoryId(generaterSwapUtil.getPopupSelectValue("394085757268070853","id","inventory_org_name",entity.getInventoryId(),inventoryIdMap));
entity.setLastModifyUserName(generaterSwapUtil.userSelectValue(entity.getLastModifyUserName()));
entity.setCreatorUserName(generaterSwapUtil.userSelectValue(entity.getCreatorUserName()));
}
List<InventoryOrgDetailListVO> listVO=JsonUtil.getJsonToList(list,InventoryOrgDetailListVO.class);
for(InventoryOrgDetailListVO inventoryOrgDetailVO:listVO){
}
PageListVO vo=new PageListVO();
vo.setList(listVO);
PaginationVO page=JsonUtil.getJsonToBean(inventoryOrgDetailPagination,PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
*
*
* @param inventoryOrgDetailCrForm
* @return
*/
@PostMapping
@Transactional
public ActionResult create(@RequestBody @Valid InventoryOrgDetailCrForm inventoryOrgDetailCrForm) throws DataException {
String mainId =RandomUtil.uuId();
UserInfo userInfo=userProvider.get();
inventoryOrgDetailCrForm.setCreatorUserName(userInfo.getUserId());
inventoryOrgDetailCrForm.setCreatorTime(DateUtil.getNow());
InventoryOrgDetailEntity entity = JsonUtil.getJsonToBean(inventoryOrgDetailCrForm, InventoryOrgDetailEntity.class);
entity.setId(mainId);
inventoryOrgDetailService.save(entity);
return ActionResult.success("创建成功");
}
/**
*
*
* @return
*/
@ApiOperation("模板下载")
@GetMapping("/templateDownload")
public ActionResult<DownloadVO> TemplateDownload(){
UserInfo userInfo=userProvider.get();
DownloadVO vo=DownloadVO.builder().build();
try{
vo.setName("职员信息.xlsx");
vo.setUrl(UploaderUtil.uploaderFile("/api/Common/DownloadModel?encryption=" ,userInfo.getId()+"#"+"职员信息.xlsx"+"#"+"Temporary"));
}catch(Exception e){
log.error("信息导出Excel错误:{}" ,e.getMessage());
}
return ActionResult.success(vo);
}
/**
* Excel
*
* @return
*/
@ApiOperation("导出Excel")
@GetMapping("/Actions/Export")
public ActionResult Export(InventoryOrgDetailPaginationExportModel inventoryOrgDetailPaginationExportModel) throws IOException {
if (StringUtil.isEmpty(inventoryOrgDetailPaginationExportModel.getSelectKey())){
return ActionResult.fail("请选择导出字段");
}
InventoryOrgDetailPagination inventoryOrgDetailPagination=JsonUtil.getJsonToBean(inventoryOrgDetailPaginationExportModel, InventoryOrgDetailPagination.class);
List<InventoryOrgDetailEntity> list= inventoryOrgDetailService.getTypeList(inventoryOrgDetailPagination,inventoryOrgDetailPaginationExportModel.getDataType());
//处理id字段转名称若无需转或者为空可删除
for(InventoryOrgDetailEntity entity:list){
Map<String,Object> inventoryIdMap = new HashMap<>();
entity.setInventoryId(generaterSwapUtil.getPopupSelectValue("394085757268070853","id","inventory_org_name",entity.getInventoryId(),inventoryIdMap));
entity.setLastModifyUserName(generaterSwapUtil.userSelectValue(entity.getLastModifyUserName()));
entity.setCreatorUserName(generaterSwapUtil.userSelectValue(entity.getCreatorUserName()));
}
List<InventoryOrgDetailListVO> listVO=JsonUtil.getJsonToList(list,InventoryOrgDetailListVO.class);
for(InventoryOrgDetailListVO inventoryOrgDetailVO:listVO){
}
//转换为map输出
List<Map<String, Object>>mapList=JsonUtil.getJsonToListMap(JsonUtil.getObjectToStringDateFormat(listVO,"yyyy-MM-dd HH:mm:ss"));
String[]keys=!StringUtil.isEmpty(inventoryOrgDetailPaginationExportModel.getSelectKey())?inventoryOrgDetailPaginationExportModel.getSelectKey().split(","):new String[0];
UserInfo userInfo=userProvider.get();
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),mapList,keys,userInfo);
return ActionResult.success(vo);
}
//导出表格
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){
case "inventoryOrgDetailCode" :
entitys.add(new ExcelExportEntity("编码" ,"inventoryOrgDetailCode"));
break;
case "inventoryOrgDetailName" :
entitys.add(new ExcelExportEntity("名称" ,"inventoryOrgDetailName"));
break;
case "inventoryId" :
entitys.add(new ExcelExportEntity("库存组织" ,"inventoryId"));
break;
case "lastModifyUserName" :
entitys.add(new ExcelExportEntity("修改人名称" ,"lastModifyUserName"));
break;
case "lastModifyTime" :
entitys.add(new ExcelExportEntity("修改时间" ,"lastModifyTime"));
break;
case "creatorUserName" :
entitys.add(new ExcelExportEntity("创建人名称" ,"creatorUserName"));
break;
case "creatorTime" :
entitys.add(new ExcelExportEntity("创建时间" ,"creatorTime"));
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";
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"));
} catch (Exception e) {
log.error("信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return vo;
}
/**
*
*
* @param id
* @return
*/
@GetMapping("/{id}")
public ActionResult<InventoryOrgDetailInfoVO> info(@PathVariable("id") String id){
InventoryOrgDetailEntity entity= inventoryOrgDetailService.getInfo(id);
InventoryOrgDetailInfoVO vo=JsonUtil.getJsonToBean(entity, InventoryOrgDetailInfoVO.class);
vo.setLastModifyUserName(generaterSwapUtil.userSelectValue(vo.getLastModifyUserName()));
if(vo.getLastModifyTime()!=null){
vo.setLastModifyTime(vo.getLastModifyTime());
}
vo.setCreatorUserName(generaterSwapUtil.userSelectValue(vo.getCreatorUserName()));
if(vo.getCreatorTime()!=null){
vo.setCreatorTime(vo.getCreatorTime());
}
//子表
//副表
return ActionResult.success(vo);
}
/**
* ()
*
* @param id
* @return
*/
@GetMapping("/detail/{id}")
public ActionResult<InventoryOrgDetailInfoVO> detailInfo(@PathVariable("id") String id){
InventoryOrgDetailEntity entity= inventoryOrgDetailService.getInfo(id);
InventoryOrgDetailInfoVO vo=JsonUtil.getJsonToBean(entity, InventoryOrgDetailInfoVO.class);
//子表数据转换
//附表数据转换
//添加到详情表单对象中
Map<String,Object> inventoryIdMap = new HashMap<>();
vo.setInventoryId(generaterSwapUtil.getPopupSelectValue("394085757268070853","id","inventory_org_name",vo.getInventoryId(),inventoryIdMap));
vo.setLastModifyUserName(generaterSwapUtil.userSelectValue(vo.getLastModifyUserName()));
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 InventoryOrgDetailUpForm inventoryOrgDetailUpForm) throws DataException {
UserInfo userInfo=userProvider.get();
InventoryOrgDetailEntity entity= inventoryOrgDetailService.getInfo(id);
if(entity!=null){
inventoryOrgDetailUpForm.setLastModifyUserName(userInfo.getUserId());
inventoryOrgDetailUpForm.setLastModifyTime(DateUtil.getNow());
InventoryOrgDetailEntity subentity=JsonUtil.getJsonToBean(inventoryOrgDetailUpForm, InventoryOrgDetailEntity.class);
subentity.setCreatorUserName(entity.getCreatorUserName());
subentity.setCreatorTime(entity.getCreatorTime());
inventoryOrgDetailService.update(id, subentity);
return ActionResult.success("更新成功");
}else{
return ActionResult.fail("更新失败,数据不存在");
}
}
/**
*
*
* @param id
* @return
*/
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id){
InventoryOrgDetailEntity entity= inventoryOrgDetailService.getInfo(id);
if(entity!=null){
inventoryOrgDetailService.delete(entity);
}
return ActionResult.success("删除成功");
}
}

@ -0,0 +1,71 @@
package jnpf.inventoryOrdDetail.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
@TableName("jg_inventory_org_detail")
public class InventoryOrgDetailEntity {
@TableId("ID")
private String id;
@TableField("INVENTORY_ID")
private String inventoryId;
@TableField("INVENTORY_ORG_DETAIL_NAME")
private String inventoryOrgDetailName;
@TableField("INVENTORY_ORG_DETAIL_CODE")
private String inventoryOrgDetailCode;
@TableField("CREATOR_USER_ID")
private String creatorUserId;
@TableField("CREATOR_USER_NAME")
private String creatorUserName;
@TableField("CREATOR_TIME")
private Date creatorTime;
@TableField("LAST_MODIFY_USER_ID")
private String lastModifyUserId;
@TableField("LAST_MODIFY_USER_NAME")
private String lastModifyUserName;
@TableField("LAST_MODIFY_TIME")
private Date lastModifyTime;
@TableField("DELETE_USER_ID")
private String deleteUserId;
@TableField("DELETE_USER_NAME")
private String deleteUserName;
@TableField("DELETE_TIME")
private Date deleteTime;
@TableField("DELETE_MARK")
private String deleteMark;
@TableField("ORGNIZE_ID")
private String orgnizeId;
@TableField("DEPARTMENT_ID")
private String departmentId;
}

@ -0,0 +1,17 @@
package jnpf.inventoryOrdDetail.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.inventoryOrdDetail.entity.InventoryOrgDetailEntity;
/**
*
*
* V3.2.0
* LINKAGE-BOOT
* LINKAGE-BOOT
* 2023-02-11
*/
public interface InventoryOrgDetailMapper extends BaseMapper<InventoryOrgDetailEntity> {
}

@ -0,0 +1,52 @@
package jnpf.inventoryOrdDetail.model.inventoryorgdetail;
import lombok.Data;
import java.util.List;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgDetailCrForm {
/** 编码 **/
@JsonProperty("inventoryOrgDetailCode")
private String inventoryOrgDetailCode;
/** 名称 **/
@JsonProperty("inventoryOrgDetailName")
private String inventoryOrgDetailName;
/** 库存组织 **/
@JsonProperty("inventoryId")
private String inventoryId;
/** 修改人名称 **/
@JsonProperty("lastModifyUserName")
private String lastModifyUserName;
/** 修改时间 **/
@JsonProperty("lastModifyTime")
private String lastModifyTime;
/** 创建人名称 **/
@JsonProperty("creatorUserName")
private String creatorUserName;
/** 创建时间 **/
@JsonProperty("creatorTime")
private String creatorTime;
}

@ -0,0 +1,56 @@
package jnpf.inventoryOrdDetail.model.inventoryorgdetail;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgDetailInfoVO{
/** 主键 **/
@JsonProperty("id")
private String id;
/** 编码 **/
@JsonProperty("inventoryOrgDetailCode")
private String inventoryOrgDetailCode;
/** 名称 **/
@JsonProperty("inventoryOrgDetailName")
private String inventoryOrgDetailName;
/** 库存组织 **/
@JsonProperty("inventoryId")
private String inventoryId;
/** 修改人名称 **/
@JsonProperty("lastModifyUserName")
private String lastModifyUserName;
/** 修改时间 **/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonProperty("lastModifyTime")
private Date lastModifyTime;
/** 创建人名称 **/
@JsonProperty("creatorUserName")
private String creatorUserName;
/** 创建时间 **/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonProperty("creatorTime")
private Date creatorTime;
}

@ -0,0 +1,27 @@
package jnpf.inventoryOrdDetail.model.inventoryorgdetail;
import lombok.Data;
import java.util.Date;
import jnpf.base.Pagination;
import java.util.List;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgDetailListQuery extends Pagination {
/** 编码 */
private String inventoryOrgDetailCode;
/** 名称 */
private String inventoryOrgDetailName;
/**
* id
*/
private String menuId;
}

@ -0,0 +1,64 @@
package jnpf.inventoryOrdDetail.model.inventoryorgdetail;
import lombok.Data;
import java.sql.Time;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgDetailListVO{
/** 主键 */
private String id;
/** 编码 **/
@JsonProperty("inventoryOrgDetailCode")
private String inventoryOrgDetailCode;
/** 名称 **/
@JsonProperty("inventoryOrgDetailName")
private String inventoryOrgDetailName;
/** 库存组织 **/
@JsonProperty("inventoryId")
private String inventoryId;
/** 修改人名称 **/
@JsonProperty("lastModifyUserName")
private String lastModifyUserName;
/** 修改时间 **/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonProperty("lastModifyTime")
private Date lastModifyTime;
/** 创建人名称 **/
@JsonProperty("creatorUserName")
private String creatorUserName;
/** 创建时间 **/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonProperty("creatorTime")
private Date creatorTime;
}

@ -0,0 +1,28 @@
package jnpf.inventoryOrdDetail.model.inventoryorgdetail;
import lombok.Data;
import jnpf.base.Pagination;
import java.util.List;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgDetailPagination extends Pagination {
/** 编码 */
private String inventoryOrgDetailCode;
/** 名称 */
private String inventoryOrgDetailName;
/**
* id
*/
private String menuId;
}

@ -0,0 +1,29 @@
package jnpf.inventoryOrdDetail.model.inventoryorgdetail;
import lombok.Data;
import jnpf.base.Pagination;
import java.util.*;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgDetailPaginationExportModel extends Pagination {
private String selectKey;
private String json;
private String dataType;
/** 编码 */
private String inventoryOrgDetailCode;
/** 名称 */
private String inventoryOrgDetailName;
}

@ -0,0 +1,61 @@
package jnpf.inventoryOrdDetail.model.inventoryorgdetail;
import lombok.Data;
import java.util.List;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-11
*/
@Data
public class InventoryOrgDetailUpForm{
/** 主键 */
private String id;
/** 编码 **/
@JsonProperty("inventoryOrgDetailCode")
private String inventoryOrgDetailCode;
/** 名称 **/
@JsonProperty("inventoryOrgDetailName")
private String inventoryOrgDetailName;
/** 库存组织 **/
@JsonProperty("inventoryId")
private String inventoryId;
/** 修改人名称 **/
@JsonProperty("lastModifyUserName")
private String lastModifyUserName;
/** 修改时间 **/
@JsonProperty("lastModifyTime")
private String lastModifyTime;
/** 创建人名称 **/
@JsonProperty("creatorUserName")
private String creatorUserName;
/** 创建时间 **/
@JsonProperty("creatorTime")
private String creatorTime;
}

@ -0,0 +1,35 @@
package jnpf.inventoryOrdDetail.service;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.inventoryOrdDetail.entity.InventoryOrgDetailEntity;
import jnpf.inventoryOrdDetail.model.inventoryorgdetail.InventoryOrgDetailPagination;
import java.util.List;
/**
*
*
* V3.2.0
* LINKAGE-BOOT
* LINKAGE-BOOT
* 2023-02-11
*/
public interface InventoryOrgDetailService extends IService<InventoryOrgDetailEntity> {
List<InventoryOrgDetailEntity> getList(InventoryOrgDetailPagination inventoryOrgDetailPagination);
List<InventoryOrgDetailEntity> getTypeList(InventoryOrgDetailPagination inventoryOrgDetailPagination,String dataType);
InventoryOrgDetailEntity getInfo(String id);
void delete(InventoryOrgDetailEntity entity);
void create(InventoryOrgDetailEntity entity);
boolean update( String id, InventoryOrgDetailEntity entity);
// 子表方法
//列表子表数据方法
}

@ -0,0 +1,222 @@
package jnpf.inventoryOrdDetail.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.inventoryOrdDetail.entity.InventoryOrgDetailEntity;
import jnpf.inventoryOrdDetail.mapper.InventoryOrgDetailMapper;
import jnpf.inventoryOrdDetail.model.inventoryorgdetail.InventoryOrgDetailPagination;
import jnpf.inventoryOrdDetail.service.InventoryOrgDetailService;
import jnpf.permission.model.authorize.AuthorizeConditionModel;
import jnpf.permission.service.AuthorizeService;
import jnpf.util.ServletUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* V3.2.0
* LINKAGE-BOOT
* LINKAGE-BOOT
* 2023-02-11
*/
@Service
public class InventoryOrgDetailServiceImpl extends ServiceImpl<InventoryOrgDetailMapper, InventoryOrgDetailEntity> implements InventoryOrgDetailService {
@Autowired
private UserProvider userProvider;
@Autowired
private AuthorizeService authorizeService;
@Override
public List<InventoryOrgDetailEntity> getList(InventoryOrgDetailPagination inventoryOrgDetailPagination){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
int total=0;
int inventoryOrgDetailNum =0;
QueryWrapper<InventoryOrgDetailEntity> inventoryOrgDetailQueryWrapper=new QueryWrapper<>();
boolean pcPermission = false;
boolean appPermission = false;
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
if(isPc && pcPermission){
if (!userProvider.get().getIsAdministrator()){
Object inventoryOrgDetailObj=authorizeService.getCondition(new AuthorizeConditionModel(inventoryOrgDetailQueryWrapper,inventoryOrgDetailPagination.getMenuId(),"inventoryOrgDetail"));
if (ObjectUtil.isEmpty(inventoryOrgDetailObj)){
return new ArrayList<>();
} else {
inventoryOrgDetailQueryWrapper = (QueryWrapper<InventoryOrgDetailEntity>)inventoryOrgDetailObj;
inventoryOrgDetailNum++;
}
}
}
if(!isPc && appPermission){
if (!userProvider.get().getIsAdministrator()){
Object inventoryOrgDetailObj=authorizeService.getCondition(new AuthorizeConditionModel(inventoryOrgDetailQueryWrapper,inventoryOrgDetailPagination.getMenuId(),"inventoryOrgDetail"));
if (ObjectUtil.isEmpty(inventoryOrgDetailObj)){
return new ArrayList<>();
} else {
inventoryOrgDetailQueryWrapper = (QueryWrapper<InventoryOrgDetailEntity>)inventoryOrgDetailObj;
inventoryOrgDetailNum++;
}
}
}
if(StringUtil.isNotEmpty(inventoryOrgDetailPagination.getInventoryOrgDetailCode())){
inventoryOrgDetailNum++;
inventoryOrgDetailQueryWrapper.lambda().like(InventoryOrgDetailEntity::getInventoryOrgDetailCode,inventoryOrgDetailPagination.getInventoryOrgDetailCode());
}
if(StringUtil.isNotEmpty(inventoryOrgDetailPagination.getInventoryOrgDetailName())){
inventoryOrgDetailNum++;
inventoryOrgDetailQueryWrapper.lambda().like(InventoryOrgDetailEntity::getInventoryOrgDetailName,inventoryOrgDetailPagination.getInventoryOrgDetailName());
}
if(AllIdList.size()>0){
inventoryOrgDetailQueryWrapper.lambda().in(InventoryOrgDetailEntity::getId, AllIdList);
}
//排序
if(StringUtil.isEmpty(inventoryOrgDetailPagination.getSidx())){
inventoryOrgDetailQueryWrapper.lambda().orderByDesc(InventoryOrgDetailEntity::getCreatorTime);
}else{
try {
String sidx = inventoryOrgDetailPagination.getSidx();
InventoryOrgDetailEntity inventoryOrgDetailEntity = new InventoryOrgDetailEntity();
Field declaredField = inventoryOrgDetailEntity.getClass().getDeclaredField(sidx);
declaredField.setAccessible(true);
String value = declaredField.getAnnotation(TableField.class).value();
inventoryOrgDetailQueryWrapper="asc".equals(inventoryOrgDetailPagination.getSort().toLowerCase())?inventoryOrgDetailQueryWrapper.orderByAsc(value):inventoryOrgDetailQueryWrapper.orderByDesc(value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
if((total>0 && AllIdList.size()>0) || total==0){
Page<InventoryOrgDetailEntity> page=new Page<>(inventoryOrgDetailPagination.getCurrentPage(), inventoryOrgDetailPagination.getPageSize());
IPage<InventoryOrgDetailEntity> userIPage=this.page(page, inventoryOrgDetailQueryWrapper);
return inventoryOrgDetailPagination.setData(userIPage.getRecords(),userIPage.getTotal());
}else{
List<InventoryOrgDetailEntity> list = new ArrayList();
return inventoryOrgDetailPagination.setData(list, list.size());
}
}
@Override
public List<InventoryOrgDetailEntity> getTypeList(InventoryOrgDetailPagination inventoryOrgDetailPagination,String dataType){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
int total=0;
int inventoryOrgDetailNum =0;
QueryWrapper<InventoryOrgDetailEntity> inventoryOrgDetailQueryWrapper=new QueryWrapper<>();
boolean pcPermission = false;
boolean appPermission = false;
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
if(isPc && pcPermission){
if (!userProvider.get().getIsAdministrator()){
Object inventoryOrgDetailObj=authorizeService.getCondition(new AuthorizeConditionModel(inventoryOrgDetailQueryWrapper,inventoryOrgDetailPagination.getMenuId(),"inventoryOrgDetail"));
if (ObjectUtil.isEmpty(inventoryOrgDetailObj)){
return new ArrayList<>();
} else {
inventoryOrgDetailQueryWrapper = (QueryWrapper<InventoryOrgDetailEntity>)inventoryOrgDetailObj;
inventoryOrgDetailNum++;
}
}
}
if(!isPc && appPermission){
if (!userProvider.get().getIsAdministrator()){
Object inventoryOrgDetailObj=authorizeService.getCondition(new AuthorizeConditionModel(inventoryOrgDetailQueryWrapper,inventoryOrgDetailPagination.getMenuId(),"inventoryOrgDetail"));
if (ObjectUtil.isEmpty(inventoryOrgDetailObj)){
return new ArrayList<>();
} else {
inventoryOrgDetailQueryWrapper = (QueryWrapper<InventoryOrgDetailEntity>)inventoryOrgDetailObj;
inventoryOrgDetailNum++;
}
}
}
if(StringUtil.isNotEmpty(inventoryOrgDetailPagination.getInventoryOrgDetailCode())){
inventoryOrgDetailNum++;
inventoryOrgDetailQueryWrapper.lambda().like(InventoryOrgDetailEntity::getInventoryOrgDetailCode,inventoryOrgDetailPagination.getInventoryOrgDetailCode());
}
if(StringUtil.isNotEmpty(inventoryOrgDetailPagination.getInventoryOrgDetailName())){
inventoryOrgDetailNum++;
inventoryOrgDetailQueryWrapper.lambda().like(InventoryOrgDetailEntity::getInventoryOrgDetailName,inventoryOrgDetailPagination.getInventoryOrgDetailName());
}
if(AllIdList.size()>0){
inventoryOrgDetailQueryWrapper.lambda().in(InventoryOrgDetailEntity::getId, AllIdList);
}
//排序
if(StringUtil.isEmpty(inventoryOrgDetailPagination.getSidx())){
inventoryOrgDetailQueryWrapper.lambda().orderByDesc(InventoryOrgDetailEntity::getCreatorTime);
}else{
try {
String sidx = inventoryOrgDetailPagination.getSidx();
InventoryOrgDetailEntity inventoryOrgDetailEntity = new InventoryOrgDetailEntity();
Field declaredField = inventoryOrgDetailEntity.getClass().getDeclaredField(sidx);
declaredField.setAccessible(true);
String value = declaredField.getAnnotation(TableField.class).value();
inventoryOrgDetailQueryWrapper="asc".equals(inventoryOrgDetailPagination.getSort().toLowerCase())?inventoryOrgDetailQueryWrapper.orderByAsc(value):inventoryOrgDetailQueryWrapper.orderByDesc(value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
if("0".equals(dataType)){
if((total>0 && AllIdList.size()>0) || total==0){
Page<InventoryOrgDetailEntity> page=new Page<>(inventoryOrgDetailPagination.getCurrentPage(), inventoryOrgDetailPagination.getPageSize());
IPage<InventoryOrgDetailEntity> userIPage=this.page(page, inventoryOrgDetailQueryWrapper);
return inventoryOrgDetailPagination.setData(userIPage.getRecords(),userIPage.getTotal());
}else{
List<InventoryOrgDetailEntity> list = new ArrayList();
return inventoryOrgDetailPagination.setData(list, list.size());
}
}else{
return this.list(inventoryOrgDetailQueryWrapper);
}
}
@Override
public InventoryOrgDetailEntity getInfo(String id){
QueryWrapper<InventoryOrgDetailEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(InventoryOrgDetailEntity::getId,id);
return this.getOne(queryWrapper);
}
@Override
public void create(InventoryOrgDetailEntity entity){
this.save(entity);
}
@Override
public boolean update(String id, InventoryOrgDetailEntity entity){
entity.setId(id);
return this.updateById(entity);
}
@Override
public void delete(InventoryOrgDetailEntity entity){
if(entity!=null){
this.removeById(entity.getId());
}
}
//子表方法
//列表子表数据方法
}

@ -0,0 +1,99 @@
package jnpf.ocr_sdk.baiduUtils;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;
/**
* @Author: WangChuang
* @Date: 10/2/2023 9:29
* @Description //注释:
* @Version 1.0
*/
public class BaiduUtils {
// 官网获取的 API Ke
private static String clientId="adcBcYqcGzoyDjQTsWTSp8No";
// 官网获取的 Secret Key
private static String clientSecret="YMOhZfVoVYvgLcTXjoOF62ZYfvGgMpr4";
// 必须参数固定为client_credentials
private String grant="grant_type";
private String accessTokenUrl="https://aip.baidubce.com/oauth/2.0/token";
/**
* token
* @return
* {
* "access_token": "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567",
* "expires_in": 2592000
* }
*/
public static String getAuth() {
// 官网获取的 API Key 更新为你注册的
String clientId ="adcBcYqcGzoyDjQTsWTSp8No" ;
// 官网获取的 Secret Key 更新为你注册的
String clientSecret = "YMOhZfVoVYvgLcTXjoOF62ZYfvGgMpr4";
return getAuth(clientId, clientSecret);
}
/**
* API访token
* token.
* @param ak - API Key
* @param sk - Secret Key
* @return assess_token
* "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567"
*/
public static String getAuth(String ak, String sk) {
// 获取token地址
String authHost = "https://aip.baidubce.com/oauth/2.0/token?";
String getAccessTokenUrl = authHost
// 1. grant_type为固定参数
+ "grant_type=client_credentials"
// 2. 官网获取的 API Key
+ "&client_id=" + ak
// 3. 官网获取的 Secret Key
+ "&client_secret=" + sk;
try {
URL realUrl = new URL(getAccessTokenUrl);
// 打开和URL之间的连接
HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();
connection.setRequestMethod("GET");
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
for (String key : map.keySet()) {
System.err.println(key + "--->" + map.get(key));
}
// 定义 BufferedReader输入流来读取URL的响应
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String result = "";
String line;
while ((line = in.readLine()) != null) {
result += line;
}
/**
*
*/
System.err.println("result:" + result);
JSONObject jsonObject = new JSONObject(result);
String access_token = jsonObject.getString("access_token");
return access_token;
} catch (Exception e) {
System.err.printf("获取token失败");
e.printStackTrace(System.err);
}
return null;
}
public static void main(String[] args) {
String auth = BaiduUtils.getAuth();
System.out.println(auth);
}
}

@ -0,0 +1,65 @@
package jnpf.ocr_sdk.baiduUtils;
/**
* Base64
*/
public class Base64Util {
private static final char last2byte = (char) Integer.parseInt("00000011", 2);
private static final char last4byte = (char) Integer.parseInt("00001111", 2);
private static final char last6byte = (char) Integer.parseInt("00111111", 2);
private static final char lead6byte = (char) Integer.parseInt("11111100", 2);
private static final char lead4byte = (char) Integer.parseInt("11110000", 2);
private static final char lead2byte = (char) Integer.parseInt("11000000", 2);
private static final char[] encodeTable = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
public Base64Util() {
}
public static String encode(byte[] from) {
StringBuilder to = new StringBuilder((int) ((double) from.length * 1.34D) + 3);
int num = 0;
char currentByte = 0;
int i;
for (i = 0; i < from.length; ++i) {
for (num %= 8; num < 8; num += 6) {
switch (num) {
case 0:
currentByte = (char) (from[i] & lead6byte);
currentByte = (char) (currentByte >>> 2);
case 1:
case 3:
case 5:
default:
break;
case 2:
currentByte = (char) (from[i] & last6byte);
break;
case 4:
currentByte = (char) (from[i] & last4byte);
currentByte = (char) (currentByte << 2);
if (i + 1 < from.length) {
currentByte = (char) (currentByte | (from[i + 1] & lead2byte) >>> 6);
}
break;
case 6:
currentByte = (char) (from[i] & last2byte);
currentByte = (char) (currentByte << 4);
if (i + 1 < from.length) {
currentByte = (char) (currentByte | (from[i + 1] & lead4byte) >>> 4);
}
}
to.append(encodeTable[currentByte]);
}
}
if (to.length() % 4 != 0) {
for (i = 4 - to.length() % 4; i > 0; --i) {
to.append("=");
}
}
return to.toString();
}
}

@ -0,0 +1,73 @@
package jnpf.ocr_sdk.baiduUtils;
import java.io.*;
/**
*
*/
public class FileUtil {
/**
*
*/
public static String readFileAsString(String filePath) throws IOException {
File file = new File(filePath);
if (!file.exists()) {
throw new FileNotFoundException(filePath);
}
if (file.length() > 1024 * 1024 * 1024) {
throw new IOException("File is too large");
}
StringBuilder sb = new StringBuilder((int) (file.length()));
// 创建字节输入流
FileInputStream fis = new FileInputStream(filePath);
// 创建一个长度为10240的Buffer
byte[] bbuf = new byte[10240];
// 用于保存实际读取的字节数
int hasRead = 0;
while ( (hasRead = fis.read(bbuf)) > 0 ) {
sb.append(new String(bbuf, 0, hasRead));
}
fis.close();
return sb.toString();
}
/**
* byte[]
*/
public static byte[] readFileByBytes(String filePath) throws IOException {
File file = new File(filePath);
if (!file.exists()) {
throw new FileNotFoundException(filePath);
} else {
ByteArrayOutputStream bos = new ByteArrayOutputStream((int) file.length());
BufferedInputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(file));
short bufSize = 1024;
byte[] buffer = new byte[bufSize];
int len1;
while (-1 != (len1 = in.read(buffer, 0, bufSize))) {
bos.write(buffer, 0, len1);
}
byte[] var7 = bos.toByteArray();
return var7;
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException var14) {
var14.printStackTrace();
}
bos.close();
}
}
}
}

@ -0,0 +1,29 @@
/*
* Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
*/
package jnpf.ocr_sdk.baiduUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
/**
* Json.
*/
public class GsonUtils {
private static Gson gson = new GsonBuilder().create();
public static String toJson(Object value) {
return gson.toJson(value);
}
public static <T> T fromJson(String json, Class<T> classOfT) throws JsonParseException {
return gson.fromJson(json, classOfT);
}
public static <T> T fromJson(String json, Type typeOfT) throws JsonParseException {
return (T) gson.fromJson(json, typeOfT);
}
}

@ -0,0 +1,77 @@
package jnpf.ocr_sdk.baiduUtils;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;
/**
* http
*/
public class HttpUtil {
public static String post(String requestUrl, String accessToken, String params)
throws Exception {
String contentType = "application/x-www-form-urlencoded";
return HttpUtil.post(requestUrl, accessToken, contentType, params);
}
public static String post(String requestUrl, String accessToken, String contentType, String params)
throws Exception {
String encoding = "UTF-8";
if (requestUrl.contains("nlp")) {
encoding = "GBK";
}
return HttpUtil.post(requestUrl, accessToken, contentType, params, encoding);
}
public static String post(String requestUrl, String accessToken, String contentType, String params, String encoding)
throws Exception {
String url = requestUrl + "?access_token=" + accessToken;
return HttpUtil.postGeneralUrl(url, contentType, params, encoding);
}
public static String postGeneralUrl(String generalUrl, String contentType, String params, String encoding)
throws Exception {
URL url = new URL(generalUrl);
// 打开和URL之间的连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
// 设置通用的请求属性
connection.setRequestProperty("Content-Type", contentType);
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setUseCaches(false);
connection.setDoOutput(true);
connection.setDoInput(true);
// 得到请求的输出流对象
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.write(params.getBytes(encoding));
out.flush();
out.close();
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> headers = connection.getHeaderFields();
// 遍历所有的响应头字段
for (String key : headers.keySet()) {
System.err.println(key + "--->" + headers.get(key));
}
// 定义 BufferedReader输入流来读取URL的响应
BufferedReader in = null;
in = new BufferedReader(
new InputStreamReader(connection.getInputStream(), encoding));
String result = "";
String getLine;
while ((getLine = in.readLine()) != null) {
result += getLine;
}
in.close();
System.err.println("result:" + result);
return result;
}
}

@ -0,0 +1,78 @@
package jnpf.ocr_sdk.baiduUtils;
import org.springframework.web.multipart.MultipartFile;
import java.net.URLEncoder;
/**
* @Author: WangChuang
* @Date: 10/2/2023 10:12
* @Description //注释:
* @Version 1.0
*/
public class VatInvoice {
/**
*
* FileUtil,Base64Util,HttpUtil,GsonUtils
* https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72
* https://ai.baidu.com/file/C8D81F3301E24D2892968F09AE1AD6E2
* https://ai.baidu.com/file/544D677F5D4E4F17B4122FBD60DB82B3
* https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
*
*/
public static String vatInvoice(MultipartFile file) {
// 请求url
String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice";
try {
// 本地文件路径
// String filePath = "[本地文件路径]";
// byte[] imgData = FileUtil.readFileByBytes(filePath);
String imgStr = Base64Util.encode(file.getBytes());
String imgParam = URLEncoder.encode(imgStr, "UTF-8");
String param = "image=" + imgParam;
// 注意这里仅为了简化编码每一次请求都去获取access_token线上环境access_token有过期时间 客户端可自行缓存,过期后重新获取。
String accessToken = BaiduUtils.getAuth();
String result = HttpUtil.post(url, accessToken, param);
System.out.println(result);
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
*
*/
public static String weightNote(MultipartFile file) {
// 请求url
String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/weight_note";
try {
// 本地文件路径
// String filePath = "[本地文件路径]";
// byte[] imgData = FileUtil.readFileByBytes(filePath);
String imgStr = Base64Util.encode(file.getBytes());
String imgParam = URLEncoder.encode(imgStr, "UTF-8");
String param = "image=" + imgParam;
// 注意这里仅为了简化编码每一次请求都去获取access_token线上环境access_token有过期时间 客户端可自行缓存,过期后重新获取。
String accessToken = BaiduUtils.getAuth();
String result = HttpUtil.post(url, accessToken, param);
System.out.println(result);
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// public static void main(String[] args) {
// VatInvoice.vatInvoice();
// }
}

@ -0,0 +1,42 @@
package jnpf.ocr_sdk.controller;
import ai.djl.ModelException;
import ai.djl.translate.TranslateException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jnpf.base.ActionResult;
import jnpf.ocr_sdk.baiduUtils.VatInvoice;
import jnpf.util.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/**
* @Author: WangChuang
* @Date: 10/2/2023 9:20
* @Description //注释:
* @Version 1.0
*/
@Slf4j
@RestController
@Api(tags = "baiduAI识别图像API" , value = "BaiduAI识别图像API")
@RequestMapping("/api/OcrAPI/BaiduOcr")
public class BaiduOcrController {
@ApiOperation("发票识别")
@PostMapping("/uPicture")
public ActionResult UploadPicture(MultipartFile file ) throws IOException, ModelException, TranslateException {
String s = VatInvoice.vatInvoice(file);
return ActionResult.success(JsonUtil.stringToMap(s));
}
@ApiOperation("榜单识别")
@PostMapping("/weightNote")
public ActionResult weightNote(MultipartFile file ) throws IOException, ModelException, TranslateException {
String s = VatInvoice.weightNote(file);
return ActionResult.success(JsonUtil.stringToMap(s));
}
}

@ -0,0 +1,81 @@
package jnpf.ocr_sdk.controller;
import ai.djl.ModelException;
import ai.djl.translate.TranslateException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jnpf.base.ActionResult;
import jnpf.ocr_sdk.OcrV3RecognitionExample;
import jnpf.ocr_sdk.utils.common.RotatedBox;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @Author: WangChuang
* @Date: 10/2/2023 9:06
* @Description //注释:
* @Version 1.0
*/
@Slf4j
@RestController
@Api(tags = "AI识别图像API" , value = "AI识别图像API")
@RequestMapping("/api/OcrAPI/OcrAPI")
public class OcrController {
// @Resource
// private OcrV3RecognitionExample ocrV3RecognitionExample;
@ApiOperation("图片上传")
@PostMapping("/uPicture")
public ActionResult UploadPicture(MultipartFile file ) throws IOException, ModelException, TranslateException {
String fileName = file.getOriginalFilename();
System.out.println(fileName);
//调用工具类的方法
ArrayList<String> columnNames = new ArrayList<>();
HashMap<String, Integer> columnMap = new HashMap<>();
// 发票代码
columnNames.add("No");
// 1:从左到右+1
// 2:从左到右-1
// -1:从上到下+1
// -2:从上到下-1
// 0:本身自己
columnMap.put("No",0);
// 发票号码
columnNames.add("机器编号");
columnMap.put("机器编号",-1);
// 发票数量
columnNames.add("量");
columnMap.put("量",-1);
// 发票金额
columnNames.add("小写");
columnMap.put("小写",-2);
// 税率
columnNames.add("税率");
columnMap.put("税率",-1);
// 税额 (用税率二次)
// 不含税金额 (金额减去税额)
// 开票日期
columnNames.add("开票日期:");
columnMap.put("开票日期:",0);
// 物料名称
columnNames.add("货物或应税劳务");
columnMap.put("货物或应税劳务",-1);
List<RotatedBox> rotatedBoxes = OcrV3RecognitionExample.ocrAI(file.getInputStream());
ArrayList<String> example = OcrV3RecognitionExample.getExample(rotatedBoxes, columnNames,columnMap);
return ActionResult.success(example);
}
}

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="jnpf.inventoryOrd.mapper.InventoryOrgMapper">
</mapper>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="jnpf.inventoryOrdDetail.mapper.InventoryOrgDetailMapper">
</mapper>

@ -0,0 +1,93 @@
<template>
<el-dialog title="详情"
:close-on-click-modal="false" append-to-body
:visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll
width="600px">
<el-row :gutter="15" class="">
<el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right" >
<template v-if="!loading">
<el-col :span="24" >
<el-form-item label="编码"
prop="inventoryOrgCode" >
<p>{{dataForm.inventoryOrgCode}}</p>
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="名称"
prop="inventoryOrgName" >
<p>{{dataForm.inventoryOrgName}}</p>
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="所属组织"
prop="companyId" >
<p>{{dataForm.companyId}}</p>
</el-form-item>
</el-col>
</template>
</el-form>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false"> </el-button>
</span>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
import PrintBrowse from '@/components/PrintBrowse'
import jnpf from '@/utils/jnpf'
export default {
components: {PrintBrowse},
props: [],
data() {
return {
visible: false,
loading: false,
printBrowseVisible: false,
printId: '',
dataForm: {
id :'',
inventoryOrgCode : '',
inventoryOrgName : '',
companyId : "",
lastModifyUserName : "",
lastModifyTime : "",
creatorUserName : "",
creatorTime : "",
},
}
},
computed: {},
watch: {},
created() {
},
mounted() {},
methods: {
dataInfo(dataAll){
let _dataAll =dataAll
this.dataForm = _dataAll
},
init(id) {
this.dataForm.id = id || 0;
this.visible = true;
this.$nextTick(() => {
if(this.dataForm.id){
this.loading = true
request({
url: '/api/example/InventoryOrg/detail/'+this.dataForm.id,
method: 'get'
}).then(res => {
this.dataInfo(res.data)
this.loading = false
})
}
})
},
},
}
</script>

@ -0,0 +1,68 @@
<template>
<el-dialog title="导出数据" :close-on-click-modal="false" :visible.sync="visible"
class="JNPF-dialog JNPF-dialog_center" lock-scroll width="600px">
<el-form label-position="top" label-width="80px">
<el-form-item label="数据选择">
<el-radio-group v-model="type">
<el-radio :label="0">当前页面数据</el-radio>
<el-radio :label="1">全部页面数据</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="导出字段">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll"
@change="handleCheckAllChange">全选</el-checkbox>
<el-checkbox-group v-model="columns" @change="handleCheckedChange">
<el-checkbox v-for="item in columnList" :label="item.prop" :key="item.prop">
{{item.label}}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible=false"> </el-button>
<el-button type="primary" @click="downLoad"> </el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data() {
return {
visible: false,
btnLoading: false,
type: 0,
columns: [],
checkAll: true,
isIndeterminate: false,
columnList: []
}
},
methods: {
init(columnList) {
this.visible = true
this.checkAll = true
this.isIndeterminate = false
this.columnList = columnList
this.columns = columnList.map(o => o.prop)
},
handleCheckAllChange(val) {
this.columns = val ? this.columnList.map(o => o.prop) : [];
this.isIndeterminate = false;
},
handleCheckedChange(value) {
let checkedCount = value.length;
this.checkAll = checkedCount === this.columnList.length;
this.isIndeterminate = checkedCount > 0 && checkedCount < this.columnList.length;
},
downLoad() {
this.$emit('download', { dataType: this.type, selectKey: this.columns.join(',') })
}
}
}
</script>
<style lang="scss" scoped>
>>> .el-dialog__body {
padding: 20px !important;
}
</style>

@ -0,0 +1,181 @@
<template>
<el-dialog :title="!dataForm.id ? '新建' : isDetail ? '详情':'编辑'"
:close-on-click-modal="false" append-to-body
:visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll
width="600px">
<el-row :gutter="15" class="">
<el-form ref="elForm" :model="dataForm" :rules="rules" size="small" label-width="100px" label-position="right" >
<template v-if="!loading">
<el-col :span="24" >
<el-form-item label="编码"
prop="inventoryOrgCode" >
<el-input v-model="dataForm.inventoryOrgCode"
placeholder="请输入库存组织编码" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="名称"
prop="inventoryOrgName" >
<el-input v-model="dataForm.inventoryOrgName"
placeholder="请输入库存组织名称" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="所属组织"
prop="companyId" >
<el-select v-model="dataForm.companyId"
placeholder="请选择" clearable :style='{"width":"100%"}'>
<el-option v-for="(item, index) in companyIdOptions" :key="index" :label="item.F_FullName" :value="item.F_Id" :disabled="item.disabled" ></el-option>
</el-select>
</el-form-item>
</el-col>
</template>
</el-form>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false"> </el-button>
<el-button type="primary" @click="dataFormSubmit()" v-if="!isDetail"> </el-button>
</span>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
import { getDataInterfaceRes } from '@/api/systemData/dataInterface'
import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
export default {
components: {},
props: [],
data() {
return {
visible: false,
loading: false,
isDetail: false,
dataForm: {
inventoryOrgCode : '',
inventoryOrgName : '',
companyId : "",
lastModifyUserName : "",
lastModifyTime : "",
creatorUserName : "",
creatorTime : "",
},
rules:
{
inventoryOrgCode: [
{
required: true,
message: '请输入库存组织编码',
trigger: 'blur'
},
],
},
companyIdOptions:[],
}
},
computed: {},
watch: {},
created() {
this.getcompanyIdOptions();
},
mounted() {},
methods: {
getcompanyIdOptions() {
getDataInterfaceRes('394016341591396805').then(res => {
let data = res.data.data
this.companyIdOptions = data
})
},
clearData(data){
for (let key in data) {
if (data[key] instanceof Array) {
data[key] = [];
} else if (data[key] instanceof Object) {
this.clearData(data[key]);
} else {
data[key] = "";
}
}
},
init(id, isDetail) {
this.dataForm.id = id || 0;
this.visible = true;
this.isDetail = isDetail || false;
this.$nextTick(() => {
this.$refs['elForm'].resetFields();
if(this.dataForm.id){
this.loading = true
request({
url: '/api/example/InventoryOrg/'+this.dataForm.id,
method: 'get'
}).then(res => {
this.dataInfo(res.data)
this.loading = false
});
}else{
this.clearData(this.dataForm)
}
});
this.$store.commit('generator/UPDATE_RELATION_DATA', {})
},
//
dataFormSubmit() {
this.$refs['elForm'].validate((valid) => {
if (valid) {
this.request()
}
})
},
request() {
var _data =this.dataList()
if (!this.dataForm.id) {
request({
url: '/api/example/InventoryOrg',
method: 'post',
data: _data
}).then((res) => {
this.$message({
message: res.msg,
type: 'success',
duration: 1000,
onClose: () => {
this.visible = false
this.$emit('refresh', true)
}
})
})
}else{
request({
url: '/api/example/InventoryOrg/'+this.dataForm.id,
method: 'PUT',
data: _data
}).then((res) => {
this.$message({
message: res.msg,
type: 'success',
duration: 1000,
onClose: () => {
this.visible = false
this.$emit('refresh', true)
}
})
})
}
},
dataList(){
var _data = JSON.parse(JSON.stringify(this.dataForm));
return _data;
},
dataInfo(dataAll){
let _dataAll =dataAll
this.dataForm = _dataAll
},
},
}
</script>

@ -0,0 +1,219 @@
<template>
<div class="JNPF-common-layout">
<div class="JNPF-common-layout-center">
<el-row class="JNPF-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="编码">
<el-input v-model="query.inventoryOrgCode" placeholder="请输入" clearable> </el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="名称">
<el-input v-model="query.inventoryOrgName" placeholder="请输入" clearable> </el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()"></el-button>
<el-button icon="el-icon-refresh-right" @click="reset()"></el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div class="JNPF-common-layout-main JNPF-flex-main">
<div class="JNPF-common-head">
<div>
<el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">
</el-button>
</div>
<div class="JNPF-common-head-right">
<el-tooltip effect="dark" content="刷新" placement="top">
<el-link icon="icon-ym icon-ym-Refresh JNPF-common-head-icon" :underline="false"
@click="reset()"/>
</el-tooltip>
<screenfull isContainer/>
</div>
</div>
<JNPF-table v-loading="listLoading" :data="list" @sort-change='sortChange' >
<el-table-column prop="inventoryOrgCode" label="编码" width="0" align="left"
/>
<el-table-column prop="inventoryOrgName" label="名称" width="0" align="left"
/>
<el-table-column prop="creatorTime" label="创建时间" width="0" align="left"
/>
<el-table-column prop="companyId" label="所属组织" width="0" align="left"
/>
<el-table-column label="操作" fixed="right"
width="100" >
<template slot-scope="scope">
<el-button type="text"
@click="addOrUpdateHandle(scope.row.id)" >编辑
</el-button>
<el-button type="text" class="JNPF-table-delBtn" @click="handleDel(scope.row.id)">
</el-button>
</template>
</el-table-column>
</JNPF-table>
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData"/>
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh"/>
<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download"/>
<Detail v-if="detailVisible" ref="Detail" @refresh="detailVisible=false"/>
</div>
</template>
<script>
import request from '@/utils/request'
import {getDictionaryDataSelector} from '@/api/systemData/dictionary'
import JNPFForm from './Form'
import ExportBox from './ExportBox'
import {getDataInterfaceRes} from '@/api/systemData/dataInterface'
import Detail from './Detail'
export default {
components: {JNPFForm, ExportBox,Detail},
data() {
return {
detailVisible: false,
query: {
inventoryOrgCode:undefined,
inventoryOrgName:undefined,
},
treeProps: {
children: 'children',
label: 'fullName',
value: 'id'
},
list: [],
listLoading: true,
total: 0,
listQuery: {
currentPage: 1,
pageSize: 20,
sort: "desc",
sidx: "creatorTime",
},
formVisible: false,
exportBoxVisible: false,
columnList: [
{prop: 'inventoryOrgCode', label: '编码'},
{prop: 'inventoryOrgName', label: '名称'},
{prop: 'creatorTime', label: '创建时间'},
{prop: 'companyId', label: '所属组织'},
],
companyIdOptions:[],
companyIdProps:{"label":"F_FullName","value":"F_Id"},
}
},
computed: {
menuId() {
return this.$route.meta.modelId || ''
}
},
created() {
this.initData()
},
methods: {
goDetail(id){
this.detailVisible = true
this.$nextTick(() => {
this.$refs.Detail.init(id)
})
},
sortChange({column, prop, order}) {
this.listQuery.sort = order == 'ascending' ? 'asc' : 'desc'
this.listQuery.sidx = !order ? '' : prop
this.initData()
},
initData() {
this.listLoading = true;
let _query = {
...this.listQuery,
...this.query,
menuId:this.menuId
};
request({
url: `/api/example/InventoryOrg/getList`,
method: 'post',
data: _query
}).then(res => {
var _list =[];
for(let i=0;i<res.data.list.length;i++){
let _data = res.data.list[i];
_list.push(_data)
}
this.list = _list
this.total = res.data.pagination.total
this.listLoading = false
})
},
handleDel(id) {
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
type: 'warning'
}).then(() => {
request({
url: `/api/example/InventoryOrg/${id}`,
method: 'DELETE'
}).then(res => {
this.$message({
type: 'success',
message: res.msg,
onClose: () => {
this.initData()
}
});
})
}).catch(() => {
});
},
addOrUpdateHandle(id, isDetail) {
this.formVisible = true
this.$nextTick(() => {
this.$refs.JNPFForm.init(id, isDetail)
})
},
exportData() {
this.exportBoxVisible = true
this.$nextTick(() => {
this.$refs.ExportBox.init(this.columnList)
})
},
download(data) {
let query = {...data, ...this.listQuery, ...this.query,menuId:this.menuId}
request({
url: `/api/example/InventoryOrg/Actions/Export`,
method: 'GET',
data: query
}).then(res => {
if (!res.data.url) return
this.jnpf.downloadFile(res.data.url)
this.$refs.ExportBox.visible = false
this.exportBoxVisible = false
})
},
search() {
this.listQuery = {
currentPage: 1,
pageSize: 20,
sort: "desc",
sidx: "creatorTime",
}
this.initData()
},
refresh(isrRefresh) {
this.formVisible = false
if (isrRefresh) this.reset()
},
reset() {
for (let key in this.query) {
this.query[key] = undefined
}
this.search()
}
}
}
</script>

@ -0,0 +1,93 @@
<template>
<el-dialog title="详情"
:close-on-click-modal="false" append-to-body
:visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll
width="600px">
<el-row :gutter="15" class="">
<el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right" >
<template v-if="!loading">
<el-col :span="24" >
<el-form-item label="编码"
prop="inventoryOrgDetailCode" >
<p>{{dataForm.inventoryOrgDetailCode}}</p>
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="名称"
prop="inventoryOrgDetailName" >
<p>{{dataForm.inventoryOrgDetailName}}</p>
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="库存组织"
prop="inventoryId" >
<p>{{dataForm.inventoryId}}</p>
</el-form-item>
</el-col>
</template>
</el-form>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false"> </el-button>
</span>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
import PrintBrowse from '@/components/PrintBrowse'
import jnpf from '@/utils/jnpf'
export default {
components: {PrintBrowse},
props: [],
data() {
return {
visible: false,
loading: false,
printBrowseVisible: false,
printId: '',
dataForm: {
id :'',
inventoryOrgDetailCode : '',
inventoryOrgDetailName : '',
inventoryId : "",
lastModifyUserName : "",
lastModifyTime : "",
creatorUserName : "",
creatorTime : "",
},
}
},
computed: {},
watch: {},
created() {
},
mounted() {},
methods: {
dataInfo(dataAll){
let _dataAll =dataAll
this.dataForm = _dataAll
},
init(id) {
this.dataForm.id = id || 0;
this.visible = true;
this.$nextTick(() => {
if(this.dataForm.id){
this.loading = true
request({
url: '/api/example/InventoryOrgDetail/detail/'+this.dataForm.id,
method: 'get'
}).then(res => {
this.dataInfo(res.data)
this.loading = false
})
}
})
},
},
}
</script>

@ -0,0 +1,68 @@
<template>
<el-dialog title="导出数据" :close-on-click-modal="false" :visible.sync="visible"
class="JNPF-dialog JNPF-dialog_center" lock-scroll width="600px">
<el-form label-position="top" label-width="80px">
<el-form-item label="数据选择">
<el-radio-group v-model="type">
<el-radio :label="0">当前页面数据</el-radio>
<el-radio :label="1">全部页面数据</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="导出字段">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll"
@change="handleCheckAllChange">全选</el-checkbox>
<el-checkbox-group v-model="columns" @change="handleCheckedChange">
<el-checkbox v-for="item in columnList" :label="item.prop" :key="item.prop">
{{item.label}}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible=false"> </el-button>
<el-button type="primary" @click="downLoad"> </el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data() {
return {
visible: false,
btnLoading: false,
type: 0,
columns: [],
checkAll: true,
isIndeterminate: false,
columnList: []
}
},
methods: {
init(columnList) {
this.visible = true
this.checkAll = true
this.isIndeterminate = false
this.columnList = columnList
this.columns = columnList.map(o => o.prop)
},
handleCheckAllChange(val) {
this.columns = val ? this.columnList.map(o => o.prop) : [];
this.isIndeterminate = false;
},
handleCheckedChange(value) {
let checkedCount = value.length;
this.checkAll = checkedCount === this.columnList.length;
this.isIndeterminate = checkedCount > 0 && checkedCount < this.columnList.length;
},
downLoad() {
this.$emit('download', { dataType: this.type, selectKey: this.columns.join(',') })
}
}
}
</script>
<style lang="scss" scoped>
>>> .el-dialog__body {
padding: 20px !important;
}
</style>

@ -0,0 +1,175 @@
<template>
<el-dialog :title="!dataForm.id ? '新建' : isDetail ? '详情':'编辑'"
:close-on-click-modal="false" append-to-body
:visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll
width="600px">
<el-row :gutter="15" class="">
<el-form ref="elForm" :model="dataForm" :rules="rules" size="small" label-width="100px" label-position="right" >
<template v-if="!loading">
<el-col :span="24" >
<el-form-item label="编码"
prop="inventoryOrgDetailCode" >
<el-input v-model="dataForm.inventoryOrgDetailCode"
placeholder="请输入库存组织编码" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="名称"
prop="inventoryOrgDetailName" >
<el-input v-model="dataForm.inventoryOrgDetailName"
placeholder="请输入库存组织名称" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="库存组织"
prop="inventoryId" >
<popupSelect v-model="dataForm.inventoryId"
placeholder="请选择库存组织" clearable field="inventoryId" interfaceId="394085757268070853" :columnOptions="inventoryIdcolumnOptions" propsValue="id" relationField="inventory_org_name" popupType="dialog"
popupTitle="选择数据" popupWidth="800px"
>
</popupSelect>
</el-form-item>
</el-col>
</template>
</el-form>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false"> </el-button>
<el-button type="primary" @click="dataFormSubmit()" v-if="!isDetail"> </el-button>
</span>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
import { getDataInterfaceRes } from '@/api/systemData/dataInterface'
import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
export default {
components: {},
props: [],
data() {
return {
visible: false,
loading: false,
isDetail: false,
dataForm: {
inventoryOrgDetailCode : '',
inventoryOrgDetailName : '',
inventoryId : "",
lastModifyUserName : "",
lastModifyTime : "",
creatorUserName : "",
creatorTime : "",
},
rules:
{
inventoryOrgDetailCode: [
{
required: true,
message: '请输入库存组织编码',
trigger: 'blur'
},
],
},
inventoryIdcolumnOptions:[ {"label":"组织编码","value":"inventory_org_code"}, {"label":"组织名称","value":"inventory_org_name"},],
}
},
computed: {},
watch: {},
created() {
},
mounted() {},
methods: {
clearData(data){
for (let key in data) {
if (data[key] instanceof Array) {
data[key] = [];
} else if (data[key] instanceof Object) {
this.clearData(data[key]);
} else {
data[key] = "";
}
}
},
init(id, isDetail) {
this.dataForm.id = id || 0;
this.visible = true;
this.isDetail = isDetail || false;
this.$nextTick(() => {
this.$refs['elForm'].resetFields();
if(this.dataForm.id){
this.loading = true
request({
url: '/api/example/InventoryOrgDetail/'+this.dataForm.id,
method: 'get'
}).then(res => {
this.dataInfo(res.data)
this.loading = false
});
}else{
this.clearData(this.dataForm)
}
});
this.$store.commit('generator/UPDATE_RELATION_DATA', {})
},
//
dataFormSubmit() {
this.$refs['elForm'].validate((valid) => {
if (valid) {
this.request()
}
})
},
request() {
var _data =this.dataList()
if (!this.dataForm.id) {
request({
url: '/api/example/InventoryOrgDetail',
method: 'post',
data: _data
}).then((res) => {
this.$message({
message: res.msg,
type: 'success',
duration: 1000,
onClose: () => {
this.visible = false
this.$emit('refresh', true)
}
})
})
}else{
request({
url: '/api/example/InventoryOrgDetail/'+this.dataForm.id,
method: 'PUT',
data: _data
}).then((res) => {
this.$message({
message: res.msg,
type: 'success',
duration: 1000,
onClose: () => {
this.visible = false
this.$emit('refresh', true)
}
})
})
}
},
dataList(){
var _data = JSON.parse(JSON.stringify(this.dataForm));
return _data;
},
dataInfo(dataAll){
let _dataAll =dataAll
this.dataForm = _dataAll
},
},
}
</script>

@ -0,0 +1,219 @@
<template>
<div class="JNPF-common-layout">
<div class="JNPF-common-layout-center">
<el-row class="JNPF-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="编码">
<el-input v-model="query.inventoryOrgDetailCode" placeholder="请输入" clearable> </el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="名称">
<el-input v-model="query.inventoryOrgDetailName" placeholder="请输入" clearable> </el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()"></el-button>
<el-button icon="el-icon-refresh-right" @click="reset()"></el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div class="JNPF-common-layout-main JNPF-flex-main">
<div class="JNPF-common-head">
<div>
<el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">
</el-button>
<el-button type="text" icon="el-icon-download" @click="exportData()" >导出
</el-button>
</div>
<div class="JNPF-common-head-right">
<el-tooltip effect="dark" content="刷新" placement="top">
<el-link icon="icon-ym icon-ym-Refresh JNPF-common-head-icon" :underline="false"
@click="reset()"/>
</el-tooltip>
<screenfull isContainer/>
</div>
</div>
<JNPF-table v-loading="listLoading" :data="list" @sort-change='sortChange' >
<el-table-column prop="inventoryOrgDetailCode" label="编码" width="0" align="left"
/>
<el-table-column prop="inventoryOrgDetailName" label="名称" width="0" align="left"
/>
<el-table-column prop="inventoryId" label="库存组织" width="0" align="left"
/>
<el-table-column prop="creatorTime" label="创建时间" width="0" align="left"
/>
<el-table-column label="操作" fixed="right"
width="100" >
<template slot-scope="scope">
<el-button type="text"
@click="addOrUpdateHandle(scope.row.id)" >编辑
</el-button>
<el-button type="text" class="JNPF-table-delBtn" @click="handleDel(scope.row.id)">
</el-button>
</template>
</el-table-column>
</JNPF-table>
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData"/>
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh"/>
<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download"/>
<Detail v-if="detailVisible" ref="Detail" @refresh="detailVisible=false"/>
</div>
</template>
<script>
import request from '@/utils/request'
import {getDictionaryDataSelector} from '@/api/systemData/dictionary'
import JNPFForm from './Form'
import ExportBox from './ExportBox'
import {getDataInterfaceRes} from '@/api/systemData/dataInterface'
import Detail from './Detail'
export default {
components: {JNPFForm, ExportBox,Detail},
data() {
return {
detailVisible: false,
query: {
inventoryOrgDetailCode:undefined,
inventoryOrgDetailName:undefined,
},
treeProps: {
children: 'children',
label: 'fullName',
value: 'id'
},
list: [],
listLoading: true,
total: 0,
listQuery: {
currentPage: 1,
pageSize: 20,
sort: "desc",
sidx: "creatorTime",
},
formVisible: false,
exportBoxVisible: false,
columnList: [
{prop: 'inventoryOrgDetailCode', label: '编码'},
{prop: 'inventoryOrgDetailName', label: '名称'},
{prop: 'inventoryId', label: '库存组织'},
{prop: 'creatorTime', label: '创建时间'},
],
}
},
computed: {
menuId() {
return this.$route.meta.modelId || ''
}
},
created() {
this.initData()
},
methods: {
goDetail(id){
this.detailVisible = true
this.$nextTick(() => {
this.$refs.Detail.init(id)
})
},
sortChange({column, prop, order}) {
this.listQuery.sort = order == 'ascending' ? 'asc' : 'desc'
this.listQuery.sidx = !order ? '' : prop
this.initData()
},
initData() {
this.listLoading = true;
let _query = {
...this.listQuery,
...this.query,
menuId:this.menuId
};
request({
url: `/api/example/InventoryOrgDetail/getList`,
method: 'post',
data: _query
}).then(res => {
var _list =[];
for(let i=0;i<res.data.list.length;i++){
let _data = res.data.list[i];
_list.push(_data)
}
this.list = _list
this.total = res.data.pagination.total
this.listLoading = false
})
},
handleDel(id) {
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
type: 'warning'
}).then(() => {
request({
url: `/api/example/InventoryOrgDetail/${id}`,
method: 'DELETE'
}).then(res => {
this.$message({
type: 'success',
message: res.msg,
onClose: () => {
this.initData()
}
});
})
}).catch(() => {
});
},
addOrUpdateHandle(id, isDetail) {
this.formVisible = true
this.$nextTick(() => {
this.$refs.JNPFForm.init(id, isDetail)
})
},
exportData() {
this.exportBoxVisible = true
this.$nextTick(() => {
this.$refs.ExportBox.init(this.columnList)
})
},
download(data) {
let query = {...data, ...this.listQuery, ...this.query,menuId:this.menuId}
request({
url: `/api/example/InventoryOrgDetail/Actions/Export`,
method: 'GET',
data: query
}).then(res => {
if (!res.data.url) return
this.jnpf.downloadFile(res.data.url)
this.$refs.ExportBox.visible = false
this.exportBoxVisible = false
})
},
search() {
this.listQuery = {
currentPage: 1,
pageSize: 20,
sort: "desc",
sidx: "creatorTime",
}
this.initData()
},
refresh(isrRefresh) {
this.formVisible = false
if (isrRefresh) this.reset()
},
reset() {
for (let key in this.query) {
this.query[key] = undefined
}
this.search()
}
}
}
</script>
Loading…
Cancel
Save