diff --git a/jnpf-java-boot/jnpf-admin/src/main/resources/application-dev.yml b/jnpf-java-boot/jnpf-admin/src/main/resources/application-dev.yml index 6de3698..1b019ad 100644 --- a/jnpf-java-boot/jnpf-admin/src/main/resources/application-dev.yml +++ b/jnpf-java-boot/jnpf-admin/src/main/resources/application-dev.yml @@ -62,7 +62,7 @@ spring: validation-query: SELECT 1 datasource: master: - url: jdbc:mysql://${spring.datasource.host}:${spring.datasource.port}/${spring.datasource.dbname}?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC + url: jdbc:mysql://${spring.datasource.host}:${spring.datasource.port}/${spring.datasource.dbname}?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=GMT%2B8 username: ${spring.datasource.username} password: ${spring.datasource.password} driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/YysSubsetMaterialMapper.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/YysSubsetMaterialMapper.java new file mode 100644 index 0000000..95243d3 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/YysSubsetMaterialMapper.java @@ -0,0 +1,7 @@ +package jnpf.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import jnpf.entity.YysSubsetMaterialEntity; + +public interface YysSubsetMaterialMapper extends BaseMapper { +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysBillMaterialService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysBillMaterialService.java index 4e2d99a..ebde8e7 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysBillMaterialService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysBillMaterialService.java @@ -33,4 +33,5 @@ public interface YysBillMaterialService extends IService YysBillMaterialEntity getByProductId(String id); List getListByProductIds(List id); + String syncMaterial(); } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysDayWorkService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysDayWorkService.java index b94b2b4..4336929 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysDayWorkService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysDayWorkService.java @@ -53,4 +53,6 @@ public interface YysDayWorkService extends IService { String isFrozen(String id); String cancelFrozen(String id); + + void syncDayWork(); } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysInventoryQueryService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysInventoryQueryService.java index 577751b..c260248 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysInventoryQueryService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysInventoryQueryService.java @@ -32,4 +32,5 @@ public interface YysInventoryQueryService extends IService { +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysBillMaterialServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysBillMaterialServiceImpl.java index 28ff068..45ada9a 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysBillMaterialServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysBillMaterialServiceImpl.java @@ -1,37 +1,45 @@ package jnpf.service.impl; -import jnpf.entity.*; -import jnpf.mapper.YysBillMaterialMapper; -import jnpf.service.*; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import jnpf.model.yysbillmaterial.*; -import java.math.BigDecimal; import cn.hutool.core.util.ObjectUtil; -import jnpf.permission.model.authorize.AuthorizeConditionModel; -import jnpf.util.GeneraterSwapUtil; -import jnpf.database.model.superQuery.SuperQueryJsonModel; -import jnpf.database.model.superQuery.ConditionJsonModel; -import jnpf.database.model.superQuery.SuperQueryConditionModel; -import java.lang.reflect.Field; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.annotation.TableField; -import java.util.regex.Pattern; -import jnpf.model.QueryModel; -import java.util.stream.Collectors; -import jnpf.base.model.ColumnDataModel; -import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import jnpf.database.model.superQuery.SuperJsonModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import java.text.SimpleDateFormat; -import jnpf.util.*; -import java.util.*; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import jnpf.base.UserInfo; +import jnpf.base.model.ColumnDataModel; +import jnpf.database.model.superQuery.SuperJsonModel; +import jnpf.entity.YysBillMaterialEntity; +import jnpf.entity.YysSubsetMaterialEntity; +import jnpf.mapper.YysBillMaterialMapper; +import jnpf.model.QueryModel; +import jnpf.model.yysbillmaterial.*; +import jnpf.model.yysmaterialinformation.MaterialInformationSync; import jnpf.permission.entity.UserEntity; +import jnpf.service.YysBillMaterialService; +import jnpf.service.YysSubsetMaterialService; +import jnpf.util.*; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + /** - * * yysBillMaterial * 版本: V3.5 * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) @@ -39,247 +47,265 @@ import jnpf.permission.entity.UserEntity; * 日期: 2024-08-08 */ @Service -public class YysBillMaterialServiceImpl extends ServiceImpl implements YysBillMaterialService{ +public class YysBillMaterialServiceImpl extends ServiceImpl implements YysBillMaterialService { @Autowired private GeneraterSwapUtil generaterSwapUtil; @Autowired private UserProvider userProvider; + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + private YysSubsetMaterialService yysSubsetMaterialService; + @Override - public List getList(YysBillMaterialPagination yysBillMaterialPagination){ - return getTypeList(yysBillMaterialPagination,yysBillMaterialPagination.getDataType()); + public List getList(YysBillMaterialPagination yysBillMaterialPagination) { + return getTypeList(yysBillMaterialPagination, yysBillMaterialPagination.getDataType()); } - /** 列表查询 */ + + /** + * 列表查询 + */ @Override - public List getTypeList(YysBillMaterialPagination yysBillMaterialPagination,String dataType){ - String userId=userProvider.get().getUserId(); - List AllIdList =new ArrayList(); - List> intersectionList =new ArrayList<>(); + public List getTypeList(YysBillMaterialPagination yysBillMaterialPagination, String dataType) { + String userId = userProvider.get().getUserId(); + List AllIdList = new ArrayList(); + List> intersectionList = new ArrayList<>(); boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc"); String columnData = !isPc ? YysBillMaterialConstant.getAppColumnData() : YysBillMaterialConstant.getColumnData(); ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class); String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList()); - int total=0; - int yysBillMaterialNum =0; - QueryWrapper yysBillMaterialQueryWrapper=new QueryWrapper<>(); + int total = 0; + int yysBillMaterialNum = 0; + QueryWrapper yysBillMaterialQueryWrapper = new QueryWrapper<>(); List allSuperIDlist = new ArrayList<>(); - String superOp =""; - if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getSuperQueryJson())){ + String superOp = ""; + if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getSuperQueryJson())) { List allSuperList = new ArrayList<>(); - List> intersectionSuperList = new ArrayList<>(); + List> intersectionSuperList = new ArrayList<>(); String queryJson = yysBillMaterialPagination.getSuperQueryJson(); SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class); int superNum = 0; QueryWrapper yysBillMaterialSuperWrapper = new QueryWrapper<>(); - yysBillMaterialSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysBillMaterialSuperWrapper,YysBillMaterialEntity.class,queryJson,"0")); + yysBillMaterialSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysBillMaterialSuperWrapper, YysBillMaterialEntity.class, queryJson, "0")); int yysBillMaterialNum1 = yysBillMaterialSuperWrapper.getExpression().getNormal().size(); - if (yysBillMaterialNum1>0){ - List yysBillMaterialList =this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList()); + if (yysBillMaterialNum1 > 0) { + List yysBillMaterialList = this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList()); allSuperList.addAll(yysBillMaterialList); intersectionSuperList.add(yysBillMaterialList); superNum++; } superOp = superNum > 0 ? superJsonModel.getMatchLogic() : ""; //and or - if(superOp.equalsIgnoreCase("and")){ + if (superOp.equalsIgnoreCase("and")) { allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList); - }else{ + } else { allSuperIDlist = allSuperList; } } List allRuleIDlist = new ArrayList<>(); - String ruleOp =""; - if (ObjectUtil.isNotEmpty(ruleJson)){ + String ruleOp = ""; + if (ObjectUtil.isNotEmpty(ruleJson)) { List allRuleList = new ArrayList<>(); - List> intersectionRuleList = new ArrayList<>(); + List> intersectionRuleList = new ArrayList<>(); SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class); int ruleNum = 0; QueryWrapper yysBillMaterialSuperWrapper = new QueryWrapper<>(); - yysBillMaterialSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysBillMaterialSuperWrapper,YysBillMaterialEntity.class,ruleJson,"0")); + yysBillMaterialSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysBillMaterialSuperWrapper, YysBillMaterialEntity.class, ruleJson, "0")); int yysBillMaterialNum1 = yysBillMaterialSuperWrapper.getExpression().getNormal().size(); - if (yysBillMaterialNum1>0){ - List yysBillMaterialList =this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList()); + if (yysBillMaterialNum1 > 0) { + List yysBillMaterialList = this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList()); allRuleList.addAll(yysBillMaterialList); intersectionRuleList.add(yysBillMaterialList); ruleNum++; } ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : ""; //and or - if(ruleOp.equalsIgnoreCase("and")){ + if (ruleOp.equalsIgnoreCase("and")) { allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList); - }else{ + } else { allRuleIDlist = allRuleList; } } - boolean pcPermission = false; - boolean appPermission = false; - if(isPc && pcPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysBillMaterialObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysBillMaterialQueryWrapper,YysBillMaterialEntity.class,yysBillMaterialPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysBillMaterialObj)){ - return new ArrayList<>(); - } else { - yysBillMaterialQueryWrapper = (QueryWrapper)yysBillMaterialObj; - if( yysBillMaterialQueryWrapper.getExpression().getNormal().size()>0){ - yysBillMaterialNum++; - } - } - } - } - if(!isPc && appPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysBillMaterialObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysBillMaterialQueryWrapper,YysBillMaterialEntity.class,yysBillMaterialPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysBillMaterialObj)){ - return new ArrayList<>(); - } else { - yysBillMaterialQueryWrapper = (QueryWrapper)yysBillMaterialObj; - if( yysBillMaterialQueryWrapper.getExpression().getNormal().size()>0){ - yysBillMaterialNum++; - } + boolean pcPermission = false; + boolean appPermission = false; + if (isPc && pcPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysBillMaterialObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysBillMaterialQueryWrapper, YysBillMaterialEntity.class, yysBillMaterialPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysBillMaterialObj)) { + return new ArrayList<>(); + } else { + yysBillMaterialQueryWrapper = (QueryWrapper) yysBillMaterialObj; + if (yysBillMaterialQueryWrapper.getExpression().getNormal().size() > 0) { + yysBillMaterialNum++; + } + } + } } + if (!isPc && appPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysBillMaterialObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysBillMaterialQueryWrapper, YysBillMaterialEntity.class, yysBillMaterialPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysBillMaterialObj)) { + return new ArrayList<>(); + } else { + yysBillMaterialQueryWrapper = (QueryWrapper) yysBillMaterialObj; + if (yysBillMaterialQueryWrapper.getExpression().getNormal().size() > 0) { + yysBillMaterialNum++; + } + } - } - } - if(isPc){ - if(ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceId())){ - yysBillMaterialNum++; + } + } + if (isPc) { + if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceId())) { + yysBillMaterialNum++; String value = yysBillMaterialPagination.getPieceId() instanceof List ? - JsonUtil.getObjectToString(yysBillMaterialPagination.getPieceId()) : - String.valueOf(yysBillMaterialPagination.getPieceId()); - yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceId,value); + JsonUtil.getObjectToString(yysBillMaterialPagination.getPieceId()) : + String.valueOf(yysBillMaterialPagination.getPieceId()); + yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceId, value); } - if(ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceName())){ - yysBillMaterialNum++; + if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceName())) { + yysBillMaterialNum++; String value = yysBillMaterialPagination.getPieceName() instanceof List ? - JsonUtil.getObjectToString(yysBillMaterialPagination.getPieceName()) : - String.valueOf(yysBillMaterialPagination.getPieceName()); - yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceName,value); + JsonUtil.getObjectToString(yysBillMaterialPagination.getPieceName()) : + String.valueOf(yysBillMaterialPagination.getPieceName()); + yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceName, value); } - if(ObjectUtil.isNotEmpty(yysBillMaterialPagination.getDocumentStatus())){ - yysBillMaterialNum++; + if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getDocumentStatus())) { + yysBillMaterialNum++; String value = yysBillMaterialPagination.getDocumentStatus() instanceof List ? - JsonUtil.getObjectToString(yysBillMaterialPagination.getDocumentStatus()) : - String.valueOf(yysBillMaterialPagination.getDocumentStatus()); - yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getDocumentStatus,value); + JsonUtil.getObjectToString(yysBillMaterialPagination.getDocumentStatus()) : + String.valueOf(yysBillMaterialPagination.getDocumentStatus()); + yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getDocumentStatus, value); } } List intersection = generaterSwapUtil.getIntersection(intersectionList); - if (total>0){ - if (intersection.size()==0){ + if (total > 0) { + if (intersection.size() == 0) { intersection.add("jnpfNullList"); } yysBillMaterialQueryWrapper.lambda().in(YysBillMaterialEntity::getId, intersection); } - //是否有高级查询 - if (StringUtil.isNotEmpty(superOp)){ - if (allSuperIDlist.size()==0){ + //是否有高级查询 + if (StringUtil.isNotEmpty(superOp)) { + if (allSuperIDlist.size() == 0) { allSuperIDlist.add("jnpfNullList"); } List finalAllSuperIDlist = allSuperIDlist; - yysBillMaterialQueryWrapper.lambda().and(t->t.in(YysBillMaterialEntity::getId, finalAllSuperIDlist)); + yysBillMaterialQueryWrapper.lambda().and(t -> t.in(YysBillMaterialEntity::getId, finalAllSuperIDlist)); } - //是否有数据过滤查询 - if (StringUtil.isNotEmpty(ruleOp)){ - if (allRuleIDlist.size()==0){ + //是否有数据过滤查询 + if (StringUtil.isNotEmpty(ruleOp)) { + if (allRuleIDlist.size() == 0) { allRuleIDlist.add("jnpfNullList"); } List finalAllRuleIDlist = allRuleIDlist; - yysBillMaterialQueryWrapper.lambda().and(t->t.in(YysBillMaterialEntity::getId, finalAllRuleIDlist)); + yysBillMaterialQueryWrapper.lambda().and(t -> t.in(YysBillMaterialEntity::getId, finalAllRuleIDlist)); } //排序 - if(StringUtil.isEmpty(yysBillMaterialPagination.getSidx())){ + if (StringUtil.isEmpty(yysBillMaterialPagination.getSidx())) { yysBillMaterialQueryWrapper.lambda().orderByDesc(YysBillMaterialEntity::getId); - }else{ + } else { try { String sidx = yysBillMaterialPagination.getSidx(); - String[] strs= sidx.split("_name"); + String[] strs = sidx.split("_name"); YysBillMaterialEntity yysBillMaterialEntity = new YysBillMaterialEntity(); Field declaredField = yysBillMaterialEntity.getClass().getDeclaredField(strs[0]); declaredField.setAccessible(true); String value = declaredField.getAnnotation(TableField.class).value(); - yysBillMaterialQueryWrapper="asc".equals(yysBillMaterialPagination.getSort().toLowerCase())?yysBillMaterialQueryWrapper.orderByAsc(value):yysBillMaterialQueryWrapper.orderByDesc(value); + yysBillMaterialQueryWrapper = "asc".equals(yysBillMaterialPagination.getSort().toLowerCase()) ? yysBillMaterialQueryWrapper.orderByAsc(value) : yysBillMaterialQueryWrapper.orderByDesc(value); } catch (NoSuchFieldException e) { e.printStackTrace(); } } - if("0".equals(dataType)){ - if((total>0 && AllIdList.size()>0) || total==0){ - Page page=new Page<>(yysBillMaterialPagination.getCurrentPage(), yysBillMaterialPagination.getPageSize()); - IPage userIPage=this.page(page, yysBillMaterialQueryWrapper); - return yysBillMaterialPagination.setData(userIPage.getRecords(),userIPage.getTotal()); - }else{ + if ("0".equals(dataType)) { + if ((total > 0 && AllIdList.size() > 0) || total == 0) { + Page page = new Page<>(yysBillMaterialPagination.getCurrentPage(), yysBillMaterialPagination.getPageSize()); + IPage userIPage = this.page(page, yysBillMaterialQueryWrapper); + return yysBillMaterialPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { List list = new ArrayList(); return yysBillMaterialPagination.setData(list, list.size()); } - }else{ + } else { return this.list(yysBillMaterialQueryWrapper); } } + @Override - public YysBillMaterialEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(YysBillMaterialEntity::getId,id); + public YysBillMaterialEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(YysBillMaterialEntity::getId, id); return this.getOne(queryWrapper); } + @Override - public void create(YysBillMaterialEntity entity){ + public void create(YysBillMaterialEntity entity) { this.save(entity); } + @Override - public boolean update(String id, YysBillMaterialEntity entity){ + public boolean update(String id, YysBillMaterialEntity entity) { return this.updateById(entity); } + @Override - public void delete(YysBillMaterialEntity entity){ - if(entity!=null){ + public void delete(YysBillMaterialEntity entity) { + if (entity != null) { this.removeById(entity.getId()); } } - /** 验证表单唯一字段,正则,非空 i-0新增-1修改*/ + + /** + * 验证表单唯一字段,正则,非空 i-0新增-1修改 + */ @Override - public String checkForm(YysBillMaterialForm form,int i) { - boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); - String id=""; + public String checkForm(YysBillMaterialForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; String countRecover = ""; - if (isUp){ + if (isUp) { id = form.getId(); } //主表字段验证 return countRecover; } + /** - * 新增修改数据(事务回滚) - * @param id - * @param yysBillMaterialForm - * @return - */ + * 新增修改数据(事务回滚) + * + * @param id + * @param yysBillMaterialForm + * @return + */ @Override @Transactional - public void saveOrUpdate(YysBillMaterialForm yysBillMaterialForm,String id, boolean isSave) throws Exception{ - UserInfo userInfo=userProvider.get(); + public void saveOrUpdate(YysBillMaterialForm yysBillMaterialForm, String id, boolean isSave) throws Exception { + UserInfo userInfo = userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); yysBillMaterialForm = JsonUtil.getJsonToBean( - generaterSwapUtil.swapDatetime(YysBillMaterialConstant.getFormData(),yysBillMaterialForm),YysBillMaterialForm.class); + generaterSwapUtil.swapDatetime(YysBillMaterialConstant.getFormData(), yysBillMaterialForm), YysBillMaterialForm.class); YysBillMaterialEntity entity = JsonUtil.getJsonToBean(yysBillMaterialForm, YysBillMaterialEntity.class); - if(isSave){ - String mainId = RandomUtil.uuId() ; + if (isSave) { + String mainId = RandomUtil.uuId(); entity.setId(mainId); - }else{ + } else { } this.saveOrUpdate(entity); @@ -288,14 +314,94 @@ public class YysBillMaterialServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); - wrapper.lambda().eq(YysBillMaterialEntity::getPieceId,id); + wrapper.lambda().eq(YysBillMaterialEntity::getPieceId, id); return this.getOne(wrapper); } @Override public List getListByProductIds(List id) { QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.lambda().in(YysBillMaterialEntity::getPieceId,id); + wrapper.lambda().in(YysBillMaterialEntity::getPieceId, id); return this.list(wrapper); } + + @Override + @DS("slave_2") + public String syncMaterial() { + List syncList = this.list(new LambdaQueryWrapper<>(YysBillMaterialEntity.class).isNull(YysBillMaterialEntity::getDeleteMark)) + .stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList()); + //母件物料 + RowMapper rowMapper = new BeanPropertyRowMapper<>(SyncMaterial.class); + String sql = "select * from v_bom_parent_rpt"; + List query = this.jdbcTemplate.query(sql, rowMapper); + if (CollectionUtils.isEmpty(query)) { + return "远程母件物料信息为空"; + } + //过滤出同步过的 + query = query.stream().filter(obj -> !syncList.contains(obj.getAutoId())).collect(Collectors.toList()); + //子件物料 + RowMapper subMapper = new BeanPropertyRowMapper<>(SyncSubsetMaterial.class); + String subsetSql = "select * from v_bom_opcomponent_rpt"; + List subsetMaterials = this.jdbcTemplate.query(subsetSql, subMapper); + Map> subsetCollect = Maps.newHashMap(); + if (CollectionUtils.isNotEmpty(subsetMaterials)) { + subsetCollect = subsetMaterials.stream().collect(Collectors.groupingBy(SyncSubsetMaterial::getBomId)); + } + //物料表数据 不从自己库取数据,防止自己库未同步,从而取不到数据 + RowMapper materialMapper = new BeanPropertyRowMapper<>(MaterialInformationSync.class); + String materialSql = "select * from dbo.Inventory"; + List informationSyncs = this.jdbcTemplate.query(materialSql, materialMapper); + Map materialCollect = Maps.newHashMap(); + if (CollectionUtils.isNotEmpty(informationSyncs)) { + materialCollect = informationSyncs.stream().collect(Collectors.toMap(MaterialInformationSync::getCInvCode, Function.identity())); + } + List materialResult = Lists.newArrayList(); + List subsetResult = Lists.newArrayList(); + for (SyncMaterial material : query) { + YysBillMaterialEntity yysBillMaterialEntity = new YysBillMaterialEntity(); + yysBillMaterialEntity.setId(material.getAutoId()); + yysBillMaterialEntity.setPieceId(material.getBomId()); + if (MapUtils.isNotEmpty(materialCollect) && materialCollect.containsKey(material.getInvCode())) { + MaterialInformationSync sync = materialCollect.get(material.getInvCode()); + yysBillMaterialEntity.setPieceName(sync.getCInvName()); + yysBillMaterialEntity.setModels(sync.getEInvStd()); + yysBillMaterialEntity.setUnit(sync.getCComUnitCode()); + } + //处理子集 + if (MapUtils.isNotEmpty(subsetCollect) && subsetCollect.containsKey(yysBillMaterialEntity.getPieceId())) { + List list = subsetCollect.get(yysBillMaterialEntity.getPieceId()); + for (SyncSubsetMaterial subsetMaterial : list) { + YysSubsetMaterialEntity yysSubsetMaterialEntity = new YysSubsetMaterialEntity(); + yysSubsetMaterialEntity.setId(subsetMaterial.getOpComponentId()); + yysSubsetMaterialEntity.setPieceId(yysBillMaterialEntity.getId()); + yysSubsetMaterialEntity.setSubsetId(subsetMaterial.getBomId()); + yysSubsetMaterialEntity.setBaseUse(subsetMaterial.getBaseQtyN()); + yysSubsetMaterialEntity.setBaseNum(subsetMaterial.getBaseQtyD()); + if (MapUtils.isNotEmpty(materialCollect) && materialCollect.containsKey(subsetMaterial.getInvCode())) { + MaterialInformationSync sync = materialCollect.get(subsetMaterial.getInvCode()); + yysSubsetMaterialEntity.setSubsetName(sync.getCInvName()); + yysSubsetMaterialEntity.setSubsetModel(sync.getEInvStd()); + yysSubsetMaterialEntity.setUnit(sync.getCComUnitCode()); + } + yysSubsetMaterialEntity.setCreatorTime(DateUtil.getNowDate()); + //默认给个状态 + yysSubsetMaterialEntity.setStatus("2"); + subsetResult.add(yysSubsetMaterialEntity); + } + } + //暂时默认单据状态为已审核 + yysBillMaterialEntity.setDocumentStatus("2"); + yysBillMaterialEntity.setCreatorTime(DateUtil.getNowDate()); + materialResult.add(yysBillMaterialEntity); + } + if (CollectionUtils.isEmpty(materialResult)) { + return "没有需要同步的数据"; + } + boolean material = this.saveBatch(materialResult); + boolean savedBatch = yysSubsetMaterialService.saveBatch(subsetResult); + if (material && savedBatch) { + return "同步成功"; + } + return "同步失败"; + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysDayWorkServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysDayWorkServiceImpl.java index 9635072..41a3b13 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysDayWorkServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysDayWorkServiceImpl.java @@ -23,8 +23,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.logging.SimpleFormatter; import java.util.stream.Collectors; /** @@ -534,4 +541,62 @@ public class YysDayWorkServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.ne(YysDayWorkEntity::getProductionStatus, "2"); + wrapper.isNull(YysDayWorkEntity::getDeleteMark); + List list = this.list(wrapper); + LocalDate currentDate = LocalDate.now(); + for (YysDayWorkEntity entity : list) { + if ("是".equals(entity.getIsFrozen())) { + entity.setProductionStatus("1"); + continue; + } + Date manufactureDate = entity.getManufactureTime(); + LocalDate productionDate = manufactureDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + if (productionDate.isBefore(currentDate)) { + entity.setProductionStatus("2"); + } else if (productionDate.isAfter(currentDate)) { + entity.setProductionStatus("1"); + } else { + if (isCurrentTimeBetween(entity.getStartTime(), entity.getEndTime())) { + entity.setProductionStatus("3"); + } else if (isBefore(entity.getStartTime())) { + entity.setProductionStatus("1"); + } else if (isAfter(entity.getEndTime())) { + entity.setProductionStatus("2"); + } + } + } + this.updateBatchById(list); + } + + private static boolean isCurrentTimeBetween(String startTimeStr, String ednTimeStr) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); + // 将字符串时间转换为LocalTime对象 + LocalTime startTime = LocalTime.parse(startTimeStr, formatter); + LocalTime endTime = LocalTime.parse(ednTimeStr, formatter); + LocalTime now = LocalTime.now(); + return !now.isBefore(startTime) && (!now.isAfter(endTime) || now.equals(endTime)); + } + + //判断当前是否小于开始时间 + private static boolean isBefore(String startTimeStr) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); + LocalTime now = LocalTime.now(); + LocalTime startTime = LocalTime.parse(startTimeStr, formatter); + return now.isBefore(startTime); + } + + //判断是否大于结束时间 + private static boolean isAfter(String endTimeStr) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); + LocalTime now = LocalTime.now(); + LocalTime endTime = LocalTime.parse(endTimeStr, formatter); + return now.isAfter(endTime); + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysInventoryQueryServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysInventoryQueryServiceImpl.java index fec757c..6be928b 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysInventoryQueryServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysInventoryQueryServiceImpl.java @@ -1,37 +1,45 @@ package jnpf.service.impl; -import jnpf.entity.*; -import jnpf.mapper.YysInventoryQueryMapper; -import jnpf.service.*; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import jnpf.model.yysinventoryquery.*; -import java.math.BigDecimal; import cn.hutool.core.util.ObjectUtil; -import jnpf.permission.model.authorize.AuthorizeConditionModel; -import jnpf.util.GeneraterSwapUtil; -import jnpf.database.model.superQuery.SuperQueryJsonModel; -import jnpf.database.model.superQuery.ConditionJsonModel; -import jnpf.database.model.superQuery.SuperQueryConditionModel; -import java.lang.reflect.Field; import com.baomidou.mybatisplus.annotation.TableField; -import java.util.regex.Pattern; -import jnpf.model.QueryModel; -import java.util.stream.Collectors; -import jnpf.base.model.ColumnDataModel; -import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import jnpf.database.model.superQuery.SuperJsonModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import java.text.SimpleDateFormat; -import jnpf.util.*; -import java.util.*; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import jnpf.base.UserInfo; +import jnpf.base.model.ColumnDataModel; +import jnpf.database.model.superQuery.SuperJsonModel; +import jnpf.entity.YysInventoryQueryEntity; +import jnpf.mapper.YysInventoryQueryMapper; +import jnpf.model.QueryModel; +import jnpf.model.yysinventoryquery.SyncInventoryQuery; +import jnpf.model.yysinventoryquery.YysInventoryQueryConstant; +import jnpf.model.yysinventoryquery.YysInventoryQueryForm; +import jnpf.model.yysinventoryquery.YysInventoryQueryPagination; +import jnpf.model.yysmaterialinformation.MaterialInformationSync; import jnpf.permission.entity.UserEntity; +import jnpf.service.YysInventoryQueryService; +import jnpf.util.*; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + /** - * * yysInventoryQuery * 版本: V3.5 * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) @@ -39,249 +47,308 @@ import jnpf.permission.entity.UserEntity; * 日期: 2024-08-08 */ @Service -public class YysInventoryQueryServiceImpl extends ServiceImpl implements YysInventoryQueryService{ +public class YysInventoryQueryServiceImpl extends ServiceImpl implements YysInventoryQueryService { @Autowired private GeneraterSwapUtil generaterSwapUtil; @Autowired private UserProvider userProvider; + @Autowired + private JdbcTemplate jdbcTemplate; + @Override - public List getList(YysInventoryQueryPagination yysInventoryQueryPagination){ - return getTypeList(yysInventoryQueryPagination,yysInventoryQueryPagination.getDataType()); + public List getList(YysInventoryQueryPagination yysInventoryQueryPagination) { + return getTypeList(yysInventoryQueryPagination, yysInventoryQueryPagination.getDataType()); } - /** 列表查询 */ + + /** + * 列表查询 + */ @Override - public List getTypeList(YysInventoryQueryPagination yysInventoryQueryPagination,String dataType){ - String userId=userProvider.get().getUserId(); - List AllIdList =new ArrayList(); - List> intersectionList =new ArrayList<>(); + public List getTypeList(YysInventoryQueryPagination yysInventoryQueryPagination, String dataType) { + String userId = userProvider.get().getUserId(); + List AllIdList = new ArrayList(); + List> intersectionList = new ArrayList<>(); boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc"); String columnData = !isPc ? YysInventoryQueryConstant.getAppColumnData() : YysInventoryQueryConstant.getColumnData(); ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class); String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList()); - int total=0; - int yysInventoryQueryNum =0; - QueryWrapper yysInventoryQueryQueryWrapper=new QueryWrapper<>(); + int total = 0; + int yysInventoryQueryNum = 0; + QueryWrapper yysInventoryQueryQueryWrapper = new QueryWrapper<>(); List allSuperIDlist = new ArrayList<>(); - String superOp =""; - if (ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getSuperQueryJson())){ + String superOp = ""; + if (ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getSuperQueryJson())) { List allSuperList = new ArrayList<>(); - List> intersectionSuperList = new ArrayList<>(); + List> intersectionSuperList = new ArrayList<>(); String queryJson = yysInventoryQueryPagination.getSuperQueryJson(); SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class); int superNum = 0; QueryWrapper yysInventoryQuerySuperWrapper = new QueryWrapper<>(); - yysInventoryQuerySuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysInventoryQuerySuperWrapper,YysInventoryQueryEntity.class,queryJson,"0")); + yysInventoryQuerySuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysInventoryQuerySuperWrapper, YysInventoryQueryEntity.class, queryJson, "0")); int yysInventoryQueryNum1 = yysInventoryQuerySuperWrapper.getExpression().getNormal().size(); - if (yysInventoryQueryNum1>0){ - List yysInventoryQueryList =this.list(yysInventoryQuerySuperWrapper).stream().map(YysInventoryQueryEntity::getId).collect(Collectors.toList()); + if (yysInventoryQueryNum1 > 0) { + List yysInventoryQueryList = this.list(yysInventoryQuerySuperWrapper).stream().map(YysInventoryQueryEntity::getId).collect(Collectors.toList()); allSuperList.addAll(yysInventoryQueryList); intersectionSuperList.add(yysInventoryQueryList); superNum++; } superOp = superNum > 0 ? superJsonModel.getMatchLogic() : ""; //and or - if(superOp.equalsIgnoreCase("and")){ + if (superOp.equalsIgnoreCase("and")) { allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList); - }else{ + } else { allSuperIDlist = allSuperList; } } List allRuleIDlist = new ArrayList<>(); - String ruleOp =""; - if (ObjectUtil.isNotEmpty(ruleJson)){ + String ruleOp = ""; + if (ObjectUtil.isNotEmpty(ruleJson)) { List allRuleList = new ArrayList<>(); - List> intersectionRuleList = new ArrayList<>(); + List> intersectionRuleList = new ArrayList<>(); SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class); int ruleNum = 0; QueryWrapper yysInventoryQuerySuperWrapper = new QueryWrapper<>(); - yysInventoryQuerySuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysInventoryQuerySuperWrapper,YysInventoryQueryEntity.class,ruleJson,"0")); + yysInventoryQuerySuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysInventoryQuerySuperWrapper, YysInventoryQueryEntity.class, ruleJson, "0")); int yysInventoryQueryNum1 = yysInventoryQuerySuperWrapper.getExpression().getNormal().size(); - if (yysInventoryQueryNum1>0){ - List yysInventoryQueryList =this.list(yysInventoryQuerySuperWrapper).stream().map(YysInventoryQueryEntity::getId).collect(Collectors.toList()); + if (yysInventoryQueryNum1 > 0) { + List yysInventoryQueryList = this.list(yysInventoryQuerySuperWrapper).stream().map(YysInventoryQueryEntity::getId).collect(Collectors.toList()); allRuleList.addAll(yysInventoryQueryList); intersectionRuleList.add(yysInventoryQueryList); ruleNum++; } ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : ""; //and or - if(ruleOp.equalsIgnoreCase("and")){ + if (ruleOp.equalsIgnoreCase("and")) { allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList); - }else{ + } else { allRuleIDlist = allRuleList; } } - boolean pcPermission = false; - boolean appPermission = false; - if(isPc && pcPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysInventoryQueryObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysInventoryQueryQueryWrapper,YysInventoryQueryEntity.class,yysInventoryQueryPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysInventoryQueryObj)){ - return new ArrayList<>(); - } else { - yysInventoryQueryQueryWrapper = (QueryWrapper)yysInventoryQueryObj; - if( yysInventoryQueryQueryWrapper.getExpression().getNormal().size()>0){ - yysInventoryQueryNum++; - } - } - } - } - if(!isPc && appPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysInventoryQueryObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysInventoryQueryQueryWrapper,YysInventoryQueryEntity.class,yysInventoryQueryPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysInventoryQueryObj)){ - return new ArrayList<>(); - } else { - yysInventoryQueryQueryWrapper = (QueryWrapper)yysInventoryQueryObj; - if( yysInventoryQueryQueryWrapper.getExpression().getNormal().size()>0){ - yysInventoryQueryNum++; - } + boolean pcPermission = false; + boolean appPermission = false; + if (isPc && pcPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysInventoryQueryObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysInventoryQueryQueryWrapper, YysInventoryQueryEntity.class, yysInventoryQueryPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysInventoryQueryObj)) { + return new ArrayList<>(); + } else { + yysInventoryQueryQueryWrapper = (QueryWrapper) yysInventoryQueryObj; + if (yysInventoryQueryQueryWrapper.getExpression().getNormal().size() > 0) { + yysInventoryQueryNum++; + } + } + } } + if (!isPc && appPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysInventoryQueryObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysInventoryQueryQueryWrapper, YysInventoryQueryEntity.class, yysInventoryQueryPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysInventoryQueryObj)) { + return new ArrayList<>(); + } else { + yysInventoryQueryQueryWrapper = (QueryWrapper) yysInventoryQueryObj; + if (yysInventoryQueryQueryWrapper.getExpression().getNormal().size() > 0) { + yysInventoryQueryNum++; + } + } - } - } - if(isPc){ - if(ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getMaterialCode())){ - yysInventoryQueryNum++; + } + } + if (isPc) { + if (ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getMaterialCode())) { + yysInventoryQueryNum++; String value = yysInventoryQueryPagination.getMaterialCode() instanceof List ? - JsonUtil.getObjectToString(yysInventoryQueryPagination.getMaterialCode()) : - String.valueOf(yysInventoryQueryPagination.getMaterialCode()); - yysInventoryQueryQueryWrapper.lambda().like(YysInventoryQueryEntity::getMaterialCode,value); + JsonUtil.getObjectToString(yysInventoryQueryPagination.getMaterialCode()) : + String.valueOf(yysInventoryQueryPagination.getMaterialCode()); + yysInventoryQueryQueryWrapper.lambda().like(YysInventoryQueryEntity::getMaterialCode, value); } - if(ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getMaterialName())){ - yysInventoryQueryNum++; + if (ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getMaterialName())) { + yysInventoryQueryNum++; String value = yysInventoryQueryPagination.getMaterialName() instanceof List ? - JsonUtil.getObjectToString(yysInventoryQueryPagination.getMaterialName()) : - String.valueOf(yysInventoryQueryPagination.getMaterialName()); - yysInventoryQueryQueryWrapper.lambda().like(YysInventoryQueryEntity::getMaterialName,value); + JsonUtil.getObjectToString(yysInventoryQueryPagination.getMaterialName()) : + String.valueOf(yysInventoryQueryPagination.getMaterialName()); + yysInventoryQueryQueryWrapper.lambda().like(YysInventoryQueryEntity::getMaterialName, value); } - if(ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getMaterialClassification())){ - yysInventoryQueryNum++; + if (ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getMaterialClassification())) { + yysInventoryQueryNum++; String value = yysInventoryQueryPagination.getMaterialClassification() instanceof List ? - JsonUtil.getObjectToString(yysInventoryQueryPagination.getMaterialClassification()) : - String.valueOf(yysInventoryQueryPagination.getMaterialClassification()); - yysInventoryQueryQueryWrapper.lambda().like(YysInventoryQueryEntity::getMaterialClassification,value); + JsonUtil.getObjectToString(yysInventoryQueryPagination.getMaterialClassification()) : + String.valueOf(yysInventoryQueryPagination.getMaterialClassification()); + yysInventoryQueryQueryWrapper.lambda().like(YysInventoryQueryEntity::getMaterialClassification, value); } } List intersection = generaterSwapUtil.getIntersection(intersectionList); - if (total>0){ - if (intersection.size()==0){ + if (total > 0) { + if (intersection.size() == 0) { intersection.add("jnpfNullList"); } yysInventoryQueryQueryWrapper.lambda().in(YysInventoryQueryEntity::getId, intersection); } - //是否有高级查询 - if (StringUtil.isNotEmpty(superOp)){ - if (allSuperIDlist.size()==0){ + //是否有高级查询 + if (StringUtil.isNotEmpty(superOp)) { + if (allSuperIDlist.size() == 0) { allSuperIDlist.add("jnpfNullList"); } List finalAllSuperIDlist = allSuperIDlist; - yysInventoryQueryQueryWrapper.lambda().and(t->t.in(YysInventoryQueryEntity::getId, finalAllSuperIDlist)); + yysInventoryQueryQueryWrapper.lambda().and(t -> t.in(YysInventoryQueryEntity::getId, finalAllSuperIDlist)); } - //是否有数据过滤查询 - if (StringUtil.isNotEmpty(ruleOp)){ - if (allRuleIDlist.size()==0){ + //是否有数据过滤查询 + if (StringUtil.isNotEmpty(ruleOp)) { + if (allRuleIDlist.size() == 0) { allRuleIDlist.add("jnpfNullList"); } List finalAllRuleIDlist = allRuleIDlist; - yysInventoryQueryQueryWrapper.lambda().and(t->t.in(YysInventoryQueryEntity::getId, finalAllRuleIDlist)); + yysInventoryQueryQueryWrapper.lambda().and(t -> t.in(YysInventoryQueryEntity::getId, finalAllRuleIDlist)); } //排序 - if(StringUtil.isEmpty(yysInventoryQueryPagination.getSidx())){ + if (StringUtil.isEmpty(yysInventoryQueryPagination.getSidx())) { yysInventoryQueryQueryWrapper.lambda().orderByDesc(YysInventoryQueryEntity::getId); - }else{ + } else { try { String sidx = yysInventoryQueryPagination.getSidx(); - String[] strs= sidx.split("_name"); + String[] strs = sidx.split("_name"); YysInventoryQueryEntity yysInventoryQueryEntity = new YysInventoryQueryEntity(); Field declaredField = yysInventoryQueryEntity.getClass().getDeclaredField(strs[0]); declaredField.setAccessible(true); String value = declaredField.getAnnotation(TableField.class).value(); - yysInventoryQueryQueryWrapper="asc".equals(yysInventoryQueryPagination.getSort().toLowerCase())?yysInventoryQueryQueryWrapper.orderByAsc(value):yysInventoryQueryQueryWrapper.orderByDesc(value); + yysInventoryQueryQueryWrapper = "asc".equals(yysInventoryQueryPagination.getSort().toLowerCase()) ? yysInventoryQueryQueryWrapper.orderByAsc(value) : yysInventoryQueryQueryWrapper.orderByDesc(value); } catch (NoSuchFieldException e) { e.printStackTrace(); } } - if("0".equals(dataType)){ - if((total>0 && AllIdList.size()>0) || total==0){ - Page page=new Page<>(yysInventoryQueryPagination.getCurrentPage(), yysInventoryQueryPagination.getPageSize()); - IPage userIPage=this.page(page, yysInventoryQueryQueryWrapper); - return yysInventoryQueryPagination.setData(userIPage.getRecords(),userIPage.getTotal()); - }else{ + if ("0".equals(dataType)) { + if ((total > 0 && AllIdList.size() > 0) || total == 0) { + Page page = new Page<>(yysInventoryQueryPagination.getCurrentPage(), yysInventoryQueryPagination.getPageSize()); + IPage userIPage = this.page(page, yysInventoryQueryQueryWrapper); + return yysInventoryQueryPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { List list = new ArrayList(); return yysInventoryQueryPagination.setData(list, list.size()); } - }else{ + } else { return this.list(yysInventoryQueryQueryWrapper); } } + @Override - public YysInventoryQueryEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(YysInventoryQueryEntity::getId,id); + public YysInventoryQueryEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(YysInventoryQueryEntity::getId, id); return this.getOne(queryWrapper); } + @Override - public void create(YysInventoryQueryEntity entity){ + public void create(YysInventoryQueryEntity entity) { this.save(entity); } + @Override - public boolean update(String id, YysInventoryQueryEntity entity){ + public boolean update(String id, YysInventoryQueryEntity entity) { return this.updateById(entity); } + @Override - public void delete(YysInventoryQueryEntity entity){ - if(entity!=null){ + public void delete(YysInventoryQueryEntity entity) { + if (entity != null) { this.removeById(entity.getId()); } } - /** 验证表单唯一字段,正则,非空 i-0新增-1修改*/ + + /** + * 验证表单唯一字段,正则,非空 i-0新增-1修改 + */ @Override - public String checkForm(YysInventoryQueryForm form,int i) { - boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); - String id=""; + public String checkForm(YysInventoryQueryForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; String countRecover = ""; - if (isUp){ + if (isUp) { id = form.getId(); } //主表字段验证 return countRecover; } + /** - * 新增修改数据(事务回滚) - * @param id - * @param yysInventoryQueryForm - * @return - */ + * 新增修改数据(事务回滚) + * + * @param id + * @param yysInventoryQueryForm + * @return + */ @Override @Transactional - public void saveOrUpdate(YysInventoryQueryForm yysInventoryQueryForm,String id, boolean isSave) throws Exception{ - UserInfo userInfo=userProvider.get(); + public void saveOrUpdate(YysInventoryQueryForm yysInventoryQueryForm, String id, boolean isSave) throws Exception { + UserInfo userInfo = userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); yysInventoryQueryForm = JsonUtil.getJsonToBean( - generaterSwapUtil.swapDatetime(YysInventoryQueryConstant.getFormData(),yysInventoryQueryForm),YysInventoryQueryForm.class); + generaterSwapUtil.swapDatetime(YysInventoryQueryConstant.getFormData(), yysInventoryQueryForm), YysInventoryQueryForm.class); YysInventoryQueryEntity entity = JsonUtil.getJsonToBean(yysInventoryQueryForm, YysInventoryQueryEntity.class); - if(isSave){ - String mainId = RandomUtil.uuId() ; + if (isSave) { + String mainId = RandomUtil.uuId(); entity.setId(mainId); - }else{ + } else { } this.saveOrUpdate(entity); } + + @Override + public String syncInventory() { + List syncList = this.list(new LambdaQueryWrapper<>(YysInventoryQueryEntity.class).isNull(YysInventoryQueryEntity::getDeleteMark)) + .stream().map(YysInventoryQueryEntity::getId).collect(Collectors.toList()); + RowMapper rowMapper = new BeanPropertyRowMapper<>(SyncInventoryQuery.class); + String sql = "select * from CurrentStock"; + List query = this.jdbcTemplate.query(sql, rowMapper); + if (CollectionUtils.isEmpty(query)) { + return "远程库存信息为空"; + } + //物料表数据 不从自己库取数据,防止自己库未同步,从而取不到数据 + RowMapper materialMapper = new BeanPropertyRowMapper<>(MaterialInformationSync.class); + String materialSql = "select * from dbo.Inventory"; + List informationSyncs = this.jdbcTemplate.query(materialSql, materialMapper); + Map materialCollect = Maps.newHashMap(); + if (CollectionUtils.isNotEmpty(informationSyncs)) { + materialCollect = informationSyncs.stream().collect(Collectors.toMap(MaterialInformationSync::getCInvCode, Function.identity())); + } + List result = Lists.newArrayList(); + + for (SyncInventoryQuery inventoryQuery : query) { + YysInventoryQueryEntity entity = new YysInventoryQueryEntity(); + entity.setId(inventoryQuery.getAutoId()); + entity.setInventoryNumber(inventoryQuery.getIQuantity()); + if (MapUtils.isNotEmpty(materialCollect) && materialCollect.containsKey(inventoryQuery.getCInvCode())) { + MaterialInformationSync sync = materialCollect.get(inventoryQuery.getCInvCode()); + entity.setMaterialName(sync.getCInvName()); + entity.setModels(sync.getEInvStd()); + entity.setUnit(sync.getCComUnitCode()); + entity.setMaterialClassification(sync.getCInvCCode()); + } + entity.setCreatorTime(DateUtil.getNowDate()); + result.add(entity); + } + if (CollectionUtils.isEmpty(result)) { + return "没有需要同步的数据"; + } + boolean b = this.saveBatch(result); + if (b) { + return "同步成功"; + } + return "同步失败"; + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSubsetMaterialServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSubsetMaterialServiceImpl.java new file mode 100644 index 0000000..ebace9c --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSubsetMaterialServiceImpl.java @@ -0,0 +1,11 @@ +package jnpf.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import jnpf.entity.YysSubsetMaterialEntity; +import jnpf.mapper.YysSubsetMaterialMapper; +import jnpf.service.YysSubsetMaterialService; +import org.springframework.stereotype.Service; + +@Service +public class YysSubsetMaterialServiceImpl extends ServiceImpl implements YysSubsetMaterialService { +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysBillMaterialController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysBillMaterialController.java index cdebba2..e948e15 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysBillMaterialController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysBillMaterialController.java @@ -15,22 +15,27 @@ import jnpf.model.yysbillmaterial.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; + import javax.validation.Valid; import java.util.*; + import jnpf.annotation.JnpfField; import jnpf.base.vo.PageListVO; import jnpf.base.vo.PaginationVO; import jnpf.base.vo.DownloadVO; import jnpf.config.ConfigValueUtil; import jnpf.base.entity.ProvinceEntity; + import java.io.IOException; import java.util.stream.Collectors; + import jnpf.engine.entity.FlowTaskEntity; import jnpf.exception.WorkFlowException; import org.springframework.transaction.annotation.Transactional; /** * yysBillMaterial + * * @版本: V3.5 * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) * @作者: JNPF开发平台组 @@ -38,7 +43,7 @@ import org.springframework.transaction.annotation.Transactional; */ @Slf4j @RestController -@Tag(name = "yysBillMaterial" , description = "example") +@Tag(name = "yysBillMaterial", description = "example") @RequestMapping("/api/example/YysBillMaterial") public class YysBillMaterialController { @@ -52,27 +57,26 @@ public class YysBillMaterialController { private YysBillMaterialService yysBillMaterialService; - /** - * 列表 - * - * @param yysBillMaterialPagination - * @return - */ + * 列表 + * + * @param yysBillMaterialPagination + * @return + */ @Operation(summary = "获取列表") @PostMapping("/getList") - public ActionResult list(@RequestBody YysBillMaterialPagination yysBillMaterialPagination)throws IOException{ - List list= yysBillMaterialService.getList(yysBillMaterialPagination); - List> realList=new ArrayList<>(); + public ActionResult list(@RequestBody YysBillMaterialPagination yysBillMaterialPagination) throws IOException { + List list = yysBillMaterialService.getList(yysBillMaterialPagination); + List> realList = new ArrayList<>(); for (YysBillMaterialEntity entity : list) { - Map yysBillMaterialMap=JsonUtil.entityToMap(entity); - yysBillMaterialMap.put("id", yysBillMaterialMap.get("id")); - //副表数据 - //子表数据 + Map yysBillMaterialMap = JsonUtil.entityToMap(entity); + yysBillMaterialMap.put("id", yysBillMaterialMap.get("id")); + //副表数据 + //子表数据 realList.add(yysBillMaterialMap); } //数据转换 - realList = generaterSwapUtil.swapDataList(realList, YysBillMaterialConstant.getFormData(), YysBillMaterialConstant.getColumnData(), yysBillMaterialPagination.getModuleId(),false); + realList = generaterSwapUtil.swapDataList(realList, YysBillMaterialConstant.getFormData(), YysBillMaterialConstant.getColumnData(), yysBillMaterialPagination.getModuleId(), false); //返回对象 PageListVO vo = new PageListVO(); @@ -81,110 +85,129 @@ public class YysBillMaterialController { vo.setPagination(page); return ActionResult.success(vo); } + /** - * 创建 - * - * @param yysBillMaterialForm - * @return - */ + * 创建 + * + * @param yysBillMaterialForm + * @return + */ @PostMapping() @Operation(summary = "创建") public ActionResult create(@RequestBody @Valid YysBillMaterialForm yysBillMaterialForm) { - String b = yysBillMaterialService.checkForm(yysBillMaterialForm,0); - if (StringUtil.isNotEmpty(b)){ - return ActionResult.fail(b ); + String b = yysBillMaterialService.checkForm(yysBillMaterialForm, 0); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); } - try{ - yysBillMaterialService.saveOrUpdate(yysBillMaterialForm, null ,true); - }catch(Exception e){ + try { + yysBillMaterialService.saveOrUpdate(yysBillMaterialForm, null, true); + } catch (Exception e) { return ActionResult.fail("新增数据失败"); } return ActionResult.success("创建成功"); } + /** - * 编辑 - * @param id - * @param yysBillMaterialForm - * @return - */ + * 编辑 + * + * @param id + * @param yysBillMaterialForm + * @return + */ @PutMapping("/{id}") @Operation(summary = "更新") - public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid YysBillMaterialForm yysBillMaterialForm, - @RequestParam(value = "isImport", required = false) boolean isImport){ + public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid YysBillMaterialForm yysBillMaterialForm, + @RequestParam(value = "isImport", required = false) boolean isImport) { yysBillMaterialForm.setId(id); if (!isImport) { - String b = yysBillMaterialService.checkForm(yysBillMaterialForm,1); - if (StringUtil.isNotEmpty(b)){ - return ActionResult.fail(b ); + String b = yysBillMaterialService.checkForm(yysBillMaterialForm, 1); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); } } - YysBillMaterialEntity entity= yysBillMaterialService.getInfo(id); - if(entity!=null){ - try{ - yysBillMaterialService.saveOrUpdate(yysBillMaterialForm,id,false); - }catch(Exception e){ + YysBillMaterialEntity entity = yysBillMaterialService.getInfo(id); + if (entity != null) { + try { + yysBillMaterialService.saveOrUpdate(yysBillMaterialForm, id, false); + } catch (Exception e) { return ActionResult.fail("修改数据失败"); } return ActionResult.success("更新成功"); - }else{ + } else { return ActionResult.fail("更新失败,数据不存在"); } } + /** - * 删除 - * @param id - * @return - */ + * 删除 + * + * @param id + * @return + */ @Operation(summary = "删除") @DeleteMapping("/{id}") @Transactional - public ActionResult delete(@PathVariable("id") String id){ - YysBillMaterialEntity entity= yysBillMaterialService.getInfo(id); - if(entity!=null){ + public ActionResult delete(@PathVariable("id") String id) { + YysBillMaterialEntity entity = yysBillMaterialService.getInfo(id); + if (entity != null) { //主表数据删除 yysBillMaterialService.delete(entity); } return ActionResult.success("删除成功"); } + /** - * 表单信息(详情页) - * 详情页面使用-转换数据 - * @param id - * @return - */ + * 表单信息(详情页) + * 详情页面使用-转换数据 + * + * @param id + * @return + */ @Operation(summary = "表单信息(详情页)") @GetMapping("/detail/{id}") - public ActionResult detailInfo(@PathVariable("id") String id){ - YysBillMaterialEntity entity= yysBillMaterialService.getInfo(id); - if(entity==null){ + public ActionResult detailInfo(@PathVariable("id") String id) { + YysBillMaterialEntity entity = yysBillMaterialService.getInfo(id); + if (entity == null) { return ActionResult.fail("表单数据不存在!"); } - Map yysBillMaterialMap=JsonUtil.entityToMap(entity); + Map yysBillMaterialMap = JsonUtil.entityToMap(entity); yysBillMaterialMap.put("id", yysBillMaterialMap.get("id")); //副表数据 //子表数据 - yysBillMaterialMap = generaterSwapUtil.swapDataDetail(yysBillMaterialMap,YysBillMaterialConstant.getFormData(),"591255830234402757",false); + yysBillMaterialMap = generaterSwapUtil.swapDataDetail(yysBillMaterialMap, YysBillMaterialConstant.getFormData(), "591255830234402757", false); return ActionResult.success(yysBillMaterialMap); } + /** - * 获取详情(编辑页) - * 编辑页面使用-不转换数据 - * @param id - * @return - */ + * 获取详情(编辑页) + * 编辑页面使用-不转换数据 + * + * @param id + * @return + */ @Operation(summary = "信息") @GetMapping("/{id}") - public ActionResult info(@PathVariable("id") String id){ - YysBillMaterialEntity entity= yysBillMaterialService.getInfo(id); - if(entity==null){ + public ActionResult info(@PathVariable("id") String id) { + YysBillMaterialEntity entity = yysBillMaterialService.getInfo(id); + if (entity == null) { return ActionResult.fail("表单数据不存在!"); } - Map yysBillMaterialMap=JsonUtil.entityToMap(entity); + Map yysBillMaterialMap = JsonUtil.entityToMap(entity); yysBillMaterialMap.put("id", yysBillMaterialMap.get("id")); //副表数据 //子表数据 - yysBillMaterialMap = generaterSwapUtil.swapDataForm(yysBillMaterialMap,YysBillMaterialConstant.getFormData(),YysBillMaterialConstant.TABLEFIELDKEY,YysBillMaterialConstant.TABLERENAMES); + yysBillMaterialMap = generaterSwapUtil.swapDataForm(yysBillMaterialMap, YysBillMaterialConstant.getFormData(), YysBillMaterialConstant.TABLEFIELDKEY, YysBillMaterialConstant.TABLERENAMES); return ActionResult.success(yysBillMaterialMap); } + @Operation(summary = "U8-获取物料清单") + @GetMapping("/syncMaterial") + public ActionResult syncMaterial() { + String result = yysBillMaterialService.syncMaterial(); + if (result.contains("成功")) { + return ActionResult.success(result); + } + return ActionResult.fail(result); + } + } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysInventoryQueryController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysInventoryQueryController.java index aa9010a..d91ceea 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysInventoryQueryController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysInventoryQueryController.java @@ -15,22 +15,27 @@ import jnpf.model.yysinventoryquery.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; + import javax.validation.Valid; import java.util.*; + import jnpf.annotation.JnpfField; import jnpf.base.vo.PageListVO; import jnpf.base.vo.PaginationVO; import jnpf.base.vo.DownloadVO; import jnpf.config.ConfigValueUtil; import jnpf.base.entity.ProvinceEntity; + import java.io.IOException; import java.util.stream.Collectors; + import jnpf.engine.entity.FlowTaskEntity; import jnpf.exception.WorkFlowException; import org.springframework.transaction.annotation.Transactional; /** * yysInventoryQuery + * * @版本: V3.5 * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) * @作者: JNPF开发平台组 @@ -38,7 +43,7 @@ import org.springframework.transaction.annotation.Transactional; */ @Slf4j @RestController -@Tag(name = "yysInventoryQuery" , description = "example") +@Tag(name = "yysInventoryQuery", description = "example") @RequestMapping("/api/example/YysInventoryQuery") public class YysInventoryQueryController { @@ -52,27 +57,26 @@ public class YysInventoryQueryController { private YysInventoryQueryService yysInventoryQueryService; - /** - * 列表 - * - * @param yysInventoryQueryPagination - * @return - */ + * 列表 + * + * @param yysInventoryQueryPagination + * @return + */ @Operation(summary = "获取列表") @PostMapping("/getList") - public ActionResult list(@RequestBody YysInventoryQueryPagination yysInventoryQueryPagination)throws IOException{ - List list= yysInventoryQueryService.getList(yysInventoryQueryPagination); - List> realList=new ArrayList<>(); + public ActionResult list(@RequestBody YysInventoryQueryPagination yysInventoryQueryPagination) throws IOException { + List list = yysInventoryQueryService.getList(yysInventoryQueryPagination); + List> realList = new ArrayList<>(); for (YysInventoryQueryEntity entity : list) { - Map yysInventoryQueryMap=JsonUtil.entityToMap(entity); - yysInventoryQueryMap.put("id", yysInventoryQueryMap.get("id")); - //副表数据 - //子表数据 + Map yysInventoryQueryMap = JsonUtil.entityToMap(entity); + yysInventoryQueryMap.put("id", yysInventoryQueryMap.get("id")); + //副表数据 + //子表数据 realList.add(yysInventoryQueryMap); } //数据转换 - realList = generaterSwapUtil.swapDataList(realList, YysInventoryQueryConstant.getFormData(), YysInventoryQueryConstant.getColumnData(), yysInventoryQueryPagination.getModuleId(),false); + realList = generaterSwapUtil.swapDataList(realList, YysInventoryQueryConstant.getFormData(), YysInventoryQueryConstant.getColumnData(), yysInventoryQueryPagination.getModuleId(), false); //返回对象 PageListVO vo = new PageListVO(); @@ -81,110 +85,129 @@ public class YysInventoryQueryController { vo.setPagination(page); return ActionResult.success(vo); } + /** - * 创建 - * - * @param yysInventoryQueryForm - * @return - */ + * 创建 + * + * @param yysInventoryQueryForm + * @return + */ @PostMapping() @Operation(summary = "创建") public ActionResult create(@RequestBody @Valid YysInventoryQueryForm yysInventoryQueryForm) { - String b = yysInventoryQueryService.checkForm(yysInventoryQueryForm,0); - if (StringUtil.isNotEmpty(b)){ - return ActionResult.fail(b ); + String b = yysInventoryQueryService.checkForm(yysInventoryQueryForm, 0); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); } - try{ - yysInventoryQueryService.saveOrUpdate(yysInventoryQueryForm, null ,true); - }catch(Exception e){ + try { + yysInventoryQueryService.saveOrUpdate(yysInventoryQueryForm, null, true); + } catch (Exception e) { return ActionResult.fail("新增数据失败"); } return ActionResult.success("创建成功"); } + /** - * 编辑 - * @param id - * @param yysInventoryQueryForm - * @return - */ + * 编辑 + * + * @param id + * @param yysInventoryQueryForm + * @return + */ @PutMapping("/{id}") @Operation(summary = "更新") - public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid YysInventoryQueryForm yysInventoryQueryForm, - @RequestParam(value = "isImport", required = false) boolean isImport){ + public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid YysInventoryQueryForm yysInventoryQueryForm, + @RequestParam(value = "isImport", required = false) boolean isImport) { yysInventoryQueryForm.setId(id); if (!isImport) { - String b = yysInventoryQueryService.checkForm(yysInventoryQueryForm,1); - if (StringUtil.isNotEmpty(b)){ - return ActionResult.fail(b ); + String b = yysInventoryQueryService.checkForm(yysInventoryQueryForm, 1); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); } } - YysInventoryQueryEntity entity= yysInventoryQueryService.getInfo(id); - if(entity!=null){ - try{ - yysInventoryQueryService.saveOrUpdate(yysInventoryQueryForm,id,false); - }catch(Exception e){ + YysInventoryQueryEntity entity = yysInventoryQueryService.getInfo(id); + if (entity != null) { + try { + yysInventoryQueryService.saveOrUpdate(yysInventoryQueryForm, id, false); + } catch (Exception e) { return ActionResult.fail("修改数据失败"); } return ActionResult.success("更新成功"); - }else{ + } else { return ActionResult.fail("更新失败,数据不存在"); } } + /** - * 删除 - * @param id - * @return - */ + * 删除 + * + * @param id + * @return + */ @Operation(summary = "删除") @DeleteMapping("/{id}") @Transactional - public ActionResult delete(@PathVariable("id") String id){ - YysInventoryQueryEntity entity= yysInventoryQueryService.getInfo(id); - if(entity!=null){ + public ActionResult delete(@PathVariable("id") String id) { + YysInventoryQueryEntity entity = yysInventoryQueryService.getInfo(id); + if (entity != null) { //主表数据删除 yysInventoryQueryService.delete(entity); } return ActionResult.success("删除成功"); } + /** - * 表单信息(详情页) - * 详情页面使用-转换数据 - * @param id - * @return - */ + * 表单信息(详情页) + * 详情页面使用-转换数据 + * + * @param id + * @return + */ @Operation(summary = "表单信息(详情页)") @GetMapping("/detail/{id}") - public ActionResult detailInfo(@PathVariable("id") String id){ - YysInventoryQueryEntity entity= yysInventoryQueryService.getInfo(id); - if(entity==null){ + public ActionResult detailInfo(@PathVariable("id") String id) { + YysInventoryQueryEntity entity = yysInventoryQueryService.getInfo(id); + if (entity == null) { return ActionResult.fail("表单数据不存在!"); } - Map yysInventoryQueryMap=JsonUtil.entityToMap(entity); + Map yysInventoryQueryMap = JsonUtil.entityToMap(entity); yysInventoryQueryMap.put("id", yysInventoryQueryMap.get("id")); //副表数据 //子表数据 - yysInventoryQueryMap = generaterSwapUtil.swapDataDetail(yysInventoryQueryMap,YysInventoryQueryConstant.getFormData(),"591261094123671493",false); + yysInventoryQueryMap = generaterSwapUtil.swapDataDetail(yysInventoryQueryMap, YysInventoryQueryConstant.getFormData(), "591261094123671493", false); return ActionResult.success(yysInventoryQueryMap); } + /** - * 获取详情(编辑页) - * 编辑页面使用-不转换数据 - * @param id - * @return - */ + * 获取详情(编辑页) + * 编辑页面使用-不转换数据 + * + * @param id + * @return + */ @Operation(summary = "信息") @GetMapping("/{id}") - public ActionResult info(@PathVariable("id") String id){ - YysInventoryQueryEntity entity= yysInventoryQueryService.getInfo(id); - if(entity==null){ + public ActionResult info(@PathVariable("id") String id) { + YysInventoryQueryEntity entity = yysInventoryQueryService.getInfo(id); + if (entity == null) { return ActionResult.fail("表单数据不存在!"); } - Map yysInventoryQueryMap=JsonUtil.entityToMap(entity); + Map yysInventoryQueryMap = JsonUtil.entityToMap(entity); yysInventoryQueryMap.put("id", yysInventoryQueryMap.get("id")); //副表数据 //子表数据 - yysInventoryQueryMap = generaterSwapUtil.swapDataForm(yysInventoryQueryMap,YysInventoryQueryConstant.getFormData(),YysInventoryQueryConstant.TABLEFIELDKEY,YysInventoryQueryConstant.TABLERENAMES); + yysInventoryQueryMap = generaterSwapUtil.swapDataForm(yysInventoryQueryMap, YysInventoryQueryConstant.getFormData(), YysInventoryQueryConstant.TABLEFIELDKEY, YysInventoryQueryConstant.TABLERENAMES); return ActionResult.success(yysInventoryQueryMap); } + @Operation(summary = "U8-获取库存查询数据") + @GetMapping("/syncInventory") + public ActionResult syncInventory() { + String result = yysInventoryQueryService.syncInventory(); + if (result.contains("成功")) { + return ActionResult.success(result); + } + return ActionResult.fail(result); + } + } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysInventoryQueryEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysInventoryQueryEntity.java index 4322377..3248eba 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysInventoryQueryEntity.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysInventoryQueryEntity.java @@ -30,7 +30,7 @@ public class YysInventoryQueryEntity { @TableField(value = "MODELS" , updateStrategy = FieldStrategy.IGNORED) private String models; @TableField(value = "INVENTORY_NUMBER" , updateStrategy = FieldStrategy.IGNORED) - private BigDecimal inventoryNumber; + private String inventoryNumber; @TableField("REAMRK") private String reamrk; @TableField("F_CREATOR_TIME") diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysSubsetMaterialEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysSubsetMaterialEntity.java new file mode 100644 index 0000000..483b9d4 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysSubsetMaterialEntity.java @@ -0,0 +1,56 @@ +package jnpf.entity; + +import com.baomidou.mybatisplus.annotation.FieldStrategy; +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; + +@Data +@TableName("yys_subset_material") +public class YysSubsetMaterialEntity { + @TableId(value = "ID") + private String id; + @TableField(value = "PIECE_ID", updateStrategy = FieldStrategy.IGNORED) + private String pieceId; + @TableField(value = "SUBSET_ID", updateStrategy = FieldStrategy.IGNORED) + private String subsetId; + @TableField(value = "SUBSET_NAME", updateStrategy = FieldStrategy.IGNORED) + private String subsetName; + @TableField(value = "SUBSET_MODEL", updateStrategy = FieldStrategy.IGNORED) + private String subsetModel; + @TableField(value = "UNIT", updateStrategy = FieldStrategy.IGNORED) + private String unit; + @TableField(value = "STATUS", updateStrategy = FieldStrategy.IGNORED) + private String status; + @TableField(value = "BASE_USE", updateStrategy = FieldStrategy.IGNORED) + private String baseUse; + @TableField(value = "BASE_NUM", updateStrategy = FieldStrategy.IGNORED) + private String baseNum; + @TableField(value = "F_CREATOR_TIME", updateStrategy = FieldStrategy.IGNORED) + private Date creatorTime; + @TableField("F_CREATOR_USER_ID") + private String creatorUserId; + @TableField("F_LAST_MODIFY_TIME") + private Date lastModifyTime; + @TableField("F_LAST_MODIFY_USER_ID") + private String lastModifyUserId; + @TableField("F_DELETE_TIME") + private Date deleteTime; + @TableField("F_DELETE_USER_ID") + private String deleteUserId; + @TableField("F_DELETE_MARK") + private Integer deleteMark; + @TableField("F_TENANT_ID") + private String tenantId; + @TableField("COMPANY_ID") + private String companyId; + @TableField("DEPARTMENT_ID") + private String departmentId; + @TableField("ORGANIZE_JSON_ID") + private String organizeJsonId; + @TableField("F_FLOW_ID") + private String flowId; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysbillmaterial/SyncMaterial.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysbillmaterial/SyncMaterial.java new file mode 100644 index 0000000..ad965f1 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysbillmaterial/SyncMaterial.java @@ -0,0 +1,23 @@ +package jnpf.model.yysbillmaterial; + +import lombok.Data; + +@Data +public class SyncMaterial { + + /** + * 母件物料主键id + */ + private String AutoId; + + /** + * 母件物料bomId + */ + private String BomId; + + /** + * 母件物料编码 + */ + private String InvCode; + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysbillmaterial/SyncSubsetMaterial.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysbillmaterial/SyncSubsetMaterial.java new file mode 100644 index 0000000..02bb561 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysbillmaterial/SyncSubsetMaterial.java @@ -0,0 +1,32 @@ +package jnpf.model.yysbillmaterial; + +import lombok.Data; + +@Data +public class SyncSubsetMaterial { + + /** + * 子件物料主键id + */ + private String OpComponentId; + + /** + * 子件物料bomId + */ + private String BomId; + + /** + * 基本用量 + */ + private String BaseQtyN; + + /** + * 基础数量 + */ + private String BaseQtyD; + + /** + * 子件物料编码 + */ + private String InvCode; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysinventoryquery/SyncInventoryQuery.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysinventoryquery/SyncInventoryQuery.java new file mode 100644 index 0000000..09815e4 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysinventoryquery/SyncInventoryQuery.java @@ -0,0 +1,21 @@ +package jnpf.model.yysinventoryquery; + +import lombok.Data; + +@Data +public class SyncInventoryQuery { + + /** + * 主键id + */ + private String AutoId; + /** + * 编码 + */ + private String cInvCode; + + /** + * 现存量 + */ + private String iQuantity; +} diff --git a/jnpf-java-boot/jnpf-scheduletask/jnpf-scheduletask-biz/src/main/java/jnpf/scheduletask/task/YysTaskHandler.java b/jnpf-java-boot/jnpf-scheduletask/jnpf-scheduletask-biz/src/main/java/jnpf/scheduletask/task/YysTaskHandler.java index 1bf5219..1b5098e 100644 --- a/jnpf-java-boot/jnpf-scheduletask/jnpf-scheduletask-biz/src/main/java/jnpf/scheduletask/task/YysTaskHandler.java +++ b/jnpf-java-boot/jnpf-scheduletask/jnpf-scheduletask-biz/src/main/java/jnpf/scheduletask/task/YysTaskHandler.java @@ -6,9 +6,7 @@ import jnpf.entity.EqmtCollectExceptMasterEntity; import jnpf.entity.EqmtCollectPubDataEntity; import jnpf.entity.YysDeviceDataEntity; import jnpf.entity.YysDeviceWarnStatisticsEntity; -import jnpf.service.YysDeviceDataService; -import jnpf.service.YysDeviceWarnService; -import jnpf.service.YysDeviceWarnStatisticsService; +import jnpf.service.*; import jnpf.util.DateUtil; import jnpf.util.RandomUtil; import jnpf.util.UserProvider; @@ -33,6 +31,30 @@ public class YysTaskHandler { @Resource private YysDeviceWarnService yysDeviceWarnService; + @Resource + private YysSupplierInformationService yysSupplierInformationService; + + @Resource + private YysSupplierClassService yysSupplierClassService; + + @Resource + private YysMaterialInformationService yysMaterialInformationService; + + @Resource + private YysMaterialClassService yysMaterialClassService; + + @Resource + private YysUnitInformationService yysUnitInformationService; + + @Resource + private YysBillMaterialService yysBillMaterialService; + + @Resource + private YysInventoryQueryService yysInventoryQueryService; + + @Resource + private YysDayWorkService yysDayWorkService; + @Autowired private UserProvider userProvider; @@ -114,4 +136,78 @@ public class YysTaskHandler { CompletableFuture.runAsync(() -> yysDeviceWarnService.syncCount(collect)); } } + + /** + * 同步U8供应商信息 + */ + //每一小时执行一次 + @XxlJob("syncSupplier") + public void syncSupplier() { + yysSupplierInformationService.syncSupplier(); + } + + /** + * 同步U8供应商分类 + */ + //每一小时执行一次 + @XxlJob("syncSupplierClass") + public void syncSupplierClass() { + yysSupplierClassService.syncSupplierClass(); + } + + /** + * 同步U8物料信息 + */ + //每一小时执行一次 + @XxlJob("syncMaterialInfo") + public void syncMaterialInfo() { + yysMaterialInformationService.syncMaterialInfo(); + } + + /** + * 同步U8物料分类信息 + */ + //每一小时执行一次 + @XxlJob("syncMaterialClass") + public void syncMaterialClass() { + yysMaterialClassService.syncMaterialClass(); + } + + /** + * 同步U8单位信息 + */ + //每一小时执行一次 + @XxlJob("syncUnit") + public void syncUnit() { + yysUnitInformationService.syncUnit(); + } + + /** + * 同步U8物料清单 + */ + //每一小时执行一次 + @XxlJob("syncMaterial") + public void syncMaterial() { + yysBillMaterialService.syncMaterial(); + } + + /** + * 同步U8供应商信息 + */ + //每一小时执行一次 + @XxlJob("syncInventory") + public void syncInventory() { + yysInventoryQueryService.syncInventory(); + } + + + /** + * 日生产工单状态实时更新 + */ + //每分钟执行一次 + @XxlJob("syncDayWork") + public void syncDayWork() { + yysDayWorkService.syncDayWork(); + } + } diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yysbillmaterial/index.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yysbillmaterial/index.vue index 6ee0c5e..0bae7ef 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yysbillmaterial/index.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yysbillmaterial/index.vue @@ -31,6 +31,8 @@
新增 + 获取数据 +
@@ -182,6 +184,25 @@ export default { this.queryData = JSON.parse(JSON.stringify(this.query)) }, methods: { + syncData(){ + this.$confirm('此操作将从远程库中拉取同步数据, 是否继续?', '提示', { + type: 'warning' + }).then(() => { + request({ + url: `/api/example/YysBillMaterial/syncMaterial`, + method: 'GET' + }).then(res => { + this.$message({ + type: 'success', + message: res.msg, + onClose: () => { + this.initData() + } + }); + }) + }).catch(() => { + }); + }, toDetail(defaultValue, modelId) { if (!defaultValue) return getConfigData(modelId).then(res => { diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yysdaywork/form.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yysdaywork/form.vue index daa2e11..3d11cdf 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yysdaywork/form.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yysdaywork/form.vue @@ -282,7 +282,7 @@ export default { deviceCodecolumnOptions: [{ "label": "设备编码", "value": "device_code" }, { "label": "设备名称", "value": "device_name" }, { "label": "设备类型", "value": "device_desc" },], postcolumnOptions: [{ "label": "班次", "value": "classes_name" }, { "label": "开始时间", "value": "start_time" }, { "label": "结束时间", "value": "end_time" }, { "label": "时长", "value": "classes_duration" },], productCodecolumnOptions: [{ "label": "产品编码", "value": "material_id" }, { "label": "产品名称", "value": "material_name" }, { "label": "规格型号", "value": "model" }, { "label": "计量单位", "value": "unit_measurement" }, { "label": "安全库存", "value": "safety_stock" },], - productionStatusOptions: [{ "fullName": "未开工", "id": "1" }, { "fullName": "已完工", "id": "2" }], + productionStatusOptions: [{ "fullName": "未开工", "id": "1" }, { "fullName": "已完工", "id": "2" }, { "fullName": "已开工", "id": "3" }], productionStatusProps: { "label": "fullName", "value": "id" }, childIndex: -1, isEdit: false, diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yysdeviceupkeep/form.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yysdeviceupkeep/form.vue index e9b7394..9b58c9e 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yysdeviceupkeep/form.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yysdeviceupkeep/form.vue @@ -83,7 +83,7 @@ @click="delyysdeviceunkeeplogsList(scope.$index)">删除 - + @@ -97,7 +97,7 @@ - + @@ -111,7 +111,7 @@ - + diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yysinventoryquery/index.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yysinventoryquery/index.vue index afd0dda..6969604 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yysinventoryquery/index.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yysinventoryquery/index.vue @@ -31,7 +31,7 @@
- 获取数据 + 获取数据
@@ -174,6 +174,25 @@ export default { this.queryData = JSON.parse(JSON.stringify(this.query)) }, methods: { + syncData(){ + this.$confirm('此操作将从远程库中拉取同步数据, 是否继续?', '提示', { + type: 'warning' + }).then(() => { + request({ + url: `/api/example/YysInventoryQuery/syncInventory`, + method: 'GET' + }).then(res => { + this.$message({ + type: 'success', + message: res.msg, + onClose: () => { + this.initData() + } + }); + }) + }).catch(() => { + }); + }, toDetail(defaultValue, modelId) { if (!defaultValue) return getConfigData(modelId).then(res => {