From 9c224ed3d1604be49d921e734182f80c540e2a83 Mon Sep 17 00:00:00 2001 From: jiyufei <67400194@qq.com> Date: Wed, 14 Aug 2024 16:14:02 +0800 Subject: [PATCH] =?UTF-8?q?feat():app=E5=90=8E=E7=AB=AF=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jnpf/service/YysDayPackageService.java | 23 +- .../java/jnpf/service/YysDayWorkService.java | 27 +- .../java/jnpf/service/YysGroupService.java | 15 +- .../impl/YysDayPackageServiceImpl.java | 381 +++++++++++------- .../service/impl/YysDayWorkServiceImpl.java | 133 ++++++ .../service/impl/YysGroupServiceImpl.java | 303 ++++++++------ .../jnpf/controller/YysDayWorkController.java | 87 ++-- .../java/jnpf/entity/YysDayPackageEntity.java | 2 + .../java/jnpf/entity/YysDayWorkEntity.java | 2 + .../jnpf/entity/YysPackageReportEntity.java | 2 + .../java/jnpf/entity/YysProdReportEntity.java | 2 + .../entity/YysRequisitionReportEntity.java | 2 + .../jnpf/model/yysdaywork/ConfirmRequest.java | 22 + .../model/yysdaywork/ConfirmResponse.java | 64 +++ 14 files changed, 738 insertions(+), 327 deletions(-) create mode 100644 jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysdaywork/ConfirmRequest.java create mode 100644 jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysdaywork/ConfirmResponse.java diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysDayPackageService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysDayPackageService.java index 10c57e3..ea3048f 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysDayPackageService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysDayPackageService.java @@ -2,9 +2,13 @@ package jnpf.service; import jnpf.model.yysdaypackage.*; import jnpf.entity.*; + import java.util.*; + import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import jnpf.model.yysdaywork.ConfirmRequest; +import jnpf.model.yysdaywork.ConfirmResponse; /** * yysDayPackage @@ -16,7 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; public interface YysDayPackageService extends IService { List getList(YysDayPackagePagination yysDayPackagePagination); - List getTypeList(YysDayPackagePagination yysDayPackagePagination,String dataType); + List getTypeList(YysDayPackagePagination yysDayPackagePagination, String dataType); YysDayPackageEntity getInfo(String id); @@ -28,8 +32,17 @@ public interface YysDayPackageService extends IService { //子表方法 //副表数据方法 - String checkForm(YysDayPackageForm form,int i); - - void saveOrUpdate(YysDayPackageForm yysDayPackageForm,String id, boolean isSave) throws Exception; - + String checkForm(YysDayPackageForm form, int i); + + void saveOrUpdate(YysDayPackageForm yysDayPackageForm, String id, boolean isSave) throws Exception; + + /** + * 报工确认列表-app + * + * @param groupName + * @param request + * @param requisitonMap + * @return + */ + List queryList(String groupName, ConfirmRequest request, Map> requisitonMap); } 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 c7ed643..3f6ee3c 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 @@ -2,7 +2,9 @@ package jnpf.service; import jnpf.model.yysdaywork.*; import jnpf.entity.*; + import java.util.*; + import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,7 +18,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; public interface YysDayWorkService extends IService { List getList(YysDayWorkPagination yysDayWorkPagination); - List getTypeList(YysDayWorkPagination yysDayWorkPagination,String dataType); + List getTypeList(YysDayWorkPagination yysDayWorkPagination, String dataType); YysDayWorkEntity getInfo(String id); @@ -28,8 +30,23 @@ public interface YysDayWorkService extends IService { //子表方法 //副表数据方法 - String checkForm(YysDayWorkForm form,int i); - - void saveOrUpdate(YysDayWorkForm yysDayWorkForm,String id, boolean isSave) throws Exception; - + String checkForm(YysDayWorkForm form, int i); + + void saveOrUpdate(YysDayWorkForm yysDayWorkForm, String id, boolean isSave) throws Exception; + + /** + * 报工确认列表-app + * + * @param request + * @return + */ + List queryList(ConfirmRequest request); + + /** + * 报工确认 + * + * @param request + * @return + */ + String sure(ConfirmResponse request); } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysGroupService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysGroupService.java index aa7dc7e..42165a0 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysGroupService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysGroupService.java @@ -2,7 +2,9 @@ package jnpf.service; import jnpf.model.yysgroup.*; import jnpf.entity.*; + import java.util.*; + import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,7 +18,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; public interface YysGroupService extends IService { List getList(YysGroupPagination yysGroupPagination); - List getTypeList(YysGroupPagination yysGroupPagination,String dataType); + List getTypeList(YysGroupPagination yysGroupPagination, String dataType); YysGroupEntity getInfo(String id); @@ -28,8 +30,15 @@ public interface YysGroupService extends IService { //子表方法 //副表数据方法 - String checkForm(YysGroupForm form,int i); + String checkForm(YysGroupForm form, int i); - void saveOrUpdate(YysGroupForm yysGroupForm,String id, boolean isSave) throws Exception; + void saveOrUpdate(YysGroupForm yysGroupForm, String id, boolean isSave) throws Exception; + /** + * 查询属于生产还是包装线 + * + * @param userId + * @return + */ + YysGroupEntity queryType(String userId); } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysDayPackageServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysDayPackageServiceImpl.java index 2e2b3f1..21846f6 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysDayPackageServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysDayPackageServiceImpl.java @@ -1,23 +1,37 @@ package jnpf.service.impl; +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.google.common.collect.Lists; import jnpf.entity.*; import jnpf.mapper.YysDayPackageMapper; +import jnpf.model.yysdaywork.ConfirmRequest; +import jnpf.model.yysdaywork.ConfirmResponse; import jnpf.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jnpf.model.yysdaypackage.*; + 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.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import jnpf.database.model.superQuery.SuperJsonModel; @@ -25,13 +39,17 @@ 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 jnpf.base.UserInfo; import jnpf.permission.entity.UserEntity; + /** - * * yysDayPackage * 版本: V3.5 * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) @@ -39,177 +57,186 @@ import jnpf.permission.entity.UserEntity; * 日期: 2024-08-06 */ @Service -public class YysDayPackageServiceImpl extends ServiceImpl implements YysDayPackageService{ +public class YysDayPackageServiceImpl extends ServiceImpl implements YysDayPackageService { @Autowired private GeneraterSwapUtil generaterSwapUtil; @Autowired private UserProvider userProvider; + @Autowired + private YysDeviceDataService yysDeviceDataService; + + @Autowired + private YysPackageReportService yysPackageReportService; + @Override - public List getList(YysDayPackagePagination yysDayPackagePagination){ - return getTypeList(yysDayPackagePagination,yysDayPackagePagination.getDataType()); + public List getList(YysDayPackagePagination yysDayPackagePagination) { + return getTypeList(yysDayPackagePagination, yysDayPackagePagination.getDataType()); } - /** 列表查询 */ + + /** + * 列表查询 + */ @Override - public List getTypeList(YysDayPackagePagination yysDayPackagePagination,String dataType){ - String userId=userProvider.get().getUserId(); - List AllIdList =new ArrayList(); - List> intersectionList =new ArrayList<>(); + public List getTypeList(YysDayPackagePagination yysDayPackagePagination, 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 ? YysDayPackageConstant.getAppColumnData() : YysDayPackageConstant.getColumnData(); ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class); String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList()); - int total=0; - int yysDayPackageNum =0; - QueryWrapper yysDayPackageQueryWrapper=new QueryWrapper<>(); + int total = 0; + int yysDayPackageNum = 0; + QueryWrapper yysDayPackageQueryWrapper = new QueryWrapper<>(); List allSuperIDlist = new ArrayList<>(); - String superOp =""; - if (ObjectUtil.isNotEmpty(yysDayPackagePagination.getSuperQueryJson())){ + String superOp = ""; + if (ObjectUtil.isNotEmpty(yysDayPackagePagination.getSuperQueryJson())) { List allSuperList = new ArrayList<>(); - List> intersectionSuperList = new ArrayList<>(); + List> intersectionSuperList = new ArrayList<>(); String queryJson = yysDayPackagePagination.getSuperQueryJson(); SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class); int superNum = 0; QueryWrapper yysDayPackageSuperWrapper = new QueryWrapper<>(); - yysDayPackageSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysDayPackageSuperWrapper,YysDayPackageEntity.class,queryJson,"0")); + yysDayPackageSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysDayPackageSuperWrapper, YysDayPackageEntity.class, queryJson, "0")); int yysDayPackageNum1 = yysDayPackageSuperWrapper.getExpression().getNormal().size(); - if (yysDayPackageNum1>0){ - List yysDayPackageList =this.list(yysDayPackageSuperWrapper).stream().map(YysDayPackageEntity::getId).collect(Collectors.toList()); + if (yysDayPackageNum1 > 0) { + List yysDayPackageList = this.list(yysDayPackageSuperWrapper).stream().map(YysDayPackageEntity::getId).collect(Collectors.toList()); allSuperList.addAll(yysDayPackageList); intersectionSuperList.add(yysDayPackageList); 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 yysDayPackageSuperWrapper = new QueryWrapper<>(); - yysDayPackageSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysDayPackageSuperWrapper,YysDayPackageEntity.class,ruleJson,"0")); + yysDayPackageSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysDayPackageSuperWrapper, YysDayPackageEntity.class, ruleJson, "0")); int yysDayPackageNum1 = yysDayPackageSuperWrapper.getExpression().getNormal().size(); - if (yysDayPackageNum1>0){ - List yysDayPackageList =this.list(yysDayPackageSuperWrapper).stream().map(YysDayPackageEntity::getId).collect(Collectors.toList()); + if (yysDayPackageNum1 > 0) { + List yysDayPackageList = this.list(yysDayPackageSuperWrapper).stream().map(YysDayPackageEntity::getId).collect(Collectors.toList()); allRuleList.addAll(yysDayPackageList); intersectionRuleList.add(yysDayPackageList); 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 yysDayPackageObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysDayPackageQueryWrapper,YysDayPackageEntity.class,yysDayPackagePagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysDayPackageObj)){ - return new ArrayList<>(); - } else { - yysDayPackageQueryWrapper = (QueryWrapper)yysDayPackageObj; - if( yysDayPackageQueryWrapper.getExpression().getNormal().size()>0){ - yysDayPackageNum++; - } - } - } - } - if(!isPc && appPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysDayPackageObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysDayPackageQueryWrapper,YysDayPackageEntity.class,yysDayPackagePagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysDayPackageObj)){ - return new ArrayList<>(); - } else { - yysDayPackageQueryWrapper = (QueryWrapper)yysDayPackageObj; - if( yysDayPackageQueryWrapper.getExpression().getNormal().size()>0){ - yysDayPackageNum++; - } + boolean pcPermission = false; + boolean appPermission = false; + if (isPc && pcPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysDayPackageObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysDayPackageQueryWrapper, YysDayPackageEntity.class, yysDayPackagePagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysDayPackageObj)) { + return new ArrayList<>(); + } else { + yysDayPackageQueryWrapper = (QueryWrapper) yysDayPackageObj; + if (yysDayPackageQueryWrapper.getExpression().getNormal().size() > 0) { + yysDayPackageNum++; + } + } + } } + if (!isPc && appPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysDayPackageObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysDayPackageQueryWrapper, YysDayPackageEntity.class, yysDayPackagePagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysDayPackageObj)) { + return new ArrayList<>(); + } else { + yysDayPackageQueryWrapper = (QueryWrapper) yysDayPackageObj; + if (yysDayPackageQueryWrapper.getExpression().getNormal().size() > 0) { + yysDayPackageNum++; + } + } - } - } - if(isPc){ - if(ObjectUtil.isNotEmpty(yysDayPackagePagination.getManufactureTime())){ - yysDayPackageNum++; + } + } + if (isPc) { + if (ObjectUtil.isNotEmpty(yysDayPackagePagination.getManufactureTime())) { + yysDayPackageNum++; - List ManufactureTimeList = JsonUtil.getJsonToList(yysDayPackagePagination.getManufactureTime(),String.class); - Long fir = Long.valueOf(String.valueOf(ManufactureTimeList.get(0))); - Long sec = Long.valueOf(String.valueOf(ManufactureTimeList.get(1))); + List ManufactureTimeList = JsonUtil.getJsonToList(yysDayPackagePagination.getManufactureTime(), String.class); + Long fir = Long.valueOf(String.valueOf(ManufactureTimeList.get(0))); + Long sec = Long.valueOf(String.valueOf(ManufactureTimeList.get(1))); - yysDayPackageQueryWrapper.lambda().ge(YysDayPackageEntity::getManufactureTime, new Date(fir)) - .le(YysDayPackageEntity::getManufactureTime, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59")); + yysDayPackageQueryWrapper.lambda().ge(YysDayPackageEntity::getManufactureTime, new Date(fir)) + .le(YysDayPackageEntity::getManufactureTime, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59")); } - if(ObjectUtil.isNotEmpty(yysDayPackagePagination.getProductCode())){ - yysDayPackageNum++; + if (ObjectUtil.isNotEmpty(yysDayPackagePagination.getProductCode())) { + yysDayPackageNum++; String value = yysDayPackagePagination.getProductCode() instanceof List ? - JsonUtil.getObjectToString(yysDayPackagePagination.getProductCode()) : - String.valueOf(yysDayPackagePagination.getProductCode()); - yysDayPackageQueryWrapper.lambda().like(YysDayPackageEntity::getProductCode,value); + JsonUtil.getObjectToString(yysDayPackagePagination.getProductCode()) : + String.valueOf(yysDayPackagePagination.getProductCode()); + yysDayPackageQueryWrapper.lambda().like(YysDayPackageEntity::getProductCode, value); } - if(ObjectUtil.isNotEmpty(yysDayPackagePagination.getProductName())){ - yysDayPackageNum++; + if (ObjectUtil.isNotEmpty(yysDayPackagePagination.getProductName())) { + yysDayPackageNum++; String value = yysDayPackagePagination.getProductName() instanceof List ? - JsonUtil.getObjectToString(yysDayPackagePagination.getProductName()) : - String.valueOf(yysDayPackagePagination.getProductName()); - yysDayPackageQueryWrapper.lambda().like(YysDayPackageEntity::getProductName,value); + JsonUtil.getObjectToString(yysDayPackagePagination.getProductName()) : + String.valueOf(yysDayPackagePagination.getProductName()); + yysDayPackageQueryWrapper.lambda().like(YysDayPackageEntity::getProductName, value); } - if(ObjectUtil.isNotEmpty(yysDayPackagePagination.getDeviceName())){ - yysDayPackageNum++; + if (ObjectUtil.isNotEmpty(yysDayPackagePagination.getDeviceName())) { + yysDayPackageNum++; String value = yysDayPackagePagination.getDeviceName() instanceof List ? - JsonUtil.getObjectToString(yysDayPackagePagination.getDeviceName()) : - String.valueOf(yysDayPackagePagination.getDeviceName()); - yysDayPackageQueryWrapper.lambda().like(YysDayPackageEntity::getDeviceName,value); + JsonUtil.getObjectToString(yysDayPackagePagination.getDeviceName()) : + String.valueOf(yysDayPackagePagination.getDeviceName()); + yysDayPackageQueryWrapper.lambda().like(YysDayPackageEntity::getDeviceName, value); } } List intersection = generaterSwapUtil.getIntersection(intersectionList); - if (total>0){ - if (intersection.size()==0){ + if (total > 0) { + if (intersection.size() == 0) { intersection.add("jnpfNullList"); } yysDayPackageQueryWrapper.lambda().in(YysDayPackageEntity::getId, intersection); } - //是否有高级查询 - if (StringUtil.isNotEmpty(superOp)){ - if (allSuperIDlist.size()==0){ + //是否有高级查询 + if (StringUtil.isNotEmpty(superOp)) { + if (allSuperIDlist.size() == 0) { allSuperIDlist.add("jnpfNullList"); } List finalAllSuperIDlist = allSuperIDlist; - yysDayPackageQueryWrapper.lambda().and(t->t.in(YysDayPackageEntity::getId, finalAllSuperIDlist)); + yysDayPackageQueryWrapper.lambda().and(t -> t.in(YysDayPackageEntity::getId, finalAllSuperIDlist)); } - //是否有数据过滤查询 - if (StringUtil.isNotEmpty(ruleOp)){ - if (allRuleIDlist.size()==0){ + //是否有数据过滤查询 + if (StringUtil.isNotEmpty(ruleOp)) { + if (allRuleIDlist.size() == 0) { allRuleIDlist.add("jnpfNullList"); } List finalAllRuleIDlist = allRuleIDlist; - yysDayPackageQueryWrapper.lambda().and(t->t.in(YysDayPackageEntity::getId, finalAllRuleIDlist)); + yysDayPackageQueryWrapper.lambda().and(t -> t.in(YysDayPackageEntity::getId, finalAllRuleIDlist)); } //假删除标志 yysDayPackageQueryWrapper.lambda().isNull(YysDayPackageEntity::getDeleteMark); @@ -232,95 +259,169 @@ public class YysDayPackageServiceImpl extends ServiceImpl0 && AllIdList.size()>0) || total==0){ - Page page=new Page<>(yysDayPackagePagination.getCurrentPage(), yysDayPackagePagination.getPageSize()); - IPage userIPage=this.page(page, yysDayPackageQueryWrapper); - return yysDayPackagePagination.setData(userIPage.getRecords(),userIPage.getTotal()); - }else{ + if ("0".equals(dataType)) { + if ((total > 0 && AllIdList.size() > 0) || total == 0) { + Page page = new Page<>(yysDayPackagePagination.getCurrentPage(), yysDayPackagePagination.getPageSize()); + IPage userIPage = this.page(page, yysDayPackageQueryWrapper); + return yysDayPackagePagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { List list = new ArrayList(); return yysDayPackagePagination.setData(list, list.size()); } - }else{ + } else { return this.list(yysDayPackageQueryWrapper); } } + @Override - public YysDayPackageEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(YysDayPackageEntity::getId,id); + public YysDayPackageEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(YysDayPackageEntity::getId, id); return this.getOne(queryWrapper); } + @Override - public void create(YysDayPackageEntity entity){ + public void create(YysDayPackageEntity entity) { this.save(entity); } + @Override - public boolean update(String id, YysDayPackageEntity entity){ + public boolean update(String id, YysDayPackageEntity entity) { return this.updateById(entity); } + @Override - public void delete(YysDayPackageEntity entity){ - if(entity!=null){ + public void delete(YysDayPackageEntity entity) { + if (entity != null) { this.removeById(entity.getId()); } } - /** 验证表单唯一字段,正则,非空 i-0新增-1修改*/ + + /** + * 验证表单唯一字段,正则,非空 i-0新增-1修改 + */ @Override - public String checkForm(YysDayPackageForm form,int i) { - boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); - String id=""; + public String checkForm(YysDayPackageForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; String countRecover = ""; - if (isUp){ + if (isUp) { id = form.getId(); } //主表字段验证 - if(StringUtil.isEmpty(form.getProductCode())){ - return "产品编码不能为空"; - } - if(StringUtil.isNotEmpty(form.getProductName())){ - form.setProductName(form.getProductName().trim()); - QueryWrapper productNameWrapper=new QueryWrapper<>(); - productNameWrapper.lambda().eq(YysDayPackageEntity::getProductName,form.getProductName()); - //假删除标志 - productNameWrapper.lambda().isNull(YysDayPackageEntity::getDeleteMark); - if (isUp){ - productNameWrapper.lambda().ne(YysDayPackageEntity::getId, id); - } - if((int) this.count(productNameWrapper)>0){ - countRecover = "产品名称不能重复"; - } - } - if(StringUtil.isEmpty(form.getModels())){ - return "规格型号不能为空"; - } - if(StringUtil.isEmpty(form.getMeasurementUnit())){ - return "计量单位不能为空"; - } + if (StringUtil.isEmpty(form.getProductCode())) { + return "产品编码不能为空"; + } + if (StringUtil.isNotEmpty(form.getProductName())) { + form.setProductName(form.getProductName().trim()); + QueryWrapper productNameWrapper = new QueryWrapper<>(); + productNameWrapper.lambda().eq(YysDayPackageEntity::getProductName, form.getProductName()); + //假删除标志 + productNameWrapper.lambda().isNull(YysDayPackageEntity::getDeleteMark); + if (isUp) { + productNameWrapper.lambda().ne(YysDayPackageEntity::getId, id); + } + if ((int) this.count(productNameWrapper) > 0) { + countRecover = "产品名称不能重复"; + } + } + if (StringUtil.isEmpty(form.getModels())) { + return "规格型号不能为空"; + } + if (StringUtil.isEmpty(form.getMeasurementUnit())) { + return "计量单位不能为空"; + } return countRecover; } + /** - * 新增修改数据(事务回滚) - * @param id - * @param yysDayPackageForm - * @return - */ + * 新增修改数据(事务回滚) + * + * @param id + * @param yysDayPackageForm + * @return + */ @Override @Transactional - public void saveOrUpdate(YysDayPackageForm yysDayPackageForm,String id, boolean isSave) throws Exception{ - UserInfo userInfo=userProvider.get(); + public void saveOrUpdate(YysDayPackageForm yysDayPackageForm, String id, boolean isSave) throws Exception { + UserInfo userInfo = userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); yysDayPackageForm = JsonUtil.getJsonToBean( - generaterSwapUtil.swapDatetime(YysDayPackageConstant.getFormData(),yysDayPackageForm),YysDayPackageForm.class); + generaterSwapUtil.swapDatetime(YysDayPackageConstant.getFormData(), yysDayPackageForm), YysDayPackageForm.class); YysDayPackageEntity entity = JsonUtil.getJsonToBean(yysDayPackageForm, YysDayPackageEntity.class); - if(isSave){ - String mainId = RandomUtil.uuId() ; + if (isSave) { + String mainId = RandomUtil.uuId(); entity.setId(mainId); entity.setVersion(0); - }else{ + } else { } this.saveOrUpdate(entity); } + + @Override + public List queryList(String groupName, ConfirmRequest request, Map> requisitonMap) { + //查询所有待确认的数据 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YysDayPackageEntity::getIsConfirm, request.getFlag()); + List root = this.list(wrapper); + if (org.apache.commons.collections4.CollectionUtils.isEmpty(root)) { + return Collections.emptyList(); + } + //构建查询条件 + Set deviceCodes = root.stream().map(YysDayPackageEntity::getDeviceCode).collect(Collectors.toSet()); + Set dates = root.stream().map(YysDayPackageEntity::getManufactureTime).collect(Collectors.toSet()); + //数采表符合条件的数据 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(YysDeviceDataEntity.class); + queryWrapper.in(YysDeviceDataEntity::getProductionTime, dates); + queryWrapper.in(YysDeviceDataEntity::getProductionLine, deviceCodes); + List data = yysDeviceDataService.list(queryWrapper); + if (CollectionUtils.isEmpty(data)) { + return Collections.emptyList(); + } + //数采数据根据生产时间和产线分组 相加当日生产数量 + Map resultMap = data.stream() + .collect(Collectors.groupingBy( + item -> item.getProductionTime() + "-" + item.getProductionLine(), + Collectors.mapping( + item -> Integer.parseInt(item.getDayNum()), + Collectors.summingInt(i -> i) + ) + )); + //再将工单分组 + Map> rootMap = root.stream() + .collect(Collectors.groupingBy(obj -> String.join("-", obj.getManufactureTime().toString(), obj.getDeviceCode()))); + //查询报工确认数据 + List reportEntityList = yysPackageReportService.list(); + Map> packMap = reportEntityList.stream().collect(Collectors.groupingBy(YysPackageReportEntity::getWorkId)); + //进行平均分配 + List result = Lists.newArrayList(); + for (Map.Entry> entry : rootMap.entrySet()) { + if (resultMap.containsKey(entry.getKey())) { + Integer total = resultMap.get(entry.getKey()); + List collected = entry.getValue().stream().sorted(Comparator.comparing(YysDayPackageEntity::getSort)).collect(Collectors.toList()); + for (YysDayPackageEntity packageEntity : collected) { + ConfirmResponse confirmResponse = BeanUtil.copyProperties(packageEntity, ConfirmResponse.class); + confirmResponse.setGroupName(groupName); + if (packMap.containsKey(packageEntity.getId())) { + confirmResponse.setPackageReportList(packMap.get(packageEntity.getId())); + } + if (requisitonMap.containsKey(packageEntity.getId())) { + confirmResponse.setRequisitionReportList(requisitonMap.get(packageEntity.getId())); + } + if (Integer.parseInt(packageEntity.getPlanNumber()) <= total) { + confirmResponse.setIsConfirmNums(packageEntity.getPlanNumber()); + total -= Integer.parseInt(packageEntity.getPlanNumber()); + result.add(confirmResponse); + } else { + confirmResponse.setIsConfirmNums(total.toString()); + result.add(confirmResponse); + break; + } + } + } + } + return result; + } } 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 90b6cfc..d7b9e11 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 @@ -1,5 +1,9 @@ package jnpf.service.impl; +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.google.common.collect.Lists; +import jnpf.base.ActionResult; import jnpf.entity.*; import jnpf.mapper.YysDayWorkMapper; import jnpf.service.*; @@ -30,6 +34,7 @@ import jnpf.model.QueryModel; import java.util.stream.Collectors; import jnpf.base.model.ColumnDataModel; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import jnpf.database.model.superQuery.SuperJsonModel; @@ -62,6 +67,24 @@ public class YysDayWorkServiceImpl extends ServiceImpl getList(YysDayWorkPagination yysDayWorkPagination) { return getTypeList(yysDayWorkPagination, yysDayWorkPagination.getDataType()); @@ -409,4 +432,114 @@ public class YysDayWorkServiceImpl extends ServiceImpl queryList(ConfirmRequest request) { + //根据登陆人判断属于生产还是包装线 + YysGroupEntity yysGroupEntity = yysGroupService.queryType(userProvider.get().getUserId()); + if (ObjectUtil.isNull(yysGroupEntity)) { + return Collections.emptyList(); + } + //领料上报 + List list = yysRequisitionReportService.list(); + Map> requisitonMap = list.stream().collect(Collectors.groupingBy(YysRequisitionReportEntity::getWorkId)); + if ("2".equals(yysGroupEntity.getGroupType())) { + return yysDayPackageService.queryList(yysGroupEntity.getGroupName(), request, requisitonMap); + } + //查询所有待确认的数据 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YysDayWorkEntity::getIsConfirm, request.getFlag()); + List root = this.list(wrapper); + if (CollectionUtils.isEmpty(root)) { + return Collections.emptyList(); + } + //构建查询条件 + Set deviceCodes = root.stream().map(YysDayWorkEntity::getDeviceCode).collect(Collectors.toSet()); + Set dates = root.stream().map(YysDayWorkEntity::getManufactureTime).collect(Collectors.toSet()); + //数采表符合条件的数据 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(YysDeviceDataEntity.class); + queryWrapper.in(YysDeviceDataEntity::getProductionTime, dates); + queryWrapper.in(YysDeviceDataEntity::getProductionLine, deviceCodes); + List data = yysDeviceDataService.list(queryWrapper); + if (CollectionUtils.isEmpty(data)) { + return Collections.emptyList(); + } + //数采数据根据生产时间和产线分组 相加当日生产数量 + Map resultMap = data.stream() + .collect(Collectors.groupingBy( + item -> item.getProductionTime() + "-" + item.getProductionLine(), + Collectors.mapping( + item -> Integer.parseInt(item.getDayNum()), + Collectors.summingInt(i -> i) + ) + )); + //再将工单分组 + Map> rootMap = root.stream() + .collect(Collectors.groupingBy(obj -> String.join("-", obj.getManufactureTime().toString(), obj.getDeviceCode()))); + //查询报工确认数据 + List reportEntityList = yysProdReportService.list(); + Map> prodMap = reportEntityList.stream().collect(Collectors.groupingBy(YysProdReportEntity::getWorkId)); + //进行平均分配 + List result = Lists.newArrayList(); + for (Map.Entry> entry : rootMap.entrySet()) { + if (resultMap.containsKey(entry.getKey())) { + Integer total = resultMap.get(entry.getKey()); + List collected = entry.getValue().stream().sorted(Comparator.comparing(YysDayWorkEntity::getSort)).collect(Collectors.toList()); + for (YysDayWorkEntity dayWork : collected) { + ConfirmResponse confirmResponse = BeanUtil.copyProperties(dayWork, ConfirmResponse.class); + confirmResponse.setGroupName(yysGroupEntity.getGroupName()); + if (prodMap.containsKey(dayWork.getId())) { + confirmResponse.setProdReportList(prodMap.get(dayWork.getId())); + } + if (requisitonMap.containsKey(dayWork.getId())) { + confirmResponse.setRequisitionReportList(requisitonMap.get(dayWork.getId())); + } + if (Integer.parseInt(dayWork.getPlanNumber()) <= total) { + confirmResponse.setIsConfirmNums(dayWork.getPlanNumber()); + total -= Integer.parseInt(dayWork.getPlanNumber()); + result.add(confirmResponse); + } else { + confirmResponse.setIsConfirmNums(total.toString()); + result.add(confirmResponse); + break; + } + } + } + } + return result; + } + + @Override + public String sure(ConfirmResponse request) { + boolean prodResult = false; + boolean packResult = false; + boolean requisitionResult = false; + if (CollectionUtils.isNotEmpty(request.getProdReportList())) { + for (YysProdReportEntity entity : request.getProdReportList()) { + BeanUtil.copyProperties(request, entity); + entity.setWorkId(request.getId()); + entity.setStatus("1"); + } + prodResult = yysProdReportService.saveBatch(request.getProdReportList()); + } + if (CollectionUtils.isNotEmpty(request.getPackageReportList())) { + for (YysPackageReportEntity entity : request.getPackageReportList()) { + BeanUtil.copyProperties(request, entity); + entity.setWorkId(request.getId()); + entity.setStatus("1"); + } + packResult = yysPackageReportService.saveBatch(request.getPackageReportList()); + } + if (CollectionUtils.isNotEmpty(request.getRequisitionReportList())) { + for (YysRequisitionReportEntity entity : request.getRequisitionReportList()) { + BeanUtil.copyProperties(request, entity); + entity.setWorkId(request.getId()); + } + requisitionResult = yysRequisitionReportService.saveBatch(request.getRequisitionReportList()); + } + if ((prodResult && requisitionResult) || (packResult && requisitionResult)) { + return "确认成功"; + } + return "确认失败"; + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysGroupServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysGroupServiceImpl.java index 8c1ff0a..5a93be2 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysGroupServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysGroupServiceImpl.java @@ -1,23 +1,33 @@ package jnpf.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import jnpf.entity.*; import jnpf.mapper.YysGroupMapper; import jnpf.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jnpf.model.yysgroup.*; + 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.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import jnpf.database.model.superQuery.SuperJsonModel; @@ -25,13 +35,17 @@ 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 jnpf.base.UserInfo; import jnpf.permission.entity.UserEntity; + /** - * * yysGroup * 版本: V3.5 * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) @@ -39,7 +53,7 @@ import jnpf.permission.entity.UserEntity; * 日期: 2024-08-05 */ @Service -public class YysGroupServiceImpl extends ServiceImpl implements YysGroupService{ +public class YysGroupServiceImpl extends ServiceImpl implements YysGroupService { @Autowired private GeneraterSwapUtil generaterSwapUtil; @@ -47,261 +61,284 @@ public class YysGroupServiceImpl extends ServiceImpl getList(YysGroupPagination yysGroupPagination){ - return getTypeList(yysGroupPagination,yysGroupPagination.getDataType()); + public List getList(YysGroupPagination yysGroupPagination) { + return getTypeList(yysGroupPagination, yysGroupPagination.getDataType()); } - /** 列表查询 */ + + /** + * 列表查询 + */ @Override - public List getTypeList(YysGroupPagination yysGroupPagination,String dataType){ - String userId=userProvider.get().getUserId(); - List AllIdList =new ArrayList(); - List> intersectionList =new ArrayList<>(); + public List getTypeList(YysGroupPagination yysGroupPagination, 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 ? YysGroupConstant.getAppColumnData() : YysGroupConstant.getColumnData(); ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class); String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList()); - int total=0; - int yysGroupNum =0; - QueryWrapper yysGroupQueryWrapper=new QueryWrapper<>(); + int total = 0; + int yysGroupNum = 0; + QueryWrapper yysGroupQueryWrapper = new QueryWrapper<>(); List allSuperIDlist = new ArrayList<>(); - String superOp =""; - if (ObjectUtil.isNotEmpty(yysGroupPagination.getSuperQueryJson())){ + String superOp = ""; + if (ObjectUtil.isNotEmpty(yysGroupPagination.getSuperQueryJson())) { List allSuperList = new ArrayList<>(); - List> intersectionSuperList = new ArrayList<>(); + List> intersectionSuperList = new ArrayList<>(); String queryJson = yysGroupPagination.getSuperQueryJson(); SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class); int superNum = 0; QueryWrapper yysGroupSuperWrapper = new QueryWrapper<>(); - yysGroupSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysGroupSuperWrapper,YysGroupEntity.class,queryJson,"0")); + yysGroupSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysGroupSuperWrapper, YysGroupEntity.class, queryJson, "0")); int yysGroupNum1 = yysGroupSuperWrapper.getExpression().getNormal().size(); - if (yysGroupNum1>0){ - List yysGroupList =this.list(yysGroupSuperWrapper).stream().map(YysGroupEntity::getId).collect(Collectors.toList()); + if (yysGroupNum1 > 0) { + List yysGroupList = this.list(yysGroupSuperWrapper).stream().map(YysGroupEntity::getId).collect(Collectors.toList()); allSuperList.addAll(yysGroupList); intersectionSuperList.add(yysGroupList); 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 yysGroupSuperWrapper = new QueryWrapper<>(); - yysGroupSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysGroupSuperWrapper,YysGroupEntity.class,ruleJson,"0")); + yysGroupSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysGroupSuperWrapper, YysGroupEntity.class, ruleJson, "0")); int yysGroupNum1 = yysGroupSuperWrapper.getExpression().getNormal().size(); - if (yysGroupNum1>0){ - List yysGroupList =this.list(yysGroupSuperWrapper).stream().map(YysGroupEntity::getId).collect(Collectors.toList()); + if (yysGroupNum1 > 0) { + List yysGroupList = this.list(yysGroupSuperWrapper).stream().map(YysGroupEntity::getId).collect(Collectors.toList()); allRuleList.addAll(yysGroupList); intersectionRuleList.add(yysGroupList); 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 yysGroupObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysGroupQueryWrapper,YysGroupEntity.class,yysGroupPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysGroupObj)){ - return new ArrayList<>(); - } else { - yysGroupQueryWrapper = (QueryWrapper)yysGroupObj; - if( yysGroupQueryWrapper.getExpression().getNormal().size()>0){ - yysGroupNum++; - } - } - } - } - if(!isPc && appPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysGroupObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysGroupQueryWrapper,YysGroupEntity.class,yysGroupPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysGroupObj)){ - return new ArrayList<>(); - } else { - yysGroupQueryWrapper = (QueryWrapper)yysGroupObj; - if( yysGroupQueryWrapper.getExpression().getNormal().size()>0){ - yysGroupNum++; - } + boolean pcPermission = false; + boolean appPermission = false; + if (isPc && pcPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysGroupObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysGroupQueryWrapper, YysGroupEntity.class, yysGroupPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysGroupObj)) { + return new ArrayList<>(); + } else { + yysGroupQueryWrapper = (QueryWrapper) yysGroupObj; + if (yysGroupQueryWrapper.getExpression().getNormal().size() > 0) { + yysGroupNum++; + } + } + } } + if (!isPc && appPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysGroupObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysGroupQueryWrapper, YysGroupEntity.class, yysGroupPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysGroupObj)) { + return new ArrayList<>(); + } else { + yysGroupQueryWrapper = (QueryWrapper) yysGroupObj; + if (yysGroupQueryWrapper.getExpression().getNormal().size() > 0) { + yysGroupNum++; + } + } - } - } - if(isPc){ - if(ObjectUtil.isNotEmpty(yysGroupPagination.getGroupName())){ - yysGroupNum++; + } + } + if (isPc) { + if (ObjectUtil.isNotEmpty(yysGroupPagination.getGroupName())) { + yysGroupNum++; String value = yysGroupPagination.getGroupName() instanceof List ? - JsonUtil.getObjectToString(yysGroupPagination.getGroupName()) : - String.valueOf(yysGroupPagination.getGroupName()); - yysGroupQueryWrapper.lambda().like(YysGroupEntity::getGroupName,value); + JsonUtil.getObjectToString(yysGroupPagination.getGroupName()) : + String.valueOf(yysGroupPagination.getGroupName()); + yysGroupQueryWrapper.lambda().like(YysGroupEntity::getGroupName, value); } - if(ObjectUtil.isNotEmpty(yysGroupPagination.getEnabledStatus())){ - yysGroupNum++; + if (ObjectUtil.isNotEmpty(yysGroupPagination.getEnabledStatus())) { + yysGroupNum++; - List idList = new ArrayList<>(); - try { - String[][] enabledStatus = JsonUtil.getJsonToBean(yysGroupPagination.getEnabledStatus(),String[][].class); - for(int i=0;i0){ - idList.add(JsonUtil.getObjectToString(Arrays.asList(enabledStatus[i]))); - } - } - }catch (Exception e1){ - try { - List enabledStatus = JsonUtil.getJsonToList(yysGroupPagination.getEnabledStatus(),String.class); - if(enabledStatus.size()>0){ - idList.addAll(enabledStatus); - } - }catch (Exception e2){ - idList.add(String.valueOf(yysGroupPagination.getEnabledStatus())); - } - } - yysGroupQueryWrapper.lambda().and(t->{ - idList.forEach(tt->{ - t.like(YysGroupEntity::getEnabledStatus, tt).or(); - }); - }); + List idList = new ArrayList<>(); + try { + String[][] enabledStatus = JsonUtil.getJsonToBean(yysGroupPagination.getEnabledStatus(), String[][].class); + for (int i = 0; i < enabledStatus.length; i++) { + if (enabledStatus[i].length > 0) { + idList.add(JsonUtil.getObjectToString(Arrays.asList(enabledStatus[i]))); + } + } + } catch (Exception e1) { + try { + List enabledStatus = JsonUtil.getJsonToList(yysGroupPagination.getEnabledStatus(), String.class); + if (enabledStatus.size() > 0) { + idList.addAll(enabledStatus); + } + } catch (Exception e2) { + idList.add(String.valueOf(yysGroupPagination.getEnabledStatus())); + } + } + yysGroupQueryWrapper.lambda().and(t -> { + idList.forEach(tt -> { + t.like(YysGroupEntity::getEnabledStatus, tt).or(); + }); + }); } } List intersection = generaterSwapUtil.getIntersection(intersectionList); - if (total>0){ - if (intersection.size()==0){ + if (total > 0) { + if (intersection.size() == 0) { intersection.add("jnpfNullList"); } yysGroupQueryWrapper.lambda().in(YysGroupEntity::getId, intersection); } - //是否有高级查询 - if (StringUtil.isNotEmpty(superOp)){ - if (allSuperIDlist.size()==0){ + //是否有高级查询 + if (StringUtil.isNotEmpty(superOp)) { + if (allSuperIDlist.size() == 0) { allSuperIDlist.add("jnpfNullList"); } List finalAllSuperIDlist = allSuperIDlist; - yysGroupQueryWrapper.lambda().and(t->t.in(YysGroupEntity::getId, finalAllSuperIDlist)); + yysGroupQueryWrapper.lambda().and(t -> t.in(YysGroupEntity::getId, finalAllSuperIDlist)); } - //是否有数据过滤查询 - if (StringUtil.isNotEmpty(ruleOp)){ - if (allRuleIDlist.size()==0){ + //是否有数据过滤查询 + if (StringUtil.isNotEmpty(ruleOp)) { + if (allRuleIDlist.size() == 0) { allRuleIDlist.add("jnpfNullList"); } List finalAllRuleIDlist = allRuleIDlist; - yysGroupQueryWrapper.lambda().and(t->t.in(YysGroupEntity::getId, finalAllRuleIDlist)); + yysGroupQueryWrapper.lambda().and(t -> t.in(YysGroupEntity::getId, finalAllRuleIDlist)); } //假删除标志 yysGroupQueryWrapper.lambda().isNull(YysGroupEntity::getDeleteMark); //排序 - if(StringUtil.isEmpty(yysGroupPagination.getSidx())){ + if (StringUtil.isEmpty(yysGroupPagination.getSidx())) { yysGroupQueryWrapper.lambda().orderByDesc(YysGroupEntity::getId); - }else{ + } else { try { String sidx = yysGroupPagination.getSidx(); - String[] strs= sidx.split("_name"); + String[] strs = sidx.split("_name"); YysGroupEntity yysGroupEntity = new YysGroupEntity(); Field declaredField = yysGroupEntity.getClass().getDeclaredField(strs[0]); declaredField.setAccessible(true); String value = declaredField.getAnnotation(TableField.class).value(); - yysGroupQueryWrapper="asc".equals(yysGroupPagination.getSort().toLowerCase())?yysGroupQueryWrapper.orderByAsc(value):yysGroupQueryWrapper.orderByDesc(value); + yysGroupQueryWrapper = "asc".equals(yysGroupPagination.getSort().toLowerCase()) ? yysGroupQueryWrapper.orderByAsc(value) : yysGroupQueryWrapper.orderByDesc(value); } catch (NoSuchFieldException e) { e.printStackTrace(); } } - if("0".equals(dataType)){ - if((total>0 && AllIdList.size()>0) || total==0){ - Page page=new Page<>(yysGroupPagination.getCurrentPage(), yysGroupPagination.getPageSize()); - IPage userIPage=this.page(page, yysGroupQueryWrapper); - return yysGroupPagination.setData(userIPage.getRecords(),userIPage.getTotal()); - }else{ + if ("0".equals(dataType)) { + if ((total > 0 && AllIdList.size() > 0) || total == 0) { + Page page = new Page<>(yysGroupPagination.getCurrentPage(), yysGroupPagination.getPageSize()); + IPage userIPage = this.page(page, yysGroupQueryWrapper); + return yysGroupPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { List list = new ArrayList(); return yysGroupPagination.setData(list, list.size()); } - }else{ + } else { return this.list(yysGroupQueryWrapper); } } + @Override - public YysGroupEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(YysGroupEntity::getId,id); + public YysGroupEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(YysGroupEntity::getId, id); return this.getOne(queryWrapper); } + @Override - public void create(YysGroupEntity entity){ + public void create(YysGroupEntity entity) { this.save(entity); } + @Override - public boolean update(String id, YysGroupEntity entity){ + public boolean update(String id, YysGroupEntity entity) { entity.setDeleteTime(DateUtil.getNowDate()); return this.updateById(entity); } + @Override - public void delete(YysGroupEntity entity){ - if(entity!=null){ + public void delete(YysGroupEntity entity) { + if (entity != null) { this.removeById(entity.getId()); } } - /** 验证表单唯一字段,正则,非空 i-0新增-1修改*/ + + /** + * 验证表单唯一字段,正则,非空 i-0新增-1修改 + */ @Override - public String checkForm(YysGroupForm form,int i) { - boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); - String id=""; + public String checkForm(YysGroupForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; String countRecover = ""; - if (isUp){ + if (isUp) { id = form.getId(); } //主表字段验证 - if(StringUtil.isEmpty(form.getGroupName())){ - return "班组名称不能为空"; - } + if (StringUtil.isEmpty(form.getGroupName())) { + return "班组名称不能为空"; + } return countRecover; } + /** - * 新增修改数据(事务回滚) - * @param id - * @param yysGroupForm - * @return - */ + * 新增修改数据(事务回滚) + * + * @param id + * @param yysGroupForm + * @return + */ @Override @Transactional - public void saveOrUpdate(YysGroupForm yysGroupForm,String id, boolean isSave) throws Exception{ - UserInfo userInfo=userProvider.get(); + public void saveOrUpdate(YysGroupForm yysGroupForm, String id, boolean isSave) throws Exception { + UserInfo userInfo = userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); yysGroupForm = JsonUtil.getJsonToBean( - generaterSwapUtil.swapDatetime(YysGroupConstant.getFormData(),yysGroupForm),YysGroupForm.class); + generaterSwapUtil.swapDatetime(YysGroupConstant.getFormData(), yysGroupForm), YysGroupForm.class); YysGroupEntity entity = JsonUtil.getJsonToBean(yysGroupForm, YysGroupEntity.class); - if(isSave){ - String mainId = RandomUtil.uuId() ; + if (isSave) { + String mainId = RandomUtil.uuId(); entity.setCreatorTime(DateUtil.getNowDate()); entity.setCreatorUserId(userInfo.getUserId()); entity.setId(mainId); entity.setVersion(0); - }else{ + } else { entity.setLastModifyTime(DateUtil.getNowDate()); entity.setLastModifyUserId(userInfo.getUserId()); } this.saveOrUpdate(entity); } + + @Override + public YysGroupEntity queryType(String userId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YysGroupEntity::getLeader, userId); + List list = this.list(wrapper); + if (CollectionUtils.isEmpty(list) || list.size() > 1) { + return new YysGroupEntity(); + } + return list.get(0); + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysDayWorkController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysDayWorkController.java index bed86e1..a492882 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysDayWorkController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysDayWorkController.java @@ -1,59 +1,49 @@ package jnpf.controller; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.ExcelImportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.ImportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; import cn.hutool.core.util.ObjectUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import cn.xuyanwu.spring.file.storage.FileInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jnpf.base.ActionResult; import jnpf.base.UserInfo; -import jnpf.exception.DataException; -import jnpf.permission.entity.UserEntity; -import jnpf.service.*; -import jnpf.entity.*; -import jnpf.util.*; -import jnpf.model.yysdaywork.*; -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.model.ColumnDataModel; +import jnpf.base.util.VisualUtils; +import jnpf.base.vo.DownloadVO; 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.web.multipart.MultipartFile; -import cn.afterturn.easypoi.excel.ExcelExportUtil; -import cn.afterturn.easypoi.excel.ExcelImportUtil; -import cn.afterturn.easypoi.excel.entity.ExportParams; -import cn.afterturn.easypoi.excel.entity.ImportParams; -import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; -import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Workbook; - -import java.io.File; - +import jnpf.entity.YysDayWorkEntity; +import jnpf.entity.YysGroupEntity; +import jnpf.model.visualJson.config.HeaderModel; +import jnpf.model.yysdaywork.*; import jnpf.onlinedev.model.ExcelImFieldModel; +import jnpf.onlinedev.model.OnlineImport.ExcelImportModel; import jnpf.onlinedev.model.OnlineImport.ImportDataModel; import jnpf.onlinedev.model.OnlineImport.ImportFormCheckUniqueModel; -import jnpf.onlinedev.model.OnlineImport.ExcelImportModel; import jnpf.onlinedev.model.OnlineImport.VisualImportModel; -import cn.xuyanwu.spring.file.storage.FileInfo; +import jnpf.service.YysDayPackageService; +import jnpf.service.YysDayWorkService; +import jnpf.service.YysGroupService; +import jnpf.util.*; import lombok.Cleanup; -import jnpf.model.visualJson.config.HeaderModel; -import jnpf.base.model.ColumnDataModel; -import jnpf.base.util.VisualUtils; +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 org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import java.io.File; +import java.io.IOException; +import java.util.*; /** * yysDayWork @@ -78,7 +68,6 @@ public class YysDayWorkController { @Autowired private YysDayWorkService yysDayWorkService; - @Autowired private ConfigValueUtil configValueUtil; @@ -550,4 +539,20 @@ public class YysDayWorkController { return ActionResult.success(yysDayWorkMap); } + @Operation(summary = "报工确认列表-app") + @PostMapping("confirm") + public ActionResult confirm(@RequestBody ConfirmRequest request) { + return ActionResult.success(yysDayWorkService.queryList(request)); + } + + @Operation(summary = "报工确认-app") + @PostMapping("sure") + public ActionResult sure(@RequestBody ConfirmResponse request) { + String result = yysDayWorkService.sure(request); + 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/YysDayPackageEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysDayPackageEntity.java index 6767c57..ddefdee 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysDayPackageEntity.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysDayPackageEntity.java @@ -40,6 +40,8 @@ public class YysDayPackageEntity { private String measurementUnit; @TableField(value = "PLAN_NUMBER" , updateStrategy = FieldStrategy.IGNORED) private String planNumber; + @TableField(value = "IS_CONFIRM" , updateStrategy = FieldStrategy.IGNORED) + private String isConfirm; @TableField("F_CREATOR_TIME") private Date creatorTime; @TableField("F_CREATOR_USER_ID") diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysDayWorkEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysDayWorkEntity.java index df5d95f..99ff960 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysDayWorkEntity.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysDayWorkEntity.java @@ -46,6 +46,8 @@ public class YysDayWorkEntity { private String productionStatus; @TableField("DELIVERY_TIME") private Date deliveryTime; + @TableField(value = "IS_CONFIRM" , updateStrategy = FieldStrategy.IGNORED) + private String isConfirm; @TableField("F_CREATOR_TIME") private Date creatorTime; @TableField("F_CREATOR_USER_ID") diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysPackageReportEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysPackageReportEntity.java index 952f638..58230e2 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysPackageReportEntity.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysPackageReportEntity.java @@ -17,6 +17,8 @@ import java.math.BigDecimal; public class YysPackageReportEntity { @TableId(value ="ID" ) private String id; + @TableField(value = "WORK_ID" , updateStrategy = FieldStrategy.IGNORED) + private String workId; @TableField(value = "MANUFACTURE_TIME" , updateStrategy = FieldStrategy.IGNORED) private Date manufactureTime; @TableField(value = "DEVICE_CODE" , updateStrategy = FieldStrategy.IGNORED) diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysProdReportEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysProdReportEntity.java index b45417b..4efb4bc 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysProdReportEntity.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysProdReportEntity.java @@ -17,6 +17,8 @@ import java.math.BigDecimal; public class YysProdReportEntity { @TableId(value ="ID" ) private String id; + @TableField(value = "WORK_ID" , updateStrategy = FieldStrategy.IGNORED) + private String workId; @TableField(value = "MANUFACTURE_TIME" , updateStrategy = FieldStrategy.IGNORED) private Date manufactureTime; @TableField(value = "DEVICE_CODE" , updateStrategy = FieldStrategy.IGNORED) diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysRequisitionReportEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysRequisitionReportEntity.java index 65e3ae2..916597b 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysRequisitionReportEntity.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysRequisitionReportEntity.java @@ -16,6 +16,8 @@ import java.util.Date; public class YysRequisitionReportEntity { @TableId(value ="ID" ) private String id; + @TableField(value = "WORK_ID" , updateStrategy = FieldStrategy.IGNORED) + private String workId; @TableField(value = "MANUFACTURE_TIME" , updateStrategy = FieldStrategy.IGNORED) private Date manufactureTime; @TableField(value = "DEVICE_CODE" , updateStrategy = FieldStrategy.IGNORED) diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysdaywork/ConfirmRequest.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysdaywork/ConfirmRequest.java new file mode 100644 index 0000000..faf07ac --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysdaywork/ConfirmRequest.java @@ -0,0 +1,22 @@ +package jnpf.model.yysdaywork; + +import lombok.Data; + +@Data +public class ConfirmRequest { + /** + * 工单id + */ + private String workId; + + /** + * 产线名称 + */ + private String line; + + /** + * 查询待确认/已确认标志 + */ + private String flag; + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysdaywork/ConfirmResponse.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysdaywork/ConfirmResponse.java new file mode 100644 index 0000000..3e9f78e --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysdaywork/ConfirmResponse.java @@ -0,0 +1,64 @@ +package jnpf.model.yysdaywork; + +import jnpf.entity.YysPackageReportEntity; +import jnpf.entity.YysProdReportEntity; +import jnpf.entity.YysRequisitionReportEntity; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class ConfirmResponse { + private String id; + private String monthId; + private Date manufactureTime; + private String deviceCode; + private String deviceName; + private Integer sort; + private String post; + private String startTime; + private String endTime; + private String productCode; + private String productName; + private String models; + private String measurementUnit; + private String planNumber; + private String productionStatus; + private Date deliveryTime; + /** + * 机采数量 + */ + private String acquisitionNum; + /** + * 合格数量 + */ + private String defectiveNum; + /** + * 次品数量 + */ + private String qualifiedNum; + /** + * 待确认数量 + */ + private String isConfirmNums; + + /** + * 报工班组 + */ + private String groupName; + + /** + * 生产报工确认列表 + */ + List prodReportList; + /** + * 包装报工确认列表 + */ + List packageReportList; + /** + * 领料上报记录 + */ + List requisitionReportList; + +}