Commit 5783a335 by ice

修改商品新增接口

parent a688d167
...@@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param;
import org.bson.Document; import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import orthopedics.controller.error.ErrorEnum; import orthopedics.controller.error.ErrorEnum;
import orthopedics.dao.HrOrganizationMapper; import orthopedics.dao.HrOrganizationMapper;
...@@ -27,6 +28,7 @@ import orthopedics.util.Result; ...@@ -27,6 +28,7 @@ import orthopedics.util.Result;
import orthopedics.util.StatusCode; import orthopedics.util.StatusCode;
import orthopedics.util.StringUtil; import orthopedics.util.StringUtil;
import orthopedics.util.UuidUtil; import orthopedics.util.UuidUtil;
import orthopedics.vo.InvItemPage;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -63,7 +65,7 @@ public class InvItemController { ...@@ -63,7 +65,7 @@ public class InvItemController {
**/ **/
@RequestMapping(path = "/ruleFill",method = RequestMethod.POST) @RequestMapping(path = "/ruleFill",method = RequestMethod.POST)
@Transactional @Transactional
public Result ruleFill(@RequestBody InvItem invItem){ public Result ruleFill(@RequestBody InvItemPage invItem){
//填充规则:itemCode(商品代码)(13) = proType(商品类型)(4位)+流水号(000000001--) //填充规则:itemCode(商品代码)(13) = proType(商品类型)(4位)+流水号(000000001--)
//查询该商品类型最新的商品代码 //查询该商品类型最新的商品代码
String newItemCode = invItemService.findTheNewItemCode(invItem.getProType()); String newItemCode = invItemService.findTheNewItemCode(invItem.getProType());
...@@ -122,14 +124,20 @@ public class InvItemController { ...@@ -122,14 +124,20 @@ public class InvItemController {
} }
} }
} }
if(invItem.getId()==null || invItem.getId().equals("")){ //赋值id
invItem.setId(UuidUtil.get32UUIDString()); String itemId = StringUtils.isEmpty(invItem.getId())?UuidUtil.get32UUIDString():invItem.getId();
} invItem.setId(itemId);
//赋值默认值
invItem.setLotControl("N");
invItem.setSerialControl("N");
invItem.setExtcode(StringUtils.isEmpty(invItem.getExtcode())?"0":invItem.getExtcode());
invItem.setMedia(StringUtils.isEmpty(invItem.getMedia())?"0":invItem.getMedia());
try { try {
// Skus skus = getSkus(invItem);
// skusService.update(skus);
invItemService.insert(invItem); invItemService.insert(invItem);
for(InvItemAttribute itemAttribute:invItem.getInv_item_attribute()){
itemAttribute.setItemId(itemId);
invItemService.insertInvItemAttribute(itemAttribute);
}
return new Result(true,StatusCode.OK,"保存成功",invItem); return new Result(true,StatusCode.OK,"保存成功",invItem);
}catch (Exception e){ }catch (Exception e){
return new Result(false,StatusCode.ERROR,"保存失败",invItem); return new Result(false,StatusCode.ERROR,"保存失败",invItem);
......
...@@ -3,11 +3,11 @@ package orthopedics.dao; ...@@ -3,11 +3,11 @@ package orthopedics.dao;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import orthopedics.model.InvItemAttribute; import orthopedics.model.InvItemAttribute;
import org.apache.ibatis.annotations.Param;
/** /**
* @author author * @author ice
*/ */
public interface InvItemAttributeMapper{ public interface InvItemAttributeMapper{
...@@ -31,6 +31,7 @@ public interface InvItemAttributeMapper{ ...@@ -31,6 +31,7 @@ public interface InvItemAttributeMapper{
@Result(property = "attribute9", column = "attribute9"), @Result(property = "attribute9", column = "attribute9"),
@Result(property = "attribute10", column = "attribute10"), @Result(property = "attribute10", column = "attribute10"),
@Result(property = "itemId", column = "item_id"), @Result(property = "itemId", column = "item_id"),
@Result(property = "type", column = "type"),
@Result(property = "itemCode", column = "item_code"), @Result(property = "itemCode", column = "item_code"),
@Result(property = "series", column = "series"), @Result(property = "series", column = "series"),
@Result(property = "author", column = "author"), @Result(property = "author", column = "author"),
...@@ -53,20 +54,39 @@ public interface InvItemAttributeMapper{ ...@@ -53,20 +54,39 @@ public interface InvItemAttributeMapper{
@Result(property = "award", column = "award"), @Result(property = "award", column = "award"),
@Result(property = "bcontent", column = "bcontent"), @Result(property = "bcontent", column = "bcontent"),
@Result(property = "bksize", column = "bksize"), @Result(property = "bksize", column = "bksize"),
@Result(property = "isRack", column = "is_rack"),
@Result(property = "isChinese", column = "is_chinese"),
@Result(property = "isrcCode", column = "isrc_code"),
@Result(property = "seeCode", column = "see_code"),
@Result(property = "seriesCode", column = "series_code"),
@Result(property = "contentDesc", column = "content_desc"),
@Result(property = "vesionDesc", column = "vesion_desc"),
@Result(property = "london", column = "london"),
@Result(property = "duty", column = "duty"),
@Result(property = "product", column = "product"),
@Result(property = "reserved", column = "reserved"),
@Result(property = "digital", column = "digital"),
@Result(property = "kind", column = "kind"),
@Result(property = "model", column = "model"),
@Result(property = "producedDate", column = "produced_date"),
@Result(property = "brand", column = "brand"),
@Result(property = "manufacturer", column = "manufacturer"),
@Result(property = "palce", column = "palce"),
@Result(property = "agent", column = "agent"),
}) })
public List<InvItemAttribute> select(); public List<InvItemAttribute> select();
@Insert("<script>" + @Insert("<script>" +
"INSERT INTO inv_item_attribute(id,create_by,create_time,update_by,update_time,sys_org_code,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,item_id,item_code,series,author,translator,prndate,edition,nprint,binding,len_cm,wid_cm,thk_cm,wt_g,pages,words,keywds,reader,directory,summary,brief,award,bcontent,bksize) VALUES" + "INSERT INTO inv_item_attribute(id,create_by,create_time,update_by,update_time,sys_org_code,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,item_id,type,item_code,series,author,translator,prndate,edition,nprint,binding,len_cm,wid_cm,thk_cm,wt_g,pages,words,keywds,reader,directory,summary,brief,award,bcontent,bksize,is_rack,is_chinese,isrc_code,see_code,series_code,content_desc,vesion_desc,london,duty,product,reserved,digital,kind,model,produced_date,brand,manufacturer,palce,agent) VALUES" +
"<foreach collection='invitemattributes' item='item' index='index' separator=','>" + "<foreach collection='invitemattributes' item='item' index='index' separator=','>" +
"(#{item.id},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.sysOrgCode},#{item.attributeCategory},#{item.attribute1},#{item.attribute2},#{item.attribute3},#{item.attribute4},#{item.attribute5},#{item.attribute6},#{item.attribute7},#{item.attribute8},#{item.attribute9},#{item.attribute10},#{item.itemId},#{item.itemCode},#{item.series},#{item.author},#{item.translator},#{item.prndate},#{item.edition},#{item.nprint},#{item.binding},#{item.lenCm},#{item.widCm},#{item.thkCm},#{item.wtG},#{item.pages},#{item.words},#{item.keywds},#{item.reader},#{item.directory},#{item.summary},#{item.brief},#{item.award},#{item.bcontent},#{item.bksize})" + "(#{item.id},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.sysOrgCode},#{item.attributeCategory},#{item.attribute1},#{item.attribute2},#{item.attribute3},#{item.attribute4},#{item.attribute5},#{item.attribute6},#{item.attribute7},#{item.attribute8},#{item.attribute9},#{item.attribute10},#{item.itemId},#{item.type},#{item.itemCode},#{item.series},#{item.author},#{item.translator},#{item.prndate},#{item.edition},#{item.nprint},#{item.binding},#{item.lenCm},#{item.widCm},#{item.thkCm},#{item.wtG},#{item.pages},#{item.words},#{item.keywds},#{item.reader},#{item.directory},#{item.summary},#{item.brief},#{item.award},#{item.bcontent},#{item.bksize},#{item.isRack},#{item.isChinese},#{item.isrcCode},#{item.seeCode},#{item.seriesCode},#{item.contentDesc},#{item.vesionDesc},#{item.london},#{item.duty},#{item.product},#{item.reserved},#{item.digital},#{item.kind},#{item.model},#{item.producedDate},#{item.brand},#{item.manufacturer},#{item.palce},#{item.agent})" +
"</foreach>" + "</foreach>" +
"</script>") "</script>")
Integer insertBatch(@Param("invitemattributes") List<InvItemAttribute> InvItemAttributeList); Integer insertBatch(@Param("invitemattributes")List<InvItemAttribute> InvItemAttributeList);
@Insert( @Insert(
"INSERT INTO inv_item_attribute(id,create_by,create_time,update_by,update_time,sys_org_code,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,item_id,item_code,series,author,translator,prndate,edition,nprint,binding,len_cm,wid_cm,thk_cm,wt_g,pages,words,keywds,reader,directory,summary,brief,award,bcontent,bksize) VALUES" + "INSERT INTO inv_item_attribute(id,create_by,create_time,update_by,update_time,sys_org_code,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,item_id,type,item_code,series,author,translator,prndate,edition,nprint,binding,len_cm,wid_cm,thk_cm,wt_g,pages,words,keywds,reader,directory,summary,brief,award,bcontent,bksize,is_rack,is_chinese,isrc_code,see_code,series_code,content_desc,vesion_desc,london,duty,product,reserved,digital,kind,model,produced_date,brand,manufacturer,palce,agent) VALUES" +
"(#{id},#{createBy},#{createTime},#{updateBy},#{updateTime},#{sysOrgCode},#{attributeCategory},#{attribute1},#{attribute2},#{attribute3},#{attribute4},#{attribute5},#{attribute6},#{attribute7},#{attribute8},#{attribute9},#{attribute10},#{itemId},#{itemCode},#{series},#{author},#{translator},#{prndate},#{edition},#{nprint},#{binding},#{lenCm},#{widCm},#{thkCm},#{wtG},#{pages},#{words},#{keywds},#{reader},#{directory},#{summary},#{brief},#{award},#{bcontent},#{bksize})" "(#{id},#{createBy},#{createTime},#{updateBy},#{updateTime},#{sysOrgCode},#{attributeCategory},#{attribute1},#{attribute2},#{attribute3},#{attribute4},#{attribute5},#{attribute6},#{attribute7},#{attribute8},#{attribute9},#{attribute10},#{itemId},#{type},#{itemCode},#{series},#{author},#{translator},#{prndate},#{edition},#{nprint},#{binding},#{lenCm},#{widCm},#{thkCm},#{wtG},#{pages},#{words},#{keywds},#{reader},#{directory},#{summary},#{brief},#{award},#{bcontent},#{bksize},#{isRack},#{isChinese},#{isrcCode},#{seeCode},#{seriesCode},#{contentDesc},#{vesionDesc},#{london},#{duty},#{product},#{reserved},#{digital},#{kind},#{model},#{producedDate},#{brand},#{manufacturer},#{palce},#{agent})"
) )
Integer insert(InvItemAttribute InvItemAttribute); Integer insert(InvItemAttribute InvItemAttribute);
......
...@@ -7,16 +7,16 @@ import java.util.List; ...@@ -7,16 +7,16 @@ import java.util.List;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
/** /**
* *
* @author author * @author ice
*/ */
public class InvItemAttribute implements Serializable { public class InvItemAttribute implements Serializable {
private static final long serialVersionUID = 1569734973337L; private static final long serialVersionUID = 1571825871692L;
/** /**
* 主键 * 主键
* 主键 *
* isNullAble:0 * isNullAble:0
*/ */
@JSONField(name = "id") @JSONField(name = "id")
...@@ -142,6 +142,13 @@ public class InvItemAttribute implements Serializable { ...@@ -142,6 +142,13 @@ public class InvItemAttribute implements Serializable {
private String itemId; private String itemId;
/** /**
* 属性类型
* isNullAble:1
*/
@JSONField(name = "type")
private String type;
/**
* 商品代码 * 商品代码
* isNullAble:1 * isNullAble:1
*/ */
...@@ -295,6 +302,139 @@ public class InvItemAttribute implements Serializable { ...@@ -295,6 +302,139 @@ public class InvItemAttribute implements Serializable {
@JSONField(name = "bksize") @JSONField(name = "bksize")
private String bksize; private String bksize;
/**
* 建议上架
* isNullAble:1
*/
@JSONField(name = "is_rack")
private String isRack;
/**
* 是否国版
* isNullAble:1
*/
@JSONField(name = "is_chinese")
private String isChinese;
/**
* 国际标准录音制品编码
* isNullAble:1
*/
@JSONField(name = "isrc_code")
private String isrcCode;
/**
* 国际标准视听资料号
* isNullAble:1
*/
@JSONField(name = "see_code")
private String seeCode;
/**
* 系列名
* isNullAble:1
*/
@JSONField(name = "series_code")
private String seriesCode;
/**
* 内容描述
* isNullAble:1
*/
@JSONField(name = "content_desc")
private String contentDesc;
/**
* 版本说明
* isNullAble:1
*/
@JSONField(name = "vesion_desc")
private String vesionDesc;
/**
* 出版地
* isNullAble:1
*/
@JSONField(name = "london")
private String london;
/**
* 责任者
* isNullAble:1
*/
@JSONField(name = "duty")
private String duty;
/**
* 出品者
* isNullAble:1
*/
@JSONField(name = "product")
private String product;
/**
* 版权所有
* isNullAble:1
*/
@JSONField(name = "reserved")
private String reserved;
/**
* 载体形态
* isNullAble:1
*/
@JSONField(name = "digital")
private String digital;
/**
* 种类
* isNullAble:1
*/
@JSONField(name = "kind")
private String kind;
/**
* 型号
* isNullAble:1
*/
@JSONField(name = "model")
private String model;
/**
* 生产日期
* isNullAble:1
*/
@JSONField(name = "produced_date")
private java.time.LocalDateTime producedDate;
/**
* 品牌
* isNullAble:1
*/
@JSONField(name = "brand")
private String brand;
/**
* 生产商
* isNullAble:1
*/
@JSONField(name = "manufacturer")
private String manufacturer;
/**
* 产地
* isNullAble:1
*/
@JSONField(name = "palce")
private String palce;
/**
* 代理商
* isNullAble:1
*/
@JSONField(name = "agent")
private String agent;
public void setId(String id){this.id = id;} public void setId(String id){this.id = id;}
...@@ -368,6 +508,10 @@ public class InvItemAttribute implements Serializable { ...@@ -368,6 +508,10 @@ public class InvItemAttribute implements Serializable {
public String getItemId(){return this.itemId;} public String getItemId(){return this.itemId;}
public void setType(String type){this.type = type;}
public String getType(){return this.type;}
public void setItemCode(String itemCode){this.itemCode = itemCode;} public void setItemCode(String itemCode){this.itemCode = itemCode;}
public String getItemCode(){return this.itemCode;} public String getItemCode(){return this.itemCode;}
...@@ -455,6 +599,82 @@ public class InvItemAttribute implements Serializable { ...@@ -455,6 +599,82 @@ public class InvItemAttribute implements Serializable {
public void setBksize(String bksize){this.bksize = bksize;} public void setBksize(String bksize){this.bksize = bksize;}
public String getBksize(){return this.bksize;} public String getBksize(){return this.bksize;}
public void setIsRack(String isRack){this.isRack = isRack;}
public String getIsRack(){return this.isRack;}
public void setIsChinese(String isChinese){this.isChinese = isChinese;}
public String getIsChinese(){return this.isChinese;}
public void setIsrcCode(String isrcCode){this.isrcCode = isrcCode;}
public String getIsrcCode(){return this.isrcCode;}
public void setSeeCode(String seeCode){this.seeCode = seeCode;}
public String getSeeCode(){return this.seeCode;}
public void setSeriesCode(String seriesCode){this.seriesCode = seriesCode;}
public String getSeriesCode(){return this.seriesCode;}
public void setContentDesc(String contentDesc){this.contentDesc = contentDesc;}
public String getContentDesc(){return this.contentDesc;}
public void setVesionDesc(String vesionDesc){this.vesionDesc = vesionDesc;}
public String getVesionDesc(){return this.vesionDesc;}
public void setLondon(String london){this.london = london;}
public String getLondon(){return this.london;}
public void setDuty(String duty){this.duty = duty;}
public String getDuty(){return this.duty;}
public void setProduct(String product){this.product = product;}
public String getProduct(){return this.product;}
public void setReserved(String reserved){this.reserved = reserved;}
public String getReserved(){return this.reserved;}
public void setDigital(String digital){this.digital = digital;}
public String getDigital(){return this.digital;}
public void setKind(String kind){this.kind = kind;}
public String getKind(){return this.kind;}
public void setModel(String model){this.model = model;}
public String getModel(){return this.model;}
public void setProducedDate(java.time.LocalDateTime producedDate){this.producedDate = producedDate;}
public java.time.LocalDateTime getProducedDate(){return this.producedDate;}
public void setBrand(String brand){this.brand = brand;}
public String getBrand(){return this.brand;}
public void setManufacturer(String manufacturer){this.manufacturer = manufacturer;}
public String getManufacturer(){return this.manufacturer;}
public void setPalce(String palce){this.palce = palce;}
public String getPalce(){return this.palce;}
public void setAgent(String agent){this.agent = agent;}
public String getAgent(){return this.agent;}
@Override @Override
public String toString() { public String toString() {
return "InvItemAttribute{" + return "InvItemAttribute{" +
...@@ -476,6 +696,7 @@ public class InvItemAttribute implements Serializable { ...@@ -476,6 +696,7 @@ public class InvItemAttribute implements Serializable {
"attribute9='" + attribute9 + '\'' + "attribute9='" + attribute9 + '\'' +
"attribute10='" + attribute10 + '\'' + "attribute10='" + attribute10 + '\'' +
"itemId='" + itemId + '\'' + "itemId='" + itemId + '\'' +
"type='" + type + '\'' +
"itemCode='" + itemCode + '\'' + "itemCode='" + itemCode + '\'' +
"series='" + series + '\'' + "series='" + series + '\'' +
"author='" + author + '\'' + "author='" + author + '\'' +
...@@ -498,6 +719,25 @@ public class InvItemAttribute implements Serializable { ...@@ -498,6 +719,25 @@ public class InvItemAttribute implements Serializable {
"award='" + award + '\'' + "award='" + award + '\'' +
"bcontent='" + bcontent + '\'' + "bcontent='" + bcontent + '\'' +
"bksize='" + bksize + '\'' + "bksize='" + bksize + '\'' +
"isRack='" + isRack + '\'' +
"isChinese='" + isChinese + '\'' +
"isrcCode='" + isrcCode + '\'' +
"seeCode='" + seeCode + '\'' +
"seriesCode='" + seriesCode + '\'' +
"contentDesc='" + contentDesc + '\'' +
"vesionDesc='" + vesionDesc + '\'' +
"london='" + london + '\'' +
"duty='" + duty + '\'' +
"product='" + product + '\'' +
"reserved='" + reserved + '\'' +
"digital='" + digital + '\'' +
"kind='" + kind + '\'' +
"model='" + model + '\'' +
"producedDate='" + producedDate + '\'' +
"brand='" + brand + '\'' +
"manufacturer='" + manufacturer + '\'' +
"palce='" + palce + '\'' +
"agent='" + agent + '\'' +
'}'; '}';
} }
......
...@@ -3,8 +3,10 @@ package orthopedics.service; ...@@ -3,8 +3,10 @@ package orthopedics.service;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import orthopedics.dao.InvItemAttributeMapper;
import orthopedics.dao.InvItemMapper; import orthopedics.dao.InvItemMapper;
import orthopedics.model.InvItem; import orthopedics.model.InvItem;
import orthopedics.model.InvItemAttribute;
import java.util.List; import java.util.List;
...@@ -13,6 +15,8 @@ public class InvItemService { ...@@ -13,6 +15,8 @@ public class InvItemService {
@Autowired @Autowired
private InvItemMapper invItemMapper; private InvItemMapper invItemMapper;
@Autowired
private InvItemAttributeMapper invItemAttributeMapper;
//查询出该商品类型中最新的一条商品代码 //查询出该商品类型中最新的一条商品代码
public String findTheNewItemCode(String number){ public String findTheNewItemCode(String number){
...@@ -36,5 +40,10 @@ public class InvItemService { ...@@ -36,5 +40,10 @@ public class InvItemService {
//根据扫描码scancode查询记录 //根据扫描码scancode查询记录
public List<InvItem> selectByScancode(String scancode){ public List<InvItem> selectByScancode(String scancode){
return invItemMapper.selectByScancode(scancode); return invItemMapper.selectByScancode(scancode);
}; }
//插入商品信息行数据
public Integer insertInvItemAttribute(InvItemAttribute invItemAttribute){
return invItemAttributeMapper.insert(invItemAttribute);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment