| | |
| | | |
| | | import com.zy.common.service.erp.ErpSqlServer; |
| | | import com.zy.third.erp.entity.ItemTB; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 物料档案 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class ERPItemScheduler { |
| | | @Value("${erp.enabled}") |
| | | private Boolean erpEnabled; |
| | | |
| | | @Autowired |
| | | private ERPItemSchedulerMS erpItemSchedulerMS; |
| | | private ERPItemService erpItemService; |
| | | |
| | | @Autowired |
| | | private ErpSqlServer erpSqlServer; |
| | | |
| | | |
| | | |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | @Scheduled(cron = "${erp.refreshtime}") |
| | | public void ItemScheduler() { |
| | | //log.info("ItemScheduler开始了"); |
| | | if (!erpEnabled) return; |
| | | |
| | | // String selectALL = "SELECT AutoId AS autoId,ItemId AS ItemID,ItemCode AS ItemCode,ItemName AS ItemName ,ItemSpc AS ItemSpc,ItemPic AS itemPic,ItemUnit AS ItemUnit,ItemKind AS ItemKind ,Remark AS remark ,Flag AS flag ,MakeDate AS makedate,Temp1 AS temp1,Temp2 AS temp2 ,Temp3 AS temp3 FROM dbo.erp_ItemTB"; |
| | | // List<ItemTB> itemTBS = erpSqlServer.select(selectALL, ItemTB.class); |
| | | // List<ItemTB> itemTBS = erpSqlServer.selectAll(ItemTB.class); |
| | | |
| | | String sqlItemTB = "select * from erp_ItemTB where LKName='中扬二期'"; |
| | | List<ItemTB> itemTBS = erpSqlServer.select(sqlItemTB, ItemTB.class); |
| | | if (itemTBS != null && itemTBS.size() > 0) { |
| | | for (ItemTB itemTB : itemTBS) { |
| | | System.out.println(itemTB); |
| | | //00代表新增 |
| | | if (itemTB.getFlag().equals("00")) { |
| | | erpItemSchedulerMS.addToMainDatabase(itemTB); |
| | | erpItemService.addToMainDatabase(itemTB); |
| | | } |
| | | //22代表删除 |
| | | if (itemTB.getFlag().equals("22")) { |
| | | erpItemSchedulerMS.deleteFromMainDatabase(itemTB); |
| | | erpItemService.deleteFromMainDatabase(itemTB); |
| | | } |
| | | moveToBak(itemTB); |
| | | } |
| | |
| | | */ |
| | | //将数据从主表移动到bak表里 |
| | | private void moveToBak(ItemTB itemTB) { |
| | | // ItemTBBak itemTBBak = new ItemTBBak(); |
| | | // BeanUtils.copyProperties(itemTB, itemTBBak); |
| | | // itemTBBak.setDelDate(new Date()); |
| | | // erpItemTBBakMapper.insert(itemTBBak); |
| | | erpSqlServer.update("delete from erp_ItemTB where LKName='中扬二期' and ItemId = '" + itemTB.getItemId() + "'"); |
| | | // erpItemTBMapper.delete(new EntityWrapper<ItemTB>() |
| | | // .eq("ItemId",itemTB.getItemID())); |
| | | } |
| | | } |