| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.entity.Tag; |
| | |
| | | import com.zy.asrs.service.TagService; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.common.service.erp.ErpService; |
| | | import com.zy.common.service.erp.dto.VoucherDto; |
| | | import com.zy.common.service.erp.entity.Goods; |
| | | import lombok.Synchronized; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Transactional |
| | | public synchronized void syncMat() { |
| | | Tag top = tagService.getTop(); |
| | | List<Goods> goods = erpService.selectGoods(1); |
| | | List<Goods> goods = erpService.selectGoods(0); |
| | | Date now = new Date(); |
| | | if (!Cools.isEmpty(goods)) { |
| | | for (Goods good : goods) { |
| | | Mat mat = matService.selectByMatnr(good.getBarCode()); |
| | |
| | | mat.setUnits(good.getNumOfBobbins()==null?null:good.getNumOfBobbins().doubleValue()); |
| | | mat.setManuDate(good.getProdDate()); |
| | | |
| | | mat.setCreateTime(now); |
| | | mat.setSku(good.getLocation()); |
| | | if (!Cools.isEmpty(good.getLastUpdatedDate())) { |
| | | mat.setUpdateTime(DateUtils.convert(good.getLastUpdatedDate().substring(0, 19))); |
| | | } |
| | | |
| | | if (!matService.insert(mat)) { |
| | | throw new CoolException(JSON.toJSONString(good) + "商品同步失败"); |
| | | throw new CoolException(good.getBarCode() + "商品同步失败"); |
| | | } else { |
| | | int state = 1; |
| | | if (!erpService.updateStateForGoods(good.getBarCode(), state)) { |
| | | throw new CoolException(good.getBarCode() + "商品修改State为"+state+"失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Synchronized |
| | | @Transactional |
| | | public synchronized void syncOrder() { |
| | | List<VoucherDto> list = erpService.selectOrder(0); |
| | | System.out.println(JSON.toJSONString(list)); |
| | | } |
| | | |
| | | } |