|
@@ -1,15 +1,25 @@
|
|
|
package com.huimv.management.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.huimv.common.utils.R;
|
|
|
+import com.huimv.management.dao.PeriodDao;
|
|
|
+import com.huimv.management.dao.UnitDao;
|
|
|
+import com.huimv.management.entity.SysUserEntity;
|
|
|
import com.huimv.management.entity.YearPigBaseEntity;
|
|
|
import com.huimv.management.entity.vo.CountOut;
|
|
|
import com.huimv.management.entity.vo.DrinkingWaterVo;
|
|
|
import com.huimv.management.entity.vo.PigBaseVo;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
|
|
|
@@ -23,8 +33,10 @@ import com.huimv.common.utils.PageUtils;
|
|
|
import com.huimv.common.utils.Query;
|
|
|
import com.huimv.management.dao.YearPigBaseDao;
|
|
|
import com.huimv.management.service.YearPigBaseService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
-
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
@Service("yearPigBaseService")
|
|
@@ -230,4 +242,57 @@ public class YearPigBaseServiceImpl extends ServiceImpl<YearPigBaseDao, YearPigB
|
|
|
List<CountOut> endList = pigBaseDao.suchStatistics(farmId,wrapper);
|
|
|
System.out.println(endList);
|
|
|
}
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
+ @Value("${user.info.url}")
|
|
|
+ private String url;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PeriodDao periodDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UnitDao unitDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void transferPeriod(HashMap<String, Object> map, HttpServletRequest request) {
|
|
|
+
|
|
|
+ String token = request.getHeader("token");
|
|
|
+
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.add("token",token);
|
|
|
+ HttpEntity httpEntity = new HttpEntity<>(null,headers);
|
|
|
+
|
|
|
+ ResponseEntity<R> responseEntity = restTemplate.exchange(url, HttpMethod.GET,httpEntity, R.class);
|
|
|
+ R sysUserEntity = responseEntity.getBody();
|
|
|
+ String jsonString = JSONObject.toJSONString(sysUserEntity.get("user"));
|
|
|
+ SysUserEntity user = JSONObject.parseObject(jsonString,SysUserEntity.class);
|
|
|
+
|
|
|
+ String username = user.getUsername();
|
|
|
+ System.out.println(username);
|
|
|
+
|
|
|
+ List<String> earTagList = (List<String>) map.get("earTagList");
|
|
|
+ Integer periodId = (Integer) map.get("periodId");
|
|
|
+ System.out.println(earTagList);
|
|
|
+ System.out.println(periodId);
|
|
|
+ LambdaQueryWrapper<YearPigBaseEntity> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ UpdateWrapper updateWrapper = new UpdateWrapper();
|
|
|
+ for (String earTag : earTagList) {
|
|
|
+
|
|
|
+ queryWrapper.eq(YearPigBaseEntity::getEartag,earTag);
|
|
|
+ YearPigBaseEntity oldEntity = baseMapper.selectOne(queryWrapper);
|
|
|
+ queryWrapper.clear();
|
|
|
+
|
|
|
+ Integer oldPeriodId = oldEntity.getPeriodId();
|
|
|
+ String oldPeroidName = periodDao.selectById(oldPeriodId).getNumber();
|
|
|
+ Integer oldUnitId = oldEntity.getUnitId();
|
|
|
+ String oldUnitName = unitDao.selectById(oldUnitId).getNumber();
|
|
|
+
|
|
|
+
|
|
|
+// update()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|