feat():U8同步设为定时任务,日生产工单定时任务同步状态

master
jiyufei 2 months ago
parent e6c928a673
commit 0eae65d071

@ -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

@ -0,0 +1,7 @@
package jnpf.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.entity.YysSubsetMaterialEntity;
public interface YysSubsetMaterialMapper extends BaseMapper<YysSubsetMaterialEntity> {
}

@ -33,4 +33,5 @@ public interface YysBillMaterialService extends IService<YysBillMaterialEntity>
YysBillMaterialEntity getByProductId(String id);
List<YysBillMaterialEntity> getListByProductIds(List<String> id);
String syncMaterial();
}

@ -53,4 +53,6 @@ public interface YysDayWorkService extends IService<YysDayWorkEntity> {
String isFrozen(String id);
String cancelFrozen(String id);
void syncDayWork();
}

@ -32,4 +32,5 @@ public interface YysInventoryQueryService extends IService<YysInventoryQueryEnti
void saveOrUpdate(YysInventoryQueryForm yysInventoryQueryForm,String id, boolean isSave) throws Exception;
String syncInventory();
}

@ -0,0 +1,7 @@
package jnpf.service;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.entity.YysSubsetMaterialEntity;
public interface YysSubsetMaterialService extends IService<YysSubsetMaterialEntity> {
}

@ -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,103 +47,112 @@ import jnpf.permission.entity.UserEntity;
* 2024-08-08
*/
@Service
public class YysBillMaterialServiceImpl extends ServiceImpl<YysBillMaterialMapper, YysBillMaterialEntity> implements YysBillMaterialService{
public class YysBillMaterialServiceImpl extends ServiceImpl<YysBillMaterialMapper, YysBillMaterialEntity> implements YysBillMaterialService {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private YysSubsetMaterialService yysSubsetMaterialService;
@Override
public List<YysBillMaterialEntity> getList(YysBillMaterialPagination yysBillMaterialPagination){
return getTypeList(yysBillMaterialPagination,yysBillMaterialPagination.getDataType());
public List<YysBillMaterialEntity> getList(YysBillMaterialPagination yysBillMaterialPagination) {
return getTypeList(yysBillMaterialPagination, yysBillMaterialPagination.getDataType());
}
/** 列表查询 */
/**
*
*/
@Override
public List<YysBillMaterialEntity> getTypeList(YysBillMaterialPagination yysBillMaterialPagination,String dataType){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
List<List<String>> intersectionList =new ArrayList<>();
public List<YysBillMaterialEntity> getTypeList(YysBillMaterialPagination yysBillMaterialPagination, String dataType) {
String userId = userProvider.get().getUserId();
List<String> AllIdList = new ArrayList();
List<List<String>> 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<YysBillMaterialEntity> yysBillMaterialQueryWrapper=new QueryWrapper<>();
int total = 0;
int yysBillMaterialNum = 0;
QueryWrapper<YysBillMaterialEntity> yysBillMaterialQueryWrapper = new QueryWrapper<>();
List<String> allSuperIDlist = new ArrayList<>();
String superOp ="";
if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getSuperQueryJson())){
String superOp = "";
if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getSuperQueryJson())) {
List<String> allSuperList = new ArrayList<>();
List<List<String>> intersectionSuperList = new ArrayList<>();
String queryJson = yysBillMaterialPagination.getSuperQueryJson();
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
int superNum = 0;
QueryWrapper<YysBillMaterialEntity> 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<String> yysBillMaterialList =this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList());
if (yysBillMaterialNum1 > 0) {
List<String> 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<String> allRuleIDlist = new ArrayList<>();
String ruleOp ="";
if (ObjectUtil.isNotEmpty(ruleJson)){
String ruleOp = "";
if (ObjectUtil.isNotEmpty(ruleJson)) {
List<String> allRuleList = new ArrayList<>();
List<List<String>> intersectionRuleList = new ArrayList<>();
SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class);
int ruleNum = 0;
QueryWrapper<YysBillMaterialEntity> 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<String> yysBillMaterialList =this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList());
if (yysBillMaterialNum1 > 0) {
List<String> 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)){
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<YysBillMaterialEntity>)yysBillMaterialObj;
if( yysBillMaterialQueryWrapper.getExpression().getNormal().size()>0){
yysBillMaterialQueryWrapper = (QueryWrapper<YysBillMaterialEntity>) 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)){
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<YysBillMaterialEntity>)yysBillMaterialObj;
if( yysBillMaterialQueryWrapper.getExpression().getNormal().size()>0){
yysBillMaterialQueryWrapper = (QueryWrapper<YysBillMaterialEntity>) yysBillMaterialObj;
if (yysBillMaterialQueryWrapper.getExpression().getNormal().size() > 0) {
yysBillMaterialNum++;
}
}
@ -143,143 +160,152 @@ public class YysBillMaterialServiceImpl extends ServiceImpl<YysBillMaterialMappe
}
}
if(isPc){
if(ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceId())){
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);
yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceId, value);
}
if(ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceName())){
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);
yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceName, value);
}
if(ObjectUtil.isNotEmpty(yysBillMaterialPagination.getDocumentStatus())){
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);
yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getDocumentStatus, value);
}
}
List<String> 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<String> 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<String> 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<YysBillMaterialEntity> page=new Page<>(yysBillMaterialPagination.getCurrentPage(), yysBillMaterialPagination.getPageSize());
IPage<YysBillMaterialEntity> 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<YysBillMaterialEntity> page = new Page<>(yysBillMaterialPagination.getCurrentPage(), yysBillMaterialPagination.getPageSize());
IPage<YysBillMaterialEntity> userIPage = this.page(page, yysBillMaterialQueryWrapper);
return yysBillMaterialPagination.setData(userIPage.getRecords(), userIPage.getTotal());
} else {
List<YysBillMaterialEntity> list = new ArrayList();
return yysBillMaterialPagination.setData(list, list.size());
}
}else{
} else {
return this.list(yysBillMaterialQueryWrapper);
}
}
@Override
public YysBillMaterialEntity getInfo(String id){
QueryWrapper<YysBillMaterialEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(YysBillMaterialEntity::getId,id);
public YysBillMaterialEntity getInfo(String id) {
QueryWrapper<YysBillMaterialEntity> 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
*/
@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<YysBillMaterialMappe
@Override
public YysBillMaterialEntity getByProductId(String id) {
QueryWrapper<YysBillMaterialEntity> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(YysBillMaterialEntity::getPieceId,id);
wrapper.lambda().eq(YysBillMaterialEntity::getPieceId, id);
return this.getOne(wrapper);
}
@Override
public List<YysBillMaterialEntity> getListByProductIds(List<String> id) {
QueryWrapper<YysBillMaterialEntity> 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<String> syncList = this.list(new LambdaQueryWrapper<>(YysBillMaterialEntity.class).isNull(YysBillMaterialEntity::getDeleteMark))
.stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList());
//母件物料
RowMapper<SyncMaterial> rowMapper = new BeanPropertyRowMapper<>(SyncMaterial.class);
String sql = "select * from v_bom_parent_rpt";
List<SyncMaterial> query = this.jdbcTemplate.query(sql, rowMapper);
if (CollectionUtils.isEmpty(query)) {
return "远程母件物料信息为空";
}
//过滤出同步过的
query = query.stream().filter(obj -> !syncList.contains(obj.getAutoId())).collect(Collectors.toList());
//子件物料
RowMapper<SyncSubsetMaterial> subMapper = new BeanPropertyRowMapper<>(SyncSubsetMaterial.class);
String subsetSql = "select * from v_bom_opcomponent_rpt";
List<SyncSubsetMaterial> subsetMaterials = this.jdbcTemplate.query(subsetSql, subMapper);
Map<String, List<SyncSubsetMaterial>> subsetCollect = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(subsetMaterials)) {
subsetCollect = subsetMaterials.stream().collect(Collectors.groupingBy(SyncSubsetMaterial::getBomId));
}
//物料表数据 不从自己库取数据,防止自己库未同步,从而取不到数据
RowMapper<MaterialInformationSync> materialMapper = new BeanPropertyRowMapper<>(MaterialInformationSync.class);
String materialSql = "select * from dbo.Inventory";
List<MaterialInformationSync> informationSyncs = this.jdbcTemplate.query(materialSql, materialMapper);
Map<String, MaterialInformationSync> materialCollect = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(informationSyncs)) {
materialCollect = informationSyncs.stream().collect(Collectors.toMap(MaterialInformationSync::getCInvCode, Function.identity()));
}
List<YysBillMaterialEntity> materialResult = Lists.newArrayList();
List<YysSubsetMaterialEntity> 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<SyncSubsetMaterial> 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 "同步失败";
}
}

@ -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<YysDayWorkMapper, YysDayW
this.updateById(entity);
return "取消冻结成功";
}
@Override
@Transactional(rollbackFor = Exception.class)
public void syncDayWork() {
//查询数据
LambdaQueryWrapper<YysDayWorkEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(YysDayWorkEntity::getProductionStatus, "2");
wrapper.isNull(YysDayWorkEntity::getDeleteMark);
List<YysDayWorkEntity> 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);
}
}

@ -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,103 +47,109 @@ import jnpf.permission.entity.UserEntity;
* 2024-08-08
*/
@Service
public class YysInventoryQueryServiceImpl extends ServiceImpl<YysInventoryQueryMapper, YysInventoryQueryEntity> implements YysInventoryQueryService{
public class YysInventoryQueryServiceImpl extends ServiceImpl<YysInventoryQueryMapper, YysInventoryQueryEntity> implements YysInventoryQueryService {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public List<YysInventoryQueryEntity> getList(YysInventoryQueryPagination yysInventoryQueryPagination){
return getTypeList(yysInventoryQueryPagination,yysInventoryQueryPagination.getDataType());
public List<YysInventoryQueryEntity> getList(YysInventoryQueryPagination yysInventoryQueryPagination) {
return getTypeList(yysInventoryQueryPagination, yysInventoryQueryPagination.getDataType());
}
/** 列表查询 */
/**
*
*/
@Override
public List<YysInventoryQueryEntity> getTypeList(YysInventoryQueryPagination yysInventoryQueryPagination,String dataType){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
List<List<String>> intersectionList =new ArrayList<>();
public List<YysInventoryQueryEntity> getTypeList(YysInventoryQueryPagination yysInventoryQueryPagination, String dataType) {
String userId = userProvider.get().getUserId();
List<String> AllIdList = new ArrayList();
List<List<String>> 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<YysInventoryQueryEntity> yysInventoryQueryQueryWrapper=new QueryWrapper<>();
int total = 0;
int yysInventoryQueryNum = 0;
QueryWrapper<YysInventoryQueryEntity> yysInventoryQueryQueryWrapper = new QueryWrapper<>();
List<String> allSuperIDlist = new ArrayList<>();
String superOp ="";
if (ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getSuperQueryJson())){
String superOp = "";
if (ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getSuperQueryJson())) {
List<String> allSuperList = new ArrayList<>();
List<List<String>> intersectionSuperList = new ArrayList<>();
String queryJson = yysInventoryQueryPagination.getSuperQueryJson();
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
int superNum = 0;
QueryWrapper<YysInventoryQueryEntity> 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<String> yysInventoryQueryList =this.list(yysInventoryQuerySuperWrapper).stream().map(YysInventoryQueryEntity::getId).collect(Collectors.toList());
if (yysInventoryQueryNum1 > 0) {
List<String> 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<String> allRuleIDlist = new ArrayList<>();
String ruleOp ="";
if (ObjectUtil.isNotEmpty(ruleJson)){
String ruleOp = "";
if (ObjectUtil.isNotEmpty(ruleJson)) {
List<String> allRuleList = new ArrayList<>();
List<List<String>> intersectionRuleList = new ArrayList<>();
SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class);
int ruleNum = 0;
QueryWrapper<YysInventoryQueryEntity> 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<String> yysInventoryQueryList =this.list(yysInventoryQuerySuperWrapper).stream().map(YysInventoryQueryEntity::getId).collect(Collectors.toList());
if (yysInventoryQueryNum1 > 0) {
List<String> 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)){
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<YysInventoryQueryEntity>)yysInventoryQueryObj;
if( yysInventoryQueryQueryWrapper.getExpression().getNormal().size()>0){
yysInventoryQueryQueryWrapper = (QueryWrapper<YysInventoryQueryEntity>) 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)){
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<YysInventoryQueryEntity>)yysInventoryQueryObj;
if( yysInventoryQueryQueryWrapper.getExpression().getNormal().size()>0){
yysInventoryQueryQueryWrapper = (QueryWrapper<YysInventoryQueryEntity>) yysInventoryQueryObj;
if (yysInventoryQueryQueryWrapper.getExpression().getNormal().size() > 0) {
yysInventoryQueryNum++;
}
}
@ -143,145 +157,198 @@ public class YysInventoryQueryServiceImpl extends ServiceImpl<YysInventoryQueryM
}
}
if(isPc){
if(ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getMaterialCode())){
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);
yysInventoryQueryQueryWrapper.lambda().like(YysInventoryQueryEntity::getMaterialCode, value);
}
if(ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getMaterialName())){
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);
yysInventoryQueryQueryWrapper.lambda().like(YysInventoryQueryEntity::getMaterialName, value);
}
if(ObjectUtil.isNotEmpty(yysInventoryQueryPagination.getMaterialClassification())){
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);
yysInventoryQueryQueryWrapper.lambda().like(YysInventoryQueryEntity::getMaterialClassification, value);
}
}
List<String> 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<String> 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<String> 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<YysInventoryQueryEntity> page=new Page<>(yysInventoryQueryPagination.getCurrentPage(), yysInventoryQueryPagination.getPageSize());
IPage<YysInventoryQueryEntity> 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<YysInventoryQueryEntity> page = new Page<>(yysInventoryQueryPagination.getCurrentPage(), yysInventoryQueryPagination.getPageSize());
IPage<YysInventoryQueryEntity> userIPage = this.page(page, yysInventoryQueryQueryWrapper);
return yysInventoryQueryPagination.setData(userIPage.getRecords(), userIPage.getTotal());
} else {
List<YysInventoryQueryEntity> list = new ArrayList();
return yysInventoryQueryPagination.setData(list, list.size());
}
}else{
} else {
return this.list(yysInventoryQueryQueryWrapper);
}
}
@Override
public YysInventoryQueryEntity getInfo(String id){
QueryWrapper<YysInventoryQueryEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(YysInventoryQueryEntity::getId,id);
public YysInventoryQueryEntity getInfo(String id) {
QueryWrapper<YysInventoryQueryEntity> 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
*/
@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<String> syncList = this.list(new LambdaQueryWrapper<>(YysInventoryQueryEntity.class).isNull(YysInventoryQueryEntity::getDeleteMark))
.stream().map(YysInventoryQueryEntity::getId).collect(Collectors.toList());
RowMapper<SyncInventoryQuery> rowMapper = new BeanPropertyRowMapper<>(SyncInventoryQuery.class);
String sql = "select * from CurrentStock";
List<SyncInventoryQuery> query = this.jdbcTemplate.query(sql, rowMapper);
if (CollectionUtils.isEmpty(query)) {
return "远程库存信息为空";
}
//物料表数据 不从自己库取数据,防止自己库未同步,从而取不到数据
RowMapper<MaterialInformationSync> materialMapper = new BeanPropertyRowMapper<>(MaterialInformationSync.class);
String materialSql = "select * from dbo.Inventory";
List<MaterialInformationSync> informationSyncs = this.jdbcTemplate.query(materialSql, materialMapper);
Map<String, MaterialInformationSync> materialCollect = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(informationSyncs)) {
materialCollect = informationSyncs.stream().collect(Collectors.toMap(MaterialInformationSync::getCInvCode, Function.identity()));
}
List<YysInventoryQueryEntity> 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 "同步失败";
}
}

@ -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<YysSubsetMaterialMapper, YysSubsetMaterialEntity> implements YysSubsetMaterialService {
}

@ -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,7 +57,6 @@ public class YysBillMaterialController {
private YysBillMaterialService yysBillMaterialService;
/**
*
*
@ -61,18 +65,18 @@ public class YysBillMaterialController {
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody YysBillMaterialPagination yysBillMaterialPagination)throws IOException{
List<YysBillMaterialEntity> list= yysBillMaterialService.getList(yysBillMaterialPagination);
List<Map<String, Object>> realList=new ArrayList<>();
public ActionResult list(@RequestBody YysBillMaterialPagination yysBillMaterialPagination) throws IOException {
List<YysBillMaterialEntity> list = yysBillMaterialService.getList(yysBillMaterialPagination);
List<Map<String, Object>> realList = new ArrayList<>();
for (YysBillMaterialEntity entity : list) {
Map<String, Object> yysBillMaterialMap=JsonUtil.entityToMap(entity);
Map<String, Object> 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,6 +85,7 @@ public class YysBillMaterialController {
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
*
*
@ -90,101 +95,119 @@ public class YysBillMaterialController {
@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
*/
@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
*/
@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
*/
@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<String, Object> yysBillMaterialMap=JsonUtil.entityToMap(entity);
Map<String, Object> 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
*/
@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<String, Object> yysBillMaterialMap=JsonUtil.entityToMap(entity);
Map<String, Object> 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);
}
}

@ -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,7 +57,6 @@ public class YysInventoryQueryController {
private YysInventoryQueryService yysInventoryQueryService;
/**
*
*
@ -61,18 +65,18 @@ public class YysInventoryQueryController {
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody YysInventoryQueryPagination yysInventoryQueryPagination)throws IOException{
List<YysInventoryQueryEntity> list= yysInventoryQueryService.getList(yysInventoryQueryPagination);
List<Map<String, Object>> realList=new ArrayList<>();
public ActionResult list(@RequestBody YysInventoryQueryPagination yysInventoryQueryPagination) throws IOException {
List<YysInventoryQueryEntity> list = yysInventoryQueryService.getList(yysInventoryQueryPagination);
List<Map<String, Object>> realList = new ArrayList<>();
for (YysInventoryQueryEntity entity : list) {
Map<String, Object> yysInventoryQueryMap=JsonUtil.entityToMap(entity);
Map<String, Object> 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,6 +85,7 @@ public class YysInventoryQueryController {
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
*
*
@ -90,101 +95,119 @@ public class YysInventoryQueryController {
@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
*/
@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
*/
@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
*/
@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<String, Object> yysInventoryQueryMap=JsonUtil.entityToMap(entity);
Map<String, Object> 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
*/
@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<String, Object> yysInventoryQueryMap=JsonUtil.entityToMap(entity);
Map<String, Object> 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);
}
}

@ -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")

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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();
}
}

@ -31,6 +31,8 @@
<div>
<el-button type="primary" icon="icon-ym icon-ym-btn-add" @click="addOrUpdateHandle()">
</el-button>
<el-button type="success" icon="icon-ym el-icon-refresh" @click="syncData()">
</el-button>
</div>
<div class="JNPF-common-head-right">
<el-tooltip content="高级查询" placement="top" v-if="true">
@ -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 => {

@ -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,

@ -83,7 +83,7 @@
@click="delyysdeviceunkeeplogsList(scope.$index)">删除</el-button>
</template>
</el-table-column>
<el-table-column label="维保类型" prop="unkeepType" fixed="left" width="200" align="center">
<el-table-column label="维保类型" prop="unkeepType" width="200" align="center">
<template slot="header" v-if="true">
<span class="required-sign">*</span>维保类型
</template>
@ -97,7 +97,7 @@
</template>
</el-table-column>
<el-table-column label="维保开始时间" prop="startTime" fixed="left" width="200" align="center">
<el-table-column label="维保开始时间" prop="startTime" width="200" align="center">
<template slot="header" v-if="true">
<span class="required-sign">*</span>维保开始时间
</template>
@ -111,7 +111,7 @@
</template>
</el-table-column>
<el-table-column label="维保结束时间" prop="endTime" fixed="left" width="200" align="center">
<el-table-column label="维保结束时间" prop="endTime" width="200" align="center">
<template slot="header" v-if="true">
<span class="required-sign">*</span>维保结束时间
</template>

@ -31,7 +31,7 @@
<div>
<!-- <el-button type="primary" icon="icon-ym icon-ym-btn-add" @click="addOrUpdateHandle()">
</el-button> -->
<el-button type="success" disabled icon="icon-ym el-icon-refresh" @click="syncData()">
<el-button type="success" icon="icon-ym el-icon-refresh" @click="syncData()">
</el-button>
</div>
<div class="JNPF-common-head-right">
@ -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 => {

Loading…
Cancel
Save