|
@@ -16,6 +16,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.pj.current.config.SystemObject;
|
|
|
import com.pj.project.tb_business_car.ExportTbBusinessDTO;
|
|
|
import com.pj.project.tb_business_car.TbBusinessCar;
|
|
|
+import com.pj.project.tb_business_car.TbBusinessCarService;
|
|
|
import com.pj.project.tb_item.TbItem;
|
|
|
import com.pj.project.tb_item.TbItemMapper;
|
|
|
import com.pj.project4sp.uploadfile.UploadConfig;
|
|
@@ -30,75 +31,110 @@ import javax.annotation.Resource;
|
|
|
|
|
|
/**
|
|
|
* Service: tb_mild_car -- 4.2~9.6车辆管理
|
|
|
- * @author qzy
|
|
|
+ *
|
|
|
+ * @author qzy
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public class TbMildCarService extends ServiceImpl<TbMildCarMapper, TbMildCar> implements IService<TbMildCar> {
|
|
|
|
|
|
- /** 底层 Mapper 对象 */
|
|
|
- @Autowired
|
|
|
- TbMildCarMapper tbMildCarMapper;
|
|
|
- @Resource
|
|
|
- private UploadConfig uploadConfig;
|
|
|
- /** 增 */
|
|
|
- int add(TbMildCar t){
|
|
|
- if (StrUtil.isEmpty(t.getCarNo())){
|
|
|
- throw new AjaxError("车牌号不能为空");
|
|
|
- }
|
|
|
- t.setCarNo(t.getCarNo().toUpperCase());
|
|
|
- this.save(t);
|
|
|
- return 1;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 底层 Mapper 对象
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ TbMildCarMapper tbMildCarMapper;
|
|
|
+ @Resource
|
|
|
+ private UploadConfig uploadConfig;
|
|
|
+ @Resource
|
|
|
+ private TbBusinessCarService tbBusinessCarService;
|
|
|
|
|
|
- /** 删 */
|
|
|
- int delete(Long id){
|
|
|
- return tbMildCarMapper.delete(id);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 增
|
|
|
+ */
|
|
|
+ int add(TbMildCar t) {
|
|
|
+ if (StrUtil.isEmpty(t.getCarNo())) {
|
|
|
+ throw new AjaxError("车牌号不能为空");
|
|
|
+ }
|
|
|
+ if (t.getCarLength() == null) {
|
|
|
+ throw new AjaxError("车长不正确");
|
|
|
+ }
|
|
|
+ String carNo = t.getCarNo().toUpperCase();
|
|
|
+ t.setCarNo(carNo);
|
|
|
+ this.save(t);
|
|
|
+ List<TbBusinessCar> businessCars = tbBusinessCarService.findByCarNo(carNo);
|
|
|
+ businessCars.parallelStream().forEach(tbBusinessCar -> tbBusinessCar.setCarSize(t.getCarLength()));
|
|
|
+ tbBusinessCarService.updateBatchById(businessCars);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
|
|
|
- /** 改 */
|
|
|
- int update(TbMildCar t){
|
|
|
- if (StrUtil.isEmpty(t.getCarNo())){
|
|
|
- throw new AjaxError("车牌号不能为空");
|
|
|
- }
|
|
|
- this.updateById(t);
|
|
|
- return 1;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 删
|
|
|
+ */
|
|
|
+ int delete(Long id) {
|
|
|
+ return tbMildCarMapper.delete(id);
|
|
|
+ }
|
|
|
|
|
|
- /** 查 */
|
|
|
- TbMildCar getById(Long id){
|
|
|
- return tbMildCarMapper.getById(id);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 改
|
|
|
+ */
|
|
|
+ int update(TbMildCar t) {
|
|
|
+ if (StrUtil.isEmpty(t.getCarNo())) {
|
|
|
+ throw new AjaxError("车牌号不能为空");
|
|
|
+ }
|
|
|
+ if (t.getCarLength() == null) {
|
|
|
+ throw new AjaxError("车长不正确");
|
|
|
+ }
|
|
|
+ String carNo = t.getCarNo().toUpperCase();
|
|
|
+ t.setCarNo(carNo);
|
|
|
+ TbMildCar db=this.getById(t.getId());
|
|
|
+ if (!t.getCarLength().equals(db.getCarLength())){
|
|
|
+ List<TbBusinessCar> businessCars = tbBusinessCarService.findByCarNo(carNo);
|
|
|
+ businessCars.parallelStream().forEach(tbBusinessCar -> tbBusinessCar.setCarSize(t.getCarLength()));
|
|
|
+ tbBusinessCarService.updateBatchById(businessCars);
|
|
|
+ }
|
|
|
+ this.updateById(t);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
|
|
|
- /** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
|
|
|
- List<TbMildCar> getList(SoMap so) {
|
|
|
- return tbMildCarMapper.getList(so);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 查
|
|
|
+ */
|
|
|
+ TbMildCar getById(Long id) {
|
|
|
+ return tbMildCarMapper.getById(id);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 查集合 - 根据条件(参数为空时代表忽略指定条件)
|
|
|
+ */
|
|
|
+ List<TbMildCar> getList(SoMap so) {
|
|
|
+ return tbMildCarMapper.getList(so);
|
|
|
+ }
|
|
|
|
|
|
- public String export(SoMap soMap) {
|
|
|
- List<TbMildCar> cars = this.getList(soMap);
|
|
|
- String flieTypeFolder = "/export/";
|
|
|
- String currDateFolder = DateUtil.today();
|
|
|
- String fileName = "record-" +RandomUtil.randomNumbers(6) + ".xlsx";
|
|
|
- String fileFolder = new File(uploadConfig.rootFolder).getAbsolutePath() +
|
|
|
- uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/";
|
|
|
- if (!FileUtil.exist(fileFolder)) {
|
|
|
- FileUtil.mkdir(fileFolder);
|
|
|
- }
|
|
|
- EasyExcel.write(fileFolder + fileName, TbMildCar.class).sheet("4.2米~9.6米车导出记录")
|
|
|
- .doWrite(() -> cars);
|
|
|
- return SystemObject.config.getDomain() + uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/" + fileName;
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 根据车牌查询
|
|
|
- * @param carNo
|
|
|
- * @return
|
|
|
- */
|
|
|
- public TbMildCar findByCarNo(String carNo) {
|
|
|
- QueryWrapper<TbMildCar>ew=new QueryWrapper<>();
|
|
|
- ew.lambda().eq(TbMildCar::getCarNo,carNo);
|
|
|
- return getOne(ew);
|
|
|
- }
|
|
|
+ public String export(SoMap soMap) {
|
|
|
+ List<TbMildCar> cars = this.getList(soMap);
|
|
|
+ String flieTypeFolder = "/export/";
|
|
|
+ String currDateFolder = DateUtil.today();
|
|
|
+ String fileName = "record-" + RandomUtil.randomNumbers(6) + ".xlsx";
|
|
|
+ String fileFolder = new File(uploadConfig.rootFolder).getAbsolutePath() +
|
|
|
+ uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/";
|
|
|
+ if (!FileUtil.exist(fileFolder)) {
|
|
|
+ FileUtil.mkdir(fileFolder);
|
|
|
+ }
|
|
|
+ EasyExcel.write(fileFolder + fileName, TbMildCar.class).sheet("4.2米~9.6米车导出记录")
|
|
|
+ .doWrite(() -> cars);
|
|
|
+ return SystemObject.config.getDomain() + uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/" + fileName;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据车牌查询
|
|
|
+ *
|
|
|
+ * @param carNo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public TbMildCar findByCarNo(String carNo) {
|
|
|
+ QueryWrapper<TbMildCar> ew = new QueryWrapper<>();
|
|
|
+ ew.lambda().eq(TbMildCar::getCarNo, carNo);
|
|
|
+ return getOne(ew);
|
|
|
+ }
|
|
|
}
|