提交 087d632f authored 作者: 邓砥奕's avatar 邓砥奕

代码提交

上级 bb04c140
...@@ -21,8 +21,6 @@ import java.util.List; ...@@ -21,8 +21,6 @@ import java.util.List;
@Data @Data
@Entity @Entity
@EntityListeners(AuditingEntityListener.class) @EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_library set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@Table(name = "device_library") @Table(name = "device_library")
public class DeviceLibrary { public class DeviceLibrary {
......
...@@ -21,8 +21,6 @@ import java.util.List; ...@@ -21,8 +21,6 @@ import java.util.List;
@Data @Data
@Entity @Entity
@EntityListeners(AuditingEntityListener.class) @EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update packing_library set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@Table(name = "packing_library") @Table(name = "packing_library")
public class PackingLibrary { public class PackingLibrary {
......
package com.example.removetolocal.olddevice.dao;
import com.example.removetolocal.olddevice.domin.DevAcrossunit;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DevAcrossunitDao extends JpaRepository<DevAcrossunit,String> {
}
...@@ -4,6 +4,8 @@ import com.example.removetolocal.olddevice.domin.DevModelEntity; ...@@ -4,6 +4,8 @@ import com.example.removetolocal.olddevice.domin.DevModelEntity;
import com.example.removetolocal.olduser.domin.DevManagerEntity; import com.example.removetolocal.olduser.domin.DevManagerEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface DevModelDao extends JpaRepository<DevModelEntity,Integer> { public interface DevModelDao extends JpaRepository<DevModelEntity,Integer> {
DevModelEntity findByModel(String model); List<DevModelEntity> findAllByModel(String model);
} }
package com.example.removetolocal.olddevice.domin;
import lombok.Data;
import javax.persistence.*;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import java.util.Date;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
/**
* entity class for dev_acrossunit
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "dev_acrossunit")
public class DevAcrossunit {
/**
* id
*/
@Id
@Column(name = "id")
private String id;
/**
* unitname
*/
@Column(name = "unitname")
private String unitname;
/**
* showorder
*/
@Column(name = "showorder")
private Double showorder;
/**
* status
*/
@Column(name = "status")
private Integer status;
/**
* ownersupid
*/
@Column(name = "ownersupid")
private String ownersupid;
/**
* groupid
*/
@Column(name = "groupid")
private String groupid;
/**
* areaid
*/
@Column(name = "areaid")
private String areaid;
/**
* 0:非独立管理 1:独立管理
*/
@Column(name = "issup")
private Integer issup;
/**
* 拼音
*/
@Column(name = "pinyin")
private String pinyin;
}
...@@ -3,6 +3,8 @@ package com.example.removetolocal.olduser.dao; ...@@ -3,6 +3,8 @@ package com.example.removetolocal.olduser.dao;
import com.example.removetolocal.olduser.domin.DevMgrcertEntity; import com.example.removetolocal.olduser.domin.DevMgrcertEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface DevMgrcertDao extends JpaRepository<DevMgrcertEntity,Integer> { public interface DevMgrcertDao extends JpaRepository<DevMgrcertEntity,Integer> {
DevMgrcertEntity findByCertMgr(String s); List<DevMgrcertEntity> findAllByCertMgr(String s);
} }
...@@ -6,17 +6,22 @@ import com.example.removetolocal.newdevice.domin.DeviceLibrary; ...@@ -6,17 +6,22 @@ import com.example.removetolocal.newdevice.domin.DeviceLibrary;
import com.example.removetolocal.newdevice.domin.PackingLibrary; import com.example.removetolocal.newdevice.domin.PackingLibrary;
import com.example.removetolocal.newuser.dao.UnitsDao; import com.example.removetolocal.newuser.dao.UnitsDao;
import com.example.removetolocal.newuser.dao.UserDao; import com.example.removetolocal.newuser.dao.UserDao;
import com.example.removetolocal.olddevice.dao.DevAcrossunitDao;
import com.example.removetolocal.olddevice.dao.DevCatalogDao; import com.example.removetolocal.olddevice.dao.DevCatalogDao;
import com.example.removetolocal.olddevice.dao.DevModelDao; import com.example.removetolocal.olddevice.dao.DevModelDao;
import com.example.removetolocal.olddevice.dao.DevRecordDao; import com.example.removetolocal.olddevice.dao.DevRecordDao;
import com.example.removetolocal.olddevice.domin.DevCatalogEntity; import com.example.removetolocal.olddevice.domin.DevCatalogEntity;
import com.example.removetolocal.olddevice.domin.DevModelEntity;
import com.example.removetolocal.olddevice.domin.DevRecordEntity; import com.example.removetolocal.olddevice.domin.DevRecordEntity;
import com.example.removetolocal.olduser.dao.SysCompanyDao;
import com.example.removetolocal.service.DeviceService; import com.example.removetolocal.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class DeviceServiceImpl implements DeviceService { public class DeviceServiceImpl implements DeviceService {
...@@ -34,6 +39,10 @@ public class DeviceServiceImpl implements DeviceService { ...@@ -34,6 +39,10 @@ public class DeviceServiceImpl implements DeviceService {
UnitsDao unitsDao; UnitsDao unitsDao;
@Autowired @Autowired
DevModelDao devModelDao; DevModelDao devModelDao;
@Autowired
DevAcrossunitDao devAcrossunitDao;
@Autowired
SysCompanyDao sysCompanyDao;
/** /**
* 列装和装备库转换 * 列装和装备库转换
*/ */
...@@ -55,10 +64,12 @@ public class DeviceServiceImpl implements DeviceService { ...@@ -55,10 +64,12 @@ public class DeviceServiceImpl implements DeviceService {
packingLibrary.setUpdateUserId(userDao.findByOldCode(devCatalogEntity.getUpdateuser()) == null ? userDao.findByOldId(devCatalogEntity.getUpdateuser()).getUserId() : userDao.findByOldCode(devCatalogEntity.getUpdateuser()).getUserId()); packingLibrary.setUpdateUserId(userDao.findByOldCode(devCatalogEntity.getUpdateuser()) == null ? userDao.findByOldId(devCatalogEntity.getUpdateuser()).getUserId() : userDao.findByOldCode(devCatalogEntity.getUpdateuser()).getUserId());
} }
} }
if (devCatalogEntity.getEndDate() != null) { if (devCatalogEntity.getEndDate() != null && !"".equals(devCatalogEntity.getEndDate())) {
packingLibrary.setExitTime(Timestamp.valueOf(devCatalogEntity.getEndDate() + " 00:00:00")); packingLibrary.setExitTime(Timestamp.valueOf(devCatalogEntity.getEndDate() + " 00:00:00"));
} }
packingLibrary.setPrice(String.valueOf(devCatalogEntity.getPrice())); if (devCatalogEntity.getPrice()!=null) {
packingLibrary.setPrice(String.valueOf(devCatalogEntity.getPrice()));
}
if (devCatalogEntity.getCreateSup() != null && unitsDao.findByOldId(devCatalogEntity.getCreateSup()) != null) { if (devCatalogEntity.getCreateSup() != null && unitsDao.findByOldId(devCatalogEntity.getCreateSup()) != null) {
packingLibrary.setCreateUnit(unitsDao.findByOldId(devCatalogEntity.getCreateSup()).getName()); packingLibrary.setCreateUnit(unitsDao.findByOldId(devCatalogEntity.getCreateSup()).getName());
} }
...@@ -177,8 +188,10 @@ public class DeviceServiceImpl implements DeviceService { ...@@ -177,8 +188,10 @@ public class DeviceServiceImpl implements DeviceService {
packingLibrary.setStyle(devCatalogEntity.getDevType()); packingLibrary.setStyle(devCatalogEntity.getDevType());
if (devCatalogEntity.getIsModelDir()==1) { if (devCatalogEntity.getIsModelDir()==1) {
packingLibrary.setIsRoot(1); packingLibrary.setIsRoot(1);
if (devModelDao.findByModel(devCatalogEntity.getModel())!=null) { if (devModelDao.findAllByModel(devCatalogEntity.getModel()).size()>0) {
packingLibrary.setShowOrder(devModelDao.findByModel(devCatalogEntity.getModel()).getShoworder()); packingLibrary.setShowOrder(devModelDao.findAllByModel(devCatalogEntity.getModel()).stream()
.sorted(Comparator.comparing(DevModelEntity::getCreatetime).reversed())
.collect(Collectors.toList()).get(0).getShoworder());
} }
} }
else { else {
...@@ -205,7 +218,7 @@ public class DeviceServiceImpl implements DeviceService { ...@@ -205,7 +218,7 @@ public class DeviceServiceImpl implements DeviceService {
List<DevRecordEntity> devRecordEntities = devRecordDao.findAll(); List<DevRecordEntity> devRecordEntities = devRecordDao.findAll();
devRecordEntities.forEach(devRecordEntity -> { devRecordEntities.forEach(devRecordEntity -> {
//对应列装 //对应列装
PackingLibrary packingLibrary = packingLibraryDao.findByOldId(devRecordEntity.getPid()); PackingLibrary packingLibrary = packingLibraryDao.findByOldId(devRecordEntity.getCatalogId());
DeviceLibrary deviceLibrary = new DeviceLibrary(); DeviceLibrary deviceLibrary = new DeviceLibrary();
deviceLibrary.setCreateTime(devRecordEntity.getCreateTime()); deviceLibrary.setCreateTime(devRecordEntity.getCreateTime());
deviceLibrary.setUpdateTime(devRecordEntity.getUpdateTime()); deviceLibrary.setUpdateTime(devRecordEntity.getUpdateTime());
...@@ -228,12 +241,22 @@ public class DeviceServiceImpl implements DeviceService { ...@@ -228,12 +241,22 @@ public class DeviceServiceImpl implements DeviceService {
deviceLibrary.setSeqNumber(devRecordEntity.getSerNum()); deviceLibrary.setSeqNumber(devRecordEntity.getSerNum());
deviceLibrary.setProdNumber(devRecordEntity.getProNum()); deviceLibrary.setProdNumber(devRecordEntity.getProNum());
deviceLibrary.setRfidCardId(devRecordEntity.getRfid()); deviceLibrary.setRfidCardId(devRecordEntity.getRfid());
deviceLibrary.setRfidSurfaceId(makeRfidNumber(String.valueOf(packingLibrary.getType()),devRecordEntity.getSerNum(),devRecordEntity.getProNum(),devRecordEntity.getModel())); deviceLibrary.setRfidSurfaceId(makeRfidNumber(packingLibrary.getType()==null?"0":String.valueOf(packingLibrary.getType()),devRecordEntity.getSerNum(),devRecordEntity.getProNum(),devRecordEntity.getModel()));
if (devRecordEntity.getWhereUnit()!=null){ if (devRecordEntity.getWhereUnit()!=null){
deviceLibrary.setLocationUnit(unitsDao.findByOldId(devRecordEntity.getWhereUnit()).getName()); if (sysCompanyDao.findById(devRecordEntity.getWhereUnit()).isPresent()) {
deviceLibrary.setLocationUnit(sysCompanyDao.findById(devRecordEntity.getWhereUnit()).get().getCompanyName());
}
else {
deviceLibrary.setLocationUnit(devAcrossunitDao.findById(devRecordEntity.getWhereUnit()).get().getUnitname());
}
} }
if (devRecordEntity.getOwnUnit()!=null){ if (devRecordEntity.getOwnUnit()!=null){
deviceLibrary.setOwnUnit(unitsDao.findByOldId(devRecordEntity.getOwnUnit()).getName()); if (sysCompanyDao.findById(devRecordEntity.getOwnUnit()).isPresent()) {
deviceLibrary.setOwnUnit(sysCompanyDao.findById(devRecordEntity.getOwnUnit()).get().getCompanyName());
}
else {
deviceLibrary.setOwnUnit(devAcrossunitDao.findById(devRecordEntity.getOwnUnit()).get().getUnitname());
}
} }
deviceLibrary.setMatchingRange(packingLibrary.getMatchingRange()); deviceLibrary.setMatchingRange(packingLibrary.getMatchingRange());
deviceLibrary.setInvisibleRange(packingLibrary.getInvisibleRange()); deviceLibrary.setInvisibleRange(packingLibrary.getInvisibleRange());
...@@ -309,7 +332,9 @@ public class DeviceServiceImpl implements DeviceService { ...@@ -309,7 +332,9 @@ public class DeviceServiceImpl implements DeviceService {
deviceLibraries.forEach(deviceLibrary -> { deviceLibraries.forEach(deviceLibrary -> {
DevRecordEntity devRecordEntity = devRecordDao.findById(deviceLibrary.getOldId()).get(); DevRecordEntity devRecordEntity = devRecordDao.findById(deviceLibrary.getOldId()).get();
if (devRecordEntity.getPid()!=null&&devRecordEntity.getPid()>0){ if (devRecordEntity.getPid()!=null&&devRecordEntity.getPid()>0){
deviceLibrary.setPartParentId(deviceLibraryDao.findByOldId(devRecordEntity.getPid()).getId()); if (deviceLibraryDao.findByOldId(devRecordEntity.getPid())!=null) {
deviceLibrary.setPartParentId(deviceLibraryDao.findByOldId(devRecordEntity.getPid()).getId());
}
deviceLibraryDao.save(deviceLibrary); deviceLibraryDao.save(deviceLibrary);
} }
}); });
......
...@@ -14,6 +14,7 @@ import com.example.removetolocal.service.UserService; ...@@ -14,6 +14,7 @@ import com.example.removetolocal.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -152,7 +153,9 @@ public class UserServiceImpl implements UserService { ...@@ -152,7 +153,9 @@ public class UserServiceImpl implements UserService {
user.setPassword("123456"); user.setPassword("123456");
user.setNoPassword("123456"); user.setNoPassword("123456");
user.setUsername(sysUserEntity.getLoginid()); user.setUsername(sysUserEntity.getLoginid());
user.setShowOrder(sysUserEntity.getShoworder().intValue()); if (sysUserEntity.getShoworder()!=null) {
user.setShowOrder(sysUserEntity.getShoworder().intValue());
}
user.setMobile(sysUserEntity.getMobile()); user.setMobile(sysUserEntity.getMobile());
user.setTelphone(sysUserEntity.getTelphone()); user.setTelphone(sysUserEntity.getTelphone());
user.setEmail(sysUserEntity.getEmail()); user.setEmail(sysUserEntity.getEmail());
...@@ -166,8 +169,11 @@ public class UserServiceImpl implements UserService { ...@@ -166,8 +169,11 @@ public class UserServiceImpl implements UserService {
user.setOldCode("0"); user.setOldCode("0");
} }
User user1 = userDao.save(user); User user1 = userDao.save(user);
if (devMgrcertDao.findByCertMgr(String.valueOf(user1.getOldCode()))!=null&&devMgrcertDao.findByCertMgr(user1.getOldId())!=null){ List<DevMgrcertEntity> devMgrcertEntities = new ArrayList<>();
DevMgrcertEntity devMgrcertEntity = devMgrcertDao.findByCertMgr(String.valueOf(user1.getOldCode()))==null?devMgrcertDao.findByCertMgr(user1.getOldId()):devMgrcertDao.findByCertMgr(String.valueOf(user1.getOldCode())); devMgrcertEntities.addAll(devMgrcertDao.findAllByCertMgr(String.valueOf(user1.getOldCode())));
devMgrcertEntities.addAll(devMgrcertDao.findAllByCertMgr(String.valueOf(user1.getOldId())));
if (devMgrcertEntities.size()>0){
DevMgrcertEntity devMgrcertEntity = devMgrcertEntities.get(0);
user1.setTrainStatus(0); user1.setTrainStatus(0);
userDao.save(user1); userDao.save(user1);
Mgrcert mgrcert = new Mgrcert(); Mgrcert mgrcert = new Mgrcert();
...@@ -181,6 +187,10 @@ public class UserServiceImpl implements UserService { ...@@ -181,6 +187,10 @@ public class UserServiceImpl implements UserService {
mgrcert.setOldId(devMgrcertEntity.getId()); mgrcert.setOldId(devMgrcertEntity.getId());
mgrcertDao.save(mgrcert); mgrcertDao.save(mgrcert);
} }
else {
user1.setTrainStatus(2);
userDao.save(user1);
}
}); });
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论