|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.plugins.Page; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.entity.StoreType; | 
|---|
|  |  |  | import com.zy.asrs.entity.Tag; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.MatSyncParam; | 
|---|
|  |  |  | import com.zy.asrs.service.OpenService; | 
|---|
|  |  |  | import com.zy.asrs.service.StoreTypeService; | 
|---|
|  |  |  | import com.zy.asrs.service.TagService; | 
|---|
|  |  |  | import com.zy.asrs.task.AbstractHandler; | 
|---|
|  |  |  | import com.zy.asrs.task.core.ReturnT; | 
|---|
|  |  |  | import com.zy.nc.entity.NccBdCustomerWms; | 
|---|
|  |  |  | import com.zy.nc.entity.NccSaleDbckmxb; | 
|---|
|  |  |  | import com.zy.nc.service.NccBdCustomerWmsService; | 
|---|
|  |  |  | import com.zy.nc.service.NccCgCgdhdWmsService; | 
|---|
|  |  |  | import com.zy.common.utils.NodeUtils; | 
|---|
|  |  |  | import com.zy.nc.entity.*; | 
|---|
|  |  |  | import com.zy.nc.service.*; | 
|---|
|  |  |  | import com.zy.system.entity.User; | 
|---|
|  |  |  | import com.zy.system.service.UserService; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccCgCgdhdWmsService nccCgCgdhdWmsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccCkPddWmsService nccCkPddWmsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccJcBmWmsService nccJcBmWmsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccJcCkhwService nccJcCkhwService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccJcCkWmsService nccJcCkWmsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccJcQilibcBarcodeflowWmsService nccJcQilibcBarcodeflowWmsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccJcRyWmsService nccJcRyWmsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccJcWlflWmsService nccJcWlflWmsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccOrgCorpWmsService nccOrgCorpWmsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private VGetBdMaterialService vGetBdMaterialService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OpenService openService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TagService tagService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserService userService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private StoreTypeService storeTypeService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${NYNC.pageSize}") | 
|---|
|  |  |  | private Integer pageSize; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start1() { | 
|---|
|  |  |  | nccBdCustomerWmsService.selectList(new EntityWrapper<NccBdCustomerWms>().ne("wms_flag",1)) | 
|---|
|  |  |  | log.info("shuju:{}", JSONObject.toJSON(nccSaleXsckmx)); | 
|---|
|  |  |  | Page<NccBdCustomerWms> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccBdCustomerWms> wmsFlag = nccBdCustomerWmsService.selectPage(page, new EntityWrapper<NccBdCustomerWms>().ne("wms_flag", 1)); | 
|---|
|  |  |  | for (NccBdCustomerWms nccBdCustomerWms : wmsFlag.getRecords()) { | 
|---|
|  |  |  | //TODO | 
|---|
|  |  |  | log.info("NccBdCustomerWms数据:{}", JSONObject.toJSON(nccBdCustomerWms)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start2() { | 
|---|
|  |  |  | NccSaleDbckmxb nccSaleDbckmxb = NccCgCgdhdWmsService.selectById("1001A1100000000H9KKJ"); | 
|---|
|  |  |  | log.info("shuju:{}", JSONObject.toJSON(nccSaleDbckmxb)); | 
|---|
|  |  |  | Page<NccCgCgdhdWms> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccCgCgdhdWms> wmsFlag = nccCgCgdhdWmsService.selectPage(page, new EntityWrapper<NccCgCgdhdWms>().ne("wms_flag", 1)); | 
|---|
|  |  |  | for (NccCgCgdhdWms nccCgCgdhdWms : wmsFlag.getRecords()) { | 
|---|
|  |  |  | log.info("NccCgCgdhdWms数据:{}", JSONObject.toJSON(nccCgCgdhdWms)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start3() { | 
|---|
|  |  |  | Page<NccCkPddWms> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccCkPddWms> wmsFlag = nccCkPddWmsService.selectPage(page, new EntityWrapper<NccCkPddWms>().ne("wms_flag", 1)); | 
|---|
|  |  |  | for (NccCkPddWms nccCkPddWms : wmsFlag.getRecords()) { | 
|---|
|  |  |  | log.info("NccCkPddWms数据:{}", JSONObject.toJSON(nccCkPddWms)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start4() { | 
|---|
|  |  |  | Page<NccJcBmWms> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccJcBmWms> wmsFlag = nccJcBmWmsService.selectPage(page, new EntityWrapper<NccJcBmWms>().ne("wms_flag", 1)); | 
|---|
|  |  |  | for (NccJcBmWms nccCkPddWms : wmsFlag.getRecords()) { | 
|---|
|  |  |  | log.info("NccJcBmWms数据:{}", JSONObject.toJSON(nccCkPddWms)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start5() { | 
|---|
|  |  |  | Page<NccJcCkhw> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccJcCkhw> wmsFlag = nccJcCkhwService.selectPage(page, new EntityWrapper<NccJcCkhw>().ne("wms_flag", 1)); | 
|---|
|  |  |  | for (NccJcCkhw nccJcCkhw : wmsFlag.getRecords()) { | 
|---|
|  |  |  | log.info("NccJcCkhw数据:{}", JSONObject.toJSON(nccJcCkhw)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start6() { | 
|---|
|  |  |  | Page<NccJcCkWms> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccJcCkWms> wmsFlag = nccJcCkWmsService.selectPage(page, new EntityWrapper<NccJcCkWms>().ne("wms_flag", 1)); | 
|---|
|  |  |  | for (NccJcCkWms nccJcCkWms : wmsFlag.getRecords()) { | 
|---|
|  |  |  | log.info("NccJcCkWms数据:{}", JSONObject.toJSON(nccJcCkWms)); | 
|---|
|  |  |  | StoreType storeType = storeTypeService.selectById(nccJcCkWms.getCode()); | 
|---|
|  |  |  | if (storeType == null) { | 
|---|
|  |  |  | storeType = new StoreType(); | 
|---|
|  |  |  | storeType.setStoreName(nccJcCkWms.getName()); | 
|---|
|  |  |  | storeType.setStatus(1); | 
|---|
|  |  |  | storeType.setStoreId(nccJcCkWms.getCode()); | 
|---|
|  |  |  | storeType.setCreateBy(1L); | 
|---|
|  |  |  | storeType.setCreateTime(new Date()); | 
|---|
|  |  |  | storeType.setDepartmentId((Cools.isEmpty(nccJcCkWms.getDef3()) || "~".equals(nccJcCkWms.getDef3())) ? null : nccJcCkWms.getDef3()); | 
|---|
|  |  |  | //storeType.setDepartment(); | 
|---|
|  |  |  | storeTypeService.insert(storeType); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | storeType.setStoreName(nccJcCkWms.getName()); | 
|---|
|  |  |  | storeType.setDepartmentId((Cools.isEmpty(nccJcCkWms.getDef3()) || "~".equals(nccJcCkWms.getDef3())) ? null : nccJcCkWms.getDef3()); | 
|---|
|  |  |  | storeTypeService.updateById(storeType); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | nccJcCkWms.setWmsFlag(1); | 
|---|
|  |  |  | nccJcCkWmsService.update(nccJcCkWms, new EntityWrapper<NccJcCkWms>().eq("code", nccJcCkWms.getCode())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start7() { | 
|---|
|  |  |  | Page<NccJcQilibcBarcodeflowWms> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccJcQilibcBarcodeflowWms> wmsFlag = nccJcQilibcBarcodeflowWmsService.selectPage(page, new EntityWrapper<NccJcQilibcBarcodeflowWms>().ne("wms_flag", 1)); | 
|---|
|  |  |  | for (NccJcQilibcBarcodeflowWms nccJcQilibcBarcodeflowWms : wmsFlag.getRecords()) { | 
|---|
|  |  |  | log.info("NccJcQilibcBarcodeflowWms数据:{}", JSONObject.toJSON(nccJcQilibcBarcodeflowWms)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start8() { | 
|---|
|  |  |  | Page<NccJcRyWms> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccJcRyWms> wmsFlag = nccJcRyWmsService.selectPage(page, new EntityWrapper<NccJcRyWms>().ne("wms_flag", 1).eq("sszzbm", "FYT")); | 
|---|
|  |  |  | for (NccJcRyWms nccJcRyWms : wmsFlag.getRecords()) { | 
|---|
|  |  |  | User user = userService.selectOne(new EntityWrapper<User>().eq("username", nccJcRyWms.getRybm())); | 
|---|
|  |  |  | if (user == null) { | 
|---|
|  |  |  | user = new User(); | 
|---|
|  |  |  | user.setUsername(nccJcRyWms.getRybm()); | 
|---|
|  |  |  | user.setNickname(nccJcRyWms.getRymc()); | 
|---|
|  |  |  | user.setMobile(nccJcRyWms.getRybm()); | 
|---|
|  |  |  | user.setRoleId(12L); | 
|---|
|  |  |  | user.setStatus(1); | 
|---|
|  |  |  | user.setCreateTime(new Date()); | 
|---|
|  |  |  | userService.insert(user); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | user.setUsername(nccJcRyWms.getRybm()); | 
|---|
|  |  |  | user.setNickname(nccJcRyWms.getRymc()); | 
|---|
|  |  |  | user.setMobile(nccJcRyWms.getRybm()); | 
|---|
|  |  |  | user.setStatus(1); | 
|---|
|  |  |  | userService.updateById(user); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | nccJcRyWms.setWmsFlag(1); | 
|---|
|  |  |  | nccJcRyWmsService.update(nccJcRyWms, new EntityWrapper<NccJcRyWms>().eq("rybm", nccJcRyWms.getRybm())); | 
|---|
|  |  |  | log.info("NccJcRyWms数据:{}", JSONObject.toJSON(nccJcRyWms)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start9() { | 
|---|
|  |  |  | Page<NccJcWlflWms> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccJcWlflWms> wmsFlag = nccJcWlflWmsService.selectPage(page, new EntityWrapper<NccJcWlflWms>().ne("wms_flag", 1)); | 
|---|
|  |  |  | Tag top = tagService.getTop(); | 
|---|
|  |  |  | for (NccJcWlflWms nccJcWlflWms : wmsFlag.getRecords()) { | 
|---|
|  |  |  | if (!Cools.isEmpty(nccJcWlflWms.getSjflbm())) { | 
|---|
|  |  |  | Tag priTag = tagService.selectOne(new EntityWrapper<Tag>().eq("uuid", nccJcWlflWms.getSjflbm())); | 
|---|
|  |  |  | if (priTag == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | Tag tag = new Tag(); | 
|---|
|  |  |  | tag.setUuid(nccJcWlflWms.getCode()); | 
|---|
|  |  |  | tag.setName(nccJcWlflWms.getName()); | 
|---|
|  |  |  | tag.setParentId(priTag.getId()); | 
|---|
|  |  |  | tag.setParentName(priTag.getName()); | 
|---|
|  |  |  | tag.setType(0); | 
|---|
|  |  |  | tag.setLevel(priTag.getLevel() + 1); | 
|---|
|  |  |  | tag.setStatus(1); | 
|---|
|  |  |  | tag.setCreateTime(new Date()); | 
|---|
|  |  |  | tag.setPath(priTag.getPath()); | 
|---|
|  |  |  | NodeUtils nodeUtils = new NodeUtils(); | 
|---|
|  |  |  | nodeUtils.executePath(priTag.getId()); | 
|---|
|  |  |  | tag.setPath(nodeUtils.path.toString()); | 
|---|
|  |  |  | tag.setPathName(nodeUtils.pathName.toString()); | 
|---|
|  |  |  | tagService.insert(tag); | 
|---|
|  |  |  | nccJcWlflWms.setWmsFlag(1); | 
|---|
|  |  |  | nccJcWlflWmsService.updateById(nccJcWlflWms); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | Tag tag = new Tag(); | 
|---|
|  |  |  | tag.setUuid(nccJcWlflWms.getCode()); | 
|---|
|  |  |  | tag.setName(nccJcWlflWms.getName()); | 
|---|
|  |  |  | tag.setStatus(1); | 
|---|
|  |  |  | tag.setCreateTime(new Date()); | 
|---|
|  |  |  | tag.setType(0); | 
|---|
|  |  |  | tag.setLevel(2); | 
|---|
|  |  |  | tag.setParentId(top.getId()); | 
|---|
|  |  |  | tag.setParentName(top.getName()); | 
|---|
|  |  |  | tag.setPath(top.getPath()); | 
|---|
|  |  |  | NodeUtils nodeUtils = new NodeUtils(); | 
|---|
|  |  |  | nodeUtils.executePath(top.getId()); | 
|---|
|  |  |  | tag.setPath(nodeUtils.path.toString()); | 
|---|
|  |  |  | tag.setPathName(nodeUtils.pathName.toString()); | 
|---|
|  |  |  | tagService.insert(tag); | 
|---|
|  |  |  | nccJcWlflWms.setWmsFlag(1); | 
|---|
|  |  |  | nccJcWlflWmsService.updateById(nccJcWlflWms); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.info("NccJcWlflWms数据:{}", JSONObject.toJSON(nccJcWlflWms)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start10() { | 
|---|
|  |  |  | Page<NccOrgCorpWms> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<NccOrgCorpWms> wmsFlag = nccOrgCorpWmsService.selectPage(page, new EntityWrapper<NccOrgCorpWms>().ne("wms_flag", 1)); | 
|---|
|  |  |  | for (NccOrgCorpWms nccOrgCorpWms : wmsFlag.getRecords()) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | log.info("NccOrgCorpWms数据:{}", JSONObject.toJSON(nccOrgCorpWms)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public ReturnT<String> start13() { | 
|---|
|  |  |  | Page<VGetBdMaterial> page = new Page<>(1, pageSize); | 
|---|
|  |  |  | Page<VGetBdMaterial> wmsFlag = vGetBdMaterialService.selectPage(page, new EntityWrapper<VGetBdMaterial>().ne("wms_flag", 1)); | 
|---|
|  |  |  | MatSyncParam param = new MatSyncParam(); | 
|---|
|  |  |  | List<MatSyncParam.MatParam> matDetails = new ArrayList<>(); | 
|---|
|  |  |  | MatSyncParam.MatParam matParam; | 
|---|
|  |  |  | for (VGetBdMaterial vGetBdMaterial : wmsFlag.getRecords()) { | 
|---|
|  |  |  | Tag priTag = tagService.selectOne(new EntityWrapper<Tag>().eq("uuid", vGetBdMaterial.get存货分类编码())); | 
|---|
|  |  |  | if (priTag == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | matParam = new MatSyncParam.MatParam(); | 
|---|
|  |  |  | matParam.setMatnr(vGetBdMaterial.get物料编码()); | 
|---|
|  |  |  | matParam.setMaktx(vGetBdMaterial.get物料名称()); | 
|---|
|  |  |  | matParam.setSpecs(vGetBdMaterial.get规格()); | 
|---|
|  |  |  | matParam.setModel(vGetBdMaterial.get型号()); | 
|---|
|  |  |  | matParam.setUnit(vGetBdMaterial.get主单位()); | 
|---|
|  |  |  | matParam.setManu(vGetBdMaterial.get辅单位()); | 
|---|
|  |  |  | matParam.setMemo(vGetBdMaterial.get备注()); | 
|---|
|  |  |  | matParam.setSku(vGetBdMaterial.get物料简称u8旧品名()); | 
|---|
|  |  |  | matParam.setOrigin(vGetBdMaterial.get主辅换算比()); | 
|---|
|  |  |  | matParam.setGroupCode(priTag.getId() + ""); | 
|---|
|  |  |  | matDetails.add(matParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!matDetails.isEmpty()) { | 
|---|
|  |  |  | param.setMatDetails(matDetails); | 
|---|
|  |  |  | openService.syncMat(param); | 
|---|
|  |  |  | for (VGetBdMaterial vGetBdMaterial : wmsFlag.getRecords()) { | 
|---|
|  |  |  | vGetBdMaterial.setWmsFlag(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (VGetBdMaterial vGetBdMaterial : wmsFlag.getRecords()) { | 
|---|
|  |  |  | vGetBdMaterialService.update(vGetBdMaterial, new EntityWrapper<VGetBdMaterial>().eq("物料编码", vGetBdMaterial.get物料编码())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|