首页>代码>基于spring boot+spring data jpa+bootstrap的企业级进销存管理系统>/src/main/java/com/java1234/controller/admin/DamageListAdminController.java
package com.java1234.controller.admin; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.data.domain.Sort.Direction; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.java1234.entity.Log; import com.java1234.entity.DamageList; import com.java1234.entity.DamageListGoods; import com.java1234.service.LogService; import com.java1234.service.UserService; import com.java1234.service.DamageListGoodsService; import com.java1234.service.DamageListService; import com.java1234.util.DateUtil; import com.java1234.util.StringUtil; /** * 报损单Controller类 * @author Administrator * */ @RestController @RequestMapping("/admin/damageList") public class DamageListAdminController { @Resource private DamageListService damageListService; @Resource private DamageListGoodsService damageListGoodsService; @Resource private LogService logService; @Resource private UserService userService; @InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setLenient(true); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); //true:允许输入空值,false:不能为空值 } /** * 根据条件分页查询报损单信息 * @param damageList * @param page * @param rows * @return * @throws Exception */ @RequestMapping("/list") @RequiresPermissions(value = { "报损报溢查询" }) public Map<String,Object> list(DamageList damageList)throws Exception{ Map<String, Object> resultMap = new HashMap<>(); List<DamageList> damageListList=damageListService.list(damageList, Direction.DESC, "damageDate"); resultMap.put("rows", damageListList); return resultMap; } /** * 根据报损单id查询所有报损单商品 * @param damageListId * @return * @throws Exception */ @RequestMapping("/listGoods") @RequiresPermissions(value = { "报损报溢查询" }) public Map<String,Object> listGoods(Integer damageListId)throws Exception{ if(damageListId==null){ return null; } Map<String, Object> resultMap = new HashMap<>(); List<DamageListGoods> damageListGoodsList=damageListGoodsService.listByDamageListId(damageListId); resultMap.put("rows", damageListGoodsList); return resultMap; } /** * 获取报损单号 * @param type * @return * @throws Exception */ @ResponseBody @RequestMapping("/getDamageNumber") @RequiresPermissions(value = {"商品报损"}) public String genBillCode(String type)throws Exception{ StringBuffer biilCodeStr=new StringBuffer(); biilCodeStr.append("BS"); biilCodeStr.append(DateUtil.getCurrentDateStr()); // 拼接当前日期 String damageNumber=damageListService.getTodayMaxDamageNumber(); // 获取当天最大的报损单号 if(damageNumber!=null){ biilCodeStr.append(StringUtil.formatCode(damageNumber)); }else{ biilCodeStr.append("0001"); } return biilCodeStr.toString(); } /** * 添加报损单 以及所有报损单商品 以及 修改商品的成本均价 * @param damageList * @param goodsJson * @return * @throws Exception */ @ResponseBody @RequestMapping("/save") @RequiresPermissions(value = {"商品报损"}) public Map<String,Object> save(DamageList damageList,String goodsJson)throws Exception{ Map<String, Object> resultMap = new HashMap<>(); damageList.setUser(userService.findByUserName((String) SecurityUtils.getSubject().getPrincipal())); // 设置操作用户 Gson gson = new Gson(); List<DamageListGoods> plgList=gson.fromJson(goodsJson, new TypeToken<List<DamageListGoods>>(){}.getType()); damageListService.save(damageList, plgList); logService.save(new Log(Log.ADD_ACTION,"添加报损单")); resultMap.put("success", true); return resultMap; } }

monster_001 LV3
2月27日
dane168 LV8
2月25日
lz88888 LV12
2024年10月18日
微信网友_7134912998903808 LV15
2024年9月11日
shuo04 LV1
2024年7月12日
sunlea LV20
2024年6月24日
cheung524071 LV8
2023年8月23日
liushao LV2
2023年5月12日
计算机暴龙战士 LV19
2023年4月2日
hbsoft2008 LV16
2023年3月24日

monster_001 LV3
2月27日
dane168 LV8
2月25日
huasir2018 LV14
1月29日
xianyu091012 LV5
2024年11月18日
lz88888 LV12
2024年10月18日
微信网友_7134912998903808 LV15
2024年9月11日
248727703 LV1
2024年7月14日
shuo04 LV1
2024年7月12日
sunlea LV20
2024年6月23日
KEKUN123 LV1
2024年6月22日